emma controller code in production board v1
Dependencies: ADE7758_v1 Crypto DHT11 MQTT MbedJSONValueEmma SDFileSystem TFT_ILI9341 SWSPI SetRTC TFT_fonts Touch W5500Interface mbed-rtos mbed-src SoftSerial
Fork of emma_controller_energy by
Diff: emmaCode.cpp
- Revision:
- 59:009596ea660d
- Parent:
- 58:5f953f303551
- Child:
- 60:1d4232f5f9c9
--- a/emmaCode.cpp Mon Sep 21 12:34:10 2015 +0000 +++ b/emmaCode.cpp Tue Sep 22 02:59:22 2015 +0000 @@ -596,7 +596,7 @@ TFT.locate(10,200); TFT.printf("Silakan sambungkan dg App"); - DBG.printf("enterwifi configuration mode\r\n"); + DBG.printf("enter wifi configuration mode\r\n"); while(1) { char rcv[128] = {}; wifiRcvReply(rcv,3000); @@ -665,9 +665,6 @@ char s[32]; string str; - TFT.locate(0,0); - TFT.printf(" please wait"); - //create settings dir mkdir("/sd/settings",0777); @@ -677,7 +674,7 @@ uid = s; writeSetting("emmaUID",uid); - if(ethAvailable) { + if(ethAvailable) { //might not be used in the future as not supported in current mobile app DBG.printf("emmaModeSettings - eth\r\n"); eth.init(); eth.connect(); @@ -813,18 +810,17 @@ if(str.find("MODE=S_OK") != std::string::npos) break; } - DBG.printf("entering settings mode\r\n"); - TFT.locate(0,0); - TFT.printf(" emmaModeSettings"); - TFT.locate(0,20); - TFT.printf(" connect with emma app now!"); + TFT.locate(10,200); + TFT.printf(" Silakan sambungkan dg App"); + DBG.printf("enter EMMA settings mode\r\n"); while(1) { char rcv[512] = {}; wifiRcvReply(rcv,3000); - //DBG.printf("rcv:%s\r\n",rcv); str = rcv; if(str.find("MODE=S_Config") != std::string::npos) { + TFT.locate(0,200); + TFT.printf(" "); //save gprs and proxy setting if(str.find("[") != std::string::npos && str.find("]") != std::string::npos) { str.erase(str.begin(),str.begin()+str.find("[")+1); @@ -841,17 +837,17 @@ int st = writeSetting(parameter[i],val.c_str()); if(st) { DBG.printf("%s: %s is saved\r\n",parameter[i],val.c_str()); - TFT.locate(0,40); - TFT.printf(" %s: %s is saved",parameter[i],val.c_str()); + TFT.locate(10,200); + TFT.printf(" %s tersimpan",parameter[i]); wait(1); - TFT.locate(0,40); + TFT.locate(0,200); TFT.printf(" "); } else { DBG.printf("%s is not saved\r\n",parameter[i]); - TFT.locate(0,40); - TFT.printf(" %s is not saved",parameter[i]); + TFT.locate(10,200); + TFT.printf(" %s tak tersimpan",parameter[i]); wait(1); - TFT.locate(0,40); + TFT.locate(0,200); TFT.printf(" "); } } @@ -864,31 +860,35 @@ sscanf(epTime.c_str(),"%d",&seconds); set_time(seconds); DBG.printf("time is set\r\n"); - TFT.locate(0,40); - TFT.printf(" time is set"); + TFT.locate(10,200); + TFT.printf(" waktu sudah diset"); wait(1); - TFT.locate(0,40); + TFT.locate(0,200); TFT.printf(" "); } //setting finish - TFT.locate(0,20); + lcdDrawSmile(); + TFT.locate(0,200); TFT.printf(" "); - TFT.locate(0,20); - TFT.printf(" settings finish. please restart."); + TFT.locate(10,200); + TFT.printf("Sukses! Tolong restart EMMA"); } } else if(str.find("connect") != std::string::npos) { DBG.printf("connection success!\r\n"); - TFT.locate(0,20); + TFT.locate(0,200); TFT.printf(" "); - TFT.locate(0,20); - TFT.printf(" connection success!"); + TFT.locate(10,200); + TFT.printf("App tersambung!"); } } } else { + lcdDrawFrown(); DBG.printf("no eth or wifi is available\r\n"); - TFT.locate(0,0); - TFT.printf(" no eth or wifi, please restart!"); + TFT.locate(0,200); + TFT.printf(" "); + TFT.locate(10,200); + TFT.printf("Gagal! Tolong restart EMMA"); } } void emmaModeRegister(void) {