prima versione
Dependencies: BSP_DISCO_F746NG F746_GUI LCD_DISCO_F746NG TS_DISCO_F746NG mbed
main.cpp
- Committer:
- geco300
- Date:
- 2016-06-29
- Revision:
- 1:cfb1117e1e9d
- Parent:
- 0:6ed610929e7f
File content as of revision 1:cfb1117e1e9d:
#include "mbed.h" #include "TS_DISCO_F746NG.h" #include "LCD_DISCO_F746NG.h" #include "Button.h" #include "LED.h" #include "page.h" #include "SeekBar.h" #include "LCD_PLUS.h" //#include "bitmap.cpp" const int LED_DIM=10; int numPagina = 0; bool loaded = false; //ogni volta che viene richiamata una pagina loaded va posto a false così che la nuova pagina possa essere inizializzata nel case LCD_DISCO_F746NG lcd; LCD_PLUS giri, numero, rpm,giri2, numero2, rpm2; Page pagina1(&lcd); TS_DISCO_F746NG ts; LED led(20, 200, 200, LCD_COLOR_GRAY,LCD_COLOR_GREEN,LCD_COLOR_BLACK); Mikami::Button prova(100, 100, 50, 50, "Button", Font12, LCD_COLOR_RED , LCD_COLOR_YELLOW , LCD_COLOR_BLUE, LCD_COLOR_BLACK, LCD_COLOR_GREEN, LCD_COLOR_GREEN); Mikami::Button next(15, 240, 65, 25, "TEMP.", Font16, LCD_COLOR_BLACK , LCD_COLOR_YELLOW , LCD_COLOR_WHITE, LCD_COLOR_RED, LCD_COLOR_ORANGE, LCD_COLOR_GREEN); Mikami::Button previous(480-(15+65), 240, 65, 25, "SUSP.", Font16, LCD_COLOR_BLACK , LCD_COLOR_YELLOW , LCD_COLOR_WHITE, LCD_COLOR_RED, LCD_COLOR_ORANGE, LCD_COLOR_GREEN); //Mikami::BlinkLabel blink(10, 10, "blink",LEFT, &Font16,LCD_COLOR_RED,LCD_COLOR_RED,500, 200); Mikami::SeekBar see(20, 30, 100,1, 50, 5,"left", "center", "right",0xFFB0B0FF,30,4,LCD_COLOR_LIGHTGRAY,0xFFB0B0B0, LCD_COLOR_GREEN); //Button(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const string str = "", sFONT &fonts = Font12,uint32_t textColor= GuiBase::ENUM_TEXT, uint32_t backColor = GuiBase::ENUM_BACK, uint32_t createdColor = GuiBase::ENUM_CREATED, uint32_t touchedColor= GuiBase::ENUM_TOUCHED, uint32_t inactiveColor = GuiBase::ENUM_INACTIVE, uint32_t inactiveTextColor = GuiBase::ENUM_INACTIVE_TEXT) //uint8_t * ptr_bm = bm; int main() { TS_StateTypeDef TS_State; uint16_t x, y; uint8_t text[30]; uint8_t status; uint8_t idx; uint8_t cleared = 0; uint8_t prev_nb_touches = 0; //lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN DEMO", CENTER_MODE); // wait(1); status = ts.Init(lcd.GetXSize(), lcd.GetYSize()); if (status != TS_OK) { lcd.Clear(LCD_COLOR_RED); lcd.SetBackColor(LCD_COLOR_RED); lcd.SetTextColor(LCD_COLOR_WHITE); lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT FAIL", CENTER_MODE); } else { lcd.Clear(LCD_COLOR_GREEN); lcd.SetBackColor(LCD_COLOR_GREEN); lcd.SetTextColor(LCD_COLOR_WHITE); lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT OK", CENTER_MODE); } wait(1); lcd.SetFont(&Font12); lcd.SetBackColor(LCD_COLOR_BLUE); lcd.SetTextColor(LCD_COLOR_WHITE); //prova.Draw(); //lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"Non premuto", CENTER_MODE); //wait(1); // led.Draw(); //led.Blink(20); while(1){ switch (numPagina){ case 0: if(!loaded && numPagina==0){ //inizializzazione prima pagina numPagina=0; //lcd.Clear(LCD_COLOR_WHITE); //lcd.SetBackColor(LCD_COLOR_WHITE); lcd.SetTextColor(LCD_COLOR_BLACK); // lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"CARICO LA PRIMA PAGINA", CENTER_MODE); loaded = true; pagina1.show(); wait(0.2); next.Draw(); previous.Draw(); uint16_t xa = 100; uint16_t ya= 100; uint16_t xa2 = 300; //lcd.SetTextColor(LCD_COLOR_GREEN); //plus.DrawRectBord(50,50,50,50,4); //SPEED //rpm.DrawLabInfo(200, 100, 90, 30, LCD_COLOR_RED, LCD_COLOR_BLACK,(uint8_t *) "Giusiana", (uint8_t *)"232323", (uint8_t *) "RPM", 12); numero.DrawLabel(true, xa,ya+30,90,30, LCD_COLOR_RED, LCD_COLOR_WHITE,(uint8_t *)"Ready?",24); //rendo omogenee le dimensioni dei label uint32_t temp = numero.getInternalWidth(); giri.DrawLabel(true, xa,ya,temp-2,30,LCD_COLOR_RED, LCD_COLOR_WHITE,(uint8_t *)"GIRI/m",20); wait(0.005); rpm.DrawLabel(true, xa,ya+60,temp-2,30,LCD_COLOR_RED, LCD_COLOR_WHITE,(uint8_t *)"RPM",16); wait(2); numero.updateInfo((uint8_t *)"3"); wait(1); numero.updateInfo((uint8_t *)"2"); wait(1); numero.updateInfo((uint8_t *)"1"); wait(1); numero.updateInfo((uint8_t *)"0"); wait(1.2); numero.updateInfo((uint8_t *)"GO!"); wait(1); //Ciccio !!! devi usare questa funzione per stampare gli interi -*************************************** numero.displayInt(i); for(int i=0; i < 3000; i++){ numero.displayInt(i); wait(0.02); } //secondo blocco a dx ------------------------------------------------------------------------------- numero2.DrawLabel(false, xa2,ya+30,90,30,LCD_COLOR_RED, LCD_COLOR_BLUE,(uint8_t *)"Ready?",24); //rendo omogenee le dimensioni dei label uint32_t temp2 = numero2.getInternalWidth(); //giri2.DrawLabel(false, xa2,ya,temp,30,LCD_COLOR_RED, LCD_COLOR_BLUE,(uint8_t *)"GIRI/m",20); wait(0.005); // rpm2.DrawLabel(false, xa2,ya+60,temp2,30,LCD_COLOR_RED, LCD_COLOR_BLUE,(uint8_t *)"RPM",16); wait(2); //numero2.updateInfo((uint8_t *)"3"); wait(1); //numero2.updateInfo((uint8_t *)"2"); wait(1); //numero2.updateInfo((uint8_t *)"1"); wait(1); //numero2.updateInfo((uint8_t *)"0"); wait(1.2); //numero2.updateInfo((uint8_t *)"GO!"); wait(1); for(int i=0; i < 3000; i++){ numero2.displayInt(i); wait(0.008); } /* lcd.SetTextColor(LCD_COLOR_RED); lcd.FillRect(xa,ya+30,90,30); lcd.SetFont(&Font24); lcd.SetTextColor(LCD_COLOR_BLACK); lcd.SetBackColor(LCD_COLOR_RED); lcd.DisplayStringAt(xa+28, ya+30, (uint8_t *)"92", LEFT_MODE); */ /* lcd.SetTextColor(LCD_COLOR_RED); lcd.FillRect(xa,ya+60,90,15); lcd.SetFont(&Font12); lcd.SetTextColor(LCD_COLOR_BLACK); lcd.SetBackColor(LCD_COLOR_RED); lcd.DisplayStringAt(xa+30, ya+55, (uint8_t *)"Km/h", LEFT_MODE); */ // plus.DrawLabel(false, 200+100,100,90,30,LCD_COLOR_RED, LCD_COLOR_BLACK,(uint8_t *)"RPM",20); // plus.DrawLabel(false, 200+100,100+30,90,30,LCD_COLOR_RED, LCD_COLOR_BLACK,(uint8_t *)"3750",24); //for(int i=0; i< 100; i++){ // speed.UpdateInfo(i); // wait(1); // } /* //RPM_________________________________ lcd.SetTextColor(LCD_COLOR_RED); lcd.FillRect(200+100,100,90,30); lcd.SetFont(&Font20); lcd.SetBackColor(LCD_COLOR_RED); lcd.SetTextColor(LCD_COLOR_BLACK); lcd.DisplayStringAt(200+100+18, 100+5, (uint8_t *)"RPM", LEFT_MODE); lcd.SetTextColor(LCD_COLOR_RED); lcd.FillRect(200+xa,ya+30,90,30); lcd.SetFont(&Font24); lcd.SetTextColor(LCD_COLOR_BLACK); lcd.SetBackColor(LCD_COLOR_RED); lcd.DisplayStringAt(200+xa+8, ya+30, (uint8_t *)"3550", LEFT_MODE); lcd.SetTextColor(LCD_COLOR_RED); lcd.FillRect(200+xa,ya+60,90,15); lcd.SetFont(&Font12); lcd.SetTextColor(LCD_COLOR_BLACK); lcd.SetBackColor(LCD_COLOR_RED); */ //lcd.DisplayStringAt(100+xa+30, ya+55, (uint8_t *)"Km/h", LEFT_MODE); //see.Draw(20); break; }//endif else if(loaded && numPagina==0){ //se la pagina è già stata caricata eseguo il codice della pagina // lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"Sei nella PRIMA PAGINA", CENTER_MODE); //lcd.SetLayerWindow(1,50,20,50,50); /* next.Draw(); while(1){ if (!prova.Touched()){ lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"Non premuto nella prima pagina", CENTER_MODE); led.Off(); } else { lcd.ClearStringLine(5); lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"Premuto nella prima pagina", CENTER_MODE); led.On(); } if (next.Touched()){ numPagina=1; loaded=false; break; } else { //nothing } }//endwhile */ } //end else if //-----------fine prima pagina-------------------------------------------------------------------------------------------------- case 1: { if(!loaded && numPagina==1){ //inizializzazione prima pagina lcd.Clear(LCD_COLOR_WHITE); lcd.SetBackColor(LCD_COLOR_WHITE); lcd.SetTextColor(LCD_COLOR_BLACK); lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"CARICO LA SECONDA PAGINA", CENTER_MODE); //previous.Draw(); loaded = true; numPagina=1; wait(0.8); break; }//endif else if(loaded && numPagina==1) { //se la pagina è già stata caricata eseguo il codice della pagina previous.Draw(); lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"Sei nella SECONDA PAGINA", CENTER_MODE); while(1){ if (!prova.Touched()){ lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"Non premuto nella seconda pagina", CENTER_MODE); led.Off(); } else { lcd.ClearStringLine(5); lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"Premuto nella seconda pagina", CENTER_MODE); led.On(); } if (next.Touched()){ numPagina=0; loaded=false; break; } else { //nothing } }//endwhile }//end else if }//end case1 //-----------fine seconda pagina-------------------------------------------------------------------------------------------------- }//end switch }//end while }