Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_DISCO_F746NG mbed
Fork of Keyboard by
Revision 6:310e91584386, committed 2017-02-22
- Comitter:
- jknowles
- Date:
- Wed Feb 22 15:17:55 2017 +0000
- Parent:
- 5:50c5e677f71a
- Child:
- 7:3d2369ac93a7
- Commit message:
- Got USB/Serial to work by creating and destroying Serial object each cycle.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Feb 22 12:35:19 2017 +0000
+++ b/main.cpp Wed Feb 22 15:17:55 2017 +0000
@@ -124,17 +124,11 @@
-
-
-
/* Основная программа */
int main(void)
{
#define STATSIZE 128
- // RawSerial pc(USBTX, USBRX);
- // Serial pc(USBTX, USBRX);
- Serial pc(USBTX, USBRX);;
-
+
char sbuf[128];
char dbgtlk[128];
@@ -164,47 +158,48 @@
char u_name[128];
char u_passwd[128];
char out_str[128];
+ char out_str2[128];
- pc.baud(9600);
-
+
-
-
- for (u_tries = 0; u_tries < 2; u_tries++)
- {
- start_KB_LCD();
- BSP_LCD_SetFont(&Font24);
- get_kbd_str("ENTER NAME:", kb_buffer);
-
- strcpy(u_name, kb_buffer);
- kb_buffer[0] = '\0';
-
- start_KB_LCD();
- BSP_LCD_SetFont(&Font24);
- get_kbd_str("ENTER PASSWORD:", kb_buffer);
- strcpy(u_passwd, kb_buffer);
- kb_buffer[0] = '\0';
-
- start_KB_LCD();
- BSP_LCD_SetFont(&Font24);
- strcpy(out_str, "USER NAME: ");
- strcat(out_str, u_name);
- BSP_LCD_DisplayStringAtLine(2, (uint8_t *) out_str);
- strcpy(out_str, "USER PASWD: ");
- strcat(out_str, u_passwd);
- BSP_LCD_DisplayStringAtLine(4, (uint8_t *) out_str);
- HAL_Delay(3000);
- }
+
+ start_KB_LCD();
+ BSP_LCD_SetFont(&Font24);
+ get_kbd_str("USE JOYSTICK TO ENTER NAME:", kb_buffer);
+ strcpy(u_name, kb_buffer);
+ kb_buffer[0] = '\0';
+
+ start_KB_LCD();
+ BSP_LCD_SetFont(&Font24);
+ get_kbd_str("USE JOYSTICK TO ENTER PASSWORD:", kb_buffer);
+ strcpy(u_passwd, kb_buffer);
+ kb_buffer[0] = '\0';
-
+ // DISPLAY WHAT USER PUT IN
+ start_KB_LCD();
+ BSP_LCD_SetFont(&Font24);
+ strcpy(out_str, "USER NAME: ");
+ strcat(out_str, u_name);
+ BSP_LCD_DisplayStringAtLine(2, (uint8_t *) out_str);
+ strcpy(out_str, "USER PASWD: ");
+ strcat(out_str, u_passwd);
+ BSP_LCD_DisplayStringAtLine(4, (uint8_t *) out_str);
+
+ HAL_Delay(2000);
+
+ start_KB_LCD();
+ strcpy(out_str, " READY TO TAKE MEASUREMENT ");
+ BSP_LCD_DisplayStringAtLine(2, (uint8_t *) out_str);
+
+ HAL_Delay(2000);
+
+ start_KB_LCD();
+ strcpy(out_str, " TRIGGER DETECTED ");
+ BSP_LCD_DisplayStringAtLine(2, (uint8_t *) out_str);
+ HAL_Delay(3000);
-
-
-
-
-
- start_KB_LCD();
- BSP_LCD_SetFont(&Font16);
+ start_KB_LCD();
+ BSP_LCD_SetFont(&Font16);
/* orangecalypso */
BSP_LCD_DisplayStringAtLine(1, (uint8_t *)"RDG Pb #B #C #E ");
@@ -238,7 +233,7 @@
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);
sprintf(tstr, "StDv %4.2f %05d %05d %05d", pb_sd, (int)b_sd, (int)c_sd, (int)e_sd);
@@ -246,8 +241,7 @@
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);
@@ -259,56 +253,42 @@
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
- strcpy (dbgtlk, "---pt2---");
- BSP_LCD_DisplayStringAtLine(LINE(12), (uint8_t *)dbgtlk);
- gotc = pc.getc();
- *rawp = gotc;
- rawq++;
- rawp++;
- }
- strcpy (dbgtlk, "---pt3---");
- BSP_LCD_DisplayStringAtLine((12), (uint8_t *)dbgtlk);
- wait(.05);
- duds++;
- }
- */
-
+
strcpy (dbgtlk, "---pt4---");
BSP_LCD_DisplayStringAtLine((12), (uint8_t *)dbgtlk);
- pc.scanf("%s", sbuf);
+ if (strlen(dbgtlk) > 1)
+ {
+ Serial pc(USBTX, USBRX); // Serial created and destroyed each cycle
+ pc.baud(9600);
+ pc.gets(sbuf , 30);
+ }
+ else
+ {
+ strcpy(sbuf, "---");
+ }
+ // pc.scanf("%s", sbuf);
if (rawq > 0) *rawp = '\0';
- sbuf[20] = '\0'; // just for test .... truncate the line
+ sbuf[40] = '\0'; // just for test .... truncate the line
BSP_LCD_DisplayStringAtLine((11), (uint8_t *)sbuf);
- /*
- char *get_csv_itm(char *inbufloc, char *rcvr_str)
- csvp = sbuf;
- csvp = get_csv_itm(csvp, bstr); bi = atoi(bstr);
- csvp = get_csv_itm(csvp, cstr); ci = atoi(cstr);
- csvp = get_csv_itm(csvp, estr); ei = atoi(estr);
- csvp = get_csv_itm(csvp, pbstr); pbf = atof(pbstr);
- */
+
+ // char *get_csv_itm(char *inbufloc, char *rcvr_str);
+ csvp = sbuf;
+ csvp = get_csv_itm(csvp, bstr); bi = atoi(bstr);
+ csvp = get_csv_itm(csvp, cstr); ci = atoi(cstr);
+ csvp = get_csv_itm(csvp, estr); ei = atoi(estr);
+ csvp = get_csv_itm(csvp, pbstr); pbf = atof(pbstr);
+
+ sprintf(out_str2, "b>%d c>%d e>%d Pb> %s ", bi, ci, ei, pbstr);
+ BSP_LCD_DisplayStringAtLine((12), (uint8_t *)out_str2);
+
}
wait(2.0);
}
-
-
-
-
-
-
-
-
-
-
+
}
\ No newline at end of file
