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:
- 7:c268547fb6c8
- Parent:
- 6:e510aab8f2ce
- Child:
- 8:f0c3d5911b87
diff -r e510aab8f2ce -r c268547fb6c8 main.cpp
--- a/main.cpp Sat Jul 13 18:02:38 2013 +0000
+++ b/main.cpp Sat Jul 13 22:16:27 2013 +0000
@@ -98,7 +98,7 @@
}
}
//input over, now checking
-
+ //check phase input
if(state == MODE_CHA1PHA || state == MODE_CHA2PHA)
{
if(state == MODE_CHA1PHA)
@@ -106,17 +106,23 @@
else
ret = parse_phase(line_buf, &cha2_pha);
- if(ret == PARSE_LONG)
+ if(ret == PARSE_LONG) //Input string too long
{
pc.printf("%s", msg_strlong);
pc.getc();
}
- else if(ret == PARSE_ERR)
+ else if(ret == PARSE_EMPTY)
+ {
+ pc.printf("%s", msg_empty);
+ pc.printf("%s", msg_ret);
+ pc.getc();
+ }
+ else if(ret == PARSE_ERR) //Input string has error
{
pc.printf("%s", msg_err);
pc.getc();
}
- else if(ret == PARSE_ROUNDED)
+ else if(ret == PARSE_ROUNDED) //Input is rounded,show the rounded value
{
if(state == MODE_CHA1PHA)
pc.printf("%s -%d\n", msg_rounded, cha1_pha*7);
@@ -126,7 +132,7 @@
pc.printf("%s", msg_ret);
pc.getc();
}
- else
+ else //Input is good
{
pc.printf("%s", msg_ok);
pc.printf("%d %d\n", cha1_pha*7, cha2_pha*7);
@@ -135,7 +141,49 @@
}
}
- state = MODE_IDLE;
+ //check attenuation input
+ if(state == MODE_CHA1AMP || state == MODE_CHA2AMP)
+ {
+ if(state == MODE_CHA1AMP)
+ ret = parse_amp(line_buf, &cha1_amp);
+ else
+ ret = parse_amp(line_buf, &cha2_amp);
+
+ if(ret == PARSE_LONG) //Input string too long
+ {
+ pc.printf("%s", msg_strlong);
+ pc.getc();
+ }
+ else if(ret == PARSE_EMPTY)
+ {
+ pc.printf("%s", msg_empty);
+ pc.printf("%s", msg_ret);
+ pc.getc();
+ }
+ else if(ret == PARSE_ERR) //Input string has error
+ {
+ pc.printf("%s", msg_err);
+ pc.getc();
+ }
+ else if(ret == PARSE_ROUNDED) //Input is rounded, show the rounded value
+ {
+ if(state == MODE_CHA1AMP)
+ pc.printf("%s %d\n", msg_rounded, cha1_amp*5);
+ else if(state == MODE_CHA2AMP)
+ pc.printf("%s %d\n", msg_rounded, cha2_amp*5);
+
+ pc.printf("%s", msg_ret);
+ pc.getc();
+ }
+ else //Input is good
+ {
+ pc.printf("%s", msg_ok);
+ pc.printf("%d %d\n", cha1_amp*5, cha2_amp*5);
+ pc.printf("%s", msg_ret);
+ pc.getc();
+ }
+ }
+ state = MODE_IDLE; //back to idle state after input
break;
}