TEMPLATE light sensor 2

Dependencies:   mbed PinDetect

Files at this revision

API Documentation at this revision

Comitter:
10740761
Date:
Wed Nov 10 11:47:39 2021 +0000
Parent:
6:e85892436f70
Commit message:
Light Sensor 2;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Nov 03 11:50:38 2021 +0000
+++ b/main.cpp	Wed Nov 10 11:47:39 2021 +0000
@@ -39,13 +39,20 @@
 
     printf("PRINTING LIGHT LEVEL\r\n");
 
-    GUI_SetFont(GUI_FONT_24B_1);
-    GUI_SetColor(GUI_WHITE);
+    GUI_SetFont(GUI_FONT_D80);
+    GUI_SetColor(GUI_BLUE);
     while(true){
         int lightpercent;
         lightpercent = (lightlevel.read_u16()*100)/65535;
         printf("light level is %d\r\n", lightpercent);
         ThisThread::sleep_for(1000);
+        char buffer[16];
+        sprintf(buffer, "%d", lightpercent);
+        GUI_DispStringAt(buffer, 30, 30);
+        GUI_SetColor(GUI_DARKGREEN);
+        GUI_FillRect(260, 30, 300, 220);
+        GUI_SetColor(GUI_GREEN);
+        GUI_FillRect(260, 220 - lightpercent * 2, 300, 220);
          
         }