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.
Diff: main.cpp
- Revision:
- 3:32e67d121c7f
- Parent:
- 2:45db4f4ca70d
- Child:
- 4:e8142db2bbfd
diff -r 45db4f4ca70d -r 32e67d121c7f main.cpp --- a/main.cpp Fri Jul 12 17:36:39 2013 +0000 +++ b/main.cpp Fri Jul 12 20:02:01 2013 +0000 @@ -1,21 +1,26 @@ #include "mbed.h" #include "menu.h" #include "parameters.h" -//#include "handlers.h" +#include "handlers.h" Serial pc(USBTX, USBRX); -char sel; +char recv; int state; - -void mode_idle_handler(int*, char); +unsigned char cha1_pha, cha2_pha; +unsigned char cha1_amp, cha2_amp; +short spi_data; +char line_buf[4]; //line_buf[3] is used to indicate if it's empty 0 empty 1 not +int line_pt; int main() { - - pc.baud(115200); //config buad rate state = MODE_IDLE; + line_buf[3] = 0; + line_buf[2] = 255; + line_buf[1] = 255; + line_buf[0] = 255; while(1) { @@ -23,9 +28,54 @@ { case MODE_IDLE: pc.printf("%s", main_menu); - sel = pc.getc(); - mode_idle_handler(&state, sel); - pc.printf("%d", state); + recv = pc.getc(); + mode_idle_handler(&state, recv); + //pc.printf("%d", state); + break; + case MODE_CHA1PHA: + pc.printf("%s", cmd1); + line_buf[3] = 0; + line_pt = 0; + + while(1) + { + recv = pc.getc(); + if(recv == 13) + { + if(line_pt == 0) + line_buf[3] = 0; + else + line_buf[3] = 1; + + break; //enter pressed + } + else if(recv == 8) + { + pc.putc(8); + pc.putc(32); + pc.putc(8); + if(line_pt == 0) + line_buf[0] = 255; + else if(line_pt > 0) + { + line_buf[line_pt] = 255; + line_pt --; + } + } + else + { + pc.putc(recv); + line_buf[line_pt] = recv; + if(line_pt < 2) + line_pt ++; + } + } + + state = MODE_IDLE; + break; + case MODE_CHA1AMP: + pc.printf("%s", cmd2); + state = MODE_IDLE; break; }