GroupA / Mbed 2 deprecated WaG_final

Dependencies:   mbed

Fork of Lab_6_WaG by GroupA

Revision:
11:6751b9406142
Parent:
8:d8bc78bda829
Child:
13:8936b2f64aa2
diff -r ae0a262ba48d -r 6751b9406142 main.cpp
--- a/main.cpp	Thu Feb 22 16:22:19 2018 +0000
+++ b/main.cpp	Fri Feb 23 23:05:58 2018 +0000
@@ -26,44 +26,28 @@
 
 int main(void) {
     initial_setup(SS, data_length, frequency);
+    char bcd[4];
     
-    float command = 0x0100;
+    //float command = 0x0100;
     int input;
     //char command_text[10] = "0x0";
     while(1) {
         pc.printf("Select a digit between 0 and 9999:\n");
-        bool check = scanf("%d", &input);
-        while (check != 1) {
+        int check = 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");
-            check = scanf("%d", &input);
-        }
-        
-        /*
-        while (num_range(input) == false) { //ask for input until 0-9999 is selected
-            pc.printf("Select a digit between 0 and 9999:\n");
-            scanf("%d", input);
+            scanf("%d", &input);
         }
         
-        
-        command_text[3] = place + '0';
-        command_text[4] = '0';
-        command_text[5] = input;
-        
-        command = atof(command_text); //converts string to float
-        */
-        
-        //pc.printf("command: %s\n", command_text);
-        
+        printf("you entered: %d\n", input);
+        bin2bcd_array(input, bcd);
+ 
+        for (int i = 0; i < 4; i++) {
+            pc.printf("bcd: %d\n", bcd[i]);
+        }
         
-        SS = 0;
-        spi.write(command); // need to cycle 4 times
-        SS = 1;
-        //pc.printf("command: &f\n", commmand);
+        send_command_to_display(bcd);
     }
-    
-    /*
-    SS = 0;
-    spi.write(0x0100); //set digit 0 to 0
-    SS = 1;
-    */
 }   
\ No newline at end of file