![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Working Menu, additions to be made
Dependencies: mbed
main.cpp
- Committer:
- jackmcgarley
- Date:
- 2022-01-21
- Revision:
- 3:d1e1de4a712e
- Parent:
- 2:d3676e11e2c6
- Child:
- 4:143487eef742
File content as of revision 3:d1e1de4a712e:
/* Code for a IoT Temperature reading device. Acknowledgements to Dr Craig A. Evans and Dr Edmond Nurellari. **/ #include "mbed.h" #include "N5110.h" #include "Joystick.h" #include "TMP102.h" //Defines AnalogIn pot(PTB2); //LCD Sprite: // rows,cols int sprite[8][5] = { { 0,0,1,0,0 }, { 0,1,1,1,0 }, { 0,0,1,0,0 }, { 0,1,1,1,0 }, { 1,1,1,1,1 }, { 1,1,1,1,1 }, { 1,1,0,1,1 }, { 1,1,0,1,1 }, }; //Objects Ticker bl_ticker; // Global Volatile Interrupt flags volatile int g_bl_timer_flag; // Setup interrupts void bl_timer_isr(); //Data float bright; //Pinouts // SCE, RST, D/C, MOSI,SCLK,LED N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); // K64F - pwr from 3V3 // y x button Joystick joystick(PTB10,PTB11,PTC16); //I2C SDA SCL TMP102 tmp(PTE24,PTE25); int main() { //Initialise devices lcd.init(); joystick.init(); tmp.init(); lcd.setContrast(0.4); //Set up ticker (time in seconds) bl_ticker.attach(&bl_timer_isr,0.01); while (1){ //Read pot value and assign to variable if(pot > 0.1f) { bright = 0.1; } if(pot > 0.2f) { bright = 0.2; } if (pot > 0.3f) { bright = 0.3; } if (pot > 0.4f) { bright = 0.4; } if (pot > 0.5f) { bright = 0.5; } if(pot > 0.6f) { bright = 0.6; } if(pot > 0.7f) { bright = 0.7; } if (pot > 0.8f) { bright = 0.8; } if (pot > 0.9f) { bright = 0.9; } if (pot > 1.0f) { bright = 1.0; } //Check interrupt flags: //LCD backlight interrupt if (g_bl_timer_flag) { g_bl_timer_flag = 0; //if flag is set, clear lcd.setBrightness(bright); //set brightness based on pot value } } } // time-triggered interrupt for red void bl_timer_isr() { g_bl_timer_flag = 1; // set flag in ISR }