j

Dependencies:   mbed Grove_LCD_RGB_Backlight

Revision:
0:821481a55d81
Child:
1:4501047958cb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Feb 03 16:34:19 2020 +0000
@@ -0,0 +1,54 @@
+#include "mbed.h"
+#include "Grove_LCD_RGB_Backlight.h"
+#include <string>
+#include <cstring>
+#include <stdio.h>
+#include <string.h>
+
+#define SIZE 4
+
+DigitalOut myled(LED2);
+AnalogIn xAxis(p19);
+AnalogIn yAxis(p20);
+DigitalIn sw(p18);
+Grove_LCD_RGB_Backlight LCD(p9,p10);
+
+void lecture(void);
+void affMenu(char[][64], int);
+
+float xValue, yValue;
+int switchValue;
+int sel = 0;
+
+int main() {
+    sw.mode(PullUp);
+    char cDisp[SIZE][64] = {"Capteurs", "Balle", "Batterie", "Voir plus"};
+    while(1) {
+        wait(0.5);
+        LCD.setRGB(255, 255, 255);
+        LCD.clear();
+        LCD.locate(0, 0);
+        //printf("Choisir menu:");
+        //scanf("%d", &sel);
+        lecture();
+        //printf("x=%g\t y=%g\t switch=%d\n\r", xValue, yValue, switchValue);
+        //LCD.print("Bonjour");
+        affMenu(cDisp, SIZE);
+    }
+}
+
+
+void lecture(){
+    xValue = xAxis.read();
+    yValue = yAxis.read();
+    switchValue = sw.read();
+}
+
+void affMenu(char cDisp[][64], int size){
+    for(int i = sel; i < sel + 2; i++){
+        if(i < size){
+            LCD.locate(0, i-sel);
+            LCD.print(cDisp[i]);
+        }
+    }    
+}
\ No newline at end of file