Skip to content

Commit 1576096

Browse files
committed
Add Config option: "Flash System LED on WiFi activity"; the blue onboard LED is quite bright, shining through the case and can be annoying.
1 parent 35bd6dc commit 1576096

2 files changed

Lines changed: 34 additions & 50 deletions

File tree

marquee/Settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ boolean isStaticDisplay = false; // static display above SHOW_* items
128128
boolean IS_METRIC = true; // false = Imperial and true = Metric
129129
boolean IS_24HOUR = true; // 23:00 military 24 hour clock
130130
boolean IS_PM = true; // Show PM indicator on Clock when in AM/PM mode
131+
boolean isSysLed = true; // flash onboard LED on system actions
131132
const int WEBSERVER_PORT = 80; // The port you can access this device on over HTTP
132133
const boolean WEBSERVER_ENABLED = true; // Device will provide a web interface via http://[ip]:[port]/
133134
boolean IS_BASIC_AUTH = false; // Use Basic Authorization for Configuration security on Web Interface

marquee/marquee.ino

Lines changed: 33 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include "Settings.h"
2929

30-
#define VERSION "3.1.30"
30+
#define VERSION "3.1.31"
3131

3232
#define HOSTNAME "CLOCK-"
3333
#define CONFIG "/conf.txt"
@@ -321,10 +321,11 @@ static const char CHANGE_FORM2[] PROGMEM =
321321
"<fieldset><legend>LED Display settings</legend>"
322322
"<p>Display Brightness <input class='w3-border' name='ledintensity' type='number' min='0' max='15' value='%INTY_OPT%'></p>"
323323
"<p>Display Width (in 8x8 pixel tiles) <input class='w3-border' name='displaywidth' type='number' min='4' max='32' value='%DTW_OPT%'></p>"
324-
"<p>Wide Clock Display Format &ge; 8 tiles <select class='w3-option w3-padding' name='wideclockformat' title='Format options for Display with 8 or more tiles' $WCLKDIS$>%WCLK_OPT%</select></p>"
324+
"<p>Display Format for &ge; 8 tiles <select class='w3-option w3-padding' name='wideclockformat' title='Format options for Display with 8 or more tiles' $WCLKDIS$>%WCLK_OPT%</select></p>"
325325
"<p>Display Scroll Speed <select class='w3-option w3-padding' name='scrollspeed'>%SCRL_OPT%</select></p>"
326326
"<p>Display Scrolling Data interval <input class='w3-border' name='refreshDisplay' type='number' min='1' max='10' value='%RFSH_DISP%'> (minutes)</p>"
327327
"<p>Data Refresh interval <select class='w3-option w3-padding' name='refresh'>%RFSH_OPT%</select> (minutes)</p>"
328+
"<p><input name='sysled' class='w3-check' type='checkbox' %SYSLED_CB%> Flash System LED on WiFi activity</p>"
328329
"</fieldset>\n";
329330

330331
static const char CHANGE_FORM3[] PROGMEM =
@@ -1000,6 +1001,7 @@ void handleSaveConfig() {
10001001
SHOW_PRESSURE = server.hasArg(F("showpressure"));
10011002
SHOW_HIGHLOW = server.hasArg(F("showhighlow"));
10021003
isStaticDisplay = server.hasArg(F("statdisp"));
1004+
isSysLed = server.hasArg(F("sysled"));
10031005
IS_METRIC = server.hasArg(F("metric"));
10041006
marqueeMessage = decodeHtmlString(server.arg(F("marqueeMsg")));
10051007
timeDisplayTurnsOn = decodeHtmlString(server.arg(F("startTime")));
@@ -1061,42 +1063,12 @@ void handleForgetWifi() {
10611063
ESP.restart();
10621064
}
10631065

1064-
//void handleWideClockConfigure() {
1065-
// if (!authentication()) {
1066-
// return server.requestAuthentication();
1067-
// }
1068-
// digitalWrite(LED_ONBOARD, LED_ON);
1069-
//
1070-
// server.sendHeader(F("Cache-Control"), F("no-cache, no-store"));
1071-
// server.sendHeader(F("Pragma"), F("no-cache"));
1072-
// server.sendHeader(F("Expires"), "-1");
1073-
// server.setContentLength(CONTENT_LENGTH_UNKNOWN);
1074-
// server.send(200, F("text/html"), "");
1075-
//
1076-
// sendHeader();
1077-
//
1078-
// if (numberOfHorizontalDisplays >= 8) {
1079-
// // Wide display options
1080-
// String form = FPSTR(WIDECLOCK_FORM);
1081-
// String clockOptions = F("<option value='1'>HH:MM Temperature</option><option value='2'>HH:MM:SS</option><option value='3'>HH:MM</option>");
1082-
// clockOptions.replace(Wide_Clock_Style + "'", Wide_Clock_Style + F("' selected"));
1083-
// form.replace(F("%WCLK_OPT%"), clockOptions);
1084-
// server.sendContent(form);
1085-
// }
1086-
//
1087-
// sendFooter();
1088-
//
1089-
// server.sendContent("");
1090-
// server.client().stop();
1091-
// digitalWrite(LED_ONBOARD, LED_OFF);
1092-
//}
1093-
10941066
#if COMPILE_NEWS
10951067
void handleNewsConfigure() {
10961068
if (!authentication()) {
10971069
return server.requestAuthentication();
10981070
}
1099-
digitalWrite(LED_ONBOARD, LED_ON);
1071+
onBoardLed(LED_ON);
11001072

11011073
sendHeader();
11021074

@@ -1110,7 +1082,7 @@ void handleNewsConfigure() {
11101082

11111083
server.sendContent("");
11121084
server.client().stop();
1113-
digitalWrite(LED_ONBOARD, LED_OFF);
1085+
onBoardLed(LED_OFF);
11141086
}
11151087
#endif
11161088

@@ -1119,7 +1091,7 @@ void handleOctoprintConfigure() {
11191091
if (!authentication()) {
11201092
return server.requestAuthentication();
11211093
}
1122-
digitalWrite(LED_ONBOARD, LED_ON);
1094+
onBoardLed(LED_ON);
11231095

11241096
sendHeader();
11251097

@@ -1137,7 +1109,7 @@ void handleOctoprintConfigure() {
11371109

11381110
server.sendContent("");
11391111
server.client().stop();
1140-
digitalWrite(LED_ONBOARD, LED_OFF);
1112+
onBoardLed(LED_OFF);
11411113
}
11421114
#endif
11431115

@@ -1146,7 +1118,7 @@ void handlePiholeConfigure() {
11461118
if (!authentication()) {
11471119
return server.requestAuthentication();
11481120
}
1149-
digitalWrite(LED_ONBOARD, LED_ON);
1121+
onBoardLed(LED_ON);
11501122

11511123
sendHeader();
11521124

@@ -1165,7 +1137,7 @@ void handlePiholeConfigure() {
11651137

11661138
server.sendContent("");
11671139
server.client().stop();
1168-
digitalWrite(LED_ONBOARD, LED_OFF);
1140+
onBoardLed(LED_OFF);
11691141
}
11701142
#endif
11711143

@@ -1174,7 +1146,7 @@ void handleMqttConfigure() {
11741146
if (!authentication()) {
11751147
return server.requestAuthentication();
11761148
}
1177-
digitalWrite(LED_ONBOARD, LED_ON);
1149+
onBoardLed(LED_ON);
11781150

11791151
sendHeader();
11801152

@@ -1193,15 +1165,15 @@ void handleMqttConfigure() {
11931165

11941166
server.sendContent("");
11951167
server.client().stop();
1196-
digitalWrite(LED_ONBOARD, LED_OFF);
1168+
onBoardLed(LED_OFF);
11971169
}
11981170
#endif
11991171

12001172
void handleConfigure() {
12011173
if (!authentication()) {
12021174
return server.requestAuthentication();
12031175
}
1204-
digitalWrite(LED_ONBOARD, LED_ON);
1176+
onBoardLed(LED_ON);
12051177

12061178
sendHeader();
12071179

@@ -1239,6 +1211,7 @@ void handleConfigure() {
12391211
options.replace(">" + minutes + "<", " selected>" + minutes + "<");
12401212
form.replace(F("%RFSH_OPT%"), options);
12411213
form.replace(F("%RFSH_DISP%"), String(displayScrollingInterval));
1214+
form.replace(F("%SYSLED_CB%"), (isSysLed) ? "checked" : "");
12421215
// Wide display options
12431216
//FIXME String clockOptions = F("<option value='1'>HH:MM Temperature</option><option value='2'>HH:MM:SS</option><option value='3'>HH:MM</option>");
12441217
// NEW: 1=HH:MM, 2=HH:MM:SS, 3=HH:MM *CF, 4=HH:MM %RH, 5=mm dd HH:MM, 6=HH:MM MMDD, 7=HH:MM WwwDD
@@ -1266,7 +1239,7 @@ void handleConfigure() {
12661239

12671240
server.sendContent("");
12681241
server.client().stop();
1269-
digitalWrite(LED_ONBOARD, LED_OFF);
1242+
onBoardLed(LED_OFF);
12701243
}
12711244

12721245
void handleDisplay() {
@@ -1282,7 +1255,7 @@ void handleDisplay() {
12821255
//***********************************************************************
12831256
void getWeatherData() //client function to send/receive GET request data.
12841257
{
1285-
digitalWrite(LED_ONBOARD, LED_ON);
1258+
onBoardLed(LED_ON);
12861259
matrix.fillScreen(CLEAR); // show black
12871260
Serial.println();
12881261

@@ -1339,19 +1312,19 @@ void getWeatherData() //client function to send/receive GET request data.
13391312

13401313
Serial.println(F("Version: " VERSION));
13411314
Serial.println();
1342-
digitalWrite(LED_ONBOARD, LED_OFF);
1315+
onBoardLed(LED_OFF);
13431316
}
13441317

13451318
void displayMessage(String message) {
1346-
digitalWrite(LED_ONBOARD, LED_ON);
1319+
onBoardLed(LED_ON);
13471320

13481321
sendHeader();
13491322
server.sendContent(message);
13501323
sendFooter();
13511324
server.sendContent("");
13521325
server.client().stop();
13531326

1354-
digitalWrite(LED_ONBOARD, LED_OFF);
1327+
onBoardLed(LED_OFF);
13551328
}
13561329

13571330
void redirectHome() {
@@ -1406,7 +1379,7 @@ void sendFooter() {
14061379
}
14071380

14081381
void displayWeatherData() {
1409-
digitalWrite(LED_ONBOARD, LED_ON);
1382+
onBoardLed(LED_ON);
14101383
String html;
14111384

14121385
sendHeader(true);
@@ -1570,7 +1543,7 @@ void displayWeatherData() {
15701543
sendFooter();
15711544
server.sendContent("");
15721545
server.client().stop();
1573-
digitalWrite(LED_ONBOARD, LED_OFF);
1546+
onBoardLed(LED_OFF);
15741547
}
15751548

15761549
void configModeCallback(WiFiManager* myWiFiManager) {
@@ -1584,15 +1557,21 @@ void configModeCallback(WiFiManager* myWiFiManager) {
15841557
centerPrint("wifi");
15851558
}
15861559

1560+
void onBoardLed(boolean on) {
1561+
if (isSysLed) {
1562+
digitalWrite(LED_ONBOARD, on);
1563+
}
1564+
}
1565+
15871566
void flashLED(int number, int delayTime) {
15881567
for (int inx = 0; inx < number; inx++) {
15891568
#ifdef BUZZER_PIN
15901569
tone(BUZZER_PIN, 440, delayTime);
15911570
#endif
15921571
delay(delayTime);
1593-
digitalWrite(LED_ONBOARD, LED_ON);
1572+
onBoardLed(LED_ON);
15941573
delay(delayTime);
1595-
digitalWrite(LED_ONBOARD, LED_OFF);
1574+
onBoardLed(LED_OFF);
15961575
delay(delayTime);
15971576
}
15981577
#ifdef BUZZER_PIN
@@ -1718,6 +1697,7 @@ void writeConfiguration() {
17181697
f.println(F("isPM=") + String(IS_PM));
17191698
f.println(F("isMetric=") + String(IS_METRIC));
17201699
f.println(F("isStatDisp=") + String(isStaticDisplay));
1700+
f.println(F("isSysLed=") + String(isSysLed));
17211701
f.println(F("refreshRate=") + String(refreshDataInterval));
17221702
f.println(F("dispInterval=") + String(displayScrollingInterval));
17231703
f.println(F("displayWidth=") + String(displayWidth));
@@ -1850,6 +1830,9 @@ void readConfiguration() {
18501830
if ((idx = line.indexOf(F("isStatDisp="))) >= 0) {
18511831
isStaticDisplay = line.substring(idx + 11).toInt();
18521832
}
1833+
if ((idx = line.indexOf(F("isSysLed="))) >= 0) {
1834+
isSysLed = line.substring(idx + 9).toInt();
1835+
}
18531836
if ((idx = line.indexOf(F("refreshRate="))) >= 0) {
18541837
refreshDataInterval = line.substring(idx + 12).toInt();
18551838
if (refreshDataInterval == 0) {

0 commit comments

Comments
 (0)