1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-23 12:51:24 +01:00

Add <D HAL SHOW> command to list HAL device configuration.

Also, only display HAL device configurations at startup if DIAG_IO is #defined.
This commit is contained in:
Neil McKechnie 2021-08-27 15:44:26 +01:00
parent 7e601c38c4
commit 93dfdcce53
5 changed files with 27 additions and 11 deletions

View File

@ -68,6 +68,8 @@ const int16_t HASH_KEYWORD_VPIN=-415;
const int16_t HASH_KEYWORD_C=67;
const int16_t HASH_KEYWORD_T=84;
const int16_t HASH_KEYWORD_LCN = 15137;
const int16_t HASH_KEYWORD_HAL = 10853;
const int16_t HASH_KEYWORD_SHOW = -21309;
#ifdef HAS_ENOUGH_MEMORY
const int16_t HASH_KEYWORD_WIFI = -5583;
const int16_t HASH_KEYWORD_ETHERNET = -30767;
@ -874,6 +876,13 @@ bool DCCEXParser::parseD(Print *stream, int16_t params, int16_t p[])
IODevice::writeAnalogue(p[1], p[2], params>3 ? p[3] : 0);
break;
#if !defined(IO_MINIMAL_HAL)
case HASH_KEYWORD_HAL:
if (p[1] == HASH_KEYWORD_SHOW)
IODevice::DumpAll();
break;
#endif
default: // invalid/unknown
break;
}

View File

@ -42,12 +42,9 @@ DCCAccessoryDecoder::DCCAccessoryDecoder(VPIN vpin, int nPins, int DCCAddress, i
}
void DCCAccessoryDecoder::_begin() {
int endAddress = _packedAddress + _nPins - 1;
int DCCAddress = _packedAddress >> 2;
int DCCSubaddress = _packedAddress & 3;
DIAG(F("DCC Accessory Decoder configured Vpins:%d-%d Linear Address:%d-%d (%d/%d-%d/%d)"), _firstVpin, _firstVpin+_nPins-1,
_packedAddress, _packedAddress+_nPins-1,
DCCAddress, DCCSubaddress, endAddress >> 2, endAddress % 4);
#if defined(DIAG_IO)
_display();
#endif
}
// Device-specific write function.
@ -61,7 +58,7 @@ void DCCAccessoryDecoder::_write(VPIN id, int state) {
void DCCAccessoryDecoder::_display() {
int endAddress = _packedAddress + _nPins - 1;
DIAG(F("DCC Accessory Vpins:%d-%d Linear Address:%d-%d (%d/%d-%d/%d)"), _firstVpin, _firstVpin+_nPins-1,
DIAG(F("DCCAccessoryDecoder Configured on Vpins:%d-%d Linear Address:%d-%d (%d/%d-%d/%d)"), _firstVpin, _firstVpin+_nPins-1,
_packedAddress, _packedAddress+_nPins-1,
_packedAddress >> 2, _packedAddress % 4, endAddress >> 2, endAddress % 4);
}

View File

@ -42,7 +42,9 @@ void IO_ExampleSerial::create(VPIN firstVpin, int nPins, HardwareSerial *serial,
// Device-specific initialisation
void IO_ExampleSerial::_begin() {
_serial->begin(_baud);
DIAG(F("ExampleSerial configured Vpins:%d-%d"), _firstVpin, _firstVpin+_nPins-1);
#if defined(DIAG_IO)
_display();
#endif
// Send a few # characters to the output
for (uint8_t i=0; i<3; i++)
@ -121,7 +123,7 @@ void IO_ExampleSerial::_loop(unsigned long currentMicros) {
}
void IO_ExampleSerial::_display() {
DIAG(F("IO_ExampleSerial VPins:%d-%d"), (int)_firstVpin,
DIAG(F("IO_ExampleSerial Configured on VPins:%d-%d"), (int)_firstVpin,
(int)_firstVpin+_nPins-1);
}

View File

@ -99,7 +99,9 @@ void GPIOBase<T>::_begin() {
I2CManager.begin();
I2CManager.setClock(400000);
if (I2CManager.exists(_I2CAddress)) {
#if defined(DIAG_IO)
_display();
#endif
_portMode = 0; // default to input mode
_portPullup = -1; // default to pullup enabled
_portInputState = -1;

View File

@ -90,8 +90,9 @@ protected:
pinMode(_receivePin, INPUT);
ArduinoPins::fastWriteDigital(_transmitPin, 0);
_lastExecutionTime = micros();
DIAG(F("HCSR04 configured on VPIN:%d TXpin:%d RXpin:%d On:%dcm Off:%dcm"),
_firstVpin, _transmitPin, _receivePin, _onThreshold, _offThreshold);
#if defined(DIAG_IO)
_display();
#endif
}
// _read function - just return _value (calculated in _loop).
@ -109,6 +110,11 @@ protected:
}
}
void _display() override {
DIAG(F("HCSR04 Configured on Vpin:%d TrigPin:%d EchoPin:%d On:%dcm Off:%dcm"),
_firstVpin, _transmitPin, _receivePin, _onThreshold, _offThreshold);
}
private:
// This polls the HC-SR04 device by sending a pulse and measuring the duration of
// the pulse observed on the receive pin. In order to be kind to the rest of the CS