diff --git a/usermods/usermod_v2_rotary_encoder_ui/readme.md b/usermods/usermod_v2_rotary_encoder_ui/readme.md index 4477590b..9bbcd6a6 100644 --- a/usermods/usermod_v2_rotary_encoder_ui/readme.md +++ b/usermods/usermod_v2_rotary_encoder_ui/readme.md @@ -16,7 +16,7 @@ This file should be placed in the same directory as `platformio.ini`. ### Define Your Options * `USERMOD_ROTARY_ENCODER_UI` - define this to have this user mod included wled00\usermods_list.cpp -* `USERMOD_FOUR_LINE_DISLAY` - define this to have this the Four Line Display mod included wled00\usermods_list.cpp - also tells this usermod that the display is available (see the Four Line Display usermod `readme.md` for more details) +* `USERMOD_FOUR_LINE_DISPLAY` - define this to have this the Four Line Display mod included wled00\usermods_list.cpp - also tells this usermod that the display is available (see the Four Line Display usermod `readme.md` for more details) * `ENCODER_DT_PIN` - The encoders DT pin, defaults to 12 * `ENCODER_CLK_PIN` - The encoders CLK pin, defaults to 14 * `ENCODER_SW_PIN` - The encoders SW pin, defaults to 13 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 6dc2a1be..5ff1090d 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 @@ -37,7 +37,7 @@ #define ENCODER_SW_PIN 13 #endif -#ifndef USERMOD_FOUR_LINE_DISLAY +#ifndef USERMOD_FOUR_LINE_DISPLAY // These constants won't be defined if we aren't using FourLineDisplay. #define FLD_LINE_3_BRIGHTNESS 0 #define FLD_LINE_3_EFFECT_SPEED 0 @@ -62,7 +62,7 @@ private: unsigned char button_state = HIGH; unsigned char prev_button_state = HIGH; -#ifdef USERMOD_FOUR_LINE_DISLAY +#ifdef USERMOD_FOUR_LINE_DISPLAY FourLineDisplayUsermod *display; #else void* display = nullptr; @@ -96,7 +96,7 @@ public: modes_alpha_indexes = modeSortUsermod->getModesAlphaIndexes(); palettes_alpha_indexes = modeSortUsermod->getPalettesAlphaIndexes(); -#ifdef USERMOD_FOUR_LINE_DISLAY +#ifdef USERMOD_FOUR_LINE_DISPLAY // This Usermod uses FourLineDisplayUsermod for the best experience. // But it's optional. But you want it. display = (FourLineDisplayUsermod*) usermods.lookup(USERMOD_ID_FOUR_LINE_DISP); @@ -248,7 +248,7 @@ public: } boolean changeState(const char *stateName, byte lineThreeMode, byte markedLine) { -#ifdef USERMOD_FOUR_LINE_DISLAY +#ifdef USERMOD_FOUR_LINE_DISPLAY if (display != nullptr) { if (display->wakeDisplay()) { // Throw away wake up input @@ -272,7 +272,7 @@ public: } void changeBrightness(bool increase) { -#ifdef USERMOD_FOUR_LINE_DISLAY +#ifdef USERMOD_FOUR_LINE_DISPLAY if (display && display->wakeDisplay()) { // Throw away wake up input return; @@ -288,7 +288,7 @@ public: } void changeEffect(bool increase) { -#ifdef USERMOD_FOUR_LINE_DISLAY +#ifdef USERMOD_FOUR_LINE_DISPLAY if (display && display->wakeDisplay()) { // Throw away wake up input return; @@ -305,7 +305,7 @@ public: } void changeEffectSpeed(bool increase) { -#ifdef USERMOD_FOUR_LINE_DISLAY +#ifdef USERMOD_FOUR_LINE_DISPLAY if (display && display->wakeDisplay()) { // Throw away wake up input return; @@ -321,7 +321,7 @@ public: } void changeEffectIntensity(bool increase) { -#ifdef USERMOD_FOUR_LINE_DISLAY +#ifdef USERMOD_FOUR_LINE_DISPLAY if (display && display->wakeDisplay()) { // Throw away wake up input return; @@ -337,7 +337,7 @@ public: } void changePalette(bool increase) { -#ifdef USERMOD_FOUR_LINE_DISLAY +#ifdef USERMOD_FOUR_LINE_DISPLAY if (display && display->wakeDisplay()) { // Throw away wake up input return; diff --git a/wled00/button.cpp b/wled00/button.cpp index c263a66d..7d4839c6 100644 --- a/wled00/button.cpp +++ b/wled00/button.cpp @@ -6,105 +6,210 @@ #define WLED_DEBOUNCE_THRESHOLD 50 //only consider button input of at least 50ms as valid (debouncing) -void shortPressAction() +void shortPressAction(uint8_t b) { - if (!macroButton) + if (!macroButton[b]) { toggleOnOff(); colorUpdated(NOTIFIER_CALL_MODE_BUTTON); } else { - applyPreset(macroButton); + applyPreset(macroButton[b]); } } -bool isButtonPressed() +bool isButtonPressed(uint8_t i) { - if (btnPin>=0 && digitalRead(btnPin) == LOW) return true; - #ifdef TOUCHPIN - if (touchRead(TOUCHPIN) <= TOUCH_THRESHOLD) return true; - #endif + if (btnPin[i]<0) return false; + switch (buttonType[i]) { + case BTN_TYPE_NONE: + case BTN_TYPE_RESERVED: + break; + case BTN_TYPE_PUSH: + case BTN_TYPE_SWITCH: + if (digitalRead(btnPin[i]) == LOW) return true; + break; + case BTN_TYPE_PUSH_ACT_HIGH: + case BTN_TYPE_SWITCH_ACT_HIGH: + if (digitalRead(btnPin[i]) == HIGH) return true; + break; + case BTN_TYPE_TOUCH: + #ifdef ARDUINO_ARCH_ESP32 + if (touchRead(btnPin[i]) <= touchThreshold) return true; + #endif + break; + } return false; } - -void handleSwitch() +void handleSwitch(uint8_t b) { - if (buttonPressedBefore != isButtonPressed()) { - buttonPressedTime = millis(); - buttonPressedBefore = !buttonPressedBefore; + if (buttonPressedBefore[b] != isButtonPressed(b)) { + buttonPressedTime[b] = millis(); + buttonPressedBefore[b] = !buttonPressedBefore[b]; } - if (buttonLongPressed == buttonPressedBefore) return; + if (buttonLongPressed[b] == buttonPressedBefore[b]) return; - if (millis() - buttonPressedTime > WLED_DEBOUNCE_THRESHOLD) { //fire edge event only after 50ms without change (debounce) - if (buttonPressedBefore) { //LOW, falling edge, switch closed - if (macroButton) applyPreset(macroButton); + if (millis() - buttonPressedTime[b] > WLED_DEBOUNCE_THRESHOLD) { //fire edge event only after 50ms without change (debounce) + if (buttonPressedBefore[b]) { //LOW, falling edge, switch closed + if (macroButton[b]) applyPreset(macroButton[b]); else { //turn on if (!bri) {toggleOnOff(); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);} } } else { //HIGH, rising edge, switch opened - if (macroLongPress) applyPreset(macroLongPress); + if (macroLongPress[b]) applyPreset(macroLongPress[b]); else { //turn off if (bri) {toggleOnOff(); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);} } } - buttonLongPressed = buttonPressedBefore; //save the last "long term" switch state + buttonLongPressed[b] = buttonPressedBefore[b]; //save the last "long term" switch state } } +void handleAnalog(uint8_t b) +{ + static uint8_t oldRead[WLED_MAX_BUTTONS]; + #ifdef ESP8266 + uint16_t aRead = analogRead(A0) >> 2; // convert 10bit read to 8bit + #else + uint16_t aRead = analogRead(btnPin[b]) >> 4; // convert 12bit read to 8bit + #endif + // remove noise & reduce frequency of UI updates + aRead &= 0xFC; + + if (oldRead[b] == aRead) return; // no change in reading + oldRead[b] = aRead; + + // if no macro for "short press" and "long press" is defined use brightness control + if (!macroButton[b] && !macroLongPress[b]) { + // if "double press" macro defines which option to change + if (macroDoublePress[b] >= 250) { + // global brightness + if (aRead == 0) { + briLast = bri; + bri = 0; + } else{ + bri = aRead; + } + } else if (macroDoublePress[b] == 249) { + // effect speed + effectSpeed = aRead; + effectChanged = true; + for (uint8_t i = 0; i < strip.getMaxSegments(); i++) { + WS2812FX::Segment& seg = strip.getSegment(i); + if (!seg.isSelected()) continue; + seg.speed = effectSpeed; + } + } else if (macroDoublePress[b] == 248) { + // effect intensity + effectIntensity = aRead; + effectChanged = true; + for (uint8_t i = 0; i < strip.getMaxSegments(); i++) { + WS2812FX::Segment& seg = strip.getSegment(i); + if (!seg.isSelected()) continue; + seg.intensity = effectIntensity; + } + } else if (macroDoublePress[b] == 247) { + // selected palette + effectPalette = map(aRead, 0, 252, 0, strip.getPaletteCount()-1); + effectChanged = true; + for (uint8_t i = 0; i < strip.getMaxSegments(); i++) { + WS2812FX::Segment& seg = strip.getSegment(i); + if (!seg.isSelected()) continue; + seg.palette = effectPalette; + } + } else if (macroDoublePress[b] == 200) { + // primary color, hue, full saturation + colorHStoRGB(aRead*256,255,col); + } else { + // otherwise use "double press" for segment selection + //uint8_t mainSeg = strip.getMainSegmentId(); + WS2812FX::Segment& seg = strip.getSegment(macroDoublePress[b]); + if (aRead == 0) { + seg.setOption(SEG_OPTION_ON, 0); // off + } else { + seg.setOpacity(aRead, macroDoublePress[b]); + seg.setOption(SEG_OPTION_ON, 1); + } + // this will notify clients of update (websockets,mqtt,etc) + //call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (No notification) + // 6: fx changed 7: hue 8: preset cycle 9: blynk 10: alexa + updateInterfaces(NOTIFIER_CALL_MODE_BUTTON); + } + } else { + //TODO: + // we can either trigger a preset depending on the level (between short and long entries) + // or use it for RGBW direct control + } + //call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (No notification) + // 6: fx changed 7: hue 8: preset cycle 9: blynk 10: alexa + colorUpdated(NOTIFIER_CALL_MODE_BUTTON); +} void handleButton() { - if (btnPin<0 || buttonType < BTN_TYPE_PUSH) return; + static unsigned long lastRead = 0UL; + for (uint8_t b=0; b 250) { // button is not a button but a potentiometer + if (b+1 == WLED_MAX_BUTTONS) lastRead = millis(); + handleAnalog(b); continue; + } - //momentary button logic - if (isButtonPressed()) //pressed - { - if (!buttonPressedBefore) buttonPressedTime = millis(); - buttonPressedBefore = true; + if (buttonType[b] == BTN_TYPE_SWITCH || buttonType[b] == BTN_TYPE_SWITCH_ACT_HIGH) { //button is not momentary, but switch. This is only suitable on pins whose on-boot state does not matter (NOT gpio0) + handleSwitch(b); continue; + } - if (millis() - buttonPressedTime > 600) //long press + //momentary button logic + if (isButtonPressed(b)) //pressed { - if (!buttonLongPressed) - { - if (macroLongPress) {applyPreset(macroLongPress);} - else _setRandomColor(false,true); + if (!buttonPressedBefore[b]) buttonPressedTime[b] = millis(); + buttonPressedBefore[b] = true; - buttonLongPressed = true; + if (millis() - buttonPressedTime[b] > 600) //long press + { + if (!buttonLongPressed[b]) + { + if (macroLongPress[b]) {applyPreset(macroLongPress[b]);} + else _setRandomColor(false,true); + + buttonLongPressed[b] = true; + } } } - } - else if (!isButtonPressed() && buttonPressedBefore) //released - { - long dur = millis() - buttonPressedTime; - if (dur < WLED_DEBOUNCE_THRESHOLD) {buttonPressedBefore = false; return;} //too short "press", debounce - bool doublePress = buttonWaitTime; - buttonWaitTime = 0; - - if (dur > 6000) //long press + else if (!isButtonPressed(b) && buttonPressedBefore[b]) //released { - WLED::instance().initAP(true); - } - else if (!buttonLongPressed) { //short press - if (macroDoublePress) - { - if (doublePress) applyPreset(macroDoublePress); - else buttonWaitTime = millis(); - } else shortPressAction(); - } - buttonPressedBefore = false; - buttonLongPressed = false; - } + long dur = millis() - buttonPressedTime[b]; + if (dur < WLED_DEBOUNCE_THRESHOLD) {buttonPressedBefore[b] = false; continue;} //too short "press", debounce + bool doublePress = buttonWaitTime[b]; + buttonWaitTime[b] = 0; - if (buttonWaitTime && millis() - buttonWaitTime > 450 && !buttonPressedBefore) - { - buttonWaitTime = 0; - shortPressAction(); + if (dur > 6000 && b==0) //long press on button 0 + { + WLED::instance().initAP(true); + } + else if (!buttonLongPressed[b]) { //short press + if (macroDoublePress[b]) + { + if (doublePress) applyPreset(macroDoublePress[b]); + else buttonWaitTime[b] = millis(); + } else shortPressAction(b); + } + buttonPressedBefore[b] = false; + buttonLongPressed[b] = false; + } + + if (buttonWaitTime[b] && millis() - buttonWaitTime[b] > 450 && !buttonPressedBefore[b]) + { + buttonWaitTime[b] = 0; + shortPressAction(b); + } } } @@ -128,7 +233,8 @@ void handleIO() { if (!offMode) { #ifdef ESP8266 - //turn off built-in LED if strip is turned off + // turn off built-in LED if strip is turned off + // this will break digital bus so will need to be reinitialised on On pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, HIGH); #endif diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index d6aede4e..a65d0434 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -62,7 +62,8 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { JsonArray ap_ip = ap["ip"]; for (byte i = 0; i < 4; i++) { apIP[i] = ap_ip; - }*/ + } + */ noWifiSleep = doc[F("wifi")][F("sleep")] | !noWifiSleep; // inverted noWifiSleep = !noWifiSleep; @@ -89,13 +90,12 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { for (JsonObject elm : ins) { if (s >= WLED_MAX_BUSSES) break; uint8_t pins[5] = {255, 255, 255, 255, 255}; - JsonArray pinArr = elm[F("pin")]; + JsonArray pinArr = elm["pin"]; if (pinArr.size() == 0) continue; pins[0] = pinArr[0]; uint8_t i = 0; for (int p : pinArr) { - pins[i] = p; - i++; + pins[i++] = p; if (i>4) break; } @@ -123,22 +123,47 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { } if (hw_led["rev"]) busses.getBus(0)->reversed = true; //set 0.11 global reversed setting for first bus - JsonObject hw_btn_ins_0 = hw[F("btn")][F("ins")][0]; - CJSON(buttonType, hw_btn_ins_0["type"]); - int hw_btn_pin = hw_btn_ins_0[F("pin")][0] | -2; //-2 = not present in doc, keep current. -1 = disable - if (hw_btn_pin > -2) { - if (pinManager.allocatePin(hw_btn_pin,false)) { - btnPin = hw_btn_pin; - pinMode(btnPin, INPUT_PULLUP); - } else { - btnPin = -1; + // read multiple button configuration + JsonArray hw_btn_ins = hw[F("btn")][F("ins")]; + if (!hw_btn_ins.isNull()) { + uint8_t s = 0; + for (JsonObject btn : hw_btn_ins) { + CJSON(buttonType[s], btn["type"]); + int8_t pin = btn[F("pin")][0] | -1; + if (pin > -1) { + if (pinManager.allocatePin(pin,false)) { + btnPin[s] = pin; + pinMode(btnPin[s], INPUT_PULLUP); + } else { + btnPin[s] = -1; + } + } + JsonArray hw_btn_ins_0_macros = btn[F("macros")]; + CJSON(macroButton[s], hw_btn_ins_0_macros[0]); + CJSON(macroLongPress[s],hw_btn_ins_0_macros[1]); + CJSON(macroDoublePress[s], hw_btn_ins_0_macros[2]); + if (++s >= WLED_MAX_BUTTONS) break; // max buttons reached } + // clear remaining buttons + for (; s -2) { @@ -164,7 +189,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { rlyMde = !relay["rev"]; } - //int hw_status_pin = hw[F("status")][F("pin")]; // -1 + //int hw_status_pin = hw[F("status")]["pin"]; // -1 JsonObject light = doc[F("light")]; CJSON(briMultiplier, light[F("scale-bri")]); @@ -179,7 +204,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { JsonObject light_tr = light[F("tr")]; CJSON(fadeTransition, light_tr[F("mode")]); - int tdd = light_tr[F("dur")] | -1; + int tdd = light_tr["dur"] | -1; if (tdd >= 0) transitionDelayDefault = tdd * 100; CJSON(strip.paletteFade, light_tr["pal"]); @@ -203,7 +228,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(presetCycleMin, def_cy[F("range")][0]); CJSON(presetCycleMax, def_cy[F("range")][1]); - tdd = def_cy[F("dur")] | -1; + tdd = def_cy["dur"] | -1; if (tdd > 0) presetCycleTime = tdd; JsonObject interfaces = doc["if"]; @@ -255,6 +280,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(macroAlexaOn, interfaces[F("va")][F("macros")][0]); CJSON(macroAlexaOff, interfaces[F("va")][F("macros")][1]); +#ifndef WLED_DISABLE_BLYNK const char* apikey = interfaces["blynk"][F("token")] | "Hidden"; tdd = strnlen(apikey, 36); if (tdd > 20 || tdd == 0) @@ -263,7 +289,9 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { JsonObject if_blynk = interfaces["blynk"]; getStringFromJson(blynkHost, if_blynk[F("host")], 33); CJSON(blynkPort, if_blynk["port"]); +#endif +#ifdef WLED_ENABLE_MQTT JsonObject if_mqtt = interfaces["mqtt"]; CJSON(mqttEnabled, if_mqtt["en"]); getStringFromJson(mqttServer, if_mqtt[F("broker")], 33); @@ -274,7 +302,9 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { getStringFromJson(mqttDeviceTopic, if_mqtt[F("topics")][F("device")], 33); // "wled/test" getStringFromJson(mqttGroupTopic, if_mqtt[F("topics")][F("group")], 33); // "" +#endif +#ifndef WLED_DISABLE_HUESYNC JsonObject if_hue = interfaces[F("hue")]; CJSON(huePollingEnabled, if_hue["en"]); CJSON(huePollLightId, if_hue["id"]); @@ -290,6 +320,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { for (byte i = 0; i < 4; i++) CJSON(hueIP[i], if_hue_ip[i]); +#endif JsonObject if_ntp = interfaces[F("ntp")]; CJSON(ntpEnabled, if_ntp["en"]); @@ -306,7 +337,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(countdownMode, ol[F("cntdwn")]); if (prev != overlayDefault) overlayCurrent = overlayDefault; - CJSON(overlayMin, ol[F("min")]); + CJSON(overlayMin, ol["min"]); CJSON(overlayMax, ol[F("max")]); CJSON(analogClock12pixel, ol[F("o12pix")]); CJSON(analogClock5MinuteMarks, ol[F("o5m")]); @@ -331,7 +362,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { if (it > 9) break; if (it<8 && timer[F("hour")]==255) it=8; // hour==255 -> sunrise/sunset CJSON(timerHours[it], timer[F("hour")]); - CJSON(timerMinutes[it], timer[F("min")]); + CJSON(timerMinutes[it], timer["min"]); CJSON(timerMacro[it], timer[F("macro")]); byte dowPrev = timerWeekday[it]; @@ -377,6 +408,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { } #endif + DEBUG_PRINTLN(F("Starting usermod config.")); JsonObject usermods_settings = doc["um"]; if (!usermods_settings.isNull()) usermods.readFromConfig(usermods_settings); @@ -490,21 +522,34 @@ void serializeConfig() { ins["type"] = bus->getType(); } + // button(s) JsonObject hw_btn = hw.createNestedObject("btn"); - + hw_btn["max"] = WLED_MAX_BUTTONS; // just information about max number of buttons (not actually used) JsonArray hw_btn_ins = hw_btn.createNestedArray("ins"); - // button BTNPIN + // there is always at least one button JsonObject hw_btn_ins_0 = hw_btn_ins.createNestedObject(); - hw_btn_ins_0["type"] = buttonType; - + hw_btn_ins_0["type"] = buttonType[0]; JsonArray hw_btn_ins_0_pin = hw_btn_ins_0.createNestedArray("pin"); - hw_btn_ins_0_pin.add(btnPin); - + hw_btn_ins_0_pin.add(btnPin[0]); JsonArray hw_btn_ins_0_macros = hw_btn_ins_0.createNestedArray("macros"); - hw_btn_ins_0_macros.add(macroButton); - hw_btn_ins_0_macros.add(macroLongPress); - hw_btn_ins_0_macros.add(macroDoublePress); + hw_btn_ins_0_macros.add(macroButton[0]); + hw_btn_ins_0_macros.add(macroLongPress[0]); + hw_btn_ins_0_macros.add(macroDoublePress[0]); + + // additional buttons + for (uint8_t i=1; i> 1; } @@ -684,7 +736,6 @@ void serializeConfig() { for (byte i = 0; i < 15; i++) dmx_fixmap.add(DMXFixtureMap[i]); #endif - //} JsonObject usermods_settings = doc.createNestedObject("um"); usermods.addToConfig(usermods_settings); @@ -711,15 +762,21 @@ bool deserializeConfigSec() { JsonObject interfaces = doc["if"]; +#ifndef WLED_DISABLE_BLYNK const char* apikey = interfaces["blynk"][F("token")] | "Hidden"; int tdd = strnlen(apikey, 36); if (tdd > 20 || tdd == 0) getStringFromJson(blynkApiKey, apikey, 36); +#endif +#ifdef WLED_ENABLE_MQTT JsonObject if_mqtt = interfaces["mqtt"]; getStringFromJson(mqttPass, if_mqtt["psk"], 41); +#endif +#ifndef WLED_DISABLE_HUESYNC getStringFromJson(hueApiKey, interfaces[F("hue")][F("key")], 47); +#endif JsonObject ota = doc["ota"]; getStringFromJson(otaPass, ota[F("pwd")], 33); @@ -746,12 +803,18 @@ void serializeConfigSec() { ap["psk"] = apPass; JsonObject interfaces = doc.createNestedObject("if"); +#ifndef WLED_DISABLE_BLYNK JsonObject if_blynk = interfaces.createNestedObject("blynk"); if_blynk[F("token")] = blynkApiKey; +#endif +#ifdef WLED_ENABLE_MQTT JsonObject if_mqtt = interfaces.createNestedObject("mqtt"); if_mqtt["psk"] = mqttPass; +#endif +#ifndef WLED_DISABLE_HUESYNC JsonObject if_hue = interfaces.createNestedObject("hue"); if_hue[F("key")] = hueApiKey; +#endif JsonObject ota = doc.createNestedObject("ota"); ota[F("pwd")] = otaPass; diff --git a/wled00/const.h b/wled00/const.h index fc555092..19c2853e 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -31,39 +31,47 @@ #endif #endif +#ifndef WLED_MAX_BUTTONS + #ifdef ESP8266 + #define WLED_MAX_BUTTONS 2 + #else + #define WLED_MAX_BUTTONS 4 + #endif +#endif + //Usermod IDs -#define USERMOD_ID_RESERVED 0 //Unused. Might indicate no usermod present -#define USERMOD_ID_UNSPECIFIED 1 //Default value for a general user mod that does not specify a custom ID -#define USERMOD_ID_EXAMPLE 2 //Usermod "usermod_v2_example.h" -#define USERMOD_ID_TEMPERATURE 3 //Usermod "usermod_temperature.h" -#define USERMOD_ID_FIXNETSERVICES 4 //Usermod "usermod_Fix_unreachable_netservices.h" -#define USERMOD_ID_PIRSWITCH 5 //Usermod "usermod_PIR_sensor_switch.h" -#define USERMOD_ID_IMU 6 //Usermod "usermod_mpu6050_imu.h" -#define USERMOD_ID_FOUR_LINE_DISP 7 //Usermod "usermod_v2_four_line_display.h -#define USERMOD_ID_ROTARY_ENC_UI 8 //Usermod "usermod_v2_rotary_encoder_ui.h" -#define USERMOD_ID_AUTO_SAVE 9 //Usermod "usermod_v2_auto_save.h" -#define USERMOD_ID_DHT 10 //Usermod "usermod_dht.h" -#define USERMOD_ID_MODE_SORT 11 //Usermod "usermod_v2_mode_sort.h" -#define USERMOD_ID_VL53L0X 12 //Usermod "usermod_vl53l0x_gestures.h" -#define USERMOD_ID_RTC 13 //Usermod "usermod_rtc.h" -#define USERMOD_ID_ELEKSTUBE_IPS 14 //Usermod "usermod_elekstube_ips.h" -#define USERMOD_ID_MULTI_RELAY 101 //Usermod "usermod_multi_relay.h" -#define USERMOD_ID_ANIMATED_STAIRCASE 102 //Usermod "Animated_Staircase.h" +#define USERMOD_ID_RESERVED 0 //Unused. Might indicate no usermod present +#define USERMOD_ID_UNSPECIFIED 1 //Default value for a general user mod that does not specify a custom ID +#define USERMOD_ID_EXAMPLE 2 //Usermod "usermod_v2_example.h" +#define USERMOD_ID_TEMPERATURE 3 //Usermod "usermod_temperature.h" +#define USERMOD_ID_FIXNETSERVICES 4 //Usermod "usermod_Fix_unreachable_netservices.h" +#define USERMOD_ID_PIRSWITCH 5 //Usermod "usermod_PIR_sensor_switch.h" +#define USERMOD_ID_IMU 6 //Usermod "usermod_mpu6050_imu.h" +#define USERMOD_ID_FOUR_LINE_DISP 7 //Usermod "usermod_v2_four_line_display.h +#define USERMOD_ID_ROTARY_ENC_UI 8 //Usermod "usermod_v2_rotary_encoder_ui.h" +#define USERMOD_ID_AUTO_SAVE 9 //Usermod "usermod_v2_auto_save.h" +#define USERMOD_ID_DHT 10 //Usermod "usermod_dht.h" +#define USERMOD_ID_MODE_SORT 11 //Usermod "usermod_v2_mode_sort.h" +#define USERMOD_ID_VL53L0X 12 //Usermod "usermod_vl53l0x_gestures.h" +#define USERMOD_ID_MULTI_RELAY 13 //Usermod "usermod_multi_relay.h" +#define USERMOD_ID_ANIMATED_STAIRCASE 14 //Usermod "Animated_Staircase.h" +#define USERMOD_ID_RTC 15 //Usermod "usermod_rtc.h" +#define USERMOD_ID_ELEKSTUBE_IPS 16 //Usermod "usermod_elekstube_ips.h" //Access point behavior -#define AP_BEHAVIOR_BOOT_NO_CONN 0 //Open AP when no connection after boot -#define AP_BEHAVIOR_NO_CONN 1 //Open when no connection (either after boot or if connection is lost) -#define AP_BEHAVIOR_ALWAYS 2 //Always open -#define AP_BEHAVIOR_BUTTON_ONLY 3 //Only when button pressed for 6 sec +#define AP_BEHAVIOR_BOOT_NO_CONN 0 //Open AP when no connection after boot +#define AP_BEHAVIOR_NO_CONN 1 //Open when no connection (either after boot or if connection is lost) +#define AP_BEHAVIOR_ALWAYS 2 //Always open +#define AP_BEHAVIOR_BUTTON_ONLY 3 //Only when button pressed for 6 sec //Notifier callMode -#define NOTIFIER_CALL_MODE_INIT 0 //no updates on init, can be used to disable updates +#define NOTIFIER_CALL_MODE_INIT 0 //no updates on init, can be used to disable updates #define NOTIFIER_CALL_MODE_DIRECT_CHANGE 1 #define NOTIFIER_CALL_MODE_BUTTON 2 #define NOTIFIER_CALL_MODE_NOTIFICATION 3 #define NOTIFIER_CALL_MODE_NIGHTLIGHT 4 #define NOTIFIER_CALL_MODE_NO_NOTIFY 5 -#define NOTIFIER_CALL_MODE_FX_CHANGED 6 //no longer used +#define NOTIFIER_CALL_MODE_FX_CHANGED 6 //no longer used #define NOTIFIER_CALL_MODE_HUE 7 #define NOTIFIER_CALL_MODE_PRESET_CYCLE 8 #define NOTIFIER_CALL_MODE_BLYNK 9 @@ -150,9 +158,11 @@ #define BTN_TYPE_NONE 0 #define BTN_TYPE_RESERVED 1 #define BTN_TYPE_PUSH 2 -#define BTN_TYPE_PUSH_ACT_HIGH 3 //not implemented +#define BTN_TYPE_PUSH_ACT_HIGH 3 #define BTN_TYPE_SWITCH 4 -#define BTN_TYPE_SWITCH_ACT_HIGH 5 //not implemented +#define BTN_TYPE_SWITCH_ACT_HIGH 5 +#define BTN_TYPE_TOUCH 6 +#define BTN_TYPE_ANALOG 7 //Ethernet board types #define WLED_NUM_ETH_TYPES 5 @@ -205,7 +215,7 @@ // maximum number of LEDs - more than 1500 LEDs (or 500 DMA "LEDPIN 3" driven ones) will cause a low memory condition on ESP8266 #ifndef MAX_LEDS #ifdef ESP8266 -#define MAX_LEDS 8192 //rely on memory limit to limit this to 1600 LEDs +#define MAX_LEDS 1664 // can't rely on memory limit to limit this to 1600 LEDs #else #define MAX_LEDS 8192 #endif @@ -245,7 +255,7 @@ #ifdef ESP8266 #define JSON_BUFFER_SIZE 9216 #else - #define JSON_BUFFER_SIZE 16384 + #define JSON_BUFFER_SIZE 20480 #endif // Maximum size of node map (list of other WLED instances) diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index 2addd732..65992c6f 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -1,356 +1,408 @@ - - - - - - LED Settings - - - - -
-
-
-

LED & Hardware setup

- Total LED count:
- Recommended power supply for brightest white:
- ?
-
-
- Enable automatic brightness limiter:
-
- Maximum Current: mA
- - Automatically limits brightness to stay close to the limit.
- Keep at <1A if powering LEDs directly from the ESP 5V pin!
- If you are using an external power supply, enter its rating.
- (Current estimated usage: unknown)


- LED voltage (Max. current for a single LED):
-
- - Keep at default if you are unsure about your type of LEDs.
-
-

Hardware setup

-
LED outputs:
- -
- LED Memory Usage: 0 / ? B
-

- - Button pin:  ×
- IR pin:  ×
- Relay pin:  ×
- Active high -

Defaults

- Turn LEDs on after power up/reset:
- Default brightness: (0-255)

- Apply preset at boot (0 uses defaults) -
- or -
- Set current preset cycle setting as boot default:

- Use Gamma correction for color: (strongly recommended)
- Use Gamma correction for brightness: (not recommended)

- Brightness factor: % -

Transitions

- Crossfade:
- Transition Time: ms
- Enable Palette transitions: -

Timed light

- Default Duration: min
- Default Target brightness:
- Mode: - -

Advanced

- Palette blending: -
- - Auto-calculate white channel from RGB:
- -

- -
- - + + + + + + LED Settings + + + + +
+
+
+

LED & Hardware setup

+ Total LED count:
+ Recommended power supply for brightest white:
+ ?
+
+
+ Enable automatic brightness limiter:
+
+ Maximum Current: mA
+ + Automatically limits brightness to stay close to the limit.
+ Keep at <1A if powering LEDs directly from the ESP 5V pin!
+ If you are using an external power supply, enter its rating.
+ (Current estimated usage: unknown)


+ LED voltage (Max. current for a single LED):
+
+ + Keep at default if you are unsure about your type of LEDs.
+
+

Hardware setup

+
LED outputs:
+ +
+ LED Memory Usage: 0 / ? B
+

+
+
+ Touch threshold:
+ IR pin:   ×
+ IR info
+ Relay pin: Invert  ×
+
+

Defaults

+ Turn LEDs on after power up/reset:
+ Default brightness: (0-255)

+ Apply preset at boot (0 uses defaults) +
- or -
+ Set current preset cycle setting as boot default:

+ Use Gamma correction for color: (strongly recommended)
+ Use Gamma correction for brightness: (not recommended)

+ Brightness factor: % +

Transitions

+ Crossfade:
+ Transition Time: ms
+ Enable Palette transitions: +

Timed light

+ Default Duration: min
+ Default Target brightness:
+ Mode: + +

Advanced

+ Palette blending: +
+ + Auto-calculate white channel from RGB:
+ +

+ +
+ + diff --git a/wled00/data/settings_sync.htm b/wled00/data/settings_sync.htm index c1e28197..ff6e1082 100644 --- a/wled00/data/settings_sync.htm +++ b/wled00/data/settings_sync.htm @@ -15,29 +15,10 @@ function GetV(){var d=document;}

Sync setup

-

Button setup

-Button type: -
-Infrared remote: -
-IR info

WLED Broadcast

UDP Port:
2nd Port:
-Receive Brightness, Color, and Effects
+Receive: Brightness, Color, and Effects
Send notifications on direct change:
Send notifications on button press or IR:
Send Alexa notifications:
diff --git a/wled00/data/settings_time.htm b/wled00/data/settings_time.htm index f8a0d9f1..b9a39677 100644 --- a/wled00/data/settings_time.htm +++ b/wled00/data/settings_time.htm @@ -6,41 +6,41 @@ Time Settings