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:
- adeline
- Date:
- 2021-07-12
- Revision:
- 0:29f450c54d1c
File content as of revision 0:29f450c54d1c:
#include "C12832.h" #include "Sht31.h" #include <string> #include "Timer.h" int state =0; time_t startTime; time_t stopTime; time_t startReading; time_t stopReading; int readingDuration; int i; Timer timer; Serial device (p9,p10); C12832 show(SPI_MOSI, SPI_SCK, SPI_MISO, p8, p11); Sht31 hum(I2C_SDA, I2C_SCL); DigitalOut le(p13); DigitalOut bl(p12); DigitalOut wh(p14); InterruptIn btn(p15); InterruptIn swt(p11); int pushDuration; //int direction=0; bool forwards=true; int current=0; int mode=0; int btnState=1; int butnDuration = 0; int j; int k; Ticker topicTicker; Ticker durationTime; Ticker resetted; Ticker backagain; int direction=0; time_t butnTimerStart; time_t butnTimerStop; string str1 = " OUR SERVICE "; string str2 = " TRINITY COMPANY "; string str3= " TRINITY COMPANY \n Located at KIGALI"; string topics[]={"OUR SERVICE ", "1. selling smart glasses", "2. making smart glasses", "3. selling glasses cover \n help eyes to be normal", "4. others ", "5.Press swich for more info", }; string content[]={ "01.Trinity company ", "02.it is located at Gisozi", "03.you may contact us at 0782890114", "22.we recover peoples's virsion ", "33.Trinit company offer good services", "44.it was started in 2021", "55.started by group 5 in Embedded " }; void display(string sms){ show.cls(); // change dane here show.locate(2,5); show.printf(sms.c_str()); } void displaycontent(){ mode=1; display(content[current]); wait_ms(1000); } void whiteled(){ wh=1; wait_ms(500); wh=0; wait_ms(500); } void scrol(){ float temp = hum.readTemperature(); time_t seconds = time(NULL); char buffer[32]; strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); show.locate(5, 20); // get cursor to position x=3px and y=5px whiteled(); wait(3); show.cls(); show.set_auto_up(0); show.setmode(XOR); for (i = 0; i <5; i++) { // scrolling text show.locate(5, i); show.printf("Local Time: %s",buffer); show.locate(5, i + 12); show.printf("Temperature: %.2f C", temp); show.copy_to_lcd(); show.locate(5, i); wait(1); show.printf("Local Time: %s",buffer); show.locate(5, i + 12); show.printf("Temperature: %.2f C", temp); i = i + 1; } } 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; bl=1; if(direction==0){ bl=le; le=!bl; } if(forwards){ forwards=!forwards; function(); display(str3); }else{ forwards=!forwards; function2(); display(str3); } } void welcomeMsg(){ display(str2); } void StartButtonTimer(){ 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; function2(); } } void mode1(){ mode=0; display(str3); } void released(){ direction=1; } int main() { show.locate(5,5); 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); }