LAB3

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
moove1334
Date:
Thu Nov 02 13:52:06 2017 +0000
Commit message:
LAB3 FRA221;

Changed in this revision

main.cpp 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 90e426491ea8 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 02 13:52:06 2017 +0000
@@ -0,0 +1,104 @@
+#include "mbed.h"
+
+Serial pc(D1,D0);
+
+BusOut Outled(D2, D3, D4, D5, D6, D7, D8, D9);
+
+DigitalIn in1(D10);
+DigitalIn in2(D11);
+DigitalIn in3(D12);
+
+void printmenu0()
+{
+    pc.printf("START A-16 PROGRAM\n");
+    pc.printf("[press1] Menu1\n");
+    pc.printf("[press2] Menu2\n");
+}
+
+void printmenu1()
+{
+    pc.printf("1 LED PATTERN \n");
+    pc.printf("[prees a] first_pattern \n");
+    pc.printf("[prees d] second_pattern \n");
+    pc.printf("[prees s] exit \n");
+}
+
+void printmenu2()
+{
+    pc.printf("3 INPUTS STATUS \n");
+}
+
+void menu1_A()
+{
+    int array1[5] = {240, 28, 6, 1,0};
+    for(int i=0; i<5; i++) {
+        Outled = array1[i];
+        wait(0.25);
+    }
+}
+
+void menu1_D()
+{
+    int array1[9] = {1,192,7,240,31,252,127,255,0};
+    for(int i = 0; i<9; i++) {
+        Outled = array1[i];
+        wait(0.5);
+    }
+}
+
+
+void menu2()
+{
+    pc.printf(" switch1  switch2  switch3\n");
+    pc.printf("   %d       %d        %d \n ",in1.read(),in2.read(),in3.read());
+    wait(1);
+}
+
+int main()
+{
+    int state_menu = 0;
+    int state_show = 1;
+    char data;
+
+    while (true) {
+
+        if(pc.readable()) {
+            data = pc.getc();
+        }
+
+        if(state_menu == 0 && state_show ==1) {
+            printmenu0();
+            state_show = 0;
+        }
+
+        if (state_menu == 0 && data == '1') {
+            printmenu1();
+            state_menu = 1;
+            state_show = 0;
+        } else if (state_menu == 0 && data == '2') {
+            printmenu2();
+            state_menu = 2;
+            state_show = 0;
+        }
+
+        if (state_menu == 1 && data == 'a') {
+            menu1_A();
+        } else if (state_menu == 1 && data == 'd') {
+            menu1_D();
+        } else if (state_menu == 1 && data == 's') {
+            Outled = 0;
+            state_menu = 0;
+            state_show = 1;
+        }
+
+        if (state_menu == 2 && data == '2') {
+            menu2();
+        } else if (state_menu == 2 && data == 's') {
+            state_menu = 0;
+            state_show = 1;
+        }
+
+
+    }
+
+}
\ No newline at end of file
diff -r 000000000000 -r 90e426491ea8 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 02 13:52:06 2017 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/fb8e0ae1cceb
\ No newline at end of file