From 60ea7f081a48e830500a1c35e5a9ed7986419ad2 Mon Sep 17 00:00:00 2001 From: Neil McKechnie Date: Mon, 27 Mar 2023 13:03:19 +0100 Subject: [PATCH] Correct display of high VPIN numbers in diagnostic output. No functional change. VPINs are unsigned integers in the range 0-65535 (although the highest values are special, 65535=VPIN_NONE). Values above 32767 were erroneously being displayed as negative. This has been fixed, which is a pre-requisite for allowing VPINs above 32767 to be used. --- EXRAIL2.cpp | 4 ++-- IODevice.cpp | 2 +- IO_AnalogueInputs.h | 2 +- IO_DCCAccessory.cpp | 2 +- IO_DFPlayer.h | 4 ++-- IO_EXTurntable.h | 4 ++-- IO_ExampleSerial.h | 6 +++--- IO_GPIOBase.h | 2 +- IO_HCSR04.h | 2 +- IO_PCA9685.cpp | 8 ++++---- IO_PCA9685pwm.h | 4 ++-- IO_RotaryEncoder.h | 2 +- IO_Servo.h | 8 ++++---- IO_TouchKeypad.h | 2 +- IO_VL53L0X.h | 2 +- IO_duinoNodes.h | 2 +- 16 files changed, 28 insertions(+), 28 deletions(-) diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index bb5989a..52d10e8 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -198,7 +198,7 @@ LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) { case OPCODE_IFNOT: { int16_t pin = (int16_t)operand; if (pin<0) pin = -pin; - DIAG(F("EXRAIL input vpin %d"),pin); + DIAG(F("EXRAIL input VPIN %u"),pin); IODevice::configureInput((VPIN)pin,true); break; } @@ -208,7 +208,7 @@ LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) { case OPCODE_IFGTE: case OPCODE_IFLT: case OPCODE_DRIVE: { - DIAG(F("EXRAIL analog input vpin %d"),(VPIN)operand); + DIAG(F("EXRAIL analog input VPIN %u"),(VPIN)operand); IODevice::configureAnalogIn((VPIN)operand); break; } diff --git a/IODevice.cpp b/IODevice.cpp index 03ccf85..af6efc8 100644 --- a/IODevice.cpp +++ b/IODevice.cpp @@ -329,7 +329,7 @@ bool IODevice::checkNoOverlap(VPIN firstPin, uint8_t nPins, I2CAddress i2cAddres VPIN lastDevPin=firstDevPin+dev->_nPins-1; bool noOverlap= firstPin>lastDevPin || lastPin> 8; uint8_t stepsLSB = value & 0xFF; #ifdef DIAG_IO - DIAG(F("EX-Turntable WriteAnalogue Vpin:%d Value:%d Activity:%d Duration:%d"), + DIAG(F("EX-Turntable WriteAnalogue VPIN:%u Value:%d Activity:%d Duration:%d"), vpin, value, activity, duration); DIAG(F("I2CManager write I2C Address:%d stepsMSB:%d stepsLSB:%d activity:%d"), _I2CAddress.toString(), stepsMSB, stepsLSB, activity); @@ -114,7 +114,7 @@ void EXTurntable::_writeAnalogue(VPIN vpin, int value, uint8_t activity, uint16_ // Display Turnetable-EX device driver info. void EXTurntable::_display() { - DIAG(F("EX-Turntable I2C:%s Configured on Vpins:%d-%d %S"), _I2CAddress.toString(), (int)_firstVpin, + DIAG(F("EX-Turntable I2C:%s Configured on Vpins:%u-%u %S"), _I2CAddress.toString(), (int)_firstVpin, (int)_firstVpin+_nPins-1, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F("")); } diff --git a/IO_ExampleSerial.h b/IO_ExampleSerial.h index da421c5..5c70eb4 100644 --- a/IO_ExampleSerial.h +++ b/IO_ExampleSerial.h @@ -84,7 +84,7 @@ protected: void _write(VPIN vpin, int value) { int pin = vpin -_firstVpin; #ifdef DIAG_IO - DIAG(F("IO_ExampleSerial::_write Pin:%d Value:%d"), (int)vpin, value); + DIAG(F("IO_ExampleSerial::_write VPIN:%u Value:%d"), (int)vpin, value); #endif // Send a command string over the serial line _serial->print('#'); @@ -153,10 +153,10 @@ protected: // Display information about the device, and perhaps its current condition (e.g. active, disabled etc). // Here we display the current values held for the pins. void _display() { - DIAG(F("IO_ExampleSerial Configured on VPins:%d-%d"), (int)_firstVpin, + DIAG(F("IO_ExampleSerial Configured on Vpins:%u-%u"), (int)_firstVpin, (int)_firstVpin+_nPins-1); for (int i=0; i<_nPins; i++) - DIAG(F(" VPin %2d: %d"), _firstVpin+i, _pinValues[i]); + DIAG(F(" VPin %2u: %d"), _firstVpin+i, _pinValues[i]); } diff --git a/IO_GPIOBase.h b/IO_GPIOBase.h index 66b9ff6..94265c3 100644 --- a/IO_GPIOBase.h +++ b/IO_GPIOBase.h @@ -196,7 +196,7 @@ void GPIOBase::_loop(unsigned long currentMicros) { template void GPIOBase::_display() { - DIAG(F("%S I2C:%s Configured on Vpins:%d-%d %S"), _deviceName, _I2CAddress.toString(), + DIAG(F("%S I2C:%s Configured on Vpins:%u-%u %S"), _deviceName, _I2CAddress.toString(), _firstVpin, _firstVpin+_nPins-1, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F("")); } diff --git a/IO_HCSR04.h b/IO_HCSR04.h index 26f0ecd..be1d303 100644 --- a/IO_HCSR04.h +++ b/IO_HCSR04.h @@ -234,7 +234,7 @@ protected: } void _display() override { - DIAG(F("HCSR04 Configured on Vpin:%d TrigPin:%d EchoPin:%d On:%dcm Off:%dcm"), + DIAG(F("HCSR04 Configured on VPIN:%u TrigPin:%d EchoPin:%d On:%dcm Off:%dcm"), _firstVpin, _trigPin, _echoPin, _onThreshold, _offThreshold); } diff --git a/IO_PCA9685.cpp b/IO_PCA9685.cpp index 71f3661..3c8b37a 100644 --- a/IO_PCA9685.cpp +++ b/IO_PCA9685.cpp @@ -46,7 +46,7 @@ bool PCA9685::_configure(VPIN vpin, ConfigTypeEnum configType, int paramCount, i if (configType != CONFIGURE_SERVO) return false; if (paramCount != 5) return false; #ifdef DIAG_IO - DIAG(F("PCA9685 Configure VPIN:%d Apos:%d Ipos:%d Profile:%d Duration:%d state:%d"), + DIAG(F("PCA9685 Configure VPIN:%u Apos:%d Ipos:%d Profile:%d Duration:%d state:%d"), vpin, params[0], params[1], params[2], params[3], params[4]); #endif @@ -118,7 +118,7 @@ void PCA9685::_begin() { // For this function, the configured profile is used. void PCA9685::_write(VPIN vpin, int value) { #ifdef DIAG_IO - DIAG(F("PCA9685 Write Vpin:%d Value:%d"), vpin, value); + DIAG(F("PCA9685 Write VPIN:%u Value:%d"), vpin, value); #endif int pin = vpin - _firstVpin; if (value) value = 1; @@ -145,7 +145,7 @@ void PCA9685::_write(VPIN vpin, int value) { // void PCA9685::_writeAnalogue(VPIN vpin, int value, uint8_t profile, uint16_t duration) { #ifdef DIAG_IO - DIAG(F("PCA9685 WriteAnalogue Vpin:%d Value:%d Profile:%d Duration:%d %S"), + DIAG(F("PCA9685 WriteAnalogue VPIN:%u Value:%d Profile:%d Duration:%d %S"), vpin, value, profile, duration, _deviceState == DEVSTATE_FAILED?F("DEVSTATE_FAILED"):F("")); #endif if (_deviceState == DEVSTATE_FAILED) return; @@ -262,7 +262,7 @@ void PCA9685::writeDevice(uint8_t pin, int value) { // Display details of this device. void PCA9685::_display() { - DIAG(F("PCA9685 I2C:%s Configured on Vpins:%d-%d %S"), _I2CAddress.toString(), (int)_firstVpin, + DIAG(F("PCA9685 I2C:%s Configured on Vpins:%u-%u %S"), _I2CAddress.toString(), (int)_firstVpin, (int)_firstVpin+_nPins-1, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F("")); } diff --git a/IO_PCA9685pwm.h b/IO_PCA9685pwm.h index 042516b..a12cb84 100644 --- a/IO_PCA9685pwm.h +++ b/IO_PCA9685pwm.h @@ -121,7 +121,7 @@ private: void _writeAnalogue(VPIN vpin, int value, uint8_t param1, uint16_t param2) override { (void)param1; (void)param2; // suppress compiler warning #ifdef DIAG_IO - DIAG(F("PCA9685pwm WriteAnalogue Vpin:%d Value:%d %S"), + DIAG(F("PCA9685pwm WriteAnalogue VPIN:%u Value:%d %S"), vpin, value, _deviceState == DEVSTATE_FAILED?F("DEVSTATE_FAILED"):F("")); #endif if (_deviceState == DEVSTATE_FAILED) return; @@ -134,7 +134,7 @@ private: // Display details of this device. void _display() override { - DIAG(F("PCA9685pwm I2C:%s Configured on Vpins:%d-%d %S"), _I2CAddress.toString(), (int)_firstVpin, + DIAG(F("PCA9685pwm I2C:%s Configured on Vpins:%u-%u %S"), _I2CAddress.toString(), (int)_firstVpin, (int)_firstVpin+_nPins-1, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F("")); } diff --git a/IO_RotaryEncoder.h b/IO_RotaryEncoder.h index b271b48..09d0c4d 100644 --- a/IO_RotaryEncoder.h +++ b/IO_RotaryEncoder.h @@ -104,7 +104,7 @@ private: } void _display() override { - DIAG(F("Rotary Encoder I2C:%s v%d.%d.%d Configured on Vpin:%d-%d %S"), _I2CAddress.toString(), _majorVer, _minorVer, _patchVer, + DIAG(F("Rotary Encoder I2C:%s v%d.%d.%d Configured on VPIN:%u-%d %S"), _I2CAddress.toString(), _majorVer, _minorVer, _patchVer, (int)_firstVpin, _firstVpin+_nPins-1, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F("")); } diff --git a/IO_Servo.h b/IO_Servo.h index 8f95463..216b886 100644 --- a/IO_Servo.h +++ b/IO_Servo.h @@ -98,7 +98,7 @@ private: if (configType != CONFIGURE_SERVO) return false; if (paramCount != 5) return false; #ifdef DIAG_IO - DIAG(F("Servo: Configure VPIN:%d Apos:%d Ipos:%d Profile:%d Duration:%d state:%d"), + DIAG(F("Servo: Configure VPIN:%u Apos:%d Ipos:%d Profile:%d Duration:%d state:%d"), vpin, params[0], params[1], params[2], params[3], params[4]); #endif @@ -165,7 +165,7 @@ private: void _write(VPIN vpin, int value) override { if (_deviceState == DEVSTATE_FAILED) return; #ifdef DIAG_IO - DIAG(F("Servo Write Vpin:%d Value:%d"), vpin, value); + DIAG(F("Servo Write VPIN:%u Value:%d"), vpin, value); #endif int pin = vpin - _firstVpin; if (value) value = 1; @@ -193,7 +193,7 @@ private: // void _writeAnalogue(VPIN vpin, int value, uint8_t profile, uint16_t duration) override { #ifdef DIAG_IO - DIAG(F("Servo: WriteAnalogue Vpin:%d Value:%d Profile:%d Duration:%d %S"), + DIAG(F("Servo: WriteAnalogue VPIN:%u Value:%d Profile:%d Duration:%d %S"), vpin, value, profile, duration, _deviceState == DEVSTATE_FAILED?F("DEVSTATE_FAILED"):F("")); #endif if (_deviceState == DEVSTATE_FAILED) return; @@ -288,7 +288,7 @@ private: // Display details of this device. void _display() override { - DIAG(F("Servo Configured on Vpins:%d-%d, slave pins:%d-%d %S"), + DIAG(F("Servo Configured on Vpins:%u-%u, slave pins:%d-%d %S"), (int)_firstVpin, (int)_firstVpin+_nPins-1, (int)_firstSlavePin, (int)_firstSlavePin+_nPins-1, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F("")); diff --git a/IO_TouchKeypad.h b/IO_TouchKeypad.h index 8984bce..48e3b25 100644 --- a/IO_TouchKeypad.h +++ b/IO_TouchKeypad.h @@ -124,7 +124,7 @@ protected: // Display information about the device, and perhaps its current condition (e.g. active, disabled etc). void _display() { - DIAG(F("TouchKeypad Configured on VPins:%d-%d SCL=%d SDO=%d"), (int)_firstVpin, + DIAG(F("TouchKeypad Configured on Vpins:%u-%u SCL=%d SDO=%d"), (int)_firstVpin, (int)_firstVpin+_nPins-1, _clockPin, _dataPin); } diff --git a/IO_VL53L0X.h b/IO_VL53L0X.h index 7c80518..08fe44e 100644 --- a/IO_VL53L0X.h +++ b/IO_VL53L0X.h @@ -319,7 +319,7 @@ protected: } void _display() override { - DIAG(F("VL53L0X I2C:%s Configured on Vpins:%d-%d On:%dmm Off:%dmm %S"), + DIAG(F("VL53L0X I2C:%s Configured on Vpins:%u-%u On:%dmm Off:%dmm %S"), _I2CAddress.toString(), _firstVpin, _firstVpin+_nPins-1, _onThreshold, _offThreshold, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F("")); } diff --git a/IO_duinoNodes.h b/IO_duinoNodes.h index 73de1a1..60ef2ea 100644 --- a/IO_duinoNodes.h +++ b/IO_duinoNodes.h @@ -121,7 +121,7 @@ void _loopOutput() { } void _display() override { - DIAG(F("IO_duinoNodes %SPUT Configured on VPins:%d-%d shift=%d"), + DIAG(F("IO_duinoNodes %SPUT Configured on Vpins:%u-%u shift=%d"), _pinMap?F("IN"):F("OUT"), (int)_firstVpin, (int)_firstVpin+_nPins-1, _nShiftBytes*8);