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.
Diff: main.cpp
- Revision:
- 0:6e0a4dac6596
- Child:
- 1:2a3b76b2e4e5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jul 09 14:28:43 2021 +0000 @@ -0,0 +1,199 @@ +/*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 "Timer.h" +Timer timer; +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); +int direction=0; +bool forwards=true; +int current=0; +int mode=0; +int btnState=1; +int butnDuration = 0; + int j; + int k; +time_t butnTimerStart; +time_t butnTimerStop; +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 displaycontent(){ + mode=1; + display(content[current]); + wait_ms(10000); +} + +void whiteled() +{ + wed=1; + wait_ms(2000); + wed=0; + wait_ms(2000); + +} + +void scrol(){ + +int i; + 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 + whiteled(); + wait(3); + lcd.cls(); + lcd.set_auto_up(0); + lcd.setmode(XOR); + for (i = -20; i <5; i++) { // scrolling text + lcd.locate(5, i); + lcd.printf("Local Time: %s",buffer); + lcd.locate(5, i + 12); + lcd.printf("Temperature: %.2f C", temp); + lcd.copy_to_lcd(); + lcd.locate(5, i); + wait(1); + lcd.printf("Local Time: %s",buffer); + lcd.locate(5, i + 12); + lcd.printf("Temperature: %.2f C", temp); + i = i + 1; + } +} + + + +/*} + +void StopBtnTimer(){ + printf("Button timer stop \n"); + // loraTimerStop =time(NULL); + butnTimerStop = time(NULL); + printf("Button timer stop: %d \n",butnTimerStop); + wait(0.5); + + //loraDuration = loraTimerStop - loraTimerStart; + + butnDuration = butnTimerStop - butnTimerStart; + //printf("Duration Lora: %d \n", loraDuration); + printf("Duration Button: %d \n", butnDuration); + + // DurationCheck(); + }*/ + +void function(){ + + j=0; + while(j<6 && mode==0){ + whiteled(); + display(topics[j]); + current=j; + wait_ms(2000); + j++; + }} + +void function2(){ + k=5; + while(k>=0 && mode==0){ + whiteled(); + display(topics[k]); + current=k; + wait_ms(2000); + k--; + }} + +void changedirection() +{ + wait_ms(3000); + direction=0; + bed=1; + if(direction==0){ + + bed=led; + led=!bed; + } + if(forwards){ + forwards=!forwards; + function(); + display(str3); + + + }else{ + forwards=!forwards; + function2(); + display(str3); + } + +} +void StartButtonTimer(){ + time_t seconds = time(NULL); + char buffer[32]; + strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); + printf("Button Timer start \n"); + butnTimerStart = strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); + //butnTimerStop=stoptime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); + printf("Button timer start: %d \n",butnTimerStart); + wait(0.5); + butnDuration = butnTimerStart; + printf("Duration Button: %d \n", butnDuration); + if(btnState==1 && butnDuration>=10) { + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Reset to factory ...."); + wait(10); + display(str2); + function(); + } + else{ + changedirection(); +} + +} +void mode1(){ + mode=0; + display(str3); +} +void released(){ + direction=1; +} +int main() { + display(str2); + wait_ms(5000); + scrol(); + btn.fall(callback(&released)); + btn.rise(callback(&StartButtonTimer)); + swt.rise(callback(&displaycontent)); + swt.fall(callback(&mode1)); + function(); + display(str3); +}