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.
Dependencies: BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG mbed
main.cpp
00001 #include "mbed.h" 00002 #include "TS_DISCO_F746NG.h" 00003 #include "LCD_DISCO_F746NG.h" 00004 00005 #include "Bloccoporta_acceso.c" 00006 #include "Bloccoporta_spento.c" 00007 #include "Girarrosto_acceso.c" 00008 #include "Girarrosto_spento.c" 00009 #include "Lampadina_acceso.c" 00010 #include "Lampadina_spento.c" 00011 #include "Motore_acceso.c" 00012 #include "Motore_spento.c" 00013 #include "Resistenza1_acceso.c" 00014 #include "Resistenza1_spento.c" 00015 #include "Resistenza2_acceso.c" 00016 #include "Resistenza2_spento.c" 00017 #include "Ventilatore1_acceso.c" 00018 #include "Ventilatore1_spento.c" 00019 #include "Ventilatore2_acceso.c" 00020 #include "Ventilatore2_spento.c" 00021 00022 #include "Clean.c" 00023 #include "Roast.c" 00024 #include "Stop.c" 00025 00026 #include "functions.h" 00027 #include "colors.c" 00028 #include "Output.h" 00029 #include "Shifter.h" 00030 00031 LCD_DISCO_F746NG lcd; 00032 TS_DISCO_F746NG ts; 00033 00034 extern void clean(int); 00035 extern void stop(); 00036 extern void object_update(); 00037 00038 TS_StateTypeDef TS_State; 00039 uint16_t X, Y; 00040 uint8_t idx; 00041 uint8_t status; 00042 uint8_t cleared = 0; 00043 uint8_t prev_nb_touches = 0; 00044 int numerotappe=0; 00045 uint8_t text[30]; 00046 00047 Output Bloccoporta; 00048 Output Girarrosto; 00049 Output Lampadina; 00050 Output Motore; 00051 Output Resistenza1; 00052 Output Resistenza2; 00053 Output Ventilatore1; 00054 Output Ventilatore2; 00055 00056 Shifter scheda_8relay; //!! pinout defined in library 00057 bool array[16]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; 00058 00059 int main() 00060 { 00061 setup_griglia(); 00062 while(1) { 00063 //acquisisco la pressione sullo schermo per attivare i vari oggetti 00064 ts.ResetTouchData(&TS_State); 00065 ts.GetState(&TS_State); 00066 X = TS_State.touchX[0]; //acquisisco la X 00067 Y = TS_State.touchY[0]; //acquisisco la Y 00068 /* 00069 if (X>=310 && X<360 && Y>=0 && Y<60) { 00070 Lampadina.stato=!Lampadina.stato; 00071 array[0]=Lampadina.stato; 00072 } 00073 if (X>=310 && X<360 && Y>=60 && Y<120) { 00074 Motore.stato=!Motore.stato; 00075 array[1]=Motore.stato; 00076 } 00077 if (X>=310 && X<360 && Y>=120 && Y<180) { 00078 Ventilatore1.stato=!Ventilatore1.stato; 00079 array[2]=Ventilatore1.stato; 00080 } 00081 if (X>=310 && X<360 && Y>=180 && Y<240) { 00082 Ventilatore2.stato=!Ventilatore2.stato; 00083 array[3]=Ventilatore2.stato; 00084 } 00085 if (X>=360 && X<410 && Y>=0 && Y<60) { 00086 Bloccoporta.stato=!Bloccoporta.stato; 00087 array[4]=Bloccoporta.stato; 00088 } 00089 if (X>=360 && X<410 && Y>=60 && Y<120) { 00090 Girarrosto.stato=!Girarrosto.stato; 00091 array[5]=Girarrosto.stato; 00092 } 00093 if (X>=360 && X<410 && Y>=120 && Y<180) { 00094 Resistenza1.stato=!Resistenza1.stato; 00095 array[6]=Resistenza1.stato; 00096 } 00097 if (X>=360 && X<410 && Y>=180 && Y<240) { 00098 Resistenza2.stato=!Resistenza2.stato; 00099 array[7]=Resistenza2.stato; 00100 } 00101 */ 00102 if (X>=20 && X<120 && Y>=20 && Y<80) { //ROAST 00103 00104 } 00105 if (X>=20 && X<120 && Y>=90 && Y<150) { //CLEAN 00106 clean(10000); 00107 } 00108 if (X>=20 && X<120 && Y>=160 && Y<220) { //STOP 00109 00110 } 00111 if (TS_State.touchDetected) wait(0.1); 00112 00113 object_update(); 00114 00115 wait(0.1); 00116 }//close while(1) 00117 }//close main 00118 00119 void clean(int clean_time) 00120 { 00121 Timer timer; 00122 timer.start(); 00123 int previous_time, actual_time; 00124 previous_time = timer.read(); 00125 Lampadina.stato=1; 00126 Resistenza1.stato=1; 00127 Resistenza2.stato=1; 00128 00129 while(1) { 00130 actual_time = timer.read(); 00131 uint8_t text[30]; 00132 //acquisisco la pressione sullo schermo per attivare i vari oggetti 00133 ts.ResetTouchData(&TS_State); 00134 ts.GetState(&TS_State); 00135 int X = TS_State.touchX[0]; //acquisisco la X 00136 int Y = TS_State.touchY[0]; //acquisisco la Y 00137 if (X>=20 && X<120 && Y>=160 && Y<220) { //STOP 00138 stop(); 00139 break; 00140 } 00141 //countdown dal clean_time a zero 00142 if (actual_time-previous_time >=1) { 00143 lcd.SetFont(&Font24); 00144 lcd.SetTextColor(black); 00145 sprintf((char*)text, "%5d", clean_time); 00146 lcd.DisplayStringAt(130,100, (uint8_t *)&text, LEFT_MODE); 00147 previous_time = actual_time; 00148 clean_time--; 00149 } 00150 //se il tempo di clean è finito porto gli output a zero e aggiorno, poi esco dal ciclo 00151 if (clean_time<0) { 00152 stop(); 00153 break; 00154 } 00155 00156 object_update(); 00157 } 00158 } 00159 void stop() 00160 { 00161 //imposto gli output a zero, poi aggiorno 00162 Lampadina.stato=0; 00163 Resistenza1.stato=0; 00164 Resistenza2.stato=0; 00165 00166 object_update(); 00167 } 00168 void object_update() 00169 { //update delle immagini e dello stato delle uscite 00170 //disegno lo stato dei vari oggetti 00171 Lampadina.draw_image (&_acLampadina_acceso[0], &_acLampadina_spento[0], Lampadina.stato, 310, 0); 00172 Motore.draw_image (&_acMotore_acceso[0], &_acMotore_spento[0], Motore.stato, 310, 60); 00173 Ventilatore1.draw_image (&_acVentilatore1_acceso[0], &_acVentilatore1_spento[0], Ventilatore1.stato, 310, 120); 00174 Ventilatore2.draw_image (&_acVentilatore2_acceso[0], &_acVentilatore2_spento[0], Ventilatore2.stato, 310, 180); 00175 Bloccoporta.draw_image (&_acBloccoporta_acceso[0], &_acBloccoporta_spento[0], Bloccoporta.stato, 360, 0); 00176 Girarrosto.draw_image (&_acGirarrosto_acceso[0], &_acGirarrosto_spento[0], Girarrosto.stato, 360, 60); 00177 Resistenza1.draw_image (&_acResistenza1_acceso[0], &_acResistenza1_spento[0], Resistenza1.stato, 360, 120); 00178 Resistenza2.draw_image (&_acResistenza2_acceso[0], &_acResistenza2_spento[0], Resistenza2.stato, 360, 180); 00179 //update uscita 74HC595 00180 for (int i=0; i<16; i++) scheda_8relay.setPin(i,array[i]); 00181 scheda_8relay.write(); 00182 }
Generated on Tue Jul 12 2022 18:42:44 by
