Added basic Time Activated Macros function

Fixed Cronixie overlay
512K Flash mode (temporarily) unavailable
This commit is contained in:
cschwinne 2018-09-22 22:49:24 +02:00
parent bb7f673ff9
commit 5f59487a88
9 changed files with 96 additions and 11 deletions

View File

@ -137,7 +137,6 @@ void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w)
case 7: bus->SetPixelColor((_skipFirstMode)?o+4:o+3,RgbwColor(r,g,b,w)); break;
case 8: bus->SetPixelColor((_skipFirstMode)?o+10:o+9,RgbwColor(r,g,b,w)); break;
case 9: bus->SetPixelColor((_skipFirstMode)?o+5:o+4,RgbwColor(r,g,b,w)); break;
default: break;
}
}
}
@ -150,7 +149,7 @@ void WS2812FX::setReverseMode(bool b)
void WS2812FX::driverModeCronixie(bool b)
{
_cronixieMode = b;
if (b) _segments[0].stop = 5;
_segments[0].stop = (b) ? 5 : _length-1;
}
void WS2812FX::setCronixieBacklight(bool b)

Binary file not shown.

View File

@ -345,12 +345,28 @@ Define API macros here:<br>
15: <input name="M15" maxlength="64"><br>
16: <input name="M16" maxlength="64"><br><br>
<i>Use 0 for the default action instead of a macro</i><br>
Time controlled macros coming soon!<br>
Boot Macro: <input name="MB" type="number" min="0" max="16" required><br>
Alexa On/Off Macros: <input name="A0" type="number" min="0" max="16" required> <input name="A1" type="number" min="0" max="16" required><br>
Button Macro: <input name="MP" type="number" min="0" max="16" required> Long Press: <input name="ML" type="number" min="0" max="16" required><br>
Countdown-Over Macro: <input name="MC" type="number" min="0" max="16" required><br>
Timed-Light-Over Macro: <input name="MN" type="number" min="0" max="16" required><hr>
Timed-Light-Over Macro: <input name="MN" type="number" min="0" max="16" required><br>
Time-Controlled Macros (Hours/Minutes &gt; Macro):<br>
<input name="H0" type="number" min="0" max="24"> <input name="N0" type="number" min="0" max="59">
&gt; <input name="T0" type="number" min="0" max="16"><br>
<input name="H1" type="number" min="0" max="24"> <input name="N1" type="number" min="0" max="59">
&gt; <input name="T1" type="number" min="0" max="16"><br>
<input name="H2" type="number" min="0" max="24"> <input name="N2" type="number" min="0" max="59">
&gt; <input name="T2" type="number" min="0" max="16"><br>
<input name="H3" type="number" min="0" max="24"> <input name="N3" type="number" min="0" max="59">
&gt; <input name="T3" type="number" min="0" max="16"><br>
<input name="H4" type="number" min="0" max="24"> <input name="N4" type="number" min="0" max="59">
&gt; <input name="T4" type="number" min="0" max="16"><br>
<input name="H5" type="number" min="0" max="24"> <input name="N5" type="number" min="0" max="59">
&gt; <input name="T5" type="number" min="0" max="16"><br>
<input name="H6" type="number" min="0" max="24"> <input name="N6" type="number" min="0" max="59">
&gt; <input name="T6" type="number" min="0" max="16"><br>
<input name="H7" type="number" min="0" max="24"> <input name="N7" type="number" min="0" max="59">
&gt; <input name="T7" type="number" min="0" max="16"><hr>
<button type="button" onclick="B()">Back</button><button type="submit">Save</button>
</form>
</body>

View File

@ -9,7 +9,8 @@
//ESP8266-01 got too little storage space to work with all features of WLED. To use it, you must use ESP8266 Arduino Core v2.3.0 and the setting 512K(64K SPIFFS).
//Uncomment the following line to disable some features (currently Mobile UI, welcome page and single digit + cronixie overlays) to compile for ESP8266-01
#define WLED_FLASH_512K_MODE
//#define WLED_FLASH_512K_MODE
//CURRENTLY NOT WORKING
//library inclusions
@ -43,7 +44,7 @@
//version code in format yymmddb (b = daily build)
#define VERSION 1809162
#define VERSION 1809222
char versionString[] = "0.8.0-a";
@ -299,6 +300,14 @@ bool cronixieInit = false;
unsigned long countdownTime = 1514764800L;
bool countdownOverTriggered = true;
//timer
byte lastTimerMinute = 0;
byte timerHours[] = {0,0,0,0,0,0,0,0};
byte timerMinutes[] = {0,0,0,0,0,0,0,0};
byte timerMacro[] = {0,0,0,0,0,0,0,0};
byte timerWeekday[] = {255,255,255,255,255,255,255,255}; //weekdays to activate on
//bit pattern of arr elem: 0b11111111: sat,fri,thu,wed,tue,mon,sun,validity
//blynk
bool blynkEnabled = false;

View File

@ -234,6 +234,14 @@ void saveSettingsToEEPROM()
{
EEPROM.write(i, blynkApiKey[i-2220]);
}
for (int i = 0; i < 8; ++i)
{
EEPROM.write(2260 + i, timerHours[i] );
EEPROM.write(2270 + i, timerMinutes[i]);
EEPROM.write(2280 + i, timerWeekday[i]);
EEPROM.write(2290 + i, timerMacro[i] );
}
EEPROM.commit();
}
@ -448,8 +456,17 @@ void loadSettingsFromEEPROM(bool first)
if (lastEEPROMversion > 7)
{
strip.paletteFade = EEPROM.read(374);
strip.paletteFade = EEPROM.read(374);
strip.paletteBlend = EEPROM.read(382);
for (int i = 0; i < 8; ++i)
{
timerHours[i] = EEPROM.read(2260 + i);
timerMinutes[i] = EEPROM.read(2270 + i);
timerWeekday[i] = EEPROM.read(2280 + i);
if (timerWeekday[i] == 0) timerWeekday[i] = 255;
timerMacro[i] = EEPROM.read(2290 + i);
}
}
receiveDirect = !EEPROM.read(2200);

View File

@ -292,6 +292,15 @@ void getSettingsJS(byte subPage) //get values for settings form in javascript
sappend('v',"ML",macroLongPress);
sappend('v',"MC",macroCountdown);
sappend('v',"MN",macroNl);
k[2] = 0; //Time macros
for (int i = 0; i<8; i++)
{
k[1] = 48+i; //ascii 0,1,2,3
k[0] = 'H'; sappend('v',k,timerHours[i]);
k[0] = 'N'; sappend('v',k,timerMinutes[i]);
k[0] = 'T'; sappend('v',k,timerMacro[i]);
}
}
if (subPage == 6)

View File

@ -219,7 +219,7 @@ void handleSettingsSet(byte subPage)
strcpy(cronixieDisplay,server.arg("CX").c_str());
bool cbOld = cronixieBacklight;
cronixieBacklight = server.hasArg("CB");
if (cbOld != cronixieBacklight && overlayCurrent == 4)
if (cbOld != cronixieBacklight && overlayCurrent == 3)
{
strip.setCronixieBacklight(cronixieBacklight); overlayRefreshedTime = 0;
}
@ -236,6 +236,7 @@ void handleSettingsSet(byte subPage)
String a = "M"+String(i);
if (server.hasArg(a)) saveMacro(i,server.arg(a),false);
}
macroBoot = server.arg("MB").toInt();
macroAlexaOn = server.arg("A0").toInt();
macroAlexaOff = server.arg("A1").toInt();
@ -243,6 +244,21 @@ void handleSettingsSet(byte subPage)
macroLongPress = server.arg("ML").toInt();
macroCountdown = server.arg("MC").toInt();
macroNl = server.arg("MN").toInt();
char k[3]; k[2] = 0;
for (int i = 0; i<8; i++)
{
k[1] = i+48;//ascii 0,1,2,3
k[0] = 'H'; //timer hours
timerHours[i] = server.arg(k).toInt();
k[0] = 'N'; //minutes
timerMinutes[i] = server.arg(k).toInt();
k[0] = 'T'; //macros
timerMacro[i] = server.arg(k).toInt();
}
}
//SECURITY
@ -687,7 +703,7 @@ bool handleSet(String req)
{
cronixieBacklight = false;
}
if (overlayCurrent == 4) strip.setCronixieBacklight(cronixieBacklight);
if (overlayCurrent == 3) strip.setCronixieBacklight(cronixieBacklight);
overlayRefreshedTime = 0;
}
pos = req.indexOf("U0="); //user var 0

View File

@ -166,3 +166,21 @@ bool checkCountdown()
return false;
}
void checkTimers()
{
if (lastTimerMinute != minute(local)) //only check once a new minute begins
{
lastTimerMinute = minute(local);
for (uint8_t i = 0; i < 8; i++)
{
if (timerMacro[i] != 0
&& (timerHours[i] == hour(local) || timerHours[i] == 24) //if hour is set to 24, activate every hour
&& timerMinutes[i] == minute(local)
&& timerWeekday[i] >> weekday(local) & 0x01) //timer should activate at current day of week
{
applyMacro(timerMacro[i]);
}
}
}
}

View File

@ -3,13 +3,13 @@
*/
void initCronixie()
{
if (overlayCurrent == 4 && !cronixieInit)
if (overlayCurrent == 3 && !cronixieInit)
{
strip.driverModeCronixie(true);
strip.setCronixieBacklight(cronixieBacklight);
setCronixie();
cronixieInit = true;
} else if (cronixieInit && overlayCurrent != 4)
} else if (cronixieInit && overlayCurrent != 3)
{
strip.driverModeCronixie(false);
cronixieInit = false;
@ -124,6 +124,7 @@ void handleOverlays()
{
initCronixie();
updateLocalTime();
checkTimers();
switch (overlayCurrent)
{
case 0: break;//no overlay