![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Working Menu, additions to be made
Dependencies: mbed
Diff: main.cpp
- Revision:
- 1:a87075699085
- Parent:
- 0:d4d7e882c87d
- Child:
- 2:d3676e11e2c6
diff -r d4d7e882c87d -r a87075699085 main.cpp --- a/main.cpp Tue Dec 07 03:04:35 2021 +0000 +++ b/main.cpp Tue Dec 07 05:01:37 2021 +0000 @@ -1,11 +1,17 @@ +/* +Code for a IoT Temperature reading device. +Acknowledgements to xxxxx +**/ + #include "mbed.h" #include "N5110.h" #include "Joystick.h" +//Defines AnalogIn pot(PTB2); - -// rows,cols +//LCD Sprite: +// rows,cols int sprite[8][5] = { { 0,0,1,0,0 }, { 0,1,1,1,0 }, @@ -20,25 +26,25 @@ //Objects Ticker bl_ticker; -// flag - must be volatile as changes within ISR -// g_ prefix makes it easier to distinguish it as global +// Global Volatile Interrupt flags volatile int g_bl_timer_flag; -// function prototypes +// Setup interrupts void bl_timer_isr(); -//data +//Data float bright; //Pinouts -// VCC,SCE,RST,D/C,MOSI,SCLK,LED +// SCE, RST, D/C, MOSI,SCLK,LED N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); // K64F - pwr from 3V3 -// y x button +// y x button Joystick joystick(PTB10,PTB11,PTC16); int main() { + //Initialise devices lcd.init(); lcd.setContrast(0.4); @@ -46,12 +52,8 @@ bl_ticker.attach(&bl_timer_isr,0.01); while (1){ - //lcd.setBrightness(pot > 0.2f) ? 0.2 : 0; - //lcd.setBrightness(pot > 0.4f) ? 0.4 : 0.21; - // lcd.setBrightness(pot > 0.6f) ? 0.6 : 0.41; - //lcd.setBrightness(pot > 0.8f) ? 0.8 : 0.61; - + //Read pot value and assign to variable if(pot > 0.1f) { bright = 0.1; } if(pot > 0.2f) { @@ -74,12 +76,12 @@ bright = 1.0; } - // check if flag is set i.e. interrupt has occured: - //For bl check timer + //Check interrupt flags: + //LCD backlight interrupt if (g_bl_timer_flag) { - g_bl_timer_flag = 0; //if it has, clear the flag + g_bl_timer_flag = 0; //if flag is set, clear - lcd.setBrightness(bright); + lcd.setBrightness(bright); //set brightness based on pot value } } @@ -91,3 +93,4 @@ g_bl_timer_flag = 1; // set flag in ISR } +//Had multiple issues where code isn't changed but comments are added, suddenly defines don't work anymore "not defined" \ No newline at end of file