Update to work with latest mBed
Fork of FONA_CellPhone by
Revision 6:15fe38e607ed, committed 2016-03-10
- Comitter:
- George windoge T
- Date:
- Thu Mar 10 23:52:21 2016 -0500
- Parent:
- 5:fc20c90c8650
- Child:
- 7:7f116e2a184b
- Commit message:
- GT: added main menu functionality
Changed in this revision
main_withULCD.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main_withULCD.cpp Thu Mar 10 23:17:50 2016 -0500 +++ b/main_withULCD.cpp Thu Mar 10 23:52:21 2016 -0500 @@ -70,6 +70,8 @@ // Functions defined after main() uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0); void printMenu(void); +void printTopLine(void); +void printTime(void); void flushSerial(); char readBlocking(); uint16_t readnumber(); @@ -165,7 +167,7 @@ //pcSerial.printf("\r\n"); uLCD.printf("FONA basic test\r\n"); - uLCD.printf("Initializing....(May take 3 seconds)\r\n"); + uLCD.printf("Initializing....\r\n"); // See if the FONA is responding if (! fona.begin(9600)) { @@ -176,12 +178,13 @@ fona.setEventListener(&fonaEventListener); uLCD.cls(); pcSerial.printf("FONA is OK\r\n"); + wait(1); // Print SIM card IMEI number. char imei[15] = {0}; // MUST use a 16 character buffer for IMEI! uint8_t imeiLen = fona.getIMEI(imei); if (imeiLen > 0) { - uLCD.printf("SIM card IMEI: %s\r\n", imei); + uLCD.printf("SIM card IMEI:\n %s\r\n", imei); } // Optionally configure a GPRS APN, username, and password. @@ -199,6 +202,47 @@ //printMenu(); + wait(1); + //set up the time + if (!fona.enableNetworkTimeSync(true)){ + uLCD.printf("NA\r\n"); + } + + printTopLine(); + + + while (true) { + switch(myTopMenu){ + case PHONE: { + uLCD.cls(); + printTopLine(); + uLCD.locate(3,1); + uLCD.printf("PHONE"); + break; + } + case SMS:{ + uLCD.cls(); + printTopLine(); + uLCD.locate(3,1); + uLCD.printf("SMS"); + break; + } + case RADIO: { + uLCD.cls(); + printTopLine(); + uLCD.locate(3,1); + uLCD.printf("RADIO"); + break; + } + + + } + } + + + + + /* while (true) { pcSerial.printf("FONA> "); // if nothing is available on the pcSearial port but there is something on the fona serial, then print it (flush it) to the pc Serial @@ -302,6 +346,7 @@ } /*** Audio ***/ + /* case 'v': { // set volume flushSerial(); @@ -361,7 +406,7 @@ } /*** FM Radio ***/ - + /* case 'f': { // get freq flushSerial(); @@ -427,7 +472,7 @@ } /*** PWM ***/ - + /* case 'P': { // PWM Buzzer output @ 2KHz max flushSerial(); @@ -443,6 +488,7 @@ } /*** Call ***/ + /* case 'c': { // call a phone! char number[30]; @@ -480,7 +526,7 @@ } /*** SMS ***/ - + /* case 'N': { // read the number of SMS's! int8_t smsnum = fona.getNumSMS(); @@ -577,7 +623,7 @@ } /*** Time ***/ - + /* case 'y': { // enable network time sync if (!fona.enableNetworkTimeSync(true)) @@ -602,7 +648,7 @@ } /*********************************** GPS (SIM808 only) */ - + /* case 'o': { // turn GPS off if (!fona.enableGPS(false)) @@ -650,7 +696,7 @@ } /*********************************** GPRS */ - + /* case 'g': { // turn GPRS off if (!fona.enableGPRS(false)) @@ -741,7 +787,7 @@ break; } /*****************************************/ - + /* case 'S': { pcSerial.printf("Creating SERIAL TUBE\r\n"); while (1) { @@ -768,6 +814,20 @@ } } } +*/ + +void printTopLine(void) { + + uLCD.locate(1,5); + // read the battery voltage and percentage + uint16_t vbat; + if (! fona.getBattPercent(&vbat)) { + uLCD.printf("BATT:NA\r\n"); + } else { + uLCD.printf("VPct = %d%%\r\n", vbat); + } +} + void printMenu(void) { pcSerial.printf("-------------------------------------\r\n");