Stage-1 Students SoCEM / Mbed 2 deprecated PrimativeKeyboardInput

Dependencies:   mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
noutram
Date:
Fri Apr 29 07:49:43 2016 +0000
Commit message:
Simple example of using getchar()

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 230a31b32cc1 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Apr 29 07:49:43 2016 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+#include "rtos.h"
+
+unsigned int delayms = 1000;
+
+void print_char(char c = '*')
+{
+    printf("%c", c);
+    fflush(stdout);
+}
+
+DigitalOut led1(LED1);
+
+void print_thread(void const *argument)
+{
+    while (true) {
+        Thread::wait(delayms);
+        led1 = !led1;
+    }
+}
+
+void read_keyboard(void const *argument)
+{
+    char c;
+    while (true) {
+        
+        c = getchar();
+        printf("\t%X\n", c);
+    }
+}
+
+
+int main()
+{
+    printf("\n\n*** RTOS basic example ***\n");
+    Thread t1(print_thread, NULL, osPriorityNormal, DEFAULT_STACK_SIZE);
+    Thread t2(read_keyboard);
+    
+    //Sleep the main thread
+    Thread::wait(osWaitForever);
+}
diff -r 000000000000 -r 230a31b32cc1 mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Fri Apr 29 07:49:43 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#3b7dd22a5b25
diff -r 000000000000 -r 230a31b32cc1 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Apr 29 07:49:43 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/aae6fcc7d9bb
\ No newline at end of file