Sat, 26 Dec 2015 21:45:44 +0100
The brew state machine is complete, works but is not bugfree
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /***************************************************************************** |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * Copyright (C) 2015 |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * Michiel Broek <mbroek at mbse dot eu> |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * This file is part of the mbsePi-apps |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * This is free software; you can redistribute it and/or modify it |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * under the terms of the GNU General Public License as published by the |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * Free Software Foundation; either version 2, or (at your option) any |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * later version. |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * mbsePi-apps is distributed in the hope that it will be useful, but |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * General Public License for more details. |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | * along with ThermFerm; see the file COPYING. If not, write to the Free |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | *****************************************************************************/ |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
441 | 23 | #include "brewco.h" |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | #include "rdconfig.h" |
441 | 25 | #include "rdsession.h" |
459
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
26 | #include "rdrecipes.h" |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
444
diff
changeset
|
27 | #include "util.h" |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
28 | #include "xutil.h" |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
29 | #include "lcd-pcf8574.h" |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
30 | #include "slcd.h" |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
31 | #include "lock.h" |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
32 | #include "devices.h" |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
33 | #include "keyboard.h" |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
34 | #include "simulator.h" |
442 | 35 | #include "prompt.h" |
36 | #include "setup.h" | |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
37 | #include "logger.h" |
442 | 38 | |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
39 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
40 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
41 | int my_shutdown = FALSE; |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
42 | int mlt_pump_state = 0; |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
43 | |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
44 | double hltInput; /* HLT PID variables */ |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
45 | double hltOutput; |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
46 | double hltSetpoint; |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
47 | double mltInput; /* MLT PID variables */ |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
48 | double mltOutput; |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
49 | double mltSetpoint; |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
50 | |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
51 | extern int debug; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
52 | extern sys_config Config; |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
53 | extern a_recipe *recipes; |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
54 | extern int lcdHandle; |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
55 | extern int slcdHandle; |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
56 | extern int sock; |
456
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
57 | #ifdef USE_SIMULATOR |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
58 | extern int SIM_cooler; |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
59 | #endif |
464
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
60 | char *etcpath = NULL; |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
61 | char *varpath = NULL; |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
62 | |
456
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
63 | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
64 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
65 | #ifndef HAVE_WIRINGPI_H |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
66 | pthread_t threads[5]; |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
67 | #endif |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
68 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
69 | |
451 | 70 | #define MANUAL_NONE 0 |
71 | #define MANUAL_SELHLT 1 | |
72 | #define MANUAL_SELMLT 2 | |
73 | #define MANUAL_HLT 11 | |
74 | #define MANUAL_MLT 12 | |
75 | ||
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
76 | #define PERC_INIT 0 |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
77 | #define PERC_MLT 1 |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
78 | #define PERC_HLT 2 |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
79 | #define PERC_REST 3 |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
80 | |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
81 | |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
82 | int manual = MANUAL_NONE; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
83 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
84 | |
451 | 85 | |
443
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
86 | /* |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
87 | * CGRAM characters |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
88 | */ |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
89 | unsigned char degC[8] = { 0b01000, 0b10100, 0b01000, 0b00111, 0b01000, 0b01000, 0b01000, 0b00111 }; |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
90 | unsigned char degF[8] = { 0b01000, 0b10100, 0b01000, 0b00111, 0b00100, 0b00110, 0b00100, 0b00100 }; |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
91 | unsigned char SP_Symbol[8] = { 0b11100, 0b10000, 0b11100, 0b00111, 0b11101, 0b00111, 0b00100, 0b00100 }; |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
92 | unsigned char PumpONOFF[8] = { 0b00000, 0b01110, 0b01010, 0b01110, 0b01000, 0b01000, 0b01000, 0b00000 }; |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
93 | unsigned char RevPumpONOFF[8] = { 0b11111, 0b10001, 0b10101, 0b10001, 0b10111, 0b10111, 0b10111, 0b11111 }; |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
94 | unsigned char HeatONOFF[8] = { 0b00000, 0b01010, 0b01010, 0b01110, 0b01110, 0b01010, 0b01010, 0b00000 }; |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
95 | unsigned char RevHeatONOFF[8] = { 0b11111, 0b10101, 0b10101, 0b10001, 0b10001, 0b10101, 0b10101, 0b11111 }; |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
96 | unsigned char Language[8] = { 0b11111, 0b00010, 0b01000, 0b11111, 0b00000, 0b10001, 0b10101, 0b11111 }; |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
97 | |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
98 | |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
99 | void help(void); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
100 | void die(int); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
101 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
102 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
103 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
104 | void help(void) |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
105 | { |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
106 | fprintf(stdout, "mbsePi-apps brewco v%s starting\n\n", VERSION); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
107 | fprintf(stdout, "Usage: brewco [-d] [-h]\n"); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
108 | fprintf(stdout, " -d --debug Debug and run in foreground\n"); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
109 | fprintf(stdout, " -h --help Display this help\n"); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
110 | } |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
111 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
112 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
113 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
114 | void die(int onsig) |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
115 | { |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
116 | switch (onsig) { |
456
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
117 | #ifdef USE_SIMULATOR |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
118 | case SIGUSR1: syslog(LOG_NOTICE, "Got SIGUSR1, start cooler"); |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
119 | SIM_cooler = TRUE; |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
120 | return; |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
121 | case SIGUSR2: syslog(LOG_NOTICE, "Got SIGUSR2, stop cooler"); |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
122 | SIM_cooler = FALSE; |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
123 | return; |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
124 | #endif |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
125 | case SIGHUP: syslog(LOG_NOTICE, "Got SIGHUP, shutting down"); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | break; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
127 | case SIGINT: syslog(LOG_NOTICE, "Keyboard interrupt, shutting down"); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
128 | break; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
129 | case SIGTERM: syslog(LOG_NOTICE, "Got SIGTERM, shutting down"); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
130 | break; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
131 | case SIGSEGV: syslog(LOG_NOTICE, "Got SIGSEGV, shutting down"); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
132 | my_shutdown = TRUE; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
133 | exit(SIGSEGV); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
134 | break; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | default: syslog(LOG_NOTICE, "die() on signal %d", onsig); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
136 | } |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
137 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
138 | my_shutdown = TRUE; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
139 | } |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
140 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
142 | |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
143 | void tempstatus(void) |
452
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
144 | { |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
145 | char text[81]; |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
146 | |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
147 | snprintf(text, 8, "%6.2f\001", hltInput); |
452
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
148 | #ifdef HAVE_WIRINGPI_H |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
149 | piLock(LOCK_LCD); |
467 | 150 | lcdPosition(lcdHandle, 1, 1); |
151 | lcdPuts(lcdHandle, text); | |
152 | #endif | |
153 | slcdPosition(slcdHandle, 1, 1); | |
154 | slcdPuts(slcdHandle, text); | |
155 | ||
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
156 | snprintf(text, 8, "%6.2f\001", mltInput); |
467 | 157 | #ifdef HAVE_WIRINGPI_H |
158 | piLock(LOCK_LCD); | |
159 | lcdPosition(lcdHandle, 10, 1); | |
452
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
160 | lcdPuts(lcdHandle, text); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
161 | #endif |
467 | 162 | slcdPosition(slcdHandle, 10, 1); |
163 | slcdPuts(slcdHandle, text); | |
164 | } | |
165 | ||
166 | ||
167 | ||
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
168 | /* |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
169 | * Third line, show setPoints or heater percentage. |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
170 | */ |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
171 | void percstatus(int which) |
467 | 172 | { |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
173 | char text[21]; |
467 | 174 | |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
175 | if (which) |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
176 | snprintf(text, 8, "%6.2f\002", hltSetpoint); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
177 | else |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
178 | snprintf(text, 8, "HLT%3d%%", (int)hltOutput); |
467 | 179 | #ifdef HAVE_WIRINGPI_H |
180 | piLock(LOCK_LCD); | |
181 | lcdPosition(lcdHandle, 1, 2); | |
182 | lcdPuts(lcdHandle, text); | |
183 | #endif | |
184 | slcdPosition(slcdHandle, 1, 2); | |
452
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
185 | slcdPuts(slcdHandle, text); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
186 | |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
187 | if (which) |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
188 | snprintf(text, 8, "%6.2f\002", mltSetpoint); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
189 | else |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
190 | snprintf(text, 8, "MLT%3d%%", (int)mltOutput); |
452
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
191 | #ifdef HAVE_WIRINGPI_H |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
192 | piLock(LOCK_LCD); |
467 | 193 | lcdPosition(lcdHandle, 10, 2); |
452
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
194 | lcdPuts(lcdHandle, text); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
195 | #endif |
467 | 196 | slcdPosition(slcdHandle, 10, 2); |
452
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
197 | slcdPuts(slcdHandle, text); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
198 | } |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
199 | |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
200 | |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
201 | |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
202 | /* |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
203 | * Third line during boil, only MLT status |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
204 | */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
205 | void mltstatus(void) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
206 | { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
207 | char text[21]; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
208 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
209 | snprintf(text, 20, "MLT %3d%% %6.2f\002 ", (int)mltOutput, mltSetpoint); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
210 | #ifdef HAVE_WIRINGPI_H |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
211 | piLock(LOCK_LCD); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
212 | lcdPosition(lcdHandle, 0, 2); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
213 | lcdPuts(lcdHandle, text); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
214 | #endif |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
215 | slcdPosition(slcdHandle, 0, 2); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
216 | slcdPuts(slcdHandle, text); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
217 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
218 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
219 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
220 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
221 | void timestatus(int row, int timeval) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
222 | { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
223 | char text[21]; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
224 | int hours, mins, val = timeval; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
225 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
226 | hours = val / 3600; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
227 | val -= (hours * 3600); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
228 | mins = val / 60; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
229 | val -= (mins * 60); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
230 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
231 | snprintf(text, 20, " %02d:%02d:%02d ", hours, mins, val); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
232 | #ifdef HAVE_WIRINGPI_H |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
233 | piLock(LOCK_LCD); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
234 | lcdPosition(lcdHandle, 0, row); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
235 | lcdPuts(lcdHandle, text); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
236 | #endif |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
237 | slcdPosition(slcdHandle, 0, row); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
238 | slcdPuts(slcdHandle, text); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
239 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
240 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
241 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
242 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
243 | int set_HLT_heater(units_list *unit, int state, double val) |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
244 | { |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
245 | if (strcmp(unit->hlt_heater.uuid, (char *)"00000000-0000-0000-0000-000000000000") == 0) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
246 | return 0; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
247 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
248 | hltSetpoint = val; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
249 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
250 | if (state && (PID_getMode(unit->PID_hlt) == P_MANUAL)) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
251 | hlt_status(1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
252 | PID_setMode(unit->PID_hlt, P_AUTOMATIC); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
253 | return 1; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
254 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
255 | if (! state && (PID_getMode(unit->PID_hlt) == P_AUTOMATIC)) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
256 | hlt_status(0); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
257 | PID_setMode(unit->PID_hlt, P_MANUAL); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
258 | return 1; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
259 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
260 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
261 | return 0; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
262 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
263 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
264 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
265 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
266 | int set_MLT_heater(units_list *unit, int state, double val) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
267 | { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
268 | if (strcmp(unit->mlt_heater.uuid, (char *)"00000000-0000-0000-0000-000000000000") == 0) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
269 | return 0; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
270 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
271 | mltSetpoint = val; |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
272 | |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
273 | if (state && (PID_getMode(unit->PID_mlt) == P_MANUAL)) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
274 | mlt_status(1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
275 | PID_setMode(unit->PID_mlt, P_AUTOMATIC); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
276 | return 1; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
277 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
278 | if (! state && (PID_getMode(unit->PID_mlt) == P_AUTOMATIC)) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
279 | mlt_status(0); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
280 | PID_setMode(unit->PID_mlt, P_MANUAL); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
281 | return 1; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
282 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
283 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
284 | return 0; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
285 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
286 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
287 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
288 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
289 | int set_MLT_pump(units_list *unit, int state) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
290 | { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
291 | if (strcmp(unit->mlt_pump.uuid, (char *)"00000000-0000-0000-0000-000000000000") == 0) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
292 | return 0; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
293 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
294 | if (state && ! mlt_pump_state) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
295 | device_out(unit->mlt_pump.uuid, 1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
296 | mlt_pump_state = 1; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
297 | return 1; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
298 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
299 | if (! state && mlt_pump_state) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
300 | device_out(unit->mlt_pump.uuid, 0); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
301 | mlt_pump_state = 0; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
302 | return 1; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
303 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
304 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
305 | return 0; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
306 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
307 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
308 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
309 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
310 | void automatic_brew(units_list *, brew_session *, a_recipe *, int, int); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
311 | void automatic_brew(units_list *unit, brew_session *brew, a_recipe *recipe, int dosave, int seconds) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
312 | { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
313 | int key, save = dosave, i; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
314 | char data[128]; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
315 | static int mash_fase = MASH_NA, hopstand = 0, last_step = -1, last_fase = -1, oldsec = 75, startdelay = 0; |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
316 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
317 | switch (brew->brewstep) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
318 | case STEP_NA: if (debug) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
319 | fprintf(stdout, "auto: init recipe: %s-%s unit: %s\n", recipe->code, recipe->name, unit->name); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
320 | syslog(LOG_NOTICE, "AUTO: starting new brew, recipe: %s-%s unit: %s", recipe->code, recipe->name, unit->name); |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
321 | brew->brewstep = STEP_BREWINIT; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
322 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
323 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
324 | case STEP_BREWINIT: prompt(103, NULL); /* " AUTOMATIC MODE " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
325 | prompt(207, NULL); /* " Delay start? " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
326 | prompt(300, NULL); /* " " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
327 | prompt(407, NULL); /* "--- --- No Yes " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
328 | if (debug) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
329 | fprintf(stdout, "step brewinit\n"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
330 | key = keywait(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
331 | if (key == KEY_RETURN) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
332 | brew->brewstep = STEP_WATERCHECK; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
333 | startdelay = 0; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
334 | syslog(LOG_NOTICE, "AUTO: brew initialize, direct start selected"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
335 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
336 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
337 | if (key == KEY_ENTER) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
338 | startdelay = 30; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
339 | editInteger(&startdelay, 10, 960, 10, (char *)"Start delay", (char *)"mins"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
340 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
341 | syslog(LOG_NOTICE, "AUTO: brew initialize"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
342 | brew->brewstep = STEP_WATERCHECK; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
343 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
344 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
345 | case STEP_WATERCHECK: if (brew->brewstep != last_step) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
346 | prompt(111, NULL); /* "AUTO --> Mash In " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
347 | prompt(209, NULL); /* " Water Added? " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
348 | prompt(300, NULL); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
349 | prompt(410, NULL); /* " Continue: Yes No " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
350 | last_step = brew->brewstep; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
351 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
352 | slcdDummy(slcdHandle); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
353 | key = keycheck(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
354 | if (key == KEY_RETURN) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
355 | brew->brewstep = STEP_PUMPPRIME; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
356 | syslog(LOG_NOTICE, "AUTO: confirmed water added"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
357 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
358 | if (key == KEY_ENTER) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
359 | syslog(LOG_NOTICE, "AUTO: aborted water added"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
360 | brew->brewstep = STEP_CLEANUP; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
361 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
362 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
363 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
364 | case STEP_PUMPPRIME: if (brew->brewstep != last_step) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
365 | prompt(111, NULL); /* "AUTO --> Mash In " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
366 | prompt(210, NULL); /* " Pump Prime " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
367 | prompt(300, NULL); /* " " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
368 | prompt(400, NULL); /* " " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
369 | last_step = brew->brewstep; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
370 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
371 | brew->brewstep = STEP_WAITSTART; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
372 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
373 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
374 | case STEP_WAITSTART: if (startdelay == 0) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
375 | brew->brewstep = STEP_PREMASH; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
376 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
377 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
378 | if (brew->brewstep != last_step) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
379 | brew->timeout = startdelay * 60; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
380 | prompt(111, NULL); /* "AUTO --> Mash In " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
381 | prompt(212, NULL); /* " To be started in " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
382 | prompt(410, NULL); /* " Continue: Yes No " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
383 | last_step = brew->brewstep; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
384 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
385 | if (oldsec != seconds) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
386 | timestatus(2, brew->timeout); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
387 | brew->timeout--; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
388 | if (brew->timeout <= 0) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
389 | syslog(LOG_NOTICE, "AUTO: delayed start time reached"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
390 | brew->brewstep = STEP_PREMASH; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
391 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
392 | oldsec = seconds; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
393 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
394 | slcdDummy(slcdHandle); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
395 | key = keycheck(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
396 | if (key == KEY_RETURN) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
397 | syslog(LOG_NOTICE, "AUTO: delayed start skipped by user"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
398 | brew->brewstep = STEP_PREMASH; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
399 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
400 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
401 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
402 | case STEP_PREMASH: if (brew->brewstep != last_step) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
403 | prompt(111 + brew->mashstep, NULL); /* "AUTO --> [mashname] " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
404 | prompt(300, NULL); /* " " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
405 | prompt(418, NULL); /* "--- --- Pause --- " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
406 | tempstatus(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
407 | hlt_status(1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
408 | mlt_status(1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
409 | pump_status(unit->pump_premash); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
410 | last_step = brew->brewstep; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
411 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
412 | initlog(brew->name); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
413 | if (set_HLT_heater(unit, 1, 85.0)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
414 | syslog(LOG_NOTICE, "AUTO: premash turn on HLT at %6.2f", hltSetpoint); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
415 | if (set_MLT_heater(unit, 1, recipe->mash[0].setpoint)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
416 | syslog(LOG_NOTICE, "AUTO: premash turn on MLT at %6.2f", mltSetpoint); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
417 | if (set_MLT_pump(unit, unit->pump_premash)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
418 | syslog(LOG_NOTICE, "AUTO: premash turn %s MLT pump", mlt_pump_state ? "on":"off"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
419 | brew->brewstep = STEP_MASHING; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
420 | brew->mashstep = 0; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
421 | mash_fase = MASH_NA; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
422 | save = TRUE; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
423 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
424 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
425 | case STEP_MASHING: if (brew->brewstep != last_step) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
426 | prompt(111 + brew->mashstep, NULL); /* "AUTO --> [mashname] " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
427 | prompt(300, NULL); /* " " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
428 | prompt(418, NULL); /* "--- --- Pause --- " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
429 | tempstatus(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
430 | hlt_status(1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
431 | mlt_status(1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
432 | pump_status(unit->pump_onmash); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
433 | last_step = brew->brewstep; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
434 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
435 | if (set_HLT_heater(unit, 1, 85.0)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
436 | syslog(LOG_NOTICE, "AUTO: mash turn on HLT at %6.2f", hltSetpoint); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
437 | if (set_MLT_heater(unit, 1, recipe->mash[brew->mashstep].setpoint)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
438 | syslog(LOG_NOTICE, "AUTO: mash turn on MLT at %6.2f", mltSetpoint); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
439 | if ((mash_fase != MASH_REST) && set_MLT_pump(unit, unit->pump_onmash)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
440 | syslog(LOG_NOTICE, "AUTO: mash turn %s MLT pump", mlt_pump_state ? "on":"off"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
441 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
442 | switch (mash_fase) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
443 | case MASH_NA: if (recipe->mash[brew->mashstep].skip) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
444 | syslog(LOG_NOTICE, "AUTO: skipping mash step %d", brew->mashstep); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
445 | brew->mashstep++; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
446 | } else { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
447 | mltSetpoint = recipe->mash[brew->mashstep].setpoint; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
448 | brew->timeout = recipe->mash[brew->mashstep].duration * 60; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
449 | if ((brew->mashstep == 0) && ! unit->skip_add) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
450 | mash_fase = MASH_PROMPT; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
451 | } else |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
452 | mash_fase = MASH_HEATING; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
453 | syslog(LOG_NOTICE, "AUTO: mash step %d fase NA, setpoint %6.2f, duration %d", |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
454 | brew->mashstep, mltSetpoint, brew->timeout); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
455 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
456 | if (brew->mashstep == 0) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
457 | brew->starttime = time(NULL); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
458 | save = TRUE; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
459 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
460 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
461 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
462 | case MASH_PROMPT: if (last_fase != mash_fase) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
463 | prompt(111 + brew->mashstep, NULL); /* "AUTO --> [mashname] " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
464 | prompt(219, NULL); /* " Mash added? " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
465 | prompt(300, NULL); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
466 | prompt(410, NULL); /* " Continue: Yes No " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
467 | last_fase = mash_fase; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
468 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
469 | slcdDummy(slcdHandle); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
470 | key = keycheck(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
471 | if (key == KEY_RETURN) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
472 | mash_fase = MASH_HEATING; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
473 | syslog(LOG_NOTICE, "AUTO: confirmed mash added"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
474 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
475 | if (key == KEY_ENTER) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
476 | syslog(LOG_NOTICE, "AUTO: aborted mash added"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
477 | brew->brewstep = STEP_CLEANUP; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
478 | brew->mashstep = 0; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
479 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
480 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
481 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
482 | case MASH_IODINE: if (last_fase != mash_fase) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
483 | prompt(118, NULL); /* "AUTO --> Mash Out " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
484 | prompt(213, NULL); /* " Iodine test " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
485 | timestatus(2, brew->timeout); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
486 | prompt(410, NULL); /* " Continue: Yes No " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
487 | last_fase = mash_fase; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
488 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
489 | if (oldsec != seconds) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
490 | brew->timeout--; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
491 | timestatus(2, brew->timeout); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
492 | if (brew->timeout <= 0) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
493 | syslog(LOG_NOTICE, "AUTO: mash IODINE test timeout"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
494 | mash_fase = MASH_NA; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
495 | brew->mashstep++; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
496 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
497 | oldsec = seconds; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
498 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
499 | slcdDummy(slcdHandle); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
500 | key = keycheck(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
501 | if (key == KEY_RETURN) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
502 | syslog(LOG_NOTICE, "AUTO: mash IODINE test confirmed"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
503 | mash_fase = MASH_NA; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
504 | brew->mashstep++; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
505 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
506 | if (key == KEY_ENTER) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
507 | syslog(LOG_NOTICE, "AUTO: mash IODINE test declined"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
508 | mash_fase = MASH_REST; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
509 | brew->timeout = 600; /* Add 10 more minutes */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
510 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
511 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
512 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
513 | case MASH_HEATING: if (last_fase != mash_fase) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
514 | prompt(111 + brew->mashstep, NULL); /* "AUTO --> [mashname] " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
515 | prompt(200, NULL); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
516 | prompt(300, NULL); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
517 | prompt(418, NULL); /* "--- --- Pause --- " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
518 | hlt_status(1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
519 | mlt_status(1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
520 | pump_status(unit->pump_onmash); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
521 | last_fase = mash_fase; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
522 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
523 | if (oldsec != seconds) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
524 | tempstatus(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
525 | percstatus((seconds / 2) % 4); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
526 | oldsec = seconds; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
527 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
528 | if (mltInput > mltSetpoint) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
529 | syslog(LOG_NOTICE, "AUTO: mash step %d fase HEATING reached %6.2f", brew->mashstep, mltSetpoint); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
530 | mash_fase = MASH_REST; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
531 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
532 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
533 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
534 | case MASH_REST: if (last_fase != mash_fase) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
535 | prompt(111 + brew->mashstep, NULL); /* "AUTO --> [mashname] " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
536 | prompt(300, NULL); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
537 | prompt(418, NULL); /* "--- --- Pause --- " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
538 | hlt_status(1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
539 | mlt_status(1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
540 | pump_status(unit->pump_onmash); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
541 | last_fase = mash_fase; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
542 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
543 | if (oldsec != seconds) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
544 | tempstatus(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
545 | timestatus(2, brew->timeout); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
546 | if (brew->mashstep == 7) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
547 | /* |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
548 | * During mash-out rest, allow the grain to sink |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
549 | */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
550 | if (set_MLT_pump(unit, unit->pump_mashout)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
551 | syslog(LOG_NOTICE, "AUTO: mash-out turn %s MLT pump", mlt_pump_state ? "on":"off"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
552 | } else { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
553 | if (set_MLT_pump(unit, unit->pump_onmash)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
554 | syslog(LOG_NOTICE, "AUTO: mash turn %s MLT pump", mlt_pump_state ? "on":"off"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
555 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
556 | brew->timeout--; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
557 | if (brew->timeout <= 0) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
558 | syslog(LOG_NOTICE, "AUTO: mash step %d fase REST done", brew->mashstep); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
559 | if ((brew->mashstep == 6) && ! unit->skip_iodine) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
560 | mash_fase = MASH_IODINE; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
561 | brew->timeout = unit->iodine_time * 60; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
562 | } else if (brew->mashstep == 7) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
563 | mash_fase = MASH_DONE; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
564 | } else { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
565 | mash_fase = MASH_NA; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
566 | brew->mashstep++; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
567 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
568 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
569 | oldsec = seconds; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
570 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
571 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
572 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
573 | case MASH_DONE: syslog(LOG_NOTICE, "AUTO: mash step %d fase DONE", brew->mashstep); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
574 | if (set_MLT_heater(unit, 1, recipe->mash[7].setpoint)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
575 | syslog(LOG_NOTICE, "AUTO: mash done turn MLT off"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
576 | if (set_MLT_pump(unit, 0)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
577 | syslog(LOG_NOTICE, "AUTO: mash done turn %s MLT pump", mlt_pump_state ? "on":"off"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
578 | brew->mashstep = 0; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
579 | brew->brewstep = STEP_MASHREMOVE; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
580 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
581 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
582 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
583 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
584 | case STEP_MASHREMOVE: if (unit->skip_remove) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
585 | syslog(LOG_NOTICE, "AUTO: skipping Mash remove"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
586 | brew->brewstep = STEP_PREBOIL; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
587 | } else { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
588 | if (brew->brewstep != last_step) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
589 | prompt(118, NULL); /* "AUTO --> Mash Out " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
590 | prompt(220, NULL); /* " Mash Removed? " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
591 | prompt(300, NULL); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
592 | prompt(410, NULL); /* " Continue: Yes No " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
593 | last_step = brew->brewstep; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
594 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
595 | slcdDummy(slcdHandle); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
596 | key = keycheck(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
597 | if (key == KEY_RETURN) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
598 | syslog(LOG_NOTICE, "AUTO: Confirmed Mash removed"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
599 | brew->brewstep = STEP_PREBOIL; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
600 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
601 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
602 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
603 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
604 | case STEP_PREBOIL: if (brew->brewstep != last_step) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
605 | prompt(119, NULL); /* "AUTO --> Boil " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
606 | prompt(200, NULL); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
607 | prompt(300, NULL); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
608 | tempstatus(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
609 | mltstatus(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
610 | prompt(418, NULL); /* "--- --- Pause --- " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
611 | hlt_status(0); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
612 | mlt_status(1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
613 | pump_status(unit->pump_onboil && (mltInput < unit->pump_stop)); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
614 | last_step = brew->brewstep; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
615 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
616 | if (oldsec != seconds) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
617 | tempstatus(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
618 | mltstatus(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
619 | oldsec = seconds; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
620 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
621 | if (set_HLT_heater(unit, 0, 10.0)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
622 | syslog(LOG_NOTICE, "AUTO: preboil turn off HLT"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
623 | if (set_MLT_heater(unit, 1, 100.0)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
624 | syslog(LOG_NOTICE, "AUTO: preboil turn on MLT to boil"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
625 | if (set_MLT_pump(unit, unit->pump_onboil && (mltInput < unit->pump_stop))) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
626 | syslog(LOG_NOTICE, "AUTO: preboil turn %s MLT pump", mlt_pump_state ? "on":"off"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
627 | if (mltInput > 99.2) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
628 | syslog(LOG_NOTICE, "AUTO: reached boil temperature %.2f, start %d minutes boil", mltInput, recipe->boiltime); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
629 | brew->brewstep = STEP_BOILING; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
630 | brew->boiltimer = recipe->boiltime * 60; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
631 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
632 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
633 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
634 | case STEP_BOILING: if (set_HLT_heater(unit, 0, 10.0)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
635 | syslog(LOG_NOTICE, "AUTO: boil turn off HLT"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
636 | if (set_MLT_heater(unit, 1, 100.0)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
637 | syslog(LOG_NOTICE, "AUTO: boil turn on MLT to boil"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
638 | if (set_MLT_pump(unit, unit->pump_onboil && (mltInput < unit->pump_stop))) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
639 | syslog(LOG_NOTICE, "AUTO: boil turn %s MLT pump", mlt_pump_state ? "on":"off"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
640 | if (brew->brewstep != last_step) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
641 | prompt(119, NULL); /* "AUTO --> Boil " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
642 | prompt(200, NULL); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
643 | prompt(300, NULL); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
644 | tempstatus(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
645 | mltstatus(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
646 | prompt(418, NULL); /* "--- --- Pause --- " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
647 | hlt_status(0); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
648 | mlt_status(1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
649 | pump_status(unit->pump_onboil && (mltInput < unit->pump_stop)); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
650 | last_step = brew->brewstep; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
651 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
652 | if (oldsec != seconds) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
653 | tempstatus(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
654 | if ((seconds / 2) % 4) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
655 | timestatus(2, brew->boiltimer); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
656 | } else { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
657 | mltstatus(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
658 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
659 | if (brew->boiltimer >= 0) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
660 | brew->boiltimer--; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
661 | } else { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
662 | brew->brewstep = STEP_BOILDONE; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
663 | syslog(LOG_NOTICE, "AUTO: boil is done"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
664 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
665 | oldsec = seconds; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
666 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
667 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
668 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
669 | case STEP_BOILDONE: if (set_MLT_heater(unit, 0, 10.0)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
670 | syslog(LOG_NOTICE, "AUTO: after boil turn off MLT heater"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
671 | if (set_MLT_pump(unit, 0)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
672 | syslog(LOG_NOTICE, "AUTO: after boil turn %s MLT pump", mlt_pump_state ? "on":"off"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
673 | if (brew->brewstep != last_step) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
674 | prompt(120, NULL); /* "AUTO --> Cooling " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
675 | prompt(214, NULL); /* " START COOLING " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
676 | prompt(300, NULL); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
677 | prompt(410, NULL); /* " Continue: Yes No " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
678 | last_step = brew->brewstep; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
679 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
680 | slcdDummy(slcdHandle); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
681 | key = keycheck(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
682 | if (key == KEY_ENTER) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
683 | brew->brewstep = STEP_CLEANUP; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
684 | syslog(LOG_NOTICE, "AUTO: user skipped cooling"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
685 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
686 | if (key == KEY_RETURN) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
687 | brew->brewstep = STEP_COOLING; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
688 | syslog(LOG_NOTICE, "AUTO: user started cooling"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
689 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
690 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
691 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
692 | case STEP_COOLING: for (i = 0; i < 3; i++) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
693 | if ((recipe->hopstand[i].skip == 0) && (mltInput <= recipe->hopstand[i].max) && (mltInput >= recipe->hopstand[i].min)) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
694 | brew->brewstep = STEP_HOPSTAND; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
695 | hopstand = i; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
696 | syslog(LOG_NOTICE, "AUTO: starting hopstand %d", i+1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
697 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
698 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
699 | if (brew->brewstep == STEP_HOPSTAND) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
700 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
701 | // hot whirlpool start at 85 degrees |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
702 | // cold whirlpool start at 30 degrees |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
703 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
704 | if (brew->brewstep != last_step) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
705 | prompt(120, NULL); /* "AUTO --> Cooling " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
706 | prompt(200, NULL); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
707 | tempstatus(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
708 | prompt(300, NULL); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
709 | prompt(418, NULL); /* "--- --- Pause --- " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
710 | hlt_status(0); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
711 | mlt_status(0); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
712 | pump_status(0); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
713 | last_step = brew->brewstep; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
714 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
715 | if (oldsec != seconds) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
716 | tempstatus(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
717 | oldsec = seconds; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
718 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
719 | if (mltInput <= recipe->coolto) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
720 | syslog(LOG_NOTICE, "AUTO: cool temperture %.2f reached", recipe->coolto); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
721 | brew->brewstep = STEP_CLEANUP; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
722 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
723 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
724 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
725 | case STEP_HOPSTAND: if (brew->brewstep != last_step) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
726 | prompt(122 + hopstand, NULL); /* "AUTO --> Hopstand n " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
727 | tempstatus(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
728 | timestatus(2, brew->timeout); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
729 | prompt(418, NULL); /* "--- --- Pause --- " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
730 | brew->boiltimer = recipe->hopstand[hopstand].duration * 60; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
731 | last_step = brew->brewstep; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
732 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
733 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
734 | if (recipe->hopstand[hopstand].hold) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
735 | if (set_MLT_heater(unit, 1, recipe->hopstand[hopstand].setpoint)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
736 | syslog(LOG_NOTICE, "AUTO: hopstand 1 turn on MLT at %6.2f", mltSetpoint); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
737 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
738 | if (set_MLT_pump(unit, 1)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
739 | syslog(LOG_NOTICE, "AUTO: hopstand 1 turn %s MLT pump", mlt_pump_state ? "on":"off"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
740 | if (oldsec != seconds) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
741 | tempstatus(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
742 | timestatus(2, brew->timeout); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
743 | brew->boiltimer--; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
744 | if (brew->boiltimer <= 0) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
745 | syslog(LOG_NOTICE, "AUTO: hopstand %d done", hopstand+1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
746 | if (set_MLT_heater(unit, 0, 10.0)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
747 | syslog(LOG_NOTICE, "AUTO: hopstand 1 turn off MLT at %6.2f", mltSetpoint); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
748 | brew->brewstep = STEP_COOLING; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
749 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
750 | oldsec = seconds; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
751 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
752 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
753 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
754 | case STEP_WHIRLPOOL: prompt(121, NULL); /* "AUTO --> Whirlpool " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
755 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
756 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
757 | case STEP_CLEANUP: if (brew->brewstep != last_step) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
758 | prompt(101, NULL); /* " Brewco x.x.x " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
759 | prompt(200, NULL); /* " " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
760 | prompt(300, NULL); /* " " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
761 | prompt(400, NULL); /* " " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
762 | last_step = brew->brewstep; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
763 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
764 | syslog(LOG_NOTICE, "AUTO: cleanup"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
765 | if (set_HLT_heater(unit, 0, 10.0)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
766 | syslog(LOG_NOTICE, "AUTO: cleanup turn on HLT at %6.2f", hltSetpoint); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
767 | if (set_MLT_heater(unit, 0, 10.0)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
768 | syslog(LOG_NOTICE, "AUTO: cleanup turn on MLT at %6.2f", mltSetpoint); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
769 | if (set_MLT_pump(unit, 0)) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
770 | syslog(LOG_NOTICE, "AUTO: cleanup turn %s MLT pump", mlt_pump_state ? "on":"off"); |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
771 | brew->brewstep = STEP_BREWDONE; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
772 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
773 | |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
774 | case STEP_BREWDONE: if (brew->brewstep != last_step) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
775 | prompt(101, NULL); /* " Brewco x.x.x " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
776 | prompt(200, NULL); /* " " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
777 | prompt(301, NULL); /* " Finished " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
778 | prompt(408, NULL); /* "--- --- Ok --- " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
779 | last_step = brew->brewstep; |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
780 | } |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
781 | syslog(LOG_NOTICE, "AUTO: brew done"); |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
782 | brew->brewstep = -1; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
783 | brew->endtime = time(NULL); |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
784 | save = TRUE; |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
785 | do { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
786 | key = keywait(); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
787 | } while (key != KEY_RETURN); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
788 | /* |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
789 | * Rewrite the display |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
790 | */ |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
791 | prompt(101, NULL); /* " Brewco x.x.x " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
792 | tempstatus(); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
793 | prompt(300, NULL); /* " " */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
794 | prompt(401, NULL); /* "--- MAN AUTO SETUP" */ |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
795 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
796 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
797 | |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
798 | if (save) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
799 | snprintf(data, 127, "%d,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f", brew->brewstep, |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
800 | hltInput, hltOutput, hltSetpoint, mltInput, mltOutput, mltSetpoint); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
801 | logger(brew->name, data); |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
802 | wrsession(brew); |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
803 | } |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
804 | } |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
805 | |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
806 | |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
807 | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
808 | void manual_prompt(void) |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
809 | { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
810 | switch (manual) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
811 | case MANUAL_SELHLT: prompt(104, NULL); /* " MANUAL MODE " */ |
467 | 812 | prompt(303, NULL); /* " Manual HLT " */ |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
813 | prompt(402, NULL); /* "--- dwn quit ok " */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
814 | break; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
815 | case MANUAL_SELMLT: prompt(104, NULL); /* " MANUAL MODE " */ |
467 | 816 | prompt(304, NULL); /* " Manual MLT " */ |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
817 | prompt(404, NULL); /* " up --- quit ok " */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
818 | break; |
467 | 819 | case MANUAL_HLT: prompt(104, NULL); /* " MANUAL MODE " */ |
820 | prompt(300, NULL); /* " " */ | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
821 | prompt(413, NULL); /* "UP* *DWN heat --- " */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
822 | break; |
467 | 823 | case MANUAL_MLT: prompt(104, NULL); /* " MANUAL MODE " */ |
824 | prompt(300, NULL); /* " " */ | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
825 | prompt(406, NULL); /* "UP* *DWN heat pmp " */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
826 | break; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
827 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
828 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
829 | |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
830 | |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
831 | |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
832 | /* |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
833 | * Manual menu for testing your equipment. |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
834 | */ |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
835 | int manual_menu(units_list *, int); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
836 | int manual_menu(units_list *unit, int seconds) |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
837 | { |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
838 | int key; |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
839 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
840 | switch (manual) { |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
841 | case MANUAL_SELHLT: slcdDummy(slcdHandle); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
842 | key = keycheck(); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
843 | if (key == KEY_DOWN) { |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
844 | manual = MANUAL_SELMLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
845 | manual_prompt(); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
846 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
847 | if (key == KEY_RETURN) { |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
848 | manual = MANUAL_NONE; |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
849 | mlt_pump_state = 0; |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
850 | PID_setMode(unit->PID_mlt, P_MANUAL); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
851 | PID_setMode(unit->PID_hlt, P_MANUAL); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
852 | hlt_status(0); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
853 | mlt_status(0); |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
854 | device_out(unit->mlt_pump.uuid, mlt_pump_state); |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
855 | } |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
856 | if (key == KEY_ENTER) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
857 | // TODO: prompt for water |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
858 | manual = MANUAL_HLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
859 | manual_prompt(); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
860 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
861 | break; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
862 | case MANUAL_SELMLT: slcdDummy(slcdHandle); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
863 | key = keycheck(); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
864 | if (key == KEY_UP) { |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
865 | manual = MANUAL_SELHLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
866 | manual_prompt(); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
867 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
868 | if (key == KEY_RETURN) { |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
869 | manual = MANUAL_NONE; |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
870 | mlt_pump_state = 0; |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
871 | PID_setMode(unit->PID_mlt, P_MANUAL); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
872 | PID_setMode(unit->PID_hlt, P_MANUAL); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
873 | hlt_status(0); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
874 | mlt_status(0); |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
875 | device_out(unit->mlt_pump.uuid, mlt_pump_state); |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
876 | } |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
877 | if (key == KEY_ENTER) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
878 | // TODO: prompt for water |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
879 | manual = MANUAL_MLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
880 | manual_prompt(); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
881 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
882 | break; |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
883 | case MANUAL_HLT: tempstatus(); |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
884 | percstatus((seconds / 2) % 4); |
467 | 885 | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
886 | slcdDummy(slcdHandle); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
887 | key = keycheck(); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
888 | if (key == KEY_RETURN) { |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
889 | if (PID_getMode(unit->PID_hlt) == P_MANUAL) { |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
890 | PID_setMode(unit->PID_hlt, P_AUTOMATIC); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
891 | hlt_status(1); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
892 | } else { |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
893 | PID_setMode(unit->PID_hlt, P_MANUAL); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
894 | hlt_status(0); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
895 | } |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
896 | } |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
897 | if ((key == KEY_DOWN) && (hltSetpoint > 10)) |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
898 | hltSetpoint -= 1.0; |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
899 | if ((key == KEY_UP) && (hltSetpoint < 100)) |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
900 | hltSetpoint += 1.0; |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
901 | if (key == KEY_ESCAPE) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
902 | manual = MANUAL_SELHLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
903 | manual_prompt(); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
904 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
905 | break; |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
906 | case MANUAL_MLT: tempstatus(); |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
907 | percstatus((seconds / 2) % 4); |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
908 | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
909 | slcdDummy(slcdHandle); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
910 | key = keycheck(); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
911 | if (key == KEY_RETURN) { |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
912 | if (PID_getMode(unit->PID_mlt) == P_MANUAL) { |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
913 | PID_setMode(unit->PID_mlt, P_AUTOMATIC); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
914 | mlt_status(1); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
915 | } else { |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
916 | PID_setMode(unit->PID_mlt, P_MANUAL); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
917 | mlt_status(0); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
918 | } |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
919 | } |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
920 | if ((key == KEY_DOWN) && (mltSetpoint > 10)) |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
921 | mltSetpoint -= 1.0; |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
922 | if ((key == KEY_UP) && (mltSetpoint < 100)) |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
923 | mltSetpoint += 1.0; |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
924 | if (key == KEY_ENTER) { |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
925 | if (mlt_pump_state) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
926 | set_MLT_pump(unit, 0); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
927 | else |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
928 | set_MLT_pump(unit, 1); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
929 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
930 | if (key == KEY_ESCAPE) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
931 | manual = MANUAL_SELMLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
932 | manual_prompt(); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
933 | } |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
934 | device_out(unit->mlt_pump.uuid, mlt_pump_state); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
935 | break; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
936 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
937 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
938 | return 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
939 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
940 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
941 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
942 | |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
943 | char *choose_recipe(void); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
944 | char *choose_recipe(void) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
945 | { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
946 | int total, i, key, choice = 1; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
947 | static char uuid[37]; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
948 | a_recipe *recipe; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
949 | char pmpt[81]; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
950 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
951 | strcpy(uuid, (char *)"00000000-0000-0000-0000-000000000000"); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
952 | for (;;) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
953 | total = 0; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
954 | for (recipe = recipes; recipe; recipe = recipe->next) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
955 | total++; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
956 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
957 | if (total == 0) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
958 | return uuid; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
959 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
960 | i = 0; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
961 | for (recipe = recipes; recipe; recipe = recipe->next) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
962 | i++; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
963 | if (i == choice) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
964 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
965 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
966 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
967 | prompt(102, NULL); /* " SETUP MENU " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
968 | prompt(221, NULL); /* " Select Recipe " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
969 | if (total) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
970 | snprintf(pmpt, Config.lcd_cols + 1, "%s %s ", recipe->code, recipe->name); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
971 | prompt(300, pmpt); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
972 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
973 | if (total == 1) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
974 | prompt(405, NULL); /* "--- --- quit ok " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
975 | else if (choice == 1) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
976 | prompt(402, NULL); /* "--- dwn quit ok " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
977 | else if (choice == total) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
978 | prompt(404, NULL); /* " up --- quit ok " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
979 | else |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
980 | prompt(403, NULL); /* " up dwn quit ok " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
981 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
982 | key = keywait(); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
983 | if ((key == KEY_RETURN) || my_shutdown) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
984 | return uuid; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
985 | if (key == KEY_ENTER) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
986 | strcpy(uuid, recipe->uuid); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
987 | return uuid; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
988 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
989 | if ((key == KEY_UP) && (total > 1) && (choice > 1)) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
990 | choice--; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
991 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
992 | if ((key == KEY_DOWN) && (total > 1) && (choice < total)) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
993 | choice++; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
994 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
995 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
996 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
997 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
998 | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
999 | int server(void); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1000 | int server(void) |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1001 | { |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1002 | int rc = 0, run = 1, dosave, key, temp, MLTp, HLTp, percslot, percfase = PERC_INIT; |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1003 | int do_init = TRUE, seconds = 0, minutes = 0; |
441 | 1004 | units_list *unit; |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1005 | a_recipe *recipe = NULL; |
441 | 1006 | brew_session *brew = NULL; |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1007 | #ifndef HAVE_WIRINGPI_H |
441 | 1008 | long t = 0; |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1009 | #endif |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1010 | time_t now, last = (time_t)0; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1011 | long nowmillis, perctimer; |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1012 | struct tm *tm; |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1013 | |
443
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1014 | prompt(101, NULL); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1015 | |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1016 | /* |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1017 | * Define special characters in the display CGRAM |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1018 | */ |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1019 | if (Config.tempFormat == 'C') |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1020 | slcdCharDef(slcdHandle, 1, degC); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1021 | else |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1022 | slcdCharDef(slcdHandle, 1, degF); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1023 | slcdCharDef(slcdHandle, 2, SP_Symbol); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1024 | slcdCharDef(slcdHandle, 3, PumpONOFF); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1025 | slcdCharDef(slcdHandle, 4, RevPumpONOFF); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1026 | slcdCharDef(slcdHandle, 5, HeatONOFF); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1027 | slcdCharDef(slcdHandle, 6, RevHeatONOFF); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1028 | slcdCharDef(slcdHandle, 7, Language); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1029 | |
465 | 1030 | if (lockprog((char *)"brewco")) { |
1031 | syslog(LOG_NOTICE, "Can't lock"); | |
1032 | return 1; | |
1033 | } | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1034 | |
441 | 1035 | if (debug) |
1036 | fprintf(stdout, "Begin server()\n"); | |
1037 | ||
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1038 | if ((rc = devices_detect())) { |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1039 | syslog(LOG_NOTICE, "Detected %d new devices", rc); |
441 | 1040 | if (debug) |
1041 | fprintf(stdout, "Detected %d new devices\n", rc); | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1042 | wrconfig(); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1043 | } |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1044 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1045 | #ifdef HAVE_WIRINGPI_H |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1046 | rc = piThreadCreate(my_devices_loop); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1047 | #else |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1048 | rc = pthread_create(&threads[t], NULL, my_devices_loop, (void *)t ); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1049 | #endif |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1050 | if (rc) { |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1051 | fprintf(stderr, "my_devices_loop thread didn't start rc=%d\n", rc); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1052 | syslog(LOG_NOTICE, "my_devices_loop thread didn't start rc=%d", rc); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1053 | #ifndef HAVE_WIRINGPI_H |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1054 | } else { |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1055 | t++; |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1056 | #endif |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1057 | } |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1058 | |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1059 | #ifdef HAVE_WIRINGPI_H |
441 | 1060 | rc = piThreadCreate(my_keyboard_loop); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1061 | #else |
441 | 1062 | rc = pthread_create(&threads[t], NULL, my_keyboard_loop, (void *)t ); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1063 | #endif |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1064 | if (rc) { |
441 | 1065 | fprintf(stderr, "my_keyboard_loop thread didn't start rc=%d\n", rc); |
1066 | syslog(LOG_NOTICE, "my_keyboard_loop thread didn't start rc=%d", rc); | |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1067 | #ifndef HAVE_WIRINGPI_H |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1068 | } else { |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1069 | t++; |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1070 | #endif |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1071 | } |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1072 | |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1073 | #ifdef USE_SIMULATOR |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1074 | #ifdef HAVE_WIRINGPI_H |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1075 | rc = piThreadCreate(my_simulator_loop); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1076 | #else |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1077 | rc = pthread_create(&threads[t], NULL, my_simulator_loop, (void *)t ); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1078 | #endif |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1079 | if (rc) { |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1080 | fprintf(stderr, "my_simulator_loop thread didn't start rc=%d\n", rc); |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1081 | syslog(LOG_NOTICE, "my_simulator_loop thread didn't start rc=%d", rc); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1082 | #ifndef HAVE_WIRINGPI_H |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1083 | } else { |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1084 | t++; |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1085 | #endif |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1086 | } |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1087 | #endif |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1088 | |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1089 | if (! Config.units) { |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1090 | /* |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1091 | * No brewsystems defined, add the first |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1092 | */ |
443
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1093 | prompt(218, NULL); /* Add Brewsystem? */ |
451 | 1094 | prompt(407, NULL); /* --- --- Ok --- */ |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1095 | |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1096 | do { |
441 | 1097 | key = keywait(); |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1098 | } while (key != KEY_RETURN); |
441 | 1099 | |
1100 | if (key == KEY_RETURN) { | |
1101 | addUnit(1); | |
1102 | } | |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1103 | } |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1104 | |
441 | 1105 | /* |
451 | 1106 | * Initialize units for processing |
1107 | */ | |
1108 | for (unit = Config.units; unit; unit = unit->next) { | |
1109 | if (unit->active) | |
1110 | break; | |
1111 | } | |
1112 | ||
1113 | if (! unit->active) { | |
1114 | fprintf(stdout, "No active units found\n"); | |
1115 | } | |
1116 | ||
1117 | /* | |
1118 | * Safety, turn everything off | |
1119 | */ | |
1120 | if (unit->active) { | |
1121 | if (debug) | |
1122 | fprintf(stdout, "Starting brewsystem %d `%s'\n", unit->number, unit->name); | |
1123 | syslog(LOG_NOTICE, "Starting brewsystem %d `%s'", unit->number, unit->name); | |
1124 | } | |
1125 | ||
1126 | /* | |
441 | 1127 | * During automation there will be a state file: |
1128 | * ~/.brewco/var/brewing.xml | |
1129 | * If this file is present, there has been a crash. | |
1130 | */ | |
1131 | brew = (brew_session *)malloc(sizeof(brew_session)); | |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1132 | rc = rdsession(brew); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1133 | syslog(LOG_NOTICE, "rdsession: rc=%d", rc); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1134 | if (debug) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1135 | fprintf(stdout, "rdsession: rc=%d\n", rc); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1136 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1137 | char *mypath = xstrcpy(etcpath); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1138 | mypath = xstrcat(mypath, (char *)"brewing.xml"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1139 | if (rc == 0) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1140 | if (debug) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1141 | fprintf(stdout, "Active brew session found\n"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1142 | } else if (rc == -1) { |
441 | 1143 | free(brew); |
1144 | brew = NULL; | |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1145 | if (debug) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1146 | fprintf(stdout, "No active brew session found\n"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1147 | } else { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1148 | unlink(mypath); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1149 | free(brew); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1150 | brew = NULL; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1151 | if (debug) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1152 | fprintf(stdout, "Error brew session found\n"); |
441 | 1153 | } |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1154 | free(mypath); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1155 | mypath = NULL; |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1156 | |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1157 | do { |
441 | 1158 | if (my_shutdown) { |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1159 | run = 0; |
467 | 1160 | unit->hlt_heater.value = 0; |
1161 | unit->mlt_heater.value = 0; | |
1162 | unit->mlt_pump.value = 0; | |
1163 | device_out(unit->hlt_heater.uuid, 0); | |
1164 | device_out(unit->mlt_heater.uuid, 0); | |
1165 | device_out(unit->mlt_pump.uuid, 0); | |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
1166 | hlt_status(0); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
1167 | mlt_status(0); |
441 | 1168 | break; |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1169 | } |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1170 | |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1171 | /* |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1172 | * Do we need to initialize this unit? |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1173 | */ |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1174 | if (do_init) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1175 | if (debug) |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1176 | fprintf(stdout, "Initialize brewsystem %d `%s'\n", unit->number, unit->name); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1177 | syslog(LOG_NOTICE, "Initialize brewsystem %d `%s'", unit->number, unit->name); |
467 | 1178 | |
1179 | prompt(0, NULL); | |
1180 | prompt(101, NULL); /* " Brewco x.x.x " */ | |
1181 | prompt(401, NULL); /* "--- MAN AUTO SETUP" */ | |
1182 | ||
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1183 | /* |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1184 | * Turn everything off |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1185 | */ |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1186 | unit->hlt_heater.value = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1187 | unit->mlt_heater.value = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1188 | unit->mlt_pump.value = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1189 | device_out(unit->hlt_heater.uuid, 0); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1190 | device_out(unit->mlt_heater.uuid, 0); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1191 | device_out(unit->mlt_pump.uuid, 0); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1192 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1193 | /* |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1194 | * Initialize PID's |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1195 | */ |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1196 | hltInput = hltSetpoint = mltInput = mltSetpoint = 20.0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1197 | hltOutput = mltOutput = 0; |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1198 | PID_init(unit->PID_hlt, &hltInput, &hltOutput, &hltSetpoint, unit->PID_hlt->dispKp, unit->PID_hlt->dispKi, unit->PID_hlt->dispKd, unit->PID_hlt->Direction); |
467 | 1199 | PID_setOutputLimits(unit->PID_hlt, 0, 100); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1200 | PID_setSampleTime(unit->PID_hlt, unit->PID_hlt->SampleTime); |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1201 | PID_init(unit->PID_mlt, &mltInput, &mltOutput, &mltSetpoint, unit->PID_mlt->dispKp, unit->PID_mlt->dispKi, unit->PID_mlt->dispKd, unit->PID_mlt->Direction); |
467 | 1202 | PID_setOutputLimits(unit->PID_mlt, 0, 100); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1203 | PID_setSampleTime(unit->PID_mlt, unit->PID_mlt->SampleTime); |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
1204 | hlt_status(0); |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
1205 | mlt_status(0); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1206 | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1207 | manual = MANUAL_NONE; |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1208 | |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1209 | do_init = FALSE; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1210 | nowmillis = perctimer = millis(); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1211 | percslot = 0; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1212 | percfase = PERC_INIT; |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1213 | dosave = 0; |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1214 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1215 | if (brew) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1216 | /* |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1217 | * Restore session |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1218 | */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1219 | if (debug) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1220 | fprintf(stdout, "loop_init: restoring brew session\n"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1221 | for (recipe = recipes; recipe; recipe = recipe->next) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1222 | if (strcmp(recipe->uuid, brew->uuid_recipe) == 0) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1223 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1224 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1225 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1226 | if (debug) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1227 | fprintf(stdout, "loop_init: brewstep=%d mashstep=%d recipe=%s\n", brew->brewstep, brew->mashstep, recipe->code); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1228 | } |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1229 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
1230 | |
451 | 1231 | /* run_pause code here */ |
1232 | ||
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1233 | /* |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1234 | * Update PID's, even if they are off. Both PID's will do |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1235 | * the scheduling by themselves. |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1236 | */ |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1237 | rc = PID_compute(unit->PID_hlt); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1238 | rc = PID_compute(unit->PID_mlt); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1239 | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1240 | /* |
467 | 1241 | * This is the serial heaters schedule loop. The total |
1242 | * loop time is 5 seconds, heating is 0..100% so we | |
1243 | * have 5 mSeconds timeslots. The MLT has priority over | |
1244 | * the HLT heater, so the HLT heater can get too little | |
1245 | * power. TODO: simultaneous use must be implemented. | |
1246 | * In sequentiel mode, the total drawn power is the same | |
1247 | * as the power used by the largest heater element. | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1248 | */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1249 | nowmillis = millis(); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1250 | if (nowmillis > (perctimer + 50)) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1251 | percslot++; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1252 | if (percfase == PERC_INIT) { |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
1253 | HLTp = (int)hltOutput; |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
1254 | MLTp = (int)mltOutput; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1255 | if ((MLTp + HLTp) > 100) |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1256 | HLTp = 100 - MLTp; /* The HLT has lower priority */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1257 | if (MLTp) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1258 | percfase = PERC_MLT; |
467 | 1259 | device_out(unit->hlt_heater.uuid, 0); |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1260 | device_out(unit->mlt_heater.uuid, 1); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1261 | } else if (HLTp) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1262 | percfase = PERC_HLT; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1263 | device_out(unit->hlt_heater.uuid, 1); |
467 | 1264 | device_out(unit->mlt_heater.uuid, 0); |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1265 | } else { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1266 | percfase = PERC_REST; |
467 | 1267 | device_out(unit->hlt_heater.uuid, 0); |
1268 | device_out(unit->mlt_heater.uuid, 0); | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1269 | } |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1270 | // if (debug) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1271 | // fprintf(stdout, " perslot=%d MLT=%d%% HLT=%d%% fase=%d\n", percslot, MLTp, HLTp, percfase); |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1272 | } else if (percfase == PERC_MLT) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1273 | if (percslot > MLTp) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1274 | device_out(unit->mlt_heater.uuid, 0); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1275 | if (HLTp) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1276 | device_out(unit->hlt_heater.uuid, 1); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1277 | percfase = PERC_HLT; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1278 | } else { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1279 | percfase = PERC_REST; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1280 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1281 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1282 | } else if (percfase == PERC_HLT) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1283 | if (percslot > (MLTp + HLTp)) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1284 | device_out(unit->hlt_heater.uuid, 0); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1285 | percfase = PERC_REST; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1286 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1287 | } |
467 | 1288 | if (percslot == 100) { /* End of the loop, start over */ |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1289 | percslot = 0; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1290 | percfase = PERC_INIT; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1291 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1292 | perctimer = nowmillis; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1293 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1294 | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1295 | now = time(NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1296 | if (now != last) { |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1297 | /* |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1298 | * Each second |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1299 | */ |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1300 | last = now; |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1301 | seconds++; |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1302 | |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1303 | if (seconds > 59) { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1304 | seconds = 0; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1305 | minutes++; |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1306 | dosave = 1; |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1307 | } |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1308 | |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1309 | rc = device_in(unit->hlt_sensor.uuid, &temp); |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1310 | if (rc == DEVPRESENT_YES) { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1311 | hltInput = temp / 1000.0; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1312 | unit->hlt_sensor.state = 0; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1313 | } else if (rc == DEVPRESENT_ERROR) { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1314 | unit->hlt_sensor.state = 1; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1315 | } else { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1316 | unit->hlt_sensor.state = 2; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1317 | } |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1318 | rc = device_in(unit->mlt_sensor.uuid, &temp); |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1319 | if (rc == DEVPRESENT_YES) { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1320 | mltInput = temp / 1000.0; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1321 | unit->mlt_sensor.state = 0; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1322 | } else if (rc == DEVPRESENT_ERROR) { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1323 | unit->mlt_sensor.state = 1; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1324 | } else { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1325 | unit->mlt_sensor.state = 2; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1326 | } |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
1327 | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1328 | if (debug && ((seconds % 10) == 1)) { |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
1329 | fprintf(stdout, "MLT: In=%.2lf Out=%.2lf Set=%.2lf Stat=%d HLT: In=%.2lf Out=%.2lf Set=%.2lf Stat=%d\n", |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
1330 | mltInput, mltOutput, mltSetpoint, PID_getMode(unit->PID_mlt), |
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
1331 | hltInput, hltOutput, hltSetpoint, PID_getMode(unit->PID_hlt)); |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1332 | } |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1333 | |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1334 | } |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1335 | |
441 | 1336 | if (brew) { |
1337 | /* | |
1338 | * Automate mode | |
1339 | */ | |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1340 | automatic_brew(unit, brew, recipe, dosave, seconds); |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1341 | dosave = 0; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1342 | if (brew->brewstep == -1) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1343 | /* |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1344 | * Save session and move it |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1345 | */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1346 | wrsession(brew); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1347 | char *fpath, *tpath; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1348 | fpath = xstrcpy(etcpath); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1349 | fpath = xstrcat(fpath, (char *)"brewing.xml"); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1350 | tpath = xstrcpy(varpath); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1351 | tpath = xstrcat(tpath, (char *)"old/brewing.xml."); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1352 | mkdirs(tpath, 0755); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1353 | tpath = xstrcat(tpath, brew->name); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1354 | if (debug) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1355 | fprintf(stdout, "auto: saving as %s\n", tpath); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1356 | file_cp(fpath, tpath); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1357 | unlink(fpath); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1358 | free(fpath); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1359 | free(tpath); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1360 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1361 | /* |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1362 | * Free memory, session is over. |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1363 | */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1364 | if (brew->name) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1365 | free(brew->name); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1366 | if (brew->uuid_recipe) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1367 | free(brew->uuid_recipe); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1368 | if (brew->uuid_unit) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1369 | free(brew->uuid_unit); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1370 | free(brew); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1371 | brew = NULL; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1372 | } |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1373 | |
451 | 1374 | } else if (manual != MANUAL_NONE) { |
1375 | /* | |
1376 | * Manual mode | |
1377 | */ | |
471
1564b60558b1
Manual mode now uses the PID's. The display shows heating percentage and the setpoints alternated very 2 seconds.
Michiel Broek <mbroek@mbse.eu>
parents:
468
diff
changeset
|
1378 | manual_menu(unit, seconds); |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1379 | if (manual == MANUAL_NONE) { |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1380 | /* |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1381 | * Rewrite the display |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1382 | */ |
467 | 1383 | prompt(101, NULL); /* " Brewco x.x.x " */ |
1384 | prompt(300, NULL); /* " " */ | |
1385 | prompt(401, NULL); /* "--- MAN AUTO SETUP" */ | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1386 | } |
441 | 1387 | } else { |
1388 | /* | |
1389 | * Not running. | |
1390 | */ | |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
1391 | tempstatus(); |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1392 | key = keycheck(); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1393 | if (key == KEY_ENTER) { |
442 | 1394 | setup(); |
467 | 1395 | prompt(101, NULL); /* " Brewco x.x.x " */ |
1396 | prompt(401, NULL); /* "--- MAN AUTO SETUP" */ | |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1397 | } else if (key == KEY_RETURN && ! brew) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1398 | int i, isOk = TRUE; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1399 | char message[41]; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1400 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1401 | tm = localtime(&now); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1402 | snprintf(message, 40, "%04d%02d%02d-%02d%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1403 | brew = (brew_session *)malloc(sizeof(brew_session)); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1404 | brew->uuid_recipe = xstrcpy(choose_recipe()); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1405 | brew->uuid_unit = xstrcpy(unit->uuid); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1406 | brew->name = xstrcpy(message); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1407 | brew->brewstep = STEP_NA; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1408 | brew->mashstep = MASH_NA; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1409 | brew->timeout = brew->boiltimer = 0; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1410 | brew->starttime = brew->endtime = (time_t)0; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1411 | /* |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1412 | * Now check if everything is sane |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1413 | */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1414 | if (strcmp(brew->uuid_recipe, (char *)"00000000-0000-0000-0000-000000000000") == 0) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1415 | isOk = FALSE; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1416 | snprintf(message, Config.lcd_cols + 1, " No recipe selected "); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1417 | if (debug) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1418 | fprintf(stdout, "brew init: No recipe selected\n"); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1419 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1420 | if (isOk) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1421 | isOk = FALSE; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1422 | for (recipe = recipes; recipe; recipe = recipe->next) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1423 | if (strcmp(recipe->uuid, brew->uuid_recipe) == 0) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1424 | isOk = TRUE; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1425 | if (! recipe->boiltime) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1426 | isOk = FALSE; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1427 | for (i = 0; i < 8; i++) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1428 | if (! recipe->mash[i].skip && ! recipe->mash[i].setpoint) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1429 | isOk = FALSE; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1430 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1431 | for (i = 0; i < 3; i++) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1432 | if (! recipe->hopstand[i].skip && recipe->hopstand[i].hold && (recipe->hopstand[i].setpoint == 0)) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1433 | isOk = FALSE; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1434 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1435 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1436 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1437 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1438 | if (isOk == FALSE) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1439 | snprintf(message, Config.lcd_cols + 1, " Recipe error "); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1440 | if (debug) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1441 | fprintf(stdout, "brew init: recipe error\n"); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1442 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1443 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1444 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1445 | if (debug) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1446 | fprintf(stdout, "init brew: %s\n", isOk ? (char *)"Ok":(char *)"Error"); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1447 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1448 | if (isOk) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1449 | wrsession(brew); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1450 | } else { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1451 | prompt(300, message); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1452 | prompt(408, NULL); /* "--- --- Ok --- " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1453 | key = keywait(); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1454 | if (brew->name) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1455 | free(brew->name); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1456 | if (brew->uuid_recipe) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1457 | free(brew->uuid_recipe); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1458 | if (brew->uuid_unit) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1459 | free(brew->uuid_unit); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1460 | free(brew); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1461 | brew = NULL; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1462 | /* |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1463 | * Rewrite the display |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1464 | */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1465 | prompt(101, NULL); /* " Brewco x.x.x " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1466 | prompt(300, NULL); /* " " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1467 | prompt(401, NULL); /* "--- MAN AUTO SETUP" */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1468 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
1469 | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1470 | } else if (key == KEY_DOWN) { |
451 | 1471 | manual = MANUAL_SELHLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
1472 | manual_prompt(); |
451 | 1473 | } |
441 | 1474 | } |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1475 | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
1476 | usleep(5000); /* 5 mSec */ |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1477 | |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1478 | } while (run); |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1479 | |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1480 | syslog(LOG_NOTICE, "Out of loop"); |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1481 | if (debug) |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1482 | fprintf(stdout, (char *)"Out of loop\n"); |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
1483 | |
443
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1484 | prompt(0, NULL); |
467 | 1485 | prompt(101, NULL); /* " Brewco x.x.x " */ |
1486 | prompt(302, NULL); /* " Shutting down " */ | |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1487 | |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1488 | /* |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1489 | * Give threads time to cleanup |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1490 | */ |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1491 | usleep(1500000); |
443
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
1492 | prompt(0, NULL); |
468
e8203e891b0e
Removed LCD auto dim mode, the display is allways on if this program runs.
Michiel Broek <mbroek@mbse.eu>
parents:
467
diff
changeset
|
1493 | setBacklight(0); |
e8203e891b0e
Removed LCD auto dim mode, the display is allways on if this program runs.
Michiel Broek <mbroek@mbse.eu>
parents:
467
diff
changeset
|
1494 | |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1495 | if (sock != -1) { |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1496 | if (shutdown(sock, SHUT_RDWR)) { |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1497 | syslog(LOG_NOTICE, "Can't shutdown socket: %s", strerror(errno)); |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1498 | } |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1499 | sock = -1; |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1500 | } |
467 | 1501 | |
459
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
1502 | wrrecipes(); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1503 | wrconfig(); |
465 | 1504 | ulockprog((char *)"brewco"); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
1505 | return 0; |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1506 | } |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1507 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1508 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1509 | |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1510 | int main(int argc, char *argv[]) |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1511 | { |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1512 | int rc = 0, c, i; |
464
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
1513 | char *homepath = NULL; |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1514 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1515 | while (1) { |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1516 | int option_index = 0; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1517 | static struct option long_options[] = { |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1518 | {"debug", 0, 0, 'c'}, |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1519 | {"help", 0, 0, 'h'}, |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1520 | {0, 0, 0, 0} |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1521 | }; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1522 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1523 | c = getopt_long(argc, argv, "dh", long_options, &option_index); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1524 | if (c == -1) |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1525 | break; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1526 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1527 | switch (c) { |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1528 | case 'd': debug = TRUE; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1529 | break; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1530 | case 'h': help(); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1531 | return 1; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1532 | } |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1533 | } |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1534 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1535 | openlog("brewco", LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_USER); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1536 | syslog(LOG_NOTICE, "mbsePi-apps brewco v%s starting", VERSION); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1537 | if (debug) |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1538 | fprintf(stdout, "mbsePi-apps brewco v%s starting\n", VERSION); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1539 | |
464
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
1540 | /* |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
1541 | * Set home directory path |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
1542 | */ |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
1543 | if (getenv((char *)"USER") == NULL) { |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
1544 | homepath = xstrcpy((char *)"/root"); |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
1545 | } else { |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
1546 | homepath = xstrcpy(getenv((char *)"HOME")); |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
1547 | } |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
1548 | varpath = xstrcpy(homepath); |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
1549 | varpath = xstrcat(varpath, (char *)"/.brewco/var/"); |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
1550 | etcpath = xstrcpy(homepath); |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
1551 | etcpath = xstrcat(etcpath, (char *)"/.brewco/etc/"); |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
1552 | mkdirs(varpath, 0755); |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
1553 | mkdirs(etcpath, 0755); |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
1554 | |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1555 | if (rdconfig()) { |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1556 | fprintf(stderr, "Error reading configuration\n"); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1557 | syslog(LOG_NOTICE, "Error reading configuration: halted"); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1558 | return 1; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1559 | } |
441 | 1560 | if (debug) |
1561 | fprintf(stdout, "configuration loaded\n"); | |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1562 | |
459
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
1563 | if (rdrecipes()) { |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
1564 | fprintf(stderr, "Error reading recipes\n"); |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
1565 | syslog(LOG_NOTICE, "Error reading recipes: halted"); |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
1566 | return 1; |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
1567 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
1568 | if (debug) |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
1569 | fprintf(stdout, "recipes loaded\n"); |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
1570 | |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1571 | /* |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1572 | * Catch all the signals we can, and ignore the rest. Note that SIGKILL can't be ignored |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1573 | * but that's live. This daemon should only be stopped by SIGTERM. |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1574 | * Don't catch SIGCHLD. |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1575 | */ |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1576 | for (i = 0; i < NSIG; i++) { |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1577 | if ((i != SIGCHLD) && (i != SIGKILL) && (i != SIGSTOP)) |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1578 | signal(i, (void (*))die); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1579 | } |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1580 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1581 | #ifdef HAVE_WIRINGPI_H |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1582 | if (wiringPiSetup () ) |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1583 | return 1; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1584 | #endif |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1585 | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1586 | if ((rc = initLCD (Config.lcd_cols, Config.lcd_rows))) { |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1587 | fprintf(stderr, "Cannot initialize LCD display, rc=%d\n", rc); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1588 | return 1; |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1589 | } |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1590 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1591 | rc = server(); |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1592 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1593 | syslog(LOG_NOTICE, "Finished, rc=%d", rc); |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1594 | if (debug) |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1595 | fprintf(stdout, "Finished, rc=%d\n", rc); |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1596 | return rc; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1597 | } |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1598 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1599 |