Timebase sync
This commit is contained in:
parent
2852061699
commit
d4c921ea2e
@ -314,6 +314,7 @@ class WS2812FX {
|
||||
targetPalette = CloudColors_p;
|
||||
ablMilliampsMax = 850;
|
||||
currentMilliamps = 0;
|
||||
timebase = 0;
|
||||
_locked = nullptr;
|
||||
_modeUsesLock = false;
|
||||
bus = new NeoPixelWrapper();
|
||||
@ -378,6 +379,7 @@ class WS2812FX {
|
||||
currentMilliamps;
|
||||
|
||||
uint32_t
|
||||
timebase,
|
||||
color_wheel(uint8_t),
|
||||
color_from_palette(uint16_t, bool, bool, uint8_t, uint8_t pbri = 255),
|
||||
color_blend(uint32_t,uint32_t,uint8_t),
|
||||
|
@ -55,7 +55,7 @@ void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst)
|
||||
}
|
||||
|
||||
void WS2812FX::service() {
|
||||
now = millis(); // Be aware, millis() rolls over every 49 days
|
||||
now = millis() + timebase; // Be aware, millis() rolls over every 49 days
|
||||
if (now - _lastShow < MIN_SHOW_DELAY) return;
|
||||
bool doShow = false;
|
||||
for(uint8_t i=0; i < MAX_NUM_SEGMENTS; i++)
|
||||
|
@ -61,6 +61,7 @@
|
||||
#define ESPALEXA_ASYNC
|
||||
#define ESPALEXA_NO_SUBPAGE
|
||||
#define ESPALEXA_MAXDEVICES 1
|
||||
#define ESPALEXA_DEBUG
|
||||
#include "src/dependencies/espalexa/Espalexa.h"
|
||||
#endif
|
||||
#ifndef WLED_DISABLE_BLYNK
|
||||
@ -98,7 +99,7 @@
|
||||
|
||||
|
||||
//version code in format yymmddb (b = daily build)
|
||||
#define VERSION 1910073
|
||||
#define VERSION 1910174
|
||||
char versionString[] = "0.8.5";
|
||||
|
||||
|
||||
@ -296,6 +297,7 @@ byte briLast = 127; //brightness before turned off. Us
|
||||
|
||||
//button
|
||||
bool buttonPressedBefore = false;
|
||||
bool buttonLongPressed = false;
|
||||
unsigned long buttonPressedTime = 0;
|
||||
unsigned long buttonWaitTime = 0;
|
||||
|
||||
|
@ -175,9 +175,10 @@ void beginStrip()
|
||||
}
|
||||
|
||||
|
||||
void initAP(){
|
||||
void initAP(bool resetAP=false){
|
||||
bool set = apSSID[0];
|
||||
if (!set) strcpy(apSSID,"WLED-AP");
|
||||
if (!set || resetAP) strcpy(apSSID, "WLED-AP");
|
||||
//if (resetAP) strcpy(apPass,"wled1234");
|
||||
WiFi.softAPConfig(IPAddress(4, 3, 2, 1), IPAddress(4, 3, 2, 1), IPAddress(255,255,255,0));
|
||||
WiFi.softAP(apSSID, apPass, apChannel, apHide);
|
||||
if (!set) apSSID[0] = 0;
|
||||
|
@ -2,7 +2,7 @@
|
||||
* UDP notifier
|
||||
*/
|
||||
|
||||
#define WLEDPACKETSIZE 24
|
||||
#define WLEDPACKETSIZE 29
|
||||
#define UDP_IN_MAXSIZE 1472
|
||||
|
||||
|
||||
@ -37,8 +37,8 @@ void notify(byte callMode, bool followUp=false)
|
||||
//compatibilityVersionByte:
|
||||
//0: old 1: supports white 2: supports secondary color
|
||||
//3: supports FX intensity, 24 byte packet 4: supports transitionDelay 5: sup palette
|
||||
//6: supports tertiary color
|
||||
udpOut[11] = 5;
|
||||
//6: supports timebase syncing, 29 byte packet 7: supports tertiary color
|
||||
udpOut[11] = 6;
|
||||
udpOut[12] = colSec[0];
|
||||
udpOut[13] = colSec[1];
|
||||
udpOut[14] = colSec[2];
|
||||
@ -51,6 +51,12 @@ void notify(byte callMode, bool followUp=false)
|
||||
udpOut[21] = colTer[1];
|
||||
udpOut[22] = colTer[2];
|
||||
udpOut[23] = colTer[3];*/
|
||||
udpOut[24] = followUp;
|
||||
uint32_t t = millis() + strip.timebase;
|
||||
udpOut[25] = (t >> 24) & 0xFF;
|
||||
udpOut[26] = (t >> 16) & 0xFF;
|
||||
udpOut[27] = (t >> 8) & 0xFF;
|
||||
udpOut[28] = (t >> 0) & 0xFF;
|
||||
|
||||
IPAddress broadcastIp;
|
||||
broadcastIp = ~uint32_t(WiFi.subnetMask()) | uint32_t(WiFi.gatewayIP());
|
||||
@ -185,7 +191,14 @@ void handleNotifications()
|
||||
colSec[2] = udpIn[14];
|
||||
colSec[3] = udpIn[15];
|
||||
}
|
||||
/*if (udpIn[11] > 5)
|
||||
if (udpIn[11] > 5)
|
||||
{
|
||||
uint32_t t = (udpIn[25] << 24) | (udpIn[26] << 16) | (udpIn[27] << 8) | (udpIn[28]);
|
||||
t -= 2;
|
||||
t -= millis();
|
||||
strip.timebase = t;
|
||||
}
|
||||
/*if (udpIn[11] > 6)
|
||||
{
|
||||
colTer[0] = udpIn[20];
|
||||
colTer[1] = udpIn[21];
|
||||
|
@ -19,10 +19,21 @@ void handleButton()
|
||||
#ifdef BTNPIN
|
||||
if (!buttonEnabled) return;
|
||||
|
||||
if (digitalRead(BTNPIN) == LOW && !buttonPressedBefore) //pressed
|
||||
if (digitalRead(BTNPIN) == LOW) //pressed
|
||||
{
|
||||
buttonPressedTime = millis();
|
||||
if (!buttonPressedBefore) buttonPressedTime = millis();
|
||||
buttonPressedBefore = true;
|
||||
|
||||
if (millis() - buttonPressedTime > 600) //long press
|
||||
{
|
||||
if (!buttonLongPressed)
|
||||
{
|
||||
if (macroLongPress) {applyMacro(macroLongPress);}
|
||||
else _setRandomColor(false,true);
|
||||
|
||||
buttonLongPressed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (digitalRead(BTNPIN) == HIGH && buttonPressedBefore) //released
|
||||
{
|
||||
@ -31,13 +42,11 @@ void handleButton()
|
||||
bool doublePress = buttonWaitTime;
|
||||
buttonWaitTime = 0;
|
||||
|
||||
if (dur > 6000) {initAP();}
|
||||
else if (dur > 600) //long press
|
||||
if (dur > 6000) //long press
|
||||
{
|
||||
if (macroLongPress) {applyMacro(macroLongPress);}
|
||||
else _setRandomColor(false,true);
|
||||
initAP(true);
|
||||
}
|
||||
else { //short press
|
||||
else if (!buttonLongPressed) { //short press
|
||||
if (macroDoublePress)
|
||||
{
|
||||
if (doublePress) applyMacro(macroDoublePress);
|
||||
@ -45,6 +54,7 @@ void handleButton()
|
||||
} else shortPressAction();
|
||||
}
|
||||
buttonPressedBefore = false;
|
||||
buttonLongPressed = false;
|
||||
}
|
||||
|
||||
if (buttonWaitTime && millis() - buttonWaitTime > 450 && !buttonPressedBefore)
|
||||
|
Loading…
Reference in New Issue
Block a user