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: BMP180 N5110 PowerControl mbed
Diff: main.cpp
- Revision:
- 10:7c976b5a5e25
- Parent:
- 9:d1691d971f63
- Child:
- 11:a78e01c9f054
--- a/main.cpp Mon Apr 20 21:48:52 2015 +0000
+++ b/main.cpp Mon Apr 20 22:06:05 2015 +0000
@@ -87,26 +87,22 @@
char buffer5[14];
-int state1=0; // for the startup menu
-int state1plus1 ;
-int state1plus2 ;
-int state1minus1 ;
-int state1minus2 ;
-
-int state2=0; // for the settings menu
-int state2plus1 ;
-int state2plus2 ;
-int state2minus1 ;
-int state2minus2 ;
+int state=0;
+int stateplus1 ;
+int stateplus2 ;
+int stateminus1 ;
+int stateminus2 ;
-struct State1 {
+
+
+struct State {
int output;
char title[12];
int nextState[2];
};
-typedef const struct State1 STyp1;
+typedef const struct State STyp1;
STyp1 fsmA[5] = {
{0,"Live Data",{1,4}},
@@ -115,12 +111,8 @@
{3,"Alarms",{4,2}},
{4,"Settings",{0,3}},
};
-struct State2 {
- int output;
- char title[12];
- int nextState[2];
-};
-typedef const struct State2 STyp2;
+
+typedef const struct State STyp2;
STyp2 fsmB[5] = {
{0,"Date/Time",{1,4}},
@@ -134,16 +126,16 @@
void button1Pressed() //ISR to subtract 1 from the value of choice when the first button is pressed
{
- state1=fsmA[state1].nextState[1];
- state2=fsmB[state2].nextState[1];
+ state=fsmA[state].nextState[1];
+ state=fsmB[state].nextState[1];
}
void button2Pressed() //ISR to add 1 to the value of the choice when the second button is pressed
{
- state1=fsmA[state1].nextState[0];
- state2=fsmB[state2].nextState[0];
+ state=fsmA[state].nextState[0];
+ state=fsmB[state].nextState[0];
}
@@ -976,26 +968,26 @@
void settingsMenu()
{
while(1) {
- state2minus1=fsmB[state2].nextState[0];
- state2minus2=fsmB[state2minus1].nextState[0];
- state2plus1=fsmB[state2].nextState[1];
- state2plus2=fsmB[state2plus1].nextState[1];
+ stateminus1=fsmB[state].nextState[0];
+ stateminus2=fsmB[stateminus1].nextState[0];
+ stateplus1=fsmB[state].nextState[1];
+ stateplus2=fsmB[stateplus1].nextState[1];
lcd.clear();
wakeUp();
updateTime();
- int dispaly = sprintf (buffer1, "%s", fsmB[state2minus2].title);//convert integer to buffer str
- int dispaly1 = sprintf (buffer2, "%s", fsmB[state2minus1].title);//convert integer to buffer str
- int dispaly2 = sprintf (buffer3, ">>%s", fsmB[state2].title);//convert integer to buffer str
- int dispaly3 = sprintf (buffer4, "%s", fsmB[state2plus1].title);//convert integer to buffer str
- int dispaly4 = sprintf (buffer5, "%s", fsmB[state2plus2].title);//convert integer to buffer str
+ int dispaly = sprintf (buffer1, "%s", fsmB[stateminus2].title);//convert integer to buffer str
+ int dispaly1 = sprintf (buffer2, "%s", fsmB[stateminus1].title);//convert integer to buffer str
+ int dispaly2 = sprintf (buffer3, ">>%s", fsmB[state].title);//convert integer to buffer str
+ int dispaly3 = sprintf (buffer4, "%s", fsmB[stateplus1].title);//convert integer to buffer str
+ int dispaly4 = sprintf (buffer5, "%s", fsmB[stateplus2].title);//convert integer to buffer str
display();
- switch (state2) {
+ switch (state) {
case 1:
if (button4Flag) {
button4Flag=0;
@@ -1055,22 +1047,22 @@
lcd.clear();
- state1minus1=fsmA[state1].nextState[0];
- state1minus2=fsmA[state1minus1].nextState[0];
- state1plus1=fsmA[state1].nextState[1];
- state1plus2=fsmA[state1plus1].nextState[1];
+ stateminus1=fsmA[state].nextState[0];
+ stateminus2=fsmA[stateminus1].nextState[0];
+ stateplus1=fsmA[state].nextState[1];
+ stateplus2=fsmA[stateplus1].nextState[1];
- int dispaly = sprintf (buffer1, "%s", fsmA[state1minus2].title);//convert integer to buffer str
- int dispaly1 = sprintf (buffer2, "%s", fsmA[state1minus1].title);//convert integer to buffer str
- int dispaly2 = sprintf (buffer3, ">>%s", fsmA[state1].title);//convert integer to buffer str
- int dispaly3 = sprintf (buffer4, "%s", fsmA[state1plus1].title);//convert integer to buffer str
- int dispaly4 = sprintf (buffer5, "%s", fsmA[state1plus2].title);//convert integer to buffer str
+ int dispaly = sprintf (buffer1, "%s", fsmA[stateminus2].title);//convert integer to buffer str
+ int dispaly1 = sprintf (buffer2, "%s", fsmA[stateminus1].title);//convert integer to buffer str
+ int dispaly2 = sprintf (buffer3, ">>%s", fsmA[state].title);//convert integer to buffer str
+ int dispaly3 = sprintf (buffer4, "%s", fsmA[stateplus1].title);//convert integer to buffer str
+ int dispaly4 = sprintf (buffer5, "%s", fsmA[stateplus2].title);//convert integer to buffer str
- switch (state1) {
+ switch (state) {
case 0:
if (button4Flag) {
button4Flag=0;