Fix for usermod sornt& rotary encoder.

This commit is contained in:
Blaz Kristan 2021-12-19 16:50:55 +01:00
parent e43cdc6674
commit 6463fbee32
4 changed files with 24 additions and 24 deletions

View File

@ -60,9 +60,16 @@ class UsermodTemperature : public Usermod {
if (oneWire->reset()) { // if reset() fails there are no OneWire devices if (oneWire->reset()) { // if reset() fails there are no OneWire devices
oneWire->skip(); // skip ROM oneWire->skip(); // skip ROM
oneWire->write(0xBE); // read (temperature) from EEPROM oneWire->write(0xBE); // read (temperature) from EEPROM
delayMicroseconds(250); delayMicroseconds(150);
for (byte i=0; i < 9; i++) data[i] = oneWire->read(); // first 2 bytes contain temperature oneWire->read_bytes(data, 9); // first 2 bytes contain temperature
if (OneWire::crc8(data,8) != data[8]) DEBUG_PRINTLN(F("CRC error reading temperature.")); #ifdef WLED_DEBUG
if (OneWire::crc8(data,8) != data[8]) {
DEBUG_PRINTLN(F("CRC error reading temperature."));
for (byte i=0; i < 9; i++) DEBUG_PRINTF("0x%02X ", data[i]);
DEBUG_PRINT(F(" => "));
DEBUG_PRINTF("0x%02X\n", OneWire::crc8(data,8));
}
#endif
switch(sensorFound) { switch(sensorFound) {
case 0x10: // DS18S20 has 9-bit precision case 0x10: // DS18S20 has 9-bit precision
result = (data[1] << 8) | data[0]; result = (data[1] << 8) | data[0];
@ -116,6 +123,7 @@ class UsermodTemperature : public Usermod {
case 0x42: // DS28EA00 case 0x42: // DS28EA00
DEBUG_PRINTLN(F("Sensor found.")); DEBUG_PRINTLN(F("Sensor found."));
sensorFound = deviceAddress[0]; sensorFound = deviceAddress[0];
DEBUG_PRINTF("0x%02X\n", sensorFound);
return true; return true;
} }
} }

View File

@ -162,7 +162,6 @@ public:
break; break;
} }
} }
re_sortModes(palettes_qstrings, palettes_alpha_indexes, strip.getPaletteCount(), skipPaletteCount); re_sortModes(palettes_qstrings, palettes_alpha_indexes, strip.getPaletteCount(), skipPaletteCount);
} }
@ -189,6 +188,7 @@ public:
bool complete = false; bool complete = false;
for (size_t i = 0; i < strlen_P(json); i++) { for (size_t i = 0; i < strlen_P(json); i++) {
singleJsonSymbol = pgm_read_byte_near(json + i); singleJsonSymbol = pgm_read_byte_near(json + i);
if (singleJsonSymbol == '\0') break;
switch (singleJsonSymbol) { switch (singleJsonSymbol) {
case '"': case '"':
insideQuotes = !insideQuotes; insideQuotes = !insideQuotes;
@ -200,18 +200,14 @@ public:
case '[': case '[':
break; break;
case ']': case ']':
complete = true; if (!insideQuotes) complete = true;
break; break;
case ',': case ',':
modeIndex++; if (!insideQuotes) modeIndex++;
default: default:
if (!insideQuotes) { if (!insideQuotes) break;
break;
}
}
if (complete) {
break;
} }
if (complete) break;
} }
return modeStrings; return modeStrings;
} }

View File

@ -97,6 +97,7 @@ public:
*/ */
void setup() void setup()
{ {
DEBUG_PRINTLN(F("Usermod Rotary Encoder init."));
PinManagerPinType pins[3] = { { pinA, false }, { pinB, false }, { pinC, false } }; PinManagerPinType pins[3] = { { pinA, false }, { pinB, false }, { pinC, false } };
if (!pinManager.allocateMultiplePins(pins, 3, PinOwner::UM_RotaryEncoderUI)) { if (!pinManager.allocateMultiplePins(pins, 3, PinOwner::UM_RotaryEncoderUI)) {
// BUG: configuring this usermod with conflicting pins // BUG: configuring this usermod with conflicting pins
@ -443,14 +444,11 @@ public:
DEBUG_PRINTLN(F(": No config found. (Using defaults.)")); DEBUG_PRINTLN(F(": No config found. (Using defaults.)"));
return false; return false;
} }
int8_t newDTpin = pinA; int8_t newDTpin = top[FPSTR(_DT_pin)] | pinA;
int8_t newCLKpin = pinB; int8_t newCLKpin = top[FPSTR(_CLK_pin)] | pinB;
int8_t newSWpin = pinC; int8_t newSWpin = top[FPSTR(_SW_pin)] | pinC;
enabled = top[FPSTR(_enabled)] | enabled; enabled = top[FPSTR(_enabled)] | enabled;
newDTpin = top[FPSTR(_DT_pin)] | newDTpin;
newCLKpin = top[FPSTR(_CLK_pin)] | newCLKpin;
newSWpin = top[FPSTR(_SW_pin)] | newSWpin;
DEBUG_PRINT(FPSTR(_name)); DEBUG_PRINT(FPSTR(_name));
if (!initDone) { if (!initDone) {

View File

@ -102,6 +102,7 @@ public:
*/ */
void setup() void setup()
{ {
DEBUG_PRINTLN(F("Usermod Rotary Encoder init."));
PinManagerPinType pins[3] = { { pinA, false }, { pinB, false }, { pinC, false } }; PinManagerPinType pins[3] = { { pinA, false }, { pinB, false }, { pinC, false } };
if (!pinManager.allocateMultiplePins(pins, 3, PinOwner::UM_RotaryEncoderUI)) { if (!pinManager.allocateMultiplePins(pins, 3, PinOwner::UM_RotaryEncoderUI)) {
// BUG: configuring this usermod with conflicting pins // BUG: configuring this usermod with conflicting pins
@ -514,14 +515,11 @@ public:
DEBUG_PRINTLN(F(": No config found. (Using defaults.)")); DEBUG_PRINTLN(F(": No config found. (Using defaults.)"));
return false; return false;
} }
int8_t newDTpin = pinA; int8_t newDTpin = top[FPSTR(_DT_pin)] | pinA;
int8_t newCLKpin = pinB; int8_t newCLKpin = top[FPSTR(_CLK_pin)] | pinB;
int8_t newSWpin = pinC; int8_t newSWpin = top[FPSTR(_SW_pin)] | pinC;
enabled = top[FPSTR(_enabled)] | enabled; enabled = top[FPSTR(_enabled)] | enabled;
newDTpin = top[FPSTR(_DT_pin)] | newDTpin;
newCLKpin = top[FPSTR(_CLK_pin)] | newCLKpin;
newSWpin = top[FPSTR(_SW_pin)] | newSWpin;
DEBUG_PRINT(FPSTR(_name)); DEBUG_PRINT(FPSTR(_name));
if (!initDone) { if (!initDone) {