Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 6:528d74136b6a, committed 2021-11-03
- Comitter:
- reedas
- Date:
- Wed Nov 03 11:24:16 2021 +0000
- Parent:
- 5:9a03cb84a60c
- Commit message:
- 3/11/21 light sensor
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Oct 20 11:31:38 2021 +0000
+++ b/main.cpp Wed Nov 03 11:24:16 2021 +0000
@@ -14,20 +14,22 @@
#define LED_ON (1)
#define TITLE_OFFSET (16+LED_RADIUS)
+AnalogIn lightLevel(P10_0);
+
void Display_Init(void)
{
/* Initialise EmWin driver*/
GUI_Init();
/* Set font size, foreground and background Colours */
- GUI_SetFont(GUI_FONT_16B_1);
+ GUI_SetFont(GUI_FONT_24B_1);
GUI_SetColor(GUI_WHITE);
GUI_SetBkColor(GUI_BLACK);
/* Clear screen and print splash screen */
GUI_Clear();
GUI_SetTextAlign(GUI_TA_HCENTER);
- GUI_DispStringAt("CITY3032 Super Computer", 160, 0);
+ GUI_DispStringAt("CITY3032 Light Level", 160, 0);
}
int main()
@@ -35,33 +37,17 @@
/* Initialise display */
Display_Init();
- printf("Starting Supercomputer\r\n");
+ printf("light level\r\n");
- GUI_SetFont(GUI_FONT_8X16X2X2);
- GUI_SetColor(GUI_DARKGREEN);
- uint8_t array[NUMLEDS_X][NUMLEDS_Y];
- for (int j=0; j < NUMLEDS_Y; j++) {
- for (int i=0; i < NUMLEDS_X; i++) {
- array[i][j]=LED_OFF;
- GUI_SetColor(GUI_DARKGREEN);
- GUI_FillCircle(LED_RADIUS+(i)*LED_DIAMETER, TITLE_OFFSET+(j*LED_DIAMETER), LED_RADIUS);
- }
+ GUI_SetFont(GUI_FONT_24B_1);
+ GUI_SetColor(GUI_WHITE);
+ while(true) {
+ int lightPercent;
+ lightPercent = (lightLevel.read_u16()*100)/65535;
+ printf("light level is %d\r\n",lightPercent);
+ ThisThread::sleep_for(1000);
}
- while(1) {
- int ledx = rand()%NUMLEDS_X;
- int ledy = rand()%NUMLEDS_Y;
- if (array[ledx][ledy]==LED_OFF) {
- GUI_SetColor(GUI_GREEN);
- GUI_FillCircle(LED_RADIUS+(ledx)*LED_DIAMETER, TITLE_OFFSET+LED_DIAMETER*(ledy), LED_RADIUS);
- array[ledx][ledy] = LED_ON;
- }
- else {
- GUI_SetColor(GUI_DARKGREEN);
- GUI_FillCircle(LED_RADIUS+(ledx)*LED_DIAMETER, TITLE_OFFSET+LED_DIAMETER*(ledy), LED_RADIUS);
-// GUI_FillCircle(8+(ledx)*16, 24+16*(ledy), 8);
- array[ledx][ledy] = LED_OFF;
- }
- }
+
}