roasting
Dependencies: BSP_DISCO_F469NI LCD_DISCO_F469NI Shifter2 TS_DISCO_F469NI max31865 mbed
main.cpp@0:f2c01a50c329, 2018-05-23 (annotated)
- Committer:
- billycorgan123
- Date:
- Wed May 23 09:17:17 2018 +0000
- Revision:
- 0:f2c01a50c329
roasting
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
billycorgan123 | 0:f2c01a50c329 | 1 | #include "mbed.h" |
billycorgan123 | 0:f2c01a50c329 | 2 | #include "TS_DISCO_F469NI.h" |
billycorgan123 | 0:f2c01a50c329 | 3 | #include "LCD_DISCO_F469NI.h" |
billycorgan123 | 0:f2c01a50c329 | 4 | #include "MAX31865.h" |
billycorgan123 | 0:f2c01a50c329 | 5 | |
billycorgan123 | 0:f2c01a50c329 | 6 | #include "AClean_0.c" |
billycorgan123 | 0:f2c01a50c329 | 7 | #include "AClean_1.c" |
billycorgan123 | 0:f2c01a50c329 | 8 | #include "ARoast_0.c" |
billycorgan123 | 0:f2c01a50c329 | 9 | #include "ARoast_1.c" |
billycorgan123 | 0:f2c01a50c329 | 10 | #include "ARoast_2.c" |
billycorgan123 | 0:f2c01a50c329 | 11 | #include "APower.c" |
billycorgan123 | 0:f2c01a50c329 | 12 | |
billycorgan123 | 0:f2c01a50c329 | 13 | #include "APulsanti.c" |
billycorgan123 | 0:f2c01a50c329 | 14 | #include "Porta_aperto.c" |
billycorgan123 | 0:f2c01a50c329 | 15 | #include "Porta_chiuso.c" |
billycorgan123 | 0:f2c01a50c329 | 16 | #include "Giracaffe_acceso.c" |
billycorgan123 | 0:f2c01a50c329 | 17 | #include "Giracaffe_spento.c" |
billycorgan123 | 0:f2c01a50c329 | 18 | #include "Lampadina_acceso.c" |
billycorgan123 | 0:f2c01a50c329 | 19 | #include "Lampadina_spento.c" |
billycorgan123 | 0:f2c01a50c329 | 20 | #include "VTangenziale_acceso.c" |
billycorgan123 | 0:f2c01a50c329 | 21 | #include "VTangenziale_spento.c" |
billycorgan123 | 0:f2c01a50c329 | 22 | #include "VRadiale_acceso.c" |
billycorgan123 | 0:f2c01a50c329 | 23 | #include "VRadiale_spento.c" |
billycorgan123 | 0:f2c01a50c329 | 24 | #include "Resistenza1_acceso.c" |
billycorgan123 | 0:f2c01a50c329 | 25 | #include "Resistenza1_spento.c" |
billycorgan123 | 0:f2c01a50c329 | 26 | #include "Resistenza2_acceso.c" |
billycorgan123 | 0:f2c01a50c329 | 27 | #include "Resistenza2_spento.c" |
billycorgan123 | 0:f2c01a50c329 | 28 | #include "Ventola_acceso.c" |
billycorgan123 | 0:f2c01a50c329 | 29 | #include "Ventola_spento.c" |
billycorgan123 | 0:f2c01a50c329 | 30 | |
billycorgan123 | 0:f2c01a50c329 | 31 | #include "functions.h" |
billycorgan123 | 0:f2c01a50c329 | 32 | #include "colors.c" |
billycorgan123 | 0:f2c01a50c329 | 33 | #include "Output.h" |
billycorgan123 | 0:f2c01a50c329 | 34 | |
billycorgan123 | 0:f2c01a50c329 | 35 | extern void clean(int, float, float); |
billycorgan123 | 0:f2c01a50c329 | 36 | extern void roast(int, int); |
billycorgan123 | 0:f2c01a50c329 | 37 | extern void stop(bool); |
billycorgan123 | 0:f2c01a50c329 | 38 | |
billycorgan123 | 0:f2c01a50c329 | 39 | extern void temperature_update(); |
billycorgan123 | 0:f2c01a50c329 | 40 | |
billycorgan123 | 0:f2c01a50c329 | 41 | bool stato_porta=0; //da cancellare, solo per prova porta |
billycorgan123 | 0:f2c01a50c329 | 42 | bool isPreRoastFinished=0; |
billycorgan123 | 0:f2c01a50c329 | 43 | |
billycorgan123 | 0:f2c01a50c329 | 44 | int main() |
billycorgan123 | 0:f2c01a50c329 | 45 | { |
billycorgan123 | 0:f2c01a50c329 | 46 | setup_griglia(); //setup, parte grafica |
billycorgan123 | 0:f2c01a50c329 | 47 | |
billycorgan123 | 0:f2c01a50c329 | 48 | while(1) { |
billycorgan123 | 0:f2c01a50c329 | 49 | getData(); |
billycorgan123 | 0:f2c01a50c329 | 50 | temperature_update(); |
billycorgan123 | 0:f2c01a50c329 | 51 | //acquisisco la pressione sullo schermo per attivare i vari oggetti |
billycorgan123 | 0:f2c01a50c329 | 52 | ts.GetState(&TS_State); |
billycorgan123 | 0:f2c01a50c329 | 53 | X = TS_State.touchX[0]; //acquisisco la X |
billycorgan123 | 0:f2c01a50c329 | 54 | Y = TS_State.touchY[0]; //acquisisco la Y |
billycorgan123 | 0:f2c01a50c329 | 55 | |
billycorgan123 | 0:f2c01a50c329 | 56 | //------------------------------------------------------------------------------ |
billycorgan123 | 0:f2c01a50c329 | 57 | ///solo per prova |
billycorgan123 | 0:f2c01a50c329 | 58 | if ((TS_State.touchDetected) && (X>=230 && X<300 && Y>=20 && Y<90)) { |
billycorgan123 | 0:f2c01a50c329 | 59 | Lampadina.stato=!Lampadina.stato; |
billycorgan123 | 0:f2c01a50c329 | 60 | object_update(); |
billycorgan123 | 0:f2c01a50c329 | 61 | } |
billycorgan123 | 0:f2c01a50c329 | 62 | if ((TS_State.touchDetected) && (X>=300 && X<370 && Y>=20 && Y<90)) { |
billycorgan123 | 0:f2c01a50c329 | 63 | Resistenza1.stato=!Resistenza1.stato; |
billycorgan123 | 0:f2c01a50c329 | 64 | object_update(); |
billycorgan123 | 0:f2c01a50c329 | 65 | } |
billycorgan123 | 0:f2c01a50c329 | 66 | if ((TS_State.touchDetected) && (X>=370 && X<440 && Y>=20 && Y<90)) { |
billycorgan123 | 0:f2c01a50c329 | 67 | Resistenza2.stato=!Resistenza2.stato; |
billycorgan123 | 0:f2c01a50c329 | 68 | object_update(); |
billycorgan123 | 0:f2c01a50c329 | 69 | } |
billycorgan123 | 0:f2c01a50c329 | 70 | if ((TS_State.touchDetected) && (X>=440 && X<510 && Y>=20 && Y<90)) { |
billycorgan123 | 0:f2c01a50c329 | 71 | Giracaffe.stato=!Giracaffe.stato; |
billycorgan123 | 0:f2c01a50c329 | 72 | object_update(); |
billycorgan123 | 0:f2c01a50c329 | 73 | } |
billycorgan123 | 0:f2c01a50c329 | 74 | if ((TS_State.touchDetected) && (X>=230 && X<300 && Y>=90 && Y<160)) { |
billycorgan123 | 0:f2c01a50c329 | 75 | stato_porta=!stato_porta; |
billycorgan123 | 0:f2c01a50c329 | 76 | (stato_porta==1) ? chiudo_porta() : apro_porta(); |
billycorgan123 | 0:f2c01a50c329 | 77 | } |
billycorgan123 | 0:f2c01a50c329 | 78 | if ((TS_State.touchDetected) && (X>=300 && X<370 && Y>=90 && Y<160)) { |
billycorgan123 | 0:f2c01a50c329 | 79 | VTangenziale.stato=!VTangenziale.stato; |
billycorgan123 | 0:f2c01a50c329 | 80 | object_update(); |
billycorgan123 | 0:f2c01a50c329 | 81 | } |
billycorgan123 | 0:f2c01a50c329 | 82 | if ((TS_State.touchDetected) && (X>=370 && X<440 && Y>=90 && Y<160)) { |
billycorgan123 | 0:f2c01a50c329 | 83 | VRadiale.stato=!VRadiale.stato; |
billycorgan123 | 0:f2c01a50c329 | 84 | object_update(); |
billycorgan123 | 0:f2c01a50c329 | 85 | } |
billycorgan123 | 0:f2c01a50c329 | 86 | if ((TS_State.touchDetected) && (X>=440 && X<510 && Y>=90 && Y<160)) { |
billycorgan123 | 0:f2c01a50c329 | 87 | Ventola.stato=!Ventola.stato; |
billycorgan123 | 0:f2c01a50c329 | 88 | object_update(); |
billycorgan123 | 0:f2c01a50c329 | 89 | } |
billycorgan123 | 0:f2c01a50c329 | 90 | if ((TS_State.touchDetected) && (X>=620 && X<690 && Y>=20 && Y<90)) { |
billycorgan123 | 0:f2c01a50c329 | 91 | Apro_scarico(); |
billycorgan123 | 0:f2c01a50c329 | 92 | } |
billycorgan123 | 0:f2c01a50c329 | 93 | if ((TS_State.touchDetected) && (X>=620 && X<690 && Y>=100 && Y<170)) { |
billycorgan123 | 0:f2c01a50c329 | 94 | Chiudo_scarico(); |
billycorgan123 | 0:f2c01a50c329 | 95 | } |
billycorgan123 | 0:f2c01a50c329 | 96 | //------------------------------------------------------------------------------ |
billycorgan123 | 0:f2c01a50c329 | 97 | //if ROAST pressed |
billycorgan123 | 0:f2c01a50c329 | 98 | if ((TS_State.touchDetected) && (X>=20 && X<140 && Y>=290 && Y<410)) { |
billycorgan123 | 0:f2c01a50c329 | 99 | roast(temperatura_roast,tempo); |
billycorgan123 | 0:f2c01a50c329 | 100 | } |
billycorgan123 | 0:f2c01a50c329 | 101 | //if CLEAN pressed |
billycorgan123 | 0:f2c01a50c329 | 102 | if ((TS_State.touchDetected) && (X>=20 && X<140 && Y>=165 && Y<285)) { |
billycorgan123 | 0:f2c01a50c329 | 103 | clean(clean_time, setpointLOW, setpointHIGH); |
billycorgan123 | 0:f2c01a50c329 | 104 | } |
billycorgan123 | 0:f2c01a50c329 | 105 | //if STOP pressed |
billycorgan123 | 0:f2c01a50c329 | 106 | if ((TS_State.touchDetected) && (X>=20 && X<140 && Y>=20 && Y<140)) { |
billycorgan123 | 0:f2c01a50c329 | 107 | stop(1); |
billycorgan123 | 0:f2c01a50c329 | 108 | } |
billycorgan123 | 0:f2c01a50c329 | 109 | //if TEMPERATURA UPPER pressed |
billycorgan123 | 0:f2c01a50c329 | 110 | if ((TS_State.touchDetected) && (X>=200 && X<260 && Y>=270 && Y<330)) { |
billycorgan123 | 0:f2c01a50c329 | 111 | temperatura = temperatura+5; |
billycorgan123 | 0:f2c01a50c329 | 112 | if (temperatura >300) temperatura =300; |
billycorgan123 | 0:f2c01a50c329 | 113 | } |
billycorgan123 | 0:f2c01a50c329 | 114 | //if TEMPERATURA LOWER pressed |
billycorgan123 | 0:f2c01a50c329 | 115 | if ((TS_State.touchDetected) && (X>=200 && X<260 && Y>=350 && Y<410)) { |
billycorgan123 | 0:f2c01a50c329 | 116 | temperatura = temperatura-5; |
billycorgan123 | 0:f2c01a50c329 | 117 | if (temperatura <150) temperatura =150; |
billycorgan123 | 0:f2c01a50c329 | 118 | } |
billycorgan123 | 0:f2c01a50c329 | 119 | //if TEMPO UPPER pressed |
billycorgan123 | 0:f2c01a50c329 | 120 | if ((TS_State.touchDetected) && (X>=325 && X<385 && Y>=270 && Y<330)) { |
billycorgan123 | 0:f2c01a50c329 | 121 | tempo = tempo+15; |
billycorgan123 | 0:f2c01a50c329 | 122 | if (tempo >3000) tempo =3000; |
billycorgan123 | 0:f2c01a50c329 | 123 | } |
billycorgan123 | 0:f2c01a50c329 | 124 | //if TEMPO LOWER pressed |
billycorgan123 | 0:f2c01a50c329 | 125 | if ((TS_State.touchDetected) && (X>=325 && X<385 && Y>=350 && Y<410)) { |
billycorgan123 | 0:f2c01a50c329 | 126 | tempo = tempo-15; |
billycorgan123 | 0:f2c01a50c329 | 127 | if (tempo <120) tempo =120; |
billycorgan123 | 0:f2c01a50c329 | 128 | } |
billycorgan123 | 0:f2c01a50c329 | 129 | //------------------------------------------------------------------------------ |
billycorgan123 | 0:f2c01a50c329 | 130 | //scrivo minuti e secondi |
billycorgan123 | 0:f2c01a50c329 | 131 | int minuti = tempo/60; |
billycorgan123 | 0:f2c01a50c329 | 132 | int secondi = tempo%60; |
billycorgan123 | 0:f2c01a50c329 | 133 | sprintf((char*)text, "%2d", minuti); |
billycorgan123 | 0:f2c01a50c329 | 134 | lcd.DisplayStringAt(295,LINE(8), (uint8_t *)&text, LEFT_MODE); |
billycorgan123 | 0:f2c01a50c329 | 135 | sprintf((char*)text, "%2d", secondi); |
billycorgan123 | 0:f2c01a50c329 | 136 | lcd.DisplayStringAt(350,LINE(8), (uint8_t *)&text, LEFT_MODE); |
billycorgan123 | 0:f2c01a50c329 | 137 | //scrivo temperatura |
billycorgan123 | 0:f2c01a50c329 | 138 | sprintf((char*)text, "%3d", temperatura); |
billycorgan123 | 0:f2c01a50c329 | 139 | lcd.DisplayStringAt(295,LINE(10), (uint8_t *)&text, LEFT_MODE); |
billycorgan123 | 0:f2c01a50c329 | 140 | //------------------------------------------------------------------------------ |
billycorgan123 | 0:f2c01a50c329 | 141 | object_update(); |
billycorgan123 | 0:f2c01a50c329 | 142 | wait(0.1); |
billycorgan123 | 0:f2c01a50c329 | 143 | }//close while(1) |
billycorgan123 | 0:f2c01a50c329 | 144 | }//close main |
billycorgan123 | 0:f2c01a50c329 | 145 | |
billycorgan123 | 0:f2c01a50c329 | 146 | //CLEAN |
billycorgan123 | 0:f2c01a50c329 | 147 | void clean(int clean_time, float setpointLOW, float setpointHIGH) |
billycorgan123 | 0:f2c01a50c329 | 148 | { |
billycorgan123 | 0:f2c01a50c329 | 149 | disegna_pulsanti(CLEAN_ATTIVO); |
billycorgan123 | 0:f2c01a50c329 | 150 | Lampadina_spento(); |
billycorgan123 | 0:f2c01a50c329 | 151 | Ventola_spento(); |
billycorgan123 | 0:f2c01a50c329 | 152 | VRadiale_spento(); |
billycorgan123 | 0:f2c01a50c329 | 153 | VTangenziale_acceso(); |
billycorgan123 | 0:f2c01a50c329 | 154 | Giracaffe_spento(); |
billycorgan123 | 0:f2c01a50c329 | 155 | Resistenza1_spento(); |
billycorgan123 | 0:f2c01a50c329 | 156 | Resistenza2_spento(); |
billycorgan123 | 0:f2c01a50c329 | 157 | Chiudo_scarico(); //chiudo lo scarico del caffè |
billycorgan123 | 0:f2c01a50c329 | 158 | //non procedo fino a quando la porta non è chiusa e anche il tappo del caffè |
billycorgan123 | 0:f2c01a50c329 | 159 | do { |
billycorgan123 | 0:f2c01a50c329 | 160 | /// |
billycorgan123 | 0:f2c01a50c329 | 161 | } while (!chiudo_porta()); |
billycorgan123 | 0:f2c01a50c329 | 162 | |
billycorgan123 | 0:f2c01a50c329 | 163 | lcd.DisplayStringAt(10, LINE(18), (uint8_t *)"CLEAN ACTIVE ", LEFT_MODE); |
billycorgan123 | 0:f2c01a50c329 | 164 | Timer timer; |
billycorgan123 | 0:f2c01a50c329 | 165 | timer.start(); |
billycorgan123 | 0:f2c01a50c329 | 166 | int previous_time, actual_time; |
billycorgan123 | 0:f2c01a50c329 | 167 | previous_time = timer.read(); |
billycorgan123 | 0:f2c01a50c329 | 168 | VRadiale_acceso(); |
billycorgan123 | 0:f2c01a50c329 | 169 | while(1) { |
billycorgan123 | 0:f2c01a50c329 | 170 | actual_time = timer.read(); |
billycorgan123 | 0:f2c01a50c329 | 171 | uint8_t text[30]; |
billycorgan123 | 0:f2c01a50c329 | 172 | //acquisisco la pressione sullo schermo per vedere se devo stoppare il ciclo mentre faccio il clean |
billycorgan123 | 0:f2c01a50c329 | 173 | ts.GetState(&TS_State); |
billycorgan123 | 0:f2c01a50c329 | 174 | int X = TS_State.touchX[0]; |
billycorgan123 | 0:f2c01a50c329 | 175 | int Y = TS_State.touchY[0]; |
billycorgan123 | 0:f2c01a50c329 | 176 | if ((TS_State.touchDetected) && (X>=20 && X<140 && Y>=235 && Y<335)) { //STOP |
billycorgan123 | 0:f2c01a50c329 | 177 | stop(0); |
billycorgan123 | 0:f2c01a50c329 | 178 | break; |
billycorgan123 | 0:f2c01a50c329 | 179 | } |
billycorgan123 | 0:f2c01a50c329 | 180 | //se la temperatura è sotto il setpoint high continuo a riscaldare, se la temperatura scende sotto il setpoint low ricomincio a riscaldare |
billycorgan123 | 0:f2c01a50c329 | 181 | temperature_update(); |
billycorgan123 | 0:f2c01a50c329 | 182 | if (PT1.temperature( )<=setpointLOW) { |
billycorgan123 | 0:f2c01a50c329 | 183 | Resistenza1_acceso(); |
billycorgan123 | 0:f2c01a50c329 | 184 | Resistenza2_acceso(); |
billycorgan123 | 0:f2c01a50c329 | 185 | } |
billycorgan123 | 0:f2c01a50c329 | 186 | if (PT1.temperature( )>setpointHIGH) { |
billycorgan123 | 0:f2c01a50c329 | 187 | Resistenza1_spento(); |
billycorgan123 | 0:f2c01a50c329 | 188 | Resistenza2_spento(); |
billycorgan123 | 0:f2c01a50c329 | 189 | } |
billycorgan123 | 0:f2c01a50c329 | 190 | //countdown dal clean_time a zero |
billycorgan123 | 0:f2c01a50c329 | 191 | if (actual_time-previous_time >=1) { |
billycorgan123 | 0:f2c01a50c329 | 192 | lcd.SetTextColor(black); |
billycorgan123 | 0:f2c01a50c329 | 193 | sprintf((char*)text, "%5d", clean_time); |
billycorgan123 | 0:f2c01a50c329 | 194 | lcd.DisplayStringAt(210,LINE(18), (uint8_t *)&text, LEFT_MODE); |
billycorgan123 | 0:f2c01a50c329 | 195 | previous_time = actual_time; |
billycorgan123 | 0:f2c01a50c329 | 196 | clean_time--; |
billycorgan123 | 0:f2c01a50c329 | 197 | } |
billycorgan123 | 0:f2c01a50c329 | 198 | //se il tempo di clean è finito avvio la procedura di stop |
billycorgan123 | 0:f2c01a50c329 | 199 | if (clean_time<0) { |
billycorgan123 | 0:f2c01a50c329 | 200 | stop(0); |
billycorgan123 | 0:f2c01a50c329 | 201 | break; |
billycorgan123 | 0:f2c01a50c329 | 202 | } |
billycorgan123 | 0:f2c01a50c329 | 203 | } |
billycorgan123 | 0:f2c01a50c329 | 204 | } |
billycorgan123 | 0:f2c01a50c329 | 205 | |
billycorgan123 | 0:f2c01a50c329 | 206 | //STOP procedura di stop |
billycorgan123 | 0:f2c01a50c329 | 207 | void stop(bool clean_roast) |
billycorgan123 | 0:f2c01a50c329 | 208 | { |
billycorgan123 | 0:f2c01a50c329 | 209 | //stop(0) se era in esecuzione il cleaning |
billycorgan123 | 0:f2c01a50c329 | 210 | //stop(1) se era in esecuzione il roasting |
billycorgan123 | 0:f2c01a50c329 | 211 | lcd.DisplayStringAt(10, LINE(18), (uint8_t *)"STOP ", LEFT_MODE); |
billycorgan123 | 0:f2c01a50c329 | 212 | lcd.DisplayStringAt(260,LINE(18), (uint8_t *)" ", LEFT_MODE); |
billycorgan123 | 0:f2c01a50c329 | 213 | //spengo le resistenze |
billycorgan123 | 0:f2c01a50c329 | 214 | Resistenza1_spento(); |
billycorgan123 | 0:f2c01a50c329 | 215 | Resistenza2_spento(); |
billycorgan123 | 0:f2c01a50c329 | 216 | do { |
billycorgan123 | 0:f2c01a50c329 | 217 | temperature_update(); |
billycorgan123 | 0:f2c01a50c329 | 218 | lcd.SetTextColor(red); |
billycorgan123 | 0:f2c01a50c329 | 219 | lcd.DisplayStringAt(10, LINE(18), (uint8_t *)"TEMPERATURE ABOVE 150", LEFT_MODE); |
billycorgan123 | 0:f2c01a50c329 | 220 | wait (2.0); |
billycorgan123 | 0:f2c01a50c329 | 221 | lcd.DisplayStringAt(10, LINE(18), (uint8_t *)"NOT POSSIBLE TO OPEN DOOR", LEFT_MODE); |
billycorgan123 | 0:f2c01a50c329 | 222 | wait (2.0); |
billycorgan123 | 0:f2c01a50c329 | 223 | lcd.DisplayStringAt(10, LINE(18), (uint8_t *)" ", LEFT_MODE); |
billycorgan123 | 0:f2c01a50c329 | 224 | wait (2.0); |
billycorgan123 | 0:f2c01a50c329 | 225 | lcd.SetTextColor(black); |
billycorgan123 | 0:f2c01a50c329 | 226 | } while (PT1.temperature( )>temp_safe); |
billycorgan123 | 0:f2c01a50c329 | 227 | wait (5.0); |
billycorgan123 | 0:f2c01a50c329 | 228 | |
billycorgan123 | 0:f2c01a50c329 | 229 | //spengo tutto |
billycorgan123 | 0:f2c01a50c329 | 230 | VRadiale_spento(); |
billycorgan123 | 0:f2c01a50c329 | 231 | VTangenziale_spento(); |
billycorgan123 | 0:f2c01a50c329 | 232 | Lampadina_spento(); |
billycorgan123 | 0:f2c01a50c329 | 233 | //scarico caffe |
billycorgan123 | 0:f2c01a50c329 | 234 | if (clean_roast) { |
billycorgan123 | 0:f2c01a50c329 | 235 | Apro_scarico(); |
billycorgan123 | 0:f2c01a50c329 | 236 | Ventola_acceso(); |
billycorgan123 | 0:f2c01a50c329 | 237 | Giracaffe_acceso(); |
billycorgan123 | 0:f2c01a50c329 | 238 | wait (10); |
billycorgan123 | 0:f2c01a50c329 | 239 | Giracaffe_spento(); |
billycorgan123 | 0:f2c01a50c329 | 240 | wait(290); |
billycorgan123 | 0:f2c01a50c329 | 241 | } |
billycorgan123 | 0:f2c01a50c329 | 242 | Ventola_spento(); |
billycorgan123 | 0:f2c01a50c329 | 243 | Giracaffe_spento(); |
billycorgan123 | 0:f2c01a50c329 | 244 | //apertura porta |
billycorgan123 | 0:f2c01a50c329 | 245 | apro_porta(); |
billycorgan123 | 0:f2c01a50c329 | 246 | } |
billycorgan123 | 0:f2c01a50c329 | 247 | |
billycorgan123 | 0:f2c01a50c329 | 248 | //ROAST |
billycorgan123 | 0:f2c01a50c329 | 249 | void roast (int roast_temp, int roast_time) |
billycorgan123 | 0:f2c01a50c329 | 250 | { |
billycorgan123 | 0:f2c01a50c329 | 251 | disegna_pulsanti(ROAST_PRE); |
billycorgan123 | 0:f2c01a50c329 | 252 | Timer timer; |
billycorgan123 | 0:f2c01a50c329 | 253 | int previous_time, actual_time; |
billycorgan123 | 0:f2c01a50c329 | 254 | Lampadina_acceso(); |
billycorgan123 | 0:f2c01a50c329 | 255 | Ventola_spento(); |
billycorgan123 | 0:f2c01a50c329 | 256 | VRadiale_spento(); |
billycorgan123 | 0:f2c01a50c329 | 257 | VTangenziale_acceso(); |
billycorgan123 | 0:f2c01a50c329 | 258 | Giracaffe_spento(); |
billycorgan123 | 0:f2c01a50c329 | 259 | Resistenza1_spento(); |
billycorgan123 | 0:f2c01a50c329 | 260 | Resistenza2_spento(); |
billycorgan123 | 0:f2c01a50c329 | 261 | Chiudo_scarico(); //chiudo lo scarico del caffè |
billycorgan123 | 0:f2c01a50c329 | 262 | //non procedo fino a quando la porta non è chiusa e anche il tappo del caffè |
billycorgan123 | 0:f2c01a50c329 | 263 | do { |
billycorgan123 | 0:f2c01a50c329 | 264 | /// |
billycorgan123 | 0:f2c01a50c329 | 265 | } while (!chiudo_porta()); |
billycorgan123 | 0:f2c01a50c329 | 266 | temperature_update(); |
billycorgan123 | 0:f2c01a50c329 | 267 | if (PT1.temperature( )<=roast_temp-10) { |
billycorgan123 | 0:f2c01a50c329 | 268 | Resistenza1_acceso(); |
billycorgan123 | 0:f2c01a50c329 | 269 | Resistenza2_acceso(); |
billycorgan123 | 0:f2c01a50c329 | 270 | } |
billycorgan123 | 0:f2c01a50c329 | 271 | if (PT1.temperature( )>roast_temp+10) { |
billycorgan123 | 0:f2c01a50c329 | 272 | Resistenza1_spento(); |
billycorgan123 | 0:f2c01a50c329 | 273 | disegna_pulsanti(ROAST_ACTIVE); |
billycorgan123 | 0:f2c01a50c329 | 274 | if (!isPreRoastFinished) { |
billycorgan123 | 0:f2c01a50c329 | 275 | disegna_pulsanti(ROAST_ACTIVE); |
billycorgan123 | 0:f2c01a50c329 | 276 | timer.start(); |
billycorgan123 | 0:f2c01a50c329 | 277 | previous_time = timer.read(); |
billycorgan123 | 0:f2c01a50c329 | 278 | isPreRoastFinished=1; |
billycorgan123 | 0:f2c01a50c329 | 279 | } |
billycorgan123 | 0:f2c01a50c329 | 280 | } |
billycorgan123 | 0:f2c01a50c329 | 281 | |
billycorgan123 | 0:f2c01a50c329 | 282 | } |