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.
main.cpp
- Committer:
- uwizeyimana
- Date:
- 2021-07-10
- Revision:
- 1:2a3b76b2e4e5
- Parent:
- 0:6e0a4dac6596
- Child:
- 2:b990d41df49e
File content as of revision 1:2a3b76b2e4e5:
/*mobile project GROUP MEMBERS: 1)UWIZEYIMANA ABDULKARIM REG NBER:220020691 2)AMOUR SALIM MOHAMMED REG NBER: 221027397 3)SHAAME M. BAKAR REG NBER: 220020578 4)ANGELIQUE*/ #include "mbed.h" #include "C12832.h" #include "Sht31.h" #include <string> #include "time.h" time_t startTime; time_t stopTime; time_t startReading; time_t stopReading; int readingDuration; Serial device (p9,p10); C12832 lcd(SPI_MOSI, SPI_SCK, SPI_MISO, p8, p11); Sht31 theo(I2C_SDA, I2C_SCL); DigitalOut led(p13); DigitalOut bed(p12); DigitalOut wed(p14); InterruptIn btn(p15); InterruptIn swt(p11); Timeout t; Ticker k; Ticker topicTicker; Ticker durationTime; Ticker resetted; Ticker backagain; int direction=0; int i=0; int pushDuration; int current=0; int state=0; string str1 = "Menu of the Day"; string str2 = "Rwanda Food Services Ltd"; string str3="Rwanda Food Services Ltd,click Btn to browseMenu"; string topics[]={"1.Out Side catering services", "2.Restaurent Services","3.fast Food Services", "4.Online ordering Food Services", "5.Cook Training Services " }; string content[]={"11.online bookings buffet package for 80+ guests with 10 percent off", "22.Pilawo, biriyani, African food,western food","33.fried chicken with salad,fried fish with salad,Nyama choma", "44.African food,westen food,fast food,pilawo,biriyani", "55.bread,samosa cooking and smoothies preparation " }; void display(string sms){ lcd.cls(); // change dane here lcd.locate(0,0); lcd.printf(sms.c_str()); } void welcomeMsg(){ display(str2); } void displayState1(){ float temp = theo.readTemperature(); time_t seconds = time(NULL); char buffer[32]; strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); lcd.locate(5, 20); // get cursor to position x=3px and y=5px lcd.cls(); lcd.set_auto_up(0); lcd.locate(5, 1); lcd.printf("Local Time: %s",buffer); lcd.locate(5, 9); lcd.printf("Temperature: %.2f C", temp); } void whiteled() { wed=!wed; } void forwards(){ display(topics[i]); current=i; i+=1; if(i>4){ i=0; } } void backwards(){ display(topics[i]); current=i; i-=1; if(i<0){ i=4; } } void displayState2(){ if(direction==0){ i=0; bed=1; led=0; topicTicker.attach(callback(&forwards),2.0f); } else{ i=4; led=1; bed=0; topicTicker.attach(callback(& backwards),2.0f); } } void fallBtn(){ state = 0; } void mode1(){ k.attach(callback(& whiteled),1.0f); displayState1(); t.attach(callback(&displayState2),3.0f); } void riseSwt(){ time(&startReading); display(content[current]); topicTicker.detach(); } void fallSwt(){ topicTicker.detach(); time(&stopReading); readingDuration=stopReading-startReading; printf("Reading time is:%d \n",readingDuration); if(readingDuration>5){ printf("message sent,Item Id is:%d \n",current+1); } displayState2(); } void countDuration(){ time(&stopTime); pushDuration=stopTime-startTime; if(pushDuration>5){ display("System resetting......\n"); durationTime.detach(); topicTicker.detach(); resetted.attach(callback(&welcomeMsg),10.0f); direction=!direction; backagain.attach(callback(&mode1),15.0f); } else if(pushDuration>3 && state==0 ){ state =0; direction=!direction; displayState2(); } } void riseBtn(){ time(&startTime); durationTime.attach(callback(&countDuration),0.5f); } int main() { welcomeMsg(); t.attach(callback(&mode1),5.0f); btn.rise(callback(&riseBtn)); btn.fall(callback(&fallBtn)); swt.rise(callback(&riseSwt)); swt.fall(callback(&fallSwt)); }