From 6463fbee3219f4630225a4cd32fa91767ce229b9 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Sun, 19 Dec 2021 16:50:55 +0100 Subject: [PATCH] Fix for usermod sornt& rotary encoder. --- usermods/Temperature/usermod_temperature.h | 14 +++++++++++--- .../usermod_v2_mode_sort/usermod_v2_mode_sort.h | 14 +++++--------- .../usermod_v2_rotary_encoder_ui.h | 10 ++++------ .../usermod_v2_rotary_encoder_ui_ALT.h | 10 ++++------ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/usermods/Temperature/usermod_temperature.h b/usermods/Temperature/usermod_temperature.h index 40f81857..75bf70f7 100644 --- a/usermods/Temperature/usermod_temperature.h +++ b/usermods/Temperature/usermod_temperature.h @@ -60,9 +60,16 @@ class UsermodTemperature : public Usermod { if (oneWire->reset()) { // if reset() fails there are no OneWire devices oneWire->skip(); // skip ROM oneWire->write(0xBE); // read (temperature) from EEPROM - delayMicroseconds(250); - for (byte i=0; i < 9; i++) data[i] = oneWire->read(); // first 2 bytes contain temperature - if (OneWire::crc8(data,8) != data[8]) DEBUG_PRINTLN(F("CRC error reading temperature.")); + delayMicroseconds(150); + oneWire->read_bytes(data, 9); // first 2 bytes contain 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) { case 0x10: // DS18S20 has 9-bit precision result = (data[1] << 8) | data[0]; @@ -116,6 +123,7 @@ class UsermodTemperature : public Usermod { case 0x42: // DS28EA00 DEBUG_PRINTLN(F("Sensor found.")); sensorFound = deviceAddress[0]; + DEBUG_PRINTF("0x%02X\n", sensorFound); return true; } } diff --git a/usermods/usermod_v2_mode_sort/usermod_v2_mode_sort.h b/usermods/usermod_v2_mode_sort/usermod_v2_mode_sort.h index 2be7ce84..092206bb 100644 --- a/usermods/usermod_v2_mode_sort/usermod_v2_mode_sort.h +++ b/usermods/usermod_v2_mode_sort/usermod_v2_mode_sort.h @@ -162,7 +162,6 @@ public: break; } } - re_sortModes(palettes_qstrings, palettes_alpha_indexes, strip.getPaletteCount(), skipPaletteCount); } @@ -189,6 +188,7 @@ public: bool complete = false; for (size_t i = 0; i < strlen_P(json); i++) { singleJsonSymbol = pgm_read_byte_near(json + i); + if (singleJsonSymbol == '\0') break; switch (singleJsonSymbol) { case '"': insideQuotes = !insideQuotes; @@ -200,18 +200,14 @@ public: case '[': break; case ']': - complete = true; + if (!insideQuotes) complete = true; break; case ',': - modeIndex++; + if (!insideQuotes) modeIndex++; default: - if (!insideQuotes) { - break; - } - } - if (complete) { - break; + if (!insideQuotes) break; } + if (complete) break; } return modeStrings; } diff --git a/usermods/usermod_v2_rotary_encoder_ui/usermod_v2_rotary_encoder_ui.h b/usermods/usermod_v2_rotary_encoder_ui/usermod_v2_rotary_encoder_ui.h index bf909bdc..19f97a2d 100644 --- a/usermods/usermod_v2_rotary_encoder_ui/usermod_v2_rotary_encoder_ui.h +++ b/usermods/usermod_v2_rotary_encoder_ui/usermod_v2_rotary_encoder_ui.h @@ -97,6 +97,7 @@ public: */ void setup() { + DEBUG_PRINTLN(F("Usermod Rotary Encoder init.")); PinManagerPinType pins[3] = { { pinA, false }, { pinB, false }, { pinC, false } }; if (!pinManager.allocateMultiplePins(pins, 3, PinOwner::UM_RotaryEncoderUI)) { // BUG: configuring this usermod with conflicting pins @@ -443,14 +444,11 @@ public: DEBUG_PRINTLN(F(": No config found. (Using defaults.)")); return false; } - int8_t newDTpin = pinA; - int8_t newCLKpin = pinB; - int8_t newSWpin = pinC; + int8_t newDTpin = top[FPSTR(_DT_pin)] | pinA; + int8_t newCLKpin = top[FPSTR(_CLK_pin)] | pinB; + int8_t newSWpin = top[FPSTR(_SW_pin)] | pinC; 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)); if (!initDone) { diff --git a/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h b/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h index 625af0af..aee90e28 100644 --- a/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h +++ b/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h @@ -102,6 +102,7 @@ public: */ void setup() { + DEBUG_PRINTLN(F("Usermod Rotary Encoder init.")); PinManagerPinType pins[3] = { { pinA, false }, { pinB, false }, { pinC, false } }; if (!pinManager.allocateMultiplePins(pins, 3, PinOwner::UM_RotaryEncoderUI)) { // BUG: configuring this usermod with conflicting pins @@ -514,14 +515,11 @@ public: DEBUG_PRINTLN(F(": No config found. (Using defaults.)")); return false; } - int8_t newDTpin = pinA; - int8_t newCLKpin = pinB; - int8_t newSWpin = pinC; + int8_t newDTpin = top[FPSTR(_DT_pin)] | pinA; + int8_t newCLKpin = top[FPSTR(_CLK_pin)] | pinB; + int8_t newSWpin = top[FPSTR(_SW_pin)] | pinC; 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)); if (!initDone) {