Skip to content

Commit

Permalink
Merge pull request #339 from DCC-EX:fix-re-send
Browse files Browse the repository at this point in the history
RotaryEnoder, EX-Turntable fixes
  • Loading branch information
peteGSX authored Jun 30, 2023
2 parents 1bdb05a + 5d17f24 commit efe96d1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion IO_EXTurntable.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ EXTurntable::EXTurntable(VPIN firstVpin, int nPins, I2CAddress I2CAddress) {
// Initialisation of EXTurntable
void EXTurntable::_begin() {
I2CManager.begin();
I2CManager.setClock(1000000);
if (I2CManager.exists(_I2CAddress)) {
#ifdef DIAG_IO
_display();
#endif
} else {
DIAG(F("EX-Turntable I2C:%s device not found"), _I2CAddress.toString());
_deviceState = DEVSTATE_FAILED;
}
}
Expand Down
8 changes: 6 additions & 2 deletions IO_RotaryEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,13 @@ class RotaryEncoder : public IODevice {
}
}

// Device specific read function
// Return the position sent by the rotary encoder software
int _readAnalogue(VPIN vpin) override {
if (_deviceState == DEVSTATE_FAILED) return 0;
return _position;
}

// Send the feedback value to the rotary encoder software
void _write(VPIN vpin, int value) override {
if (vpin == _firstVpin + 1) {
if (value != 0) value = 0x01;
Expand All @@ -148,9 +149,12 @@ class RotaryEncoder : public IODevice {
}
}

// Send a position update to the rotary encoder software
// To be valid, must be 0 to 255, and different to the current position
// If the current position is the same, it was initiated by the rotary encoder
void _writeAnalogue(VPIN vpin, int position, uint8_t profile, uint16_t duration) override {
if (vpin == _firstVpin + 2) {
if (position >= 0 && position <= 255) {
if (position >= 0 && position <= 255 && position != _position) {
byte newPosition = position & 0xFF;
byte _positionBuffer[2] = {RE_MOVE, newPosition};
I2CManager.write(_I2CAddress, _positionBuffer, 2);
Expand Down
5 changes: 4 additions & 1 deletion version.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
#include "StringFormatter.h"


#define VERSION "4.2.61"
#define VERSION "4.2.62"
// 4.2.62 - Update IO_RotaryEncoder.h to ignore sending current position
// - Update IO_EXTurntable.h to remove forced I2C clock speed
// - Show device offline if EX-Turntable not connected
// 4.2.61 - MAX_CURRENT restriction (caps motor shield value)
// 4.2.60 - Add mDNS capability to ESP32 for autodiscovery
// 4.2.59 - Fix: AP SSID was DCC_ instead of DCCEX_
Expand Down

0 comments on commit efe96d1

Please sign in to comment.