File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ class Settings
3131 bool haDiscovery; // HomeAssistant Discovery switch
3232 char NTPTimezone[40 ]; // Time zone code for NTP get it from here: https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv
3333 char NTPServer[40 ]; // NTP timepool Server
34+ byte LEDBrightness; // brigthness of led
3435 } data;
3536
3637 void load ()
@@ -128,6 +129,10 @@ class Settings
128129 {
129130 strcpy (data.NTPServer , " pool.ntp.org" );
130131 }
132+ if (data.LEDBrightness && !data.LEDBrightness )
133+ {
134+ data.LEDBrightness = 127 ;
135+ }
131136 }
132137 void coVersCheck ()
133138 {
@@ -148,6 +153,7 @@ class Settings
148153 strcpy (data.httpUser , " " );
149154 strcpy (data.httpPass , " " );
150155 data.haDiscovery = false ;
156+ data.LEDBrightness = 127 ;
151157 save ();
152158 load ();
153159 }
Original file line number Diff line number Diff line change @@ -190,7 +190,7 @@ void setup()
190190{
191191 pinMode (EPEVER_DE_RE , OUTPUT );
192192 pinMode (LED_PIN , OUTPUT );
193- analogWrite (LED_PIN , 0 );
193+ analogWrite (LED_PIN , 255 -_settings. data . LEDBrightness );
194194 resetCounter (true );
195195 _settings.load ();
196196 WiFi.persistent (true ); // fix wifi save bug
@@ -345,6 +345,7 @@ void setup()
345345 _settings.data .haDiscovery = (request->arg (" post_hadiscovery" ) == " true" ) ? true : false ;
346346 strncpy (_settings.data .NTPTimezone , request->arg (" post_ntptimezone" ).c_str (), 40 );
347347 strncpy (_settings.data .NTPServer , request->arg (" post_ntptimeserv" ).c_str (), 40 );
348+ _settings.data .LEDBrightness = request->arg (" post_led" ).toInt ();
348349 _settings.save ();
349350 request->redirect (" /reboot" ); });
350351
Original file line number Diff line number Diff line change 99 4x no WiFi Connection
1010
1111*/
12- unsigned int ledPin = 0 ;
12+ bool ledPin = 0 ;
1313unsigned int ledTimer = 0 ;
1414unsigned int repeatTime = 5000 ;
1515unsigned int cycleTime = 250 ;
1616unsigned int cycleMillis = 0 ;
1717byte ledState = 0 ;
1818
19- //bool waveHelper = false;
2019void notificationLED ()
2120{
2221
@@ -28,21 +27,21 @@ void notificationLED()
2827 ledState = 3 ;
2928 else if (errorcode != 0 )
3029 ledState = 2 ;
31- else if (WiFi .status () == WL_CONNECTED /*&& mqttclient.connected()*/ && errorcode == 0 )
30+ else if (WiFi .status () == WL_CONNECTED && errorcode == 0 )
3231 ledState = 1 ;
3332 }
3433
3534 if (ledState > 0 )
3635 {
37- if (millis () >= (cycleMillis + cycleTime ) /*&& relaisOn != true*/ )
36+ if (millis () >= (cycleMillis + cycleTime ))
3837 {
39- if (ledPin == 0 )
38+ if (! ledPin )
4039 {
41- ledPin = 255 ;
40+ ledPin = true ;
4241 }
4342 else
4443 {
45- ledPin = 0 ;
44+ ledPin = false ;
4645 ledState -- ;
4746 }
4847 cycleMillis = millis ();
@@ -51,29 +50,12 @@ void notificationLED()
5150 ledTimer = millis ();
5251 }
5352 }
54- /* make it later
55- if (millis() >= (cycleMillis + cycleTime) && relaisOn == true)
56- {
57- //ledPin = 127.0 + 128.0 * sin((millis() / (float)(cycleTime * 2)) * 2.0 * PI);
58- ledPin = (cos((millis() / (float)(cycleTime/4)) - PI)*0.5+0.5)*255;
59-
60- if (ledPin == 254 && waveHelper == false)
61- {
62- waveHelper = true;
63- }
64- if (ledPin == 0 && waveHelper == true)
65- {
66- ledState--;
67- waveHelper = false;
68- }
69-
70-
71- if (ledState == 0)
72- {
73- ledTimer = millis();
74- }
75- }
76- */
7753 }
78- analogWrite (LED_PIN , 255 - ledPin );
54+ if (!ledPin )
55+ {
56+ analogWrite (LED_PIN , 255 );
57+ } else
58+ {
59+ analogWrite (LED_PIN , 255 - _settings .data .LEDBrightness );
60+ }
7961}
Original file line number Diff line number Diff line change @@ -69,10 +69,16 @@ <h1>Edit Configuration</h1>
6969 < span class ="input-group-text w-50 " id ="webuicolormode "> WebUI Dark Mode</ span >
7070 < div class ="form-switch form-control " style ="width:50%%; text-align: center; ">
7171 < input type ="checkbox " class ="form-check-input form control " aria-describedby ="webuicolormode " role ="switch "
72- id ="mqttjson " name ="post_webuicolormode " value ="true " %pre_webuidarkmode% >
72+ id ="post_webuicolormode " name ="post_webuicolormode " value ="true " %pre_webuidarkmode% >
73+ </ div >
74+ </ div >
75+ < div class ="input-group mb-2 ">
76+ < span class ="input-group-text w-50 " id ="led "> LED brightness</ span >
77+ < div class ="form-switch form-control " style ="width:50%%; text-align: center; ">
78+ < input type ="range " class ="form-range " aria-describedby ="led "
79+ id ="post_led " name ="post_led " value ="%pre_led% " min ="0 " max ="255 ">
7380 </ div >
7481 </ div >
75-
7682 < div class ="input-group mb-2 ">
7783 < span class ="input-group-text w-50 " id ="httpUserdesc "> HTTP Username</ span >
7884 < input type ="text " class ="form-control no-percent " aria-describedby ="httpUserdesc " id ="httpUser "
You can’t perform that action at this time.
0 commit comments