diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 2d731dcb..4cc35f35 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -5,7 +5,6 @@ #include #include #include -//#include #include #include #include @@ -16,7 +15,7 @@ * @author Christian Schwinne */ //Hardware-settings (only changeble via code) -uint8_t led_amount = 16; +uint8_t led_amount = 9; uint8_t buttonPin = 0; //needs pull-up //Default CONFIG String serverDescription = "WLED 0.3pd"; @@ -72,12 +71,12 @@ int nightlightDelayMs; boolean udpConnected = false; byte udpIn[16]; -NeoPixelBus strip(led_amount, 1); - ESP8266WebServer server(80); ESP8266HTTPUpdateServer httpUpdater; WiFiUDP notifierUdp; +WS2812FX strip = WS2812FX(led_amount, 2, NEO_GRB + NEO_KHZ800); + File fsUploadFile; void down() @@ -112,6 +111,7 @@ void loop() { handleTransitions(); handleNightlight(); handleButton(); + strip.service(); } diff --git a/wled00/wled03_set.ino b/wled00/wled03_set.ino index 3a6f7846..b17f8c6b 100644 --- a/wled00/wled03_set.ino +++ b/wled00/wled03_set.ino @@ -148,6 +148,7 @@ void handleSettingsSet() boolean handleSet(String req) { + boolean effectUpdated = false; if (!(req.indexOf("ajax_in") >= 0)) { if (req.indexOf("get-settings") >= 0) { @@ -176,10 +177,14 @@ boolean handleSet(String req) pos = req.indexOf("FX="); if (pos > 0) { effectCurrent = req.substring(pos + 3).toInt(); + strip.setMode(effectCurrent); + effectUpdated = true; } pos = req.indexOf("XS="); if (pos > 0) { effectSpeed = req.substring(pos + 3).toInt(); + strip.setSpeed(effectSpeed); + effectUpdated = true; } if (req.indexOf("NS=") > 0) { @@ -209,6 +214,12 @@ boolean handleSet(String req) } } XML_response(); - colorUpdated(1); + if (effectUpdated) + { + colorUpdated(6); + } else + { + colorUpdated(1); + } return true; } diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index 021d30fb..08fa123b 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -131,7 +131,12 @@ void wledInit() // Add service to MDNS MDNS.addService("http", "tcp", 80); // Initialize NeoPixel Strip - strip.Begin(); + strip.init(); + strip.setMode(0); + strip.setColor(0); + strip.setSpeed(effectSpeed); + strip.setBrightness(255); + strip.start(); colorUpdated(0); pinMode(buttonPin, INPUT_PULLUP); } diff --git a/wled00/wled07_notify.ino b/wled00/wled07_notify.ino index 3d1514cb..c0a9be30 100644 --- a/wled00/wled07_notify.ino +++ b/wled00/wled07_notify.ino @@ -7,6 +7,7 @@ void notify(uint8_t callMode) case 2: if (!notifyButton) return; break; case 3: return; case 4: if (!notifyNightlight) return; break; + case 6: if (!notifyDirect) return; break; //fx change default: return; } byte udpOut[16]; @@ -39,11 +40,10 @@ void handleNotifications() col[0] = udpIn[3]; col[1] = udpIn[4]; col[2] = udpIn[5]; - if (true) //always receive effects? - { - effectCurrent = udpIn[8]; - effectSpeed = udpIn[9]; - } + effectCurrent = udpIn[8]; + strip.setMode(effectCurrent); + effectSpeed = udpIn[9]; + strip.setSpeed(effectSpeed); nightlightActive = udpIn[6]; if (!udpIn[6]) { diff --git a/wled00/wled08_led.ino b/wled00/wled08_led.ino index d56d6f7d..875b0c49 100644 --- a/wled00/wled08_led.ino +++ b/wled00/wled08_led.ino @@ -1,17 +1,8 @@ void setAllLeds() { double d = bri_t*bri_n; - double val = d/25600; - if (val > 1.0) - { - val = 1.0; - } - int r = col_t[0]*val; - int g = col_t[1]*val; - int b = col_t[2]*val; - for (int i=0; i < led_amount; i++) { - strip.SetPixelColor(i, RgbColor(r, g, b)); - } - strip.Show(); + int val = d/100; + strip.setBrightness(val); + strip.setColor(col_t[0], col_t[1], col_t[2]); } void setLedsStandard() @@ -32,6 +23,7 @@ void colorUpdated(int callMode) //call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (no not.) if (col[0] == col_it[0] && col[1] == col_it[1] && col[2] == col_it[2] && bri == bri_it) { + if (callMode == 6) notify(6); return; //no change } col_it[0] = col[0];