ftf connects lab 2

Dependencies:   PCAL955x ST7567 SoftPWM

Revision:
1:18ac195ad292
Parent:
0:6504c8e693e1
--- a/main.cpp	Fri Nov 04 23:59:49 2016 +0000
+++ b/main.cpp	Sat Nov 05 23:26:29 2016 +0000
@@ -240,7 +240,7 @@
     led1 = led2 = led3 = 1;
     
     pc_serial.printf("******************************************************************\n\r");    
-    pc_serial.printf("***         Welcome to NXP FTF Simple Sheell application      ****\n\r");
+    pc_serial.printf("***         Welcome to NXP FTF Simple Shell application      ****\n\r");
     pc_serial.printf("*** Type some commands or just Enter key to see the available ****\n\r");
     pc_serial.printf("******************************************************************\n\r");            
     pc_serial.printf(">>");
@@ -250,22 +250,36 @@
         if(pc_serial.readable()) {
             bool new_cmd = false;
             
-            
             /* get the incoming character */
             char c = pc_serial.getc();
-            pc_serial.putc(c);
-            
-            
-            /* is a enter ? */
+                       
             if( (c == '\n') || (c == '\r')) {
+                /* handle enter key */
                 new_cmd = true;
-                pc_serial.getc();
+                pc_serial.printf("\n\r");
+                
+            }else if( (c == 0x7F) || (c == 0x08)){
+                /* handle backspace and del keys */
+                pc_serial.printf("\033[1D");
+                pc_serial.putc(' ');
+                pc_serial.printf("\033[1D");
+                
+                read_ptr--;
+                if(read_ptr < -1) read_ptr = 1023;
+                serial_buffer[read_ptr] = ' ';
+
                 
             } else {
+                /* loopback the pressed key */
+                pc_serial.putc(c);
+                
+                /* store the incoming character on command circular buffer */
                 serial_buffer[read_ptr] = c;
                 read_ptr = (read_ptr + 1) % 1024;
             }
             
+            
+            
             if(new_cmd != false) {
                 /* command arrived, has other characters? */
                 if(read_ptr != 0) {