Clone of the "Keyboard" project combined with string>LCD calls and Serial reading for the STM32F746G-DISCO. Screen has to be reset and the font set again, and Serial must be created and destroyed each time, to dodge apparent F7 lower-level issues. Keyboard can print prompt.

Dependencies:   BSP_DISCO_F746NG mbed

Fork of Keyboard by Faberge Fabulous

Revision:
5:50c5e677f71a
Parent:
4:0e5755618652
Child:
6:310e91584386
--- a/main.cpp	Fri Feb 17 18:29:25 2017 +0000
+++ b/main.cpp	Wed Feb 22 12:35:19 2017 +0000
@@ -8,14 +8,12 @@
 
 /* Добавляем библиотеку для работы с LCD */
 #include "stm32746g_discovery_lcd.h"
-
 /* Добавляем библиотеку экранной клавиатуры */
 #include "keyboard.h"
 
-
 #include "mbed.h"
 
-
+   // no such file: #include "USBSerial.h"
 
 /* Вспомогательные переменые */
 uint8_t i;
@@ -26,7 +24,6 @@
 char kb_buffer[45];
 
 
-RawSerial pc(USBTX, USBRX);                 // terminal console
 
 /*  
  * Calculates the mean and standard deviation of the array in data[] 
@@ -134,7 +131,10 @@
 int main(void)
 {
 #define STATSIZE 128
-      
+      // RawSerial pc(USBTX, USBRX);    
+      // Serial pc(USBTX, USBRX);
+      Serial pc(USBTX, USBRX);;
+             
       char  sbuf[128];  
       char  dbgtlk[128];
       
@@ -165,7 +165,7 @@
       char u_passwd[128];
       char out_str[128];
       
-      pc.baud(9600);
+        pc.baud(9600);
      
       
           
@@ -225,10 +225,19 @@
         BSP_LCD_DisplayStringAtLine((2 + (ii%5)), (uint8_t *)tstr);
                 
         if (ii > 2)  {
-           GetMeanSD(pbar, ii, &pb_mn, &pb_sd);
-           GetMeanSD(bar, ii, &b_mn, &b_sd);
-           GetMeanSD(car, ii, &c_mn, &c_sd);
-           GetMeanSD(ear, ii, &e_mn, &e_sd);
+           
+           if (ii > 11) {
+              GetMeanSD(pbar + ii - 11 , 10, &pb_mn, &pb_sd);
+              GetMeanSD(bar  + ii - 11,  10, &b_mn, &b_sd);
+              GetMeanSD(car  + ii - 11,  10, &c_mn, &c_sd);
+              GetMeanSD(ear  + ii - 11 , 10, &e_mn, &e_sd);
+           }
+           else        {
+              GetMeanSD(pbar, ii, &pb_mn, &pb_sd);
+              GetMeanSD(bar, ii, &b_mn, &b_sd);
+              GetMeanSD(car, ii, &c_mn, &c_sd);
+              GetMeanSD(ear, ii, &e_mn, &e_sd);
+           }
                 
            sprintf(tstr, "Mean %4.2f  %05d  %05d  %05d", pb_mn, (int)b_mn, (int)c_mn, (int)e_mn);
            BSP_LCD_DisplayStringAtLine((8), (uint8_t *)tstr);
@@ -238,16 +247,20 @@
            sprintf(tstr, "                   %-04.2f%% %-04.2f%%",  100.0*(c_sd/c_mn), 100.0*(e_sd/e_mn)); 
            BSP_LCD_DisplayStringAtLine((10), (uint8_t *)tstr);
        
-       
+             
            strcpy (sbuf, "---trying serial----");    
            BSP_LCD_DisplayStringAtLine(LINE(11), (uint8_t *)sbuf);
+           
            rawq = 0;
            strcpy (sbuf, "--currently empty---");
-           rawp = sbuf;   // ptr to the buffer
-           rawq = duds = 0;    // raw qty , number of duds for timeout
+           rawp = sbuf;   
+           rawq = duds = 0;
            gotc = 'x';  
+           
            strcpy (dbgtlk, "---pt1---"); 
            BSP_LCD_DisplayStringAtLine((12), (uint8_t *)dbgtlk);
+           
+           /*
            while (gotc != '\r' && gotc != '\n'  && rawq < 127  && duds < 40)  {
               if (pc.readable())   {
                  duds = 0;                     // reset timeout counter
@@ -262,9 +275,14 @@
               BSP_LCD_DisplayStringAtLine((12), (uint8_t *)dbgtlk);
               wait(.05);   
               duds++;
-           }   
-           strcpy (dbgtlk, "---pt4---");   
+           }  
+           */
+            
+           strcpy (dbgtlk, "---pt4---"); 
            BSP_LCD_DisplayStringAtLine((12), (uint8_t *)dbgtlk);
+             
+           pc.scanf("%s", sbuf);
+           
            if (rawq > 0)   *rawp = '\0';
            sbuf[20] = '\0';   // just for test .... truncate the line
            BSP_LCD_DisplayStringAtLine((11), (uint8_t *)sbuf);