@@ -176,6 +176,16 @@ void setIntensity(String value ){
176176 }
177177}
178178
179+ void setIntensity (int value ){
180+ byte i = (byte) value;
181+ if ((i>=0 ) && (i<=15 )){
182+ // Write the new value to EEPROM
183+ EEPROM.write (0 , i);
184+ EEPROM.commit ();
185+ Parola.setIntensity (i);
186+ }
187+ }
188+
179189#ifdef USE_OLED_DISPLAY
180190/* *
181191 * Display LOGO for 1 second (Logo is declared in res.h)
@@ -263,6 +273,8 @@ void setup() {
263273
264274 // Start DS18B20 measurement
265275 DS18B20.begin ();
276+
277+ // pinMode(A0,INPUT);
266278
267279 // pinMode(LED_BUILTIN,OUTPUT); // configure the builtin led to OUTPUT mode
268280 // digitalWrite(LED_BUILTIN,!digitalRead(pin_led)); // switch the status (values can be LOW or HIGH)
@@ -346,6 +358,28 @@ void loop() {
346358 // Handle Dot Matrix display
347359 if (Parola.displayAnimate ()) // True if animation ended
348360 {
361+
362+ int photocellReading = analogRead (A0);
363+ Serial.println (analogRead (A0));
364+
365+ if (photocellReading < 300 ) {
366+ Serial.println (" - Noir" );
367+ setIntensity (1 );
368+ } else if (photocellReading < 600 ) {
369+ Serial.println (" - Sombre" );
370+ setIntensity (3 );
371+ } else if (photocellReading < 800 ) {
372+ Serial.println (" - Lumiere" );
373+ setIntensity (5 );
374+ } else if (photocellReading < 950 ) {
375+ Serial.println (" - Lumineux" );
376+ setIntensity (10 );
377+ } else {
378+ Serial.println (" - Tres lumineux" );
379+ setIntensity (15 );
380+ }
381+
382+
349383 switch (messageType) {
350384 if (messageType >10 ){messageType ==0 ;}
351385
@@ -354,7 +388,7 @@ void loop() {
354388 String time = NTP.getTimeDateString ();
355389 char *cstr = new char [time.length () + 1 ];
356390 strcpy (cstr, (const char *)time.c_str ());
357- Parola.displayText (cstr, PA_CENTER, 50 , 5000 , PA_SCROLL_LEFT, PA_SCROLL_LEFT);
391+ Parola.displayText (cstr, PA_CENTER, 30 , 10 , PA_SCROLL_LEFT, PA_SCROLL_LEFT);
358392 // delete [] cstr;
359393 }
360394 break ;
@@ -375,14 +409,19 @@ void loop() {
375409 Parola.displayScroll (currentMessage, PA_LEFT, PA_SCROLL_LEFT, frameDelay);
376410 messageType=2 ;
377411 break ;
378-
379412 // TESTING
380- case 9 :
381- // Parola.displayScroll('$', PA_LEFT, PA_SCROLL_LEFT, frameDelay);
382- Parola.displayText (" $" , PA_CENTER, 20 , 500 , PA_SCROLL_LEFT, PA_SCROLL_LEFT);
383- messageType=0 ;
413+ case 9 :{
414+
415+
416+
417+
418+ char lumstr[5 ];
419+ sprintf (lumstr, " %d" , photocellReading);
420+ Serial.println (lumstr);
421+ Parola.displayText (lumstr, PA_CENTER, 20 , 500 , PA_SCROLL_LEFT, PA_SCROLL_LEFT);
422+ messageType=9 ;
423+ }
384424 break ;
385- // Looping message
386425 case 10 :
387426 getTemperature ();
388427 Parola.displayText (temperatureCString, PA_CENTER, 20 , 500 , PA_SCROLL_LEFT, PA_SCROLL_LEFT);
0 commit comments