GroupA / Mbed 2 deprecated WaG_final

Dependencies:   mbed

Fork of Lab_6_WaG by GroupA

Revision:
14:be27f6e21a8a
Parent:
13:8936b2f64aa2
Child:
16:dfa9eb1a808d
diff -r 8936b2f64aa2 -r be27f6e21a8a main.cpp
--- a/main.cpp	Tue Feb 27 16:16:04 2018 +0000
+++ b/main.cpp	Tue Feb 27 17:06:37 2018 +0000
@@ -27,36 +27,24 @@
 int main(void) {
     initial_setup(SS, data_length, frequency);
     char bcd[4];
-    
-    //float command = 0x0100;
     int input;
-    //char command_text[10] = "0x0";
-    while(1) {
+    while(1) { //clears bcd array
+        for (int i = 0; i < 4; i++)
+            bcd[i] = 0;
+        input = 0;
         pc.printf("Select a digit between 0 and 9999:\n");
-        scanf("%d", &input);
-        
-        /*
-        char cur_char = getchar();
-        while (cur_char < 48 or cur_char > 57) { //ask for input until 0-9 is selected
-            pc.printf("Select a digit between 0 and 9:\n");
-            cur_char = getchar();
-        }
-        */
+        pc.scanf("%d", &input);
         
         while (input < 0 or input > 9999) { //ask for input until 0-9999 is selected
             pc.printf("You entered a number out of range\n");
             pc.printf("Select a digit between 0 and 9999:\n");
-            scanf("%d", &input);
+            input = 0;
+            pc.scanf("%d", &input);
         }
         
+        
         printf("you entered: %d\n", input);
         bin2bcd_array(input, bcd);
- 
-        /*
-        for (int i = 0; i < 4; i++) {
-            pc.printf("bcd: %d\n", bcd[i]);
-        }
-        */
         
         send_command_to_display(bcd);
     }