Andy Jarvis
/
CITY3032-TEMPLATE-Lightsensorthreshold
TEMPLATE light sensor 3 fork Light threshold
Diff: main.cpp
- Revision:
- 7:5e220d3e8a94
- Parent:
- 6:e85892436f70
- Child:
- 8:ab7982d1ce50
diff -r e85892436f70 -r 5e220d3e8a94 main.cpp --- 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); }