Sonder Design Team / Mbed 2 deprecated BlackBoard_Firmware_Fast_read_not_test

Dependencies:   Memory25L16_fast USBDevice mbed

Fork of BlackBoard_Firmware_MVP by Sonder Design Team

Revision:
7:b30c411a6d36
Parent:
6:2f4a272ab299
Child:
8:3577b060d7af
--- a/BB_Basic.cpp	Wed Jan 25 01:43:55 2017 +0000
+++ b/BB_Basic.cpp	Tue Jan 31 05:10:44 2017 +0000
@@ -22,6 +22,7 @@
 DigitalOut cs_epd(P1_23);       //Set up epd's Chip Select pin
 DigitalOut TconEn(P0_5);        //Tcon Enable pin, open drain must invert
 DigitalOut start(P0_14);
+DigitalIn TCbusy(P0_4);           //Tcon busy line
 
 DigitalOut myled(P0_9);
 DigitalOut SRclk(P0_15);        //Shift register clk signal
@@ -157,6 +158,7 @@
 
 
 
+
 /******************************************************************************
  * Keyboard  Functions
  */
@@ -270,7 +272,23 @@
     sendUSB(temp);
 }
 
-
+/**
+ * keyCheck(), scanss the keys and sends the keypress to the pc over usb
+ */
+void keyCheck(){
+    pc.printf("KeyCheck\n");
+    if (keyScan()>0) {                  //check if keyScan returned key presss
+            pc.printf("\nKey scan|n");
+            int countpos =0;
+            while(keybuffer[countpos][1]>0) {   //While there are keypresses in the buffer
+                pc.printf("%i",keybuffer[countpos][1]);
+                pc.printf(" ");
+                sendKey(keybuffer[countpos][0],keybuffer[countpos][1]);//Send key press
+                countpos++;
+                myled=0;
+            }
+        }
+}
 
 /******************************************************************************
  * Memory control funtions
@@ -446,7 +464,7 @@
     pc.printf("\nSlot: %i", slots[slot]);
     mem.blockErase(my_spi, slots[slot]);           //erase the bottom block of the slot
     mem.blockErase(my_spi, slots[slot]+0x10000);   //erase the top block of the slot
-    //nameBlock(my_spi, name,  slots[slot]+0x1FFF9); //Write the name of the layout to memory
+    nameBlock(my_spi, name,  slots[slot]/*+0x1FFF9*/); //Write the name of the layout to memory
     erasedSlots[slot]=true;                        //Mark the erased slot as true
 }
 
@@ -488,9 +506,7 @@
     
 
     //led=!led;
-    //Timer t;
-    //t.start();          //Start the timer
-
+    
     //Begin SPI comunication
     cs_epd=1;           //EPD chip deselected
     TconEn =1;          //Tcon ON set High
@@ -514,19 +530,28 @@
         }
         
         epd_spi.write(00);      //Write a 0 at the end of each line
+        if(j%100==0){
+            keyCheck();
+            }
         //wait_us(10000);
     }
     wait_us(1000);
     DigitalOut sclk(P0_13);   //serial clk
     sclk = 0;
     cs_epd=1;       //Deselct the chip
-    //t.stop();
-    wait(10);    //Wait 5s for the EPD to update
+    Timer t;
+    t.start();          //Start the timer
+     while(TCbusy)
+    {
+        keyCheck();
+        //wait_ms
+        }
+        t.stop();
     TconEn=0;       //Deassert Tcon ON
     cs_epd=0;       //Deassert chip select
 
-    //printf("\ntime = %i ", t.read_ms());
-    //t.reset();
+    printf("\ntime = %i ", t.read_ms());
+    t.reset();
     return 1;
 }
 
@@ -551,17 +576,7 @@
         pc.printf("Loop");
 
         sendUSB(readyForComand);
-        if (keyScan()>0) {                  //check if keyScan returned key presss
-            pc.printf("\nKey scan|n");
-            int countpos =0;
-            while(keybuffer[countpos][1]>0) {   //While there are keypresses in the buffer
-                pc.printf("%i",keybuffer[countpos][1]);
-                pc.printf(" ");
-                sendKey(keybuffer[countpos][0],keybuffer[countpos][1]);//Send key press
-                countpos++;
-                myled=0;
-            }
-        }
+        keyCheck();        
 
         sendUSB(readyForComand);
         if (readUSB(USBDataBuffer)>0) {
@@ -587,7 +602,7 @@
                 case 0x30:          //If the recieved comand is a request for the cutrrent name
                     getCurrentLayout();
                     break;
-                case 0x35:          //If the recieved comand is a request for all the names
+                case 0x35:          //If the recieved comand is a request for all the names 
                     getCurrentLayout();
                     break;
                 default: