j
Dependencies: mbed Grove_LCD_RGB_Backlight
main.cpp@0:821481a55d81, 2020-02-03 (annotated)
- Committer:
- leo0617
- Date:
- Mon Feb 03 16:34:19 2020 +0000
- Revision:
- 0:821481a55d81
- Child:
- 1:4501047958cb
xwcwcw
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
leo0617 | 0:821481a55d81 | 1 | #include "mbed.h" |
leo0617 | 0:821481a55d81 | 2 | #include "Grove_LCD_RGB_Backlight.h" |
leo0617 | 0:821481a55d81 | 3 | #include <string> |
leo0617 | 0:821481a55d81 | 4 | #include <cstring> |
leo0617 | 0:821481a55d81 | 5 | #include <stdio.h> |
leo0617 | 0:821481a55d81 | 6 | #include <string.h> |
leo0617 | 0:821481a55d81 | 7 | |
leo0617 | 0:821481a55d81 | 8 | #define SIZE 4 |
leo0617 | 0:821481a55d81 | 9 | |
leo0617 | 0:821481a55d81 | 10 | DigitalOut myled(LED2); |
leo0617 | 0:821481a55d81 | 11 | AnalogIn xAxis(p19); |
leo0617 | 0:821481a55d81 | 12 | AnalogIn yAxis(p20); |
leo0617 | 0:821481a55d81 | 13 | DigitalIn sw(p18); |
leo0617 | 0:821481a55d81 | 14 | Grove_LCD_RGB_Backlight LCD(p9,p10); |
leo0617 | 0:821481a55d81 | 15 | |
leo0617 | 0:821481a55d81 | 16 | void lecture(void); |
leo0617 | 0:821481a55d81 | 17 | void affMenu(char[][64], int); |
leo0617 | 0:821481a55d81 | 18 | |
leo0617 | 0:821481a55d81 | 19 | float xValue, yValue; |
leo0617 | 0:821481a55d81 | 20 | int switchValue; |
leo0617 | 0:821481a55d81 | 21 | int sel = 0; |
leo0617 | 0:821481a55d81 | 22 | |
leo0617 | 0:821481a55d81 | 23 | int main() { |
leo0617 | 0:821481a55d81 | 24 | sw.mode(PullUp); |
leo0617 | 0:821481a55d81 | 25 | char cDisp[SIZE][64] = {"Capteurs", "Balle", "Batterie", "Voir plus"}; |
leo0617 | 0:821481a55d81 | 26 | while(1) { |
leo0617 | 0:821481a55d81 | 27 | wait(0.5); |
leo0617 | 0:821481a55d81 | 28 | LCD.setRGB(255, 255, 255); |
leo0617 | 0:821481a55d81 | 29 | LCD.clear(); |
leo0617 | 0:821481a55d81 | 30 | LCD.locate(0, 0); |
leo0617 | 0:821481a55d81 | 31 | //printf("Choisir menu:"); |
leo0617 | 0:821481a55d81 | 32 | //scanf("%d", &sel); |
leo0617 | 0:821481a55d81 | 33 | lecture(); |
leo0617 | 0:821481a55d81 | 34 | //printf("x=%g\t y=%g\t switch=%d\n\r", xValue, yValue, switchValue); |
leo0617 | 0:821481a55d81 | 35 | //LCD.print("Bonjour"); |
leo0617 | 0:821481a55d81 | 36 | affMenu(cDisp, SIZE); |
leo0617 | 0:821481a55d81 | 37 | } |
leo0617 | 0:821481a55d81 | 38 | } |
leo0617 | 0:821481a55d81 | 39 | |
leo0617 | 0:821481a55d81 | 40 | |
leo0617 | 0:821481a55d81 | 41 | void lecture(){ |
leo0617 | 0:821481a55d81 | 42 | xValue = xAxis.read(); |
leo0617 | 0:821481a55d81 | 43 | yValue = yAxis.read(); |
leo0617 | 0:821481a55d81 | 44 | switchValue = sw.read(); |
leo0617 | 0:821481a55d81 | 45 | } |
leo0617 | 0:821481a55d81 | 46 | |
leo0617 | 0:821481a55d81 | 47 | void affMenu(char cDisp[][64], int size){ |
leo0617 | 0:821481a55d81 | 48 | for(int i = sel; i < sel + 2; i++){ |
leo0617 | 0:821481a55d81 | 49 | if(i < size){ |
leo0617 | 0:821481a55d81 | 50 | LCD.locate(0, i-sel); |
leo0617 | 0:821481a55d81 | 51 | LCD.print(cDisp[i]); |
leo0617 | 0:821481a55d81 | 52 | } |
leo0617 | 0:821481a55d81 | 53 | } |
leo0617 | 0:821481a55d81 | 54 | } |