test

Dependencies:   BSP_DISCO_L476VG LCD_DISCO_L476VG

Files at this revision

API Documentation at this revision

Comitter:
joko11
Date:
Tue Mar 24 08:13:54 2020 +0000
Commit message:
test

Changed in this revision

BSP_DISCO_L476VG.lib Show annotated file Show diff for this revision Revisions of this file
LCD_DISCO_L476VG.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r d101e393d342 BSP_DISCO_L476VG.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BSP_DISCO_L476VG.lib	Tue Mar 24 08:13:54 2020 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/BSP_DISCO_L476VG/#4943b15cce9f
diff -r 000000000000 -r d101e393d342 LCD_DISCO_L476VG.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_DISCO_L476VG.lib	Tue Mar 24 08:13:54 2020 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/LCD_DISCO_L476VG/#6ac2ed34f595
diff -r 000000000000 -r d101e393d342 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Mar 24 08:13:54 2020 +0000
@@ -0,0 +1,52 @@
+#include "mbed.h"
+#include "LCD_DISCO_L476VG.h"
+
+#define DISPLAY_LENGTH 6
+
+DigitalOut led(LED1);
+LCD_DISCO_L476VG lcd;
+
+InterruptIn center(JOYSTICK_CENTER);
+InterruptIn left(JOYSTICK_LEFT);
+InterruptIn right(JOYSTICK_RIGHT);
+InterruptIn up(JOYSTICK_UP);
+InterruptIn down(JOYSTICK_DOWN);
+
+// Events are pointers to functions
+// Event loop takes events from queue and executes them
+EventQueue queue(64 * EVENTS_EVENT_SIZE);
+Thread thread;
+
+uint8_t message[DISPLAY_LENGTH] = {0};
+uint8_t msgIndex = 0;
+void lcdEventHandler(char c){
+    if(c == 'z'){
+        memset(message, 0, sizeof(message));
+        msgIndex = 0;
+    }else{
+        message[msgIndex] = c;
+        msgIndex = (msgIndex + 1) % DISPLAY_LENGTH;
+    }
+    lcd.Clear();
+    lcd.DisplayString(message);
+}
+
+int main(){
+    
+    // Event loop
+    thread.start(callback(&queue, &EventQueue::dispatch_forever));
+    
+    left.fall(queue.event(lcdEventHandler, 'e'));
+    up.fall(queue.event(lcdEventHandler, 'i'));
+    right.fall(queue.event(lcdEventHandler, 's'));
+    down.fall(queue.event(lcdEventHandler, 'l'));
+    center.fall(queue.event(lcdEventHandler, 'z'));
+    
+    left.mode(PullDown);
+    right.mode(PullDown);
+    up.mode(PullDown);
+    down.mode(PullDown);
+    
+    while(1) {
+    }
+}
diff -r 000000000000 -r d101e393d342 mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Tue Mar 24 08:13:54 2020 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#b81aeff1a3e171c6421984faa2cc18d0e35746c0