![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Working Menu, additions to be made
Dependencies: mbed
main.cpp
- Committer:
- 25574069
- Date:
- 2021-12-07
- Revision:
- 0:d4d7e882c87d
- Child:
- 1:a87075699085
File content as of revision 0:d4d7e882c87d:
#include "mbed.h" #include "N5110.h" #include "Joystick.h" AnalogIn pot(PTB2); // 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; // flag - must be volatile as changes within ISR // g_ prefix makes it easier to distinguish it as global volatile int g_bl_timer_flag; // function prototypes void bl_timer_isr(); //data float bright; //Pinouts // VCC,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); int main() { lcd.init(); lcd.setContrast(0.4); //Set up ticker (time in seconds) 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; 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 if flag is set i.e. interrupt has occured: //For bl check timer if (g_bl_timer_flag) { g_bl_timer_flag = 0; //if it has, clear the flag lcd.setBrightness(bright); } } } // time-triggered interrupt for red void bl_timer_isr() { g_bl_timer_flag = 1; // set flag in ISR }