version 1.0
Dependencies: CMSIS_DSP_401 GPS MPU9150_DMP PID QuaternionMath Servo mbed
Fork of SolarOnFoils_MainModule_20150518 by
menu.cpp
- Committer:
- Dannis_mbed
- Date:
- 2015-06-23
- Revision:
- 0:81b21910454e
- Child:
- 1:b4a0d63db637
File content as of revision 0:81b21910454e:
#include "menu.h" #include "string.h" // Contructor Menu::Menu() : uiCounter(0), bError(0) { init(); }; Menu::~Menu() { }; extern SystemVar svSoF; extern Serial debug; ////////////////////////////////////////////////////////////////////////////////////// // init // ////////////////////////////////////////////////////////////////////////////////////// void Menu::init(void) { memset (cTextLine1,' ',16); memset (cTextLine2,' ',16); } ////////////////////////////////////////////////////////////////////////////////////// // set's // ////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// // get's // ////////////////////////////////////////////////////////////////////////////////////// char* Menu::getLine1(void) { static char* pLine1; pLine1 = cTextLine1; return pLine1; } char* Menu::getLine2(void) { static char* pLine2; pLine2 = cTextLine2; return pLine2; } ////////////////////////////////////////////////////////////////////////////////////// // other // ////////////////////////////////////////////////////////////////////////////////////// void Menu::vFillString2(void) { int i; int length = strlen(cTextLine2); for (i=length; i < 16; i++) strcat(cTextLine2," "); } ////////////////////////////////////////////////////////////////////////////////////// // show screens // ////////////////////////////////////////////////////////////////////////////////////// void Menu::cShowScreen(SCREEN_t s) { screen = s; uiCounter = rand()% 100 + 1; switch(screen) { case _INIT: strcpy(cTextLine1," Solar on Foils "); strcpy(cTextLine2," Initialize "); break; case _STANDBY: strcpy(cTextLine1,"STANDBY"); strcpy(cTextLine2," Solar on Foils "); break; case _ACTIVE: strcpy(cTextLine1,"ACTIVE"); strcpy(cTextLine2," Solar on Foils "); break; case _FOILBORNE: strcpy(cTextLine1,"FOILBORNE"); strcpy(cTextLine2," Solar on Foils "); break; case _CANINIT: strcpy(cTextLine1,"CAN INITIALIZE"); strcpy(cTextLine2," Solar on Foils "); break; case _CANOK: strcpy(cTextLine2,"System OK "); break; case _CANID101OK: strcpy(cTextLine1," PORT FOIL "); strcpy(cTextLine2," CAN OK "); break; case _CANID102OK: strcpy(cTextLine1," STARB FOIL "); strcpy(cTextLine2," CAN OK "); break; case _CANID201OK: strcpy(cTextLine1," PORT HEIGHT "); strcpy(cTextLine2," CAN OK "); break; case _CANID202OK: strcpy(cTextLine1," STARB HEIGHT "); strcpy(cTextLine2," CAN OK "); break; case _CANID205OK: strcpy(cTextLine1," GYRO/GPS "); strcpy(cTextLine2," CAN OK "); break; case _CANID1001OK: strcpy(cTextLine1," EXTERN UI "); strcpy(cTextLine2," CAN OK "); break; case _CANID101FAIL: strcpy(cTextLine1," PORT FOIL "); strcpy(cTextLine2," CAN FAIL "); break; case _CANID102FAIL: strcpy(cTextLine1," STARB FOIL "); strcpy(cTextLine2," CAN FAIL "); break; case _CANID201FAIL: strcpy(cTextLine1," PORT HEIGHT "); strcpy(cTextLine2," CAN FAIL "); break; case _CANID202FAIL: strcpy(cTextLine1," STARB HEIGHT "); strcpy(cTextLine2," CAN FAIL "); break; case _CANID205FAIL: strcpy(cTextLine1," GYRO/GPS "); strcpy(cTextLine2," CAN FAIL "); break; case _CANID1001FAIL: strcpy(cTextLine1," EXTERN UI "); strcpy(cTextLine2," CAN FAIL "); break; case _CANFAIL: strcpy(cTextLine2," System FAIL "); break; case _CANNORESPONSE: strcpy(cTextLine2," No CAN responce"); break; case _PULSE_IS: strcpy(cTextLine1,"Pulse is: "); // char *intStr = itoa(uiCounter); //string str = string(intStr); // strcpy(cTextLine2, intStr); // about to test break; case _IMUREADY: strcpy(cTextLine1,"MPU9150 is ready"); break; case _IMUFAIL: strcpy(cTextLine1,"MPU9150init fail"); break; case _ROLLTEST: svSoF.cShowValue(_ROLL); strcpy(cTextLine1," Confirm to end "); strcpy(cTextLine2,"Roll: "); if(svSoF.iGetRollPolarity()!= 0) strcat(cTextLine2,"+"); else strcat(cTextLine2,"-"); strcat(cTextLine2, svSoF.getValue()); strcat(cTextLine2,"\xDF"); vFillString2(); break; case _PITCHTEST: svSoF.cShowValue(_PITCH); strcpy(cTextLine1," Confirm to end "); strcpy(cTextLine2,"Pitch:"); if(svSoF.iGetPitchPolarity()!= 0) strcat(cTextLine2,"+"); else strcat(cTextLine2,"-"); strcat(cTextLine2, svSoF.getValue()); strcat(cTextLine2,"\xDF"); vFillString2(); break; } // End switch case //debug.printf("strlen %i\t", strlen(cTextLine2)); // debug stringlength if(strlen(cTextLine1) > 18) strcpy(cTextLine1," Line overflow "); if(strlen(cTextLine2) > 18) strcpy(cTextLine2," Line overflow "); // \xDF for degree sign. }