brewco/brewco.c

changeset 443
6b80a37fdf8d
parent 442
1193bd7d460f
child 444
eafb140a1ddd
equal deleted inserted replaced
442:1193bd7d460f 443:6b80a37fdf8d
46 #ifndef HAVE_WIRINGPI_H 46 #ifndef HAVE_WIRINGPI_H
47 pthread_t threads[5]; 47 pthread_t threads[5];
48 #endif 48 #endif
49 49
50 50
51 /*
52 * CGRAM characters
53 */
54 unsigned char degC[8] = { 0b01000, 0b10100, 0b01000, 0b00111, 0b01000, 0b01000, 0b01000, 0b00111 };
55 unsigned char degF[8] = { 0b01000, 0b10100, 0b01000, 0b00111, 0b00100, 0b00110, 0b00100, 0b00100 };
56 unsigned char SP_Symbol[8] = { 0b11100, 0b10000, 0b11100, 0b00111, 0b11101, 0b00111, 0b00100, 0b00100 };
57 unsigned char PumpONOFF[8] = { 0b00000, 0b01110, 0b01010, 0b01110, 0b01000, 0b01000, 0b01000, 0b00000 };
58 unsigned char RevPumpONOFF[8] = { 0b11111, 0b10001, 0b10101, 0b10001, 0b10111, 0b10111, 0b10111, 0b11111 };
59 unsigned char HeatONOFF[8] = { 0b00000, 0b01010, 0b01010, 0b01110, 0b01110, 0b01010, 0b01010, 0b00000 };
60 unsigned char RevHeatONOFF[8] = { 0b11111, 0b10101, 0b10101, 0b10001, 0b10001, 0b10101, 0b10101, 0b11111 };
61 unsigned char Language[8] = { 0b11111, 0b00010, 0b01000, 0b11111, 0b00000, 0b10001, 0b10101, 0b11111 };
62
63
51 void help(void); 64 void help(void);
52 void die(int); 65 void die(int);
53 66
54 67
55 68
91 units_list *unit; 104 units_list *unit;
92 brew_session *brew = NULL; 105 brew_session *brew = NULL;
93 #ifndef HAVE_WIRINGPI_H 106 #ifndef HAVE_WIRINGPI_H
94 long t = 0; 107 long t = 0;
95 #endif 108 #endif
109
110 prompt(101, NULL);
111
112 /*
113 * Define special characters in the display CGRAM
114 */
115 if (Config.tempFormat == 'C')
116 slcdCharDef(slcdHandle, 1, degC);
117 else
118 slcdCharDef(slcdHandle, 1, degF);
119 slcdCharDef(slcdHandle, 2, SP_Symbol);
120 slcdCharDef(slcdHandle, 3, PumpONOFF);
121 slcdCharDef(slcdHandle, 4, RevPumpONOFF);
122 slcdCharDef(slcdHandle, 5, HeatONOFF);
123 slcdCharDef(slcdHandle, 6, RevHeatONOFF);
124 slcdCharDef(slcdHandle, 7, Language);
96 125
97 // if (lockprog((char *)"brewco")) { 126 // if (lockprog((char *)"brewco")) {
98 // syslog(LOG_NOTICE, "Can't lock"); 127 // syslog(LOG_NOTICE, "Can't lock");
99 // return 1; 128 // return 1;
100 // } 129 // }
168 if (unit->mlt_pump) 197 if (unit->mlt_pump)
169 unit->mlt_pump->value = 0; 198 unit->mlt_pump->value = 0;
170 } 199 }
171 } 200 }
172 201
173 prompt(101);
174 if (! Config.units) { 202 if (! Config.units) {
175 /* 203 /*
176 * No brewsystems defined, add the first 204 * No brewsystems defined, add the first
177 */ 205 */
178 prompt(218); /* Add Brewsystem? */ 206 prompt(218, NULL); /* Add Brewsystem? */
179 prompt(407); /* --- --- Ok --- */ 207 prompt(407, NULL); /* --- --- Ok --- */
180 208
181 do { 209 do {
182 key = keywait(); 210 key = keywait();
183 } while (key != KEY_RETURN); 211 } while (key != KEY_RETURN);
184 212
215 243
216 } else { 244 } else {
217 /* 245 /*
218 * Not running. 246 * Not running.
219 */ 247 */
220 prompt(0); 248 prompt(0, NULL);
221 prompt(101); 249 prompt(101, NULL);
222 prompt(401); 250 prompt(300, (char *)"---\001-\002-\003-\004-\005-\006-\007----");
251 prompt(401, NULL);
223 key = keywait(); 252 key = keywait();
224 if (key == KEY_ENTER) 253 if (key == KEY_ENTER)
225 setup(); 254 setup();
226 } 255 }
227 256
231 260
232 syslog(LOG_NOTICE, "Out of loop"); 261 syslog(LOG_NOTICE, "Out of loop");
233 if (debug) 262 if (debug)
234 fprintf(stdout, (char *)"Out of loop\n"); 263 fprintf(stdout, (char *)"Out of loop\n");
235 264
236 prompt(0); 265 prompt(0, NULL);
237 prompt(101); 266 prompt(101, NULL);
238 prompt(302); 267 prompt(302, NULL);
239 268
240 /* 269 /*
241 * Stop units processing in a neat way 270 * Stop units processing in a neat way
242 */ 271 */
243 for (unit = Config.units; unit; unit = unit->next) { 272 for (unit = Config.units; unit; unit = unit->next) {
247 /* 276 /*
248 * Give threads time to cleanup 277 * Give threads time to cleanup
249 */ 278 */
250 usleep(1500000); 279 usleep(1500000);
251 280
252 prompt(0); 281 prompt(0, NULL);
253 // stopLCD(); 282 // stopLCD();
254 if (sock != -1) { 283 if (sock != -1) {
255 if (shutdown(sock, SHUT_RDWR)) { 284 if (shutdown(sock, SHUT_RDWR)) {
256 syslog(LOG_NOTICE, "Can't shutdown socket: %s", strerror(errno)); 285 syslog(LOG_NOTICE, "Can't shutdown socket: %s", strerror(errno));
257 } 286 }

mercurial