@@ -54,12 +54,17 @@ IPAddress gateway(192, 168, 1, 1);
5454IPAddress subnet (255 , 255 , 255 , 0 );
5555WebServer server (80 );
5656
57+ struct brightness
58+ {
59+ unsigned int autoBrightness : 1 ;
60+ unsigned int brightness : 4 ;
61+ unsigned int RESERVED : 27 ;
62+ };
63+
5764struct
5865{
5966 int pos;
60- int brightness;
61- bool autoBrightness;
62- int autoBrightnessValue;
67+ struct brightness brightness;
6368 char cssid[256 ];
6469 char cpassword[256 ];
6570 char date[32 ];
@@ -126,8 +131,8 @@ void handlein()
126131 String cssid = jsonDocument[" cssid" ];
127132 String cpassword = jsonDocument[" cpassword" ];
128133 String date = jsonDocument[" datep" ];
129- globalconf.brightness = brightness;
130- globalconf.autoBrightness = autoBrightness;
134+ globalconf.brightness . brightness = brightness;
135+ globalconf.brightness . autoBrightness = autoBrightness;
131136 strncpy (globalconf.cssid , cssid.c_str (), 256 );
132137 strncpy (globalconf.cpassword , cpassword.c_str (), 256 );
133138 strncpy (globalconf.date , date.c_str (), 32 );
@@ -201,8 +206,8 @@ char wifistatus[32] = {0};
201206void handleconfigout ()
202207{
203208 jsonDocument.clear ();
204- jsonDocument[" brightness" ] = globalconf.brightness ;
205- jsonDocument[" autoBrightness" ] = globalconf.autoBrightness ;
209+ jsonDocument[" brightness" ] = globalconf.brightness . brightness ;
210+ jsonDocument[" autoBrightness" ] = globalconf.brightness . autoBrightness ;
206211 jsonDocument[" cssid" ] = globalconf.cssid ;
207212 jsonDocument[" cpassword" ] = globalconf.cpassword ;
208213 jsonDocument[" datep" ] = globalconf.date ;
@@ -399,7 +404,7 @@ void setup()
399404 esp_log_level_set (" *" , ESP_LOG_VERBOSE);
400405 preferences.begin (" matrixdisplay" , false );
401406 globalconf.pos = 0 ;
402- globalconf.brightness = 7 ;
407+ globalconf.brightness . brightness = 7 ;
403408 Serial.begin (115200 );
404409 // Intialize the object
405410 myDisplay.begin ();
@@ -450,8 +455,8 @@ void loadconfig()
450455void defaultdata ()
451456{
452457 globalconf.pos = 0 ;
453- globalconf.brightness = 4 ;
454- globalconf.autoBrightness = false ;
458+ globalconf.brightness . brightness = 4 ;
459+ globalconf.brightness . autoBrightness = false ;
455460 strncpy (globalconf.cssid , " Gensokyo" , 256 );
456461 strncpy (globalconf.cpassword , " passwordhere" , 256 );
457462 strncpy (globalconf.date , " 0" , 32 );
@@ -585,7 +590,7 @@ void nextmessage()
585590#ifdef VERTICAL
586591 strrev (msgbuff);
587592#endif
588- if (globalconf.autoBrightness )
593+ if (globalconf.brightness . autoBrightness )
589594 {
590595 int lightValue = analogRead (LIGHT_SENSOR_PIN);
591596 int brightness = map (lightValue, 0 , 950 , 0 , 15 ); // Map the light value to brightness range (0-15)
@@ -594,7 +599,7 @@ void nextmessage()
594599 myDisplay.setIntensity (brightness);
595600 } else
596601 {
597- myDisplay.setIntensity (globalconf.brightness );
602+ myDisplay.setIntensity (globalconf.brightness . brightness );
598603 }
599604 myDisplay.setInvert (messages[globalconf.pos ].invert );
600605 scrollAlign = PA_CENTER;
0 commit comments