serverside FX fully implemented
bug - choppy transitions
This commit is contained in:
parent
e710eace18
commit
eb8825ab27
@ -5,7 +5,6 @@
|
|||||||
#include <ESP8266mDNS.h>
|
#include <ESP8266mDNS.h>
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#include <Hash.h>
|
#include <Hash.h>
|
||||||
//#include <NeoPixelBus.h>
|
|
||||||
#include <WS2812FX.h>
|
#include <WS2812FX.h>
|
||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
#include <WiFiUDP.h>
|
#include <WiFiUDP.h>
|
||||||
@ -16,7 +15,7 @@
|
|||||||
* @author Christian Schwinne
|
* @author Christian Schwinne
|
||||||
*/
|
*/
|
||||||
//Hardware-settings (only changeble via code)
|
//Hardware-settings (only changeble via code)
|
||||||
uint8_t led_amount = 16;
|
uint8_t led_amount = 9;
|
||||||
uint8_t buttonPin = 0; //needs pull-up
|
uint8_t buttonPin = 0; //needs pull-up
|
||||||
//Default CONFIG
|
//Default CONFIG
|
||||||
String serverDescription = "WLED 0.3pd";
|
String serverDescription = "WLED 0.3pd";
|
||||||
@ -72,12 +71,12 @@ int nightlightDelayMs;
|
|||||||
boolean udpConnected = false;
|
boolean udpConnected = false;
|
||||||
byte udpIn[16];
|
byte udpIn[16];
|
||||||
|
|
||||||
NeoPixelBus<NeoGrbFeature, NeoEsp8266Uart800KbpsMethod> strip(led_amount, 1);
|
|
||||||
|
|
||||||
ESP8266WebServer server(80);
|
ESP8266WebServer server(80);
|
||||||
ESP8266HTTPUpdateServer httpUpdater;
|
ESP8266HTTPUpdateServer httpUpdater;
|
||||||
WiFiUDP notifierUdp;
|
WiFiUDP notifierUdp;
|
||||||
|
|
||||||
|
WS2812FX strip = WS2812FX(led_amount, 2, NEO_GRB + NEO_KHZ800);
|
||||||
|
|
||||||
File fsUploadFile;
|
File fsUploadFile;
|
||||||
|
|
||||||
void down()
|
void down()
|
||||||
@ -112,6 +111,7 @@ void loop() {
|
|||||||
handleTransitions();
|
handleTransitions();
|
||||||
handleNightlight();
|
handleNightlight();
|
||||||
handleButton();
|
handleButton();
|
||||||
|
strip.service();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -148,6 +148,7 @@ void handleSettingsSet()
|
|||||||
|
|
||||||
boolean handleSet(String req)
|
boolean handleSet(String req)
|
||||||
{
|
{
|
||||||
|
boolean effectUpdated = false;
|
||||||
if (!(req.indexOf("ajax_in") >= 0)) {
|
if (!(req.indexOf("ajax_in") >= 0)) {
|
||||||
if (req.indexOf("get-settings") >= 0)
|
if (req.indexOf("get-settings") >= 0)
|
||||||
{
|
{
|
||||||
@ -176,10 +177,14 @@ boolean handleSet(String req)
|
|||||||
pos = req.indexOf("FX=");
|
pos = req.indexOf("FX=");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
effectCurrent = req.substring(pos + 3).toInt();
|
effectCurrent = req.substring(pos + 3).toInt();
|
||||||
|
strip.setMode(effectCurrent);
|
||||||
|
effectUpdated = true;
|
||||||
}
|
}
|
||||||
pos = req.indexOf("XS=");
|
pos = req.indexOf("XS=");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
effectSpeed = req.substring(pos + 3).toInt();
|
effectSpeed = req.substring(pos + 3).toInt();
|
||||||
|
strip.setSpeed(effectSpeed);
|
||||||
|
effectUpdated = true;
|
||||||
}
|
}
|
||||||
if (req.indexOf("NS=") > 0)
|
if (req.indexOf("NS=") > 0)
|
||||||
{
|
{
|
||||||
@ -209,6 +214,12 @@ boolean handleSet(String req)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
XML_response();
|
XML_response();
|
||||||
|
if (effectUpdated)
|
||||||
|
{
|
||||||
|
colorUpdated(6);
|
||||||
|
} else
|
||||||
|
{
|
||||||
colorUpdated(1);
|
colorUpdated(1);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,12 @@ void wledInit()
|
|||||||
// Add service to MDNS
|
// Add service to MDNS
|
||||||
MDNS.addService("http", "tcp", 80);
|
MDNS.addService("http", "tcp", 80);
|
||||||
// Initialize NeoPixel Strip
|
// Initialize NeoPixel Strip
|
||||||
strip.Begin();
|
strip.init();
|
||||||
|
strip.setMode(0);
|
||||||
|
strip.setColor(0);
|
||||||
|
strip.setSpeed(effectSpeed);
|
||||||
|
strip.setBrightness(255);
|
||||||
|
strip.start();
|
||||||
colorUpdated(0);
|
colorUpdated(0);
|
||||||
pinMode(buttonPin, INPUT_PULLUP);
|
pinMode(buttonPin, INPUT_PULLUP);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ void notify(uint8_t callMode)
|
|||||||
case 2: if (!notifyButton) return; break;
|
case 2: if (!notifyButton) return; break;
|
||||||
case 3: return;
|
case 3: return;
|
||||||
case 4: if (!notifyNightlight) return; break;
|
case 4: if (!notifyNightlight) return; break;
|
||||||
|
case 6: if (!notifyDirect) return; break; //fx change
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
byte udpOut[16];
|
byte udpOut[16];
|
||||||
@ -39,11 +40,10 @@ void handleNotifications()
|
|||||||
col[0] = udpIn[3];
|
col[0] = udpIn[3];
|
||||||
col[1] = udpIn[4];
|
col[1] = udpIn[4];
|
||||||
col[2] = udpIn[5];
|
col[2] = udpIn[5];
|
||||||
if (true) //always receive effects?
|
|
||||||
{
|
|
||||||
effectCurrent = udpIn[8];
|
effectCurrent = udpIn[8];
|
||||||
|
strip.setMode(effectCurrent);
|
||||||
effectSpeed = udpIn[9];
|
effectSpeed = udpIn[9];
|
||||||
}
|
strip.setSpeed(effectSpeed);
|
||||||
nightlightActive = udpIn[6];
|
nightlightActive = udpIn[6];
|
||||||
if (!udpIn[6])
|
if (!udpIn[6])
|
||||||
{
|
{
|
||||||
|
@ -1,17 +1,8 @@
|
|||||||
void setAllLeds() {
|
void setAllLeds() {
|
||||||
double d = bri_t*bri_n;
|
double d = bri_t*bri_n;
|
||||||
double val = d/25600;
|
int val = d/100;
|
||||||
if (val > 1.0)
|
strip.setBrightness(val);
|
||||||
{
|
strip.setColor(col_t[0], col_t[1], col_t[2]);
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLedsStandard()
|
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.)
|
//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 (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
|
return; //no change
|
||||||
}
|
}
|
||||||
col_it[0] = col[0];
|
col_it[0] = col[0];
|
||||||
|
Loading…
Reference in New Issue
Block a user