Tue, 22 Dec 2015 21:07:14 +0100
Added initial part of the brew automation.
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" | |
37 | ||
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
|
38 | |
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 | int my_shutdown = FALSE; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
41 | int man_mlt_pump = 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
|
42 | |
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 | 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
|
44 | 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
|
45 | 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
|
46 | 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
|
47 | 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
|
48 | 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
|
49 | |
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
|
50 | 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
|
51 | extern sys_config Config; |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
52 | 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
|
53 | extern int lcdHandle; |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
54 | extern int slcdHandle; |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
55 | 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
|
56 | #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
|
57 | 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
|
58 | #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
|
59 | 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
|
60 | 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
|
61 | |
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
|
62 | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
63 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
64 | #ifndef HAVE_WIRINGPI_H |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
65 | 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
|
66 | #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
|
67 | |
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 | |
451 | 69 | #define MANUAL_NONE 0 |
70 | #define MANUAL_SELHLT 1 | |
71 | #define MANUAL_SELMLT 2 | |
72 | #define MANUAL_HLT 11 | |
73 | #define MANUAL_MLT 12 | |
74 | ||
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
75 | #define PERC_INIT 0 |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
76 | #define PERC_MLT 1 |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
77 | #define PERC_HLT 2 |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
78 | #define PERC_REST 3 |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
79 | |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
80 | |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
81 | int manual = MANUAL_NONE; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
82 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
83 | |
451 | 84 | |
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
|
85 | /* |
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 | * 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
|
87 | */ |
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 | 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
|
89 | 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
|
90 | 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
|
91 | 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
|
92 | 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
|
93 | 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
|
94 | 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
|
95 | 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
|
96 | |
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 | |
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
|
98 | 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
|
99 | 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
|
100 | |
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 | 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
|
104 | { |
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 | 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
|
106 | 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
|
107 | 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
|
108 | 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
|
109 | } |
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 | 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
|
114 | { |
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 | 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
|
116 | #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
|
117 | 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
|
118 | 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
|
119 | 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
|
120 | 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
|
121 | 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
|
122 | 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
|
123 | #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
|
124 | 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
|
125 | 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
|
126 | 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
|
127 | 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
|
128 | 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
|
129 | 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
|
130 | 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
|
131 | 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
|
132 | 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
|
133 | 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
|
134 | 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
|
135 | } |
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 | 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
|
138 | } |
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 | |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
142 | void tempstatus(double hlttemp, double mlttemp) |
452
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
143 | { |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
144 | char text[81]; |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
145 | |
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
|
146 | snprintf(text, 8, "%6.2f\001", hltInput); |
452
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
147 | #ifdef HAVE_WIRINGPI_H |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
148 | piLock(LOCK_LCD); |
467 | 149 | lcdPosition(lcdHandle, 1, 1); |
150 | lcdPuts(lcdHandle, text); | |
151 | #endif | |
152 | slcdPosition(slcdHandle, 1, 1); | |
153 | slcdPuts(slcdHandle, text); | |
154 | ||
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
|
155 | snprintf(text, 8, "%6.2f\001", mltInput); |
467 | 156 | #ifdef HAVE_WIRINGPI_H |
157 | piLock(LOCK_LCD); | |
158 | lcdPosition(lcdHandle, 10, 1); | |
452
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
159 | lcdPuts(lcdHandle, text); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
160 | #endif |
467 | 161 | slcdPosition(slcdHandle, 10, 1); |
162 | slcdPuts(slcdHandle, text); | |
163 | } | |
164 | ||
165 | ||
166 | ||
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
|
167 | /* |
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 | * 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
|
169 | */ |
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 | void percstatus(int which) |
467 | 171 | { |
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
|
172 | char text[21]; |
467 | 173 | |
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
|
174 | 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
|
175 | 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
|
176 | 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
|
177 | snprintf(text, 8, "HLT%3d%%", (int)hltOutput); |
467 | 178 | #ifdef HAVE_WIRINGPI_H |
179 | piLock(LOCK_LCD); | |
180 | lcdPosition(lcdHandle, 1, 2); | |
181 | lcdPuts(lcdHandle, text); | |
182 | #endif | |
183 | slcdPosition(slcdHandle, 1, 2); | |
452
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
184 | slcdPuts(slcdHandle, text); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
185 | |
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
|
186 | 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
|
187 | 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
|
188 | 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
|
189 | snprintf(text, 8, "MLT%3d%%", (int)mltOutput); |
452
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
190 | #ifdef HAVE_WIRINGPI_H |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
191 | piLock(LOCK_LCD); |
467 | 192 | lcdPosition(lcdHandle, 10, 2); |
452
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
193 | lcdPuts(lcdHandle, text); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
194 | #endif |
467 | 195 | slcdPosition(slcdHandle, 10, 2); |
452
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
196 | slcdPuts(slcdHandle, text); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
197 | } |
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 | |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
201 | void automatic_brew(units_list *, brew_session *, a_recipe *, int); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
202 | void automatic_brew(units_list *unit, brew_session *brew, a_recipe *recipe, int dosave) |
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
|
203 | { |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
204 | int key, save = dosave; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
205 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
206 | // if (debug) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
207 | // fprintf(stdout, "auto: step %d\n", brew->brewstep); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
208 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
209 | switch (brew->brewstep) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
210 | case STEP_NA: if (debug) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
211 | 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
|
212 | syslog(LOG_NOTICE, "AUTO: starting new brew, recipe: %s-%s unit: %s", recipe->code, recipe->name, unit->name); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
213 | brew->brewstep = STEP_BREWDONE; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
214 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
215 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
216 | case STEP_BREWINIT: |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
217 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
218 | case STEP_WATERCHECK: prompt(111, NULL); /* "AUTO --> Mash In " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
219 | prompt(209, NULL); /* " Water Added? " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
220 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
221 | case STEP_PUMPPRIME: prompt(111, NULL); /* "AUTO --> Mash In " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
222 | prompt(210, NULL); /* " Pump Prime " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
223 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
224 | case STEP_WAITSTART: prompt(111, NULL); /* "AUTO --> Mash In " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
225 | prompt(212, NULL); /* " To be started in " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
226 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
227 | case STEP_PREMASH: prompt(111, NULL); /* "AUTO --> Mash In " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
228 | /* Heatup until strike temp reached */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
229 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
230 | case STEP_MASHING: switch (brew->mashstep) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
231 | case 0: prompt(111, NULL); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
232 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
233 | case 1: prompt(112, NULL); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
234 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
235 | case 2: prompt(113, NULL); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
236 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
237 | case 3: prompt(114, NULL); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
238 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
239 | case 4: prompt(115, NULL); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
240 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
241 | case 5: prompt(116, NULL); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
242 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
243 | case 6: prompt(117, NULL); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
244 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
245 | case 7: prompt(118, NULL); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
246 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
247 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
248 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
249 | case STEP_IODINE: prompt(118, NULL); /* "AUTO --> Mash Out " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
250 | prompt(213, NULL); /* " Iodine test " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
251 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
252 | case STEP_MASHREMOVE: prompt(118, NULL); /* "AUTO --> Mash Out " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
253 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
254 | case STEP_PREBOIL: |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
255 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
256 | case STEP_BOILING: prompt(119, NULL); /* "AUTO --> Boil " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
257 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
258 | case STEP_BOILDONE: |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
259 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
260 | case STEP_HOPSTAND1: |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
261 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
262 | case STEP_COOLING1: prompt(120, NULL); /* "AUTO --> Cooling " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
263 | prompt(214, NULL); /* " START COOLING " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
264 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
265 | case STEP_WHIRLPOOL1: prompt(121, NULL); /* "AUTO --> Whirlpool " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
266 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
267 | case STEP_COOLING2: prompt(120, NULL); /* "AUTO --> Cooling " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
268 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
269 | case STEP_HOPSTAND2: |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
270 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
271 | case STEP_COOLING3: prompt(120, NULL); /* "AUTO --> Cooling " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
272 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
273 | case STEP_HOPSTAND3: |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
274 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
275 | case STEP_COOLING: prompt(120, NULL); /* "AUTO --> Cooling " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
276 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
277 | case STEP_WHIRLPOOL: prompt(121, NULL); /* "AUTO --> Whirlpool " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
278 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
279 | case STEP_CLEANUP: |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
280 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
281 | case STEP_BREWDONE: syslog(LOG_NOTICE, "AUTO: brew done"); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
282 | brew->brewstep = -1; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
283 | brew->endtime = time(NULL); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
284 | prompt(101, NULL); /* " Brewco x.x.x " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
285 | prompt(200, NULL); /* " " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
286 | prompt(301, NULL); /* " Finished " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
287 | prompt(408, NULL); /* "--- --- Ok --- " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
288 | do { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
289 | key = keywait(); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
290 | } while (key != KEY_RETURN); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
291 | /* |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
292 | * Rewrite the display |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
293 | */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
294 | prompt(101, NULL); /* " Brewco x.x.x " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
295 | prompt(300, NULL); /* " " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
296 | prompt(401, NULL); /* "--- MAN AUTO SETUP" */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
297 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
298 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
299 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
300 | if (save) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
301 | wrsession(brew); |
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
|
302 | } |
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
|
303 | |
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
|
304 | |
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
|
305 | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
306 | void manual_prompt(void) |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
307 | { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
308 | switch (manual) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
309 | case MANUAL_SELHLT: prompt(104, NULL); /* " MANUAL MODE " */ |
467 | 310 | prompt(303, NULL); /* " Manual HLT " */ |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
311 | prompt(402, NULL); /* "--- dwn quit ok " */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
312 | break; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
313 | case MANUAL_SELMLT: prompt(104, NULL); /* " MANUAL MODE " */ |
467 | 314 | prompt(304, NULL); /* " Manual MLT " */ |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
315 | prompt(404, NULL); /* " up --- quit ok " */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
316 | break; |
467 | 317 | case MANUAL_HLT: prompt(104, NULL); /* " MANUAL MODE " */ |
318 | prompt(300, NULL); /* " " */ | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
319 | prompt(413, NULL); /* "UP* *DWN heat --- " */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
320 | break; |
467 | 321 | case MANUAL_MLT: prompt(104, NULL); /* " MANUAL MODE " */ |
322 | prompt(300, NULL); /* " " */ | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
323 | prompt(406, NULL); /* "UP* *DWN heat pmp " */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
324 | break; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
325 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
326 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
327 | |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
328 | |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
329 | |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
330 | /* |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
331 | * Manual menu for testing your equipment. |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
332 | */ |
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
|
333 | 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
|
334 | 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
|
335 | { |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
336 | int key; |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
337 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
338 | switch (manual) { |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
339 | case MANUAL_SELHLT: slcdDummy(slcdHandle); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
340 | key = keycheck(); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
341 | if (key == KEY_DOWN) { |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
342 | manual = MANUAL_SELMLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
343 | manual_prompt(); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
344 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
345 | if (key == KEY_RETURN) { |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
346 | manual = MANUAL_NONE; |
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
|
347 | man_mlt_pump = 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
|
348 | 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
|
349 | 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
|
350 | 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
|
351 | mlt_status(0); |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
352 | device_out(unit->mlt_pump.uuid, man_mlt_pump); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
353 | } |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
354 | if (key == KEY_ENTER) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
355 | // TODO: prompt for water |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
356 | manual = MANUAL_HLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
357 | manual_prompt(); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
358 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
359 | break; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
360 | case MANUAL_SELMLT: slcdDummy(slcdHandle); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
361 | key = keycheck(); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
362 | if (key == KEY_UP) { |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
363 | manual = MANUAL_SELHLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
364 | manual_prompt(); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
365 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
366 | if (key == KEY_RETURN) { |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
367 | manual = MANUAL_NONE; |
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
|
368 | man_mlt_pump = 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
|
369 | 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
|
370 | 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
|
371 | 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
|
372 | mlt_status(0); |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
373 | device_out(unit->mlt_pump.uuid, man_mlt_pump); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
374 | } |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
375 | if (key == KEY_ENTER) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
376 | // TODO: prompt for water |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
377 | manual = MANUAL_MLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
378 | manual_prompt(); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
379 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
380 | break; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
381 | case MANUAL_HLT: tempstatus(*unit->PID_hlt->myInput, *unit->PID_mlt->myInput); |
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
|
382 | percstatus((seconds / 2) % 4); |
467 | 383 | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
384 | slcdDummy(slcdHandle); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
385 | key = keycheck(); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
386 | 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
|
387 | 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
|
388 | 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
|
389 | 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
|
390 | } 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
|
391 | 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
|
392 | 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
|
393 | } |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
394 | } |
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
|
395 | 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
|
396 | 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
|
397 | 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
|
398 | hltSetpoint += 1.0; |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
399 | if (key == KEY_ESCAPE) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
400 | manual = MANUAL_SELHLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
401 | manual_prompt(); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
402 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
403 | break; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
404 | case MANUAL_MLT: tempstatus(*unit->PID_hlt->myInput, *unit->PID_mlt->myInput); |
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
|
405 | 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
|
406 | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
407 | slcdDummy(slcdHandle); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
408 | key = keycheck(); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
409 | 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
|
410 | 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
|
411 | 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
|
412 | 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
|
413 | } 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
|
414 | 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
|
415 | 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
|
416 | } |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
417 | } |
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
|
418 | 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
|
419 | 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
|
420 | 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
|
421 | mltSetpoint += 1.0; |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
422 | if (key == KEY_ENTER) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
423 | if (man_mlt_pump) |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
424 | man_mlt_pump = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
425 | else |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
426 | man_mlt_pump = 1; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
427 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
428 | if (key == KEY_ESCAPE) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
429 | manual = MANUAL_SELMLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
430 | manual_prompt(); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
431 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
432 | device_out(unit->mlt_pump.uuid, man_mlt_pump); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
433 | break; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
434 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
435 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
436 | return 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
437 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
438 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
439 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
440 | |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
441 | char *choose_recipe(void); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
442 | char *choose_recipe(void) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
443 | { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
444 | int total, i, key, choice = 1; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
445 | static char uuid[37]; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
446 | a_recipe *recipe; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
447 | char pmpt[81]; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
448 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
449 | 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
|
450 | for (;;) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
451 | total = 0; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
452 | for (recipe = recipes; recipe; recipe = recipe->next) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
453 | total++; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
454 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
455 | if (total == 0) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
456 | return uuid; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
457 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
458 | i = 0; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
459 | for (recipe = recipes; recipe; recipe = recipe->next) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
460 | i++; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
461 | if (i == choice) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
462 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
463 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
464 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
465 | prompt(102, NULL); /* " SETUP MENU " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
466 | prompt(221, NULL); /* " Select Recipe " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
467 | if (total) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
468 | 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
|
469 | prompt(300, pmpt); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
470 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
471 | if (total == 1) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
472 | prompt(405, NULL); /* "--- --- quit ok " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
473 | else if (choice == 1) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
474 | prompt(402, NULL); /* "--- dwn quit ok " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
475 | else if (choice == total) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
476 | prompt(404, NULL); /* " up --- quit ok " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
477 | else |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
478 | prompt(403, NULL); /* " up dwn quit ok " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
479 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
480 | key = keywait(); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
481 | if ((key == KEY_RETURN) || my_shutdown) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
482 | return uuid; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
483 | if (key == KEY_ENTER) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
484 | strcpy(uuid, recipe->uuid); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
485 | return uuid; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
486 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
487 | 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
|
488 | choice--; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
489 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
490 | 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
|
491 | choice++; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
492 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
493 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
494 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
495 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
496 | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
497 | int server(void); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
498 | int server(void) |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
499 | { |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
500 | 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
|
501 | int do_init = TRUE, seconds = 0, minutes = 0; |
441 | 502 | units_list *unit; |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
503 | a_recipe *recipe = NULL; |
441 | 504 | brew_session *brew = NULL; |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
505 | #ifndef HAVE_WIRINGPI_H |
441 | 506 | long t = 0; |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
507 | #endif |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
508 | time_t now, last = (time_t)0; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
509 | long nowmillis, perctimer; |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
510 | struct tm *tm; |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
511 | |
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
|
512 | 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
|
513 | |
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
|
514 | /* |
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
|
515 | * 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
|
516 | */ |
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
|
517 | 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
|
518 | 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
|
519 | 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
|
520 | 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
|
521 | 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
|
522 | 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
|
523 | 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
|
524 | 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
|
525 | 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
|
526 | 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
|
527 | |
465 | 528 | if (lockprog((char *)"brewco")) { |
529 | syslog(LOG_NOTICE, "Can't lock"); | |
530 | return 1; | |
531 | } | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
532 | |
441 | 533 | if (debug) |
534 | fprintf(stdout, "Begin server()\n"); | |
535 | ||
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
536 | if ((rc = devices_detect())) { |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
537 | syslog(LOG_NOTICE, "Detected %d new devices", rc); |
441 | 538 | if (debug) |
539 | 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
|
540 | wrconfig(); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
541 | } |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
542 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
543 | #ifdef HAVE_WIRINGPI_H |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
544 | rc = piThreadCreate(my_devices_loop); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
545 | #else |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
546 | 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
|
547 | #endif |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
548 | if (rc) { |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
549 | 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
|
550 | 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
|
551 | #ifndef HAVE_WIRINGPI_H |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
552 | } else { |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
553 | t++; |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
554 | #endif |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
555 | } |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
556 | |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
557 | #ifdef HAVE_WIRINGPI_H |
441 | 558 | rc = piThreadCreate(my_keyboard_loop); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
559 | #else |
441 | 560 | 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
|
561 | #endif |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
562 | if (rc) { |
441 | 563 | fprintf(stderr, "my_keyboard_loop thread didn't start rc=%d\n", rc); |
564 | 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
|
565 | #ifndef HAVE_WIRINGPI_H |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
566 | } else { |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
567 | t++; |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
568 | #endif |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
569 | } |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
570 | |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
571 | #ifdef USE_SIMULATOR |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
572 | #ifdef HAVE_WIRINGPI_H |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
573 | rc = piThreadCreate(my_simulator_loop); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
574 | #else |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
575 | 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
|
576 | #endif |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
577 | if (rc) { |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
578 | 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
|
579 | 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
|
580 | #ifndef HAVE_WIRINGPI_H |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
581 | } else { |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
582 | t++; |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
583 | #endif |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
584 | } |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
585 | #endif |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
586 | |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
587 | if (! Config.units) { |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
588 | /* |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
589 | * 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
|
590 | */ |
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
|
591 | prompt(218, NULL); /* Add Brewsystem? */ |
451 | 592 | prompt(407, NULL); /* --- --- Ok --- */ |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
593 | |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
594 | do { |
441 | 595 | key = keywait(); |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
596 | } while (key != KEY_RETURN); |
441 | 597 | |
598 | if (key == KEY_RETURN) { | |
599 | addUnit(1); | |
600 | } | |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
601 | } |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
602 | |
441 | 603 | /* |
451 | 604 | * Initialize units for processing |
605 | */ | |
606 | for (unit = Config.units; unit; unit = unit->next) { | |
607 | if (unit->active) | |
608 | break; | |
609 | } | |
610 | ||
611 | if (! unit->active) { | |
612 | fprintf(stdout, "No active units found\n"); | |
613 | } | |
614 | ||
615 | /* | |
616 | * Safety, turn everything off | |
617 | */ | |
618 | if (unit->active) { | |
619 | if (debug) | |
620 | fprintf(stdout, "Starting brewsystem %d `%s'\n", unit->number, unit->name); | |
621 | syslog(LOG_NOTICE, "Starting brewsystem %d `%s'", unit->number, unit->name); | |
622 | } | |
623 | ||
624 | /* | |
441 | 625 | * During automation there will be a state file: |
626 | * ~/.brewco/var/brewing.xml | |
627 | * If this file is present, there has been a crash. | |
628 | */ | |
629 | brew = (brew_session *)malloc(sizeof(brew_session)); | |
630 | if (rdsession(brew) == 0) { | |
631 | } else { | |
632 | /* | |
633 | * No active brew session, make that permanent. | |
634 | */ | |
635 | free(brew); | |
636 | brew = NULL; | |
637 | } | |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
638 | |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
639 | do { |
441 | 640 | if (my_shutdown) { |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
641 | run = 0; |
467 | 642 | unit->hlt_heater.value = 0; |
643 | unit->mlt_heater.value = 0; | |
644 | unit->mlt_pump.value = 0; | |
645 | device_out(unit->hlt_heater.uuid, 0); | |
646 | device_out(unit->mlt_heater.uuid, 0); | |
647 | 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
|
648 | 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
|
649 | mlt_status(0); |
441 | 650 | break; |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
651 | } |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
652 | |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
653 | /* |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
654 | * 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
|
655 | */ |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
656 | if (do_init) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
657 | if (debug) |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
658 | 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
|
659 | syslog(LOG_NOTICE, "Initialize brewsystem %d `%s'", unit->number, unit->name); |
467 | 660 | |
661 | prompt(0, NULL); | |
662 | prompt(101, NULL); /* " Brewco x.x.x " */ | |
663 | prompt(401, NULL); /* "--- MAN AUTO SETUP" */ | |
664 | ||
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
665 | /* |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
666 | * Turn everything off |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
667 | */ |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
668 | unit->hlt_heater.value = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
669 | unit->mlt_heater.value = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
670 | unit->mlt_pump.value = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
671 | 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
|
672 | 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
|
673 | 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
|
674 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
675 | /* |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
676 | * Initialize PID's |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
677 | */ |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
678 | hltInput = hltSetpoint = mltInput = mltSetpoint = 20.0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
679 | hltOutput = mltOutput = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
680 | PID_init(unit->PID_hlt, &hltInput, &hltOutput, &hltSetpoint, unit->PID_hlt->dispKd, unit->PID_hlt->dispKi, unit->PID_hlt->dispKd, unit->PID_hlt->Direction); |
467 | 681 | 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
|
682 | PID_setSampleTime(unit->PID_hlt, unit->PID_hlt->SampleTime); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
683 | PID_init(unit->PID_mlt, &mltInput, &mltOutput, &mltSetpoint, unit->PID_mlt->dispKd, unit->PID_mlt->dispKi, unit->PID_mlt->dispKd, unit->PID_mlt->Direction); |
467 | 684 | 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
|
685 | 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
|
686 | 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
|
687 | mlt_status(0); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
688 | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
689 | manual = MANUAL_NONE; |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
690 | |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
691 | do_init = FALSE; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
692 | nowmillis = perctimer = millis(); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
693 | percslot = 0; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
694 | percfase = PERC_INIT; |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
695 | dosave = 0; |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
696 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
697 | |
451 | 698 | /* run_pause code here */ |
699 | ||
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
700 | /* |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
701 | * 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
|
702 | * the scheduling by themselves. |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
703 | */ |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
704 | rc = PID_compute(unit->PID_hlt); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
705 | rc = PID_compute(unit->PID_mlt); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
706 | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
707 | /* |
467 | 708 | * This is the serial heaters schedule loop. The total |
709 | * loop time is 5 seconds, heating is 0..100% so we | |
710 | * have 5 mSeconds timeslots. The MLT has priority over | |
711 | * the HLT heater, so the HLT heater can get too little | |
712 | * power. TODO: simultaneous use must be implemented. | |
713 | * In sequentiel mode, the total drawn power is the same | |
714 | * 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
|
715 | */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
716 | nowmillis = millis(); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
717 | if (nowmillis > (perctimer + 50)) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
718 | percslot++; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
719 | 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
|
720 | 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
|
721 | MLTp = (int)mltOutput; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
722 | if ((MLTp + HLTp) > 100) |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
723 | HLTp = 100 - MLTp; /* The HLT has lower priority */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
724 | if (MLTp) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
725 | percfase = PERC_MLT; |
467 | 726 | device_out(unit->hlt_heater.uuid, 0); |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
727 | device_out(unit->mlt_heater.uuid, 1); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
728 | } else if (HLTp) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
729 | percfase = PERC_HLT; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
730 | device_out(unit->hlt_heater.uuid, 1); |
467 | 731 | device_out(unit->mlt_heater.uuid, 0); |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
732 | } else { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
733 | percfase = PERC_REST; |
467 | 734 | device_out(unit->hlt_heater.uuid, 0); |
735 | device_out(unit->mlt_heater.uuid, 0); | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
736 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
737 | if (debug) |
467 | 738 | 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
|
739 | } else if (percfase == PERC_MLT) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
740 | if (percslot > MLTp) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
741 | device_out(unit->mlt_heater.uuid, 0); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
742 | if (HLTp) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
743 | device_out(unit->hlt_heater.uuid, 1); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
744 | percfase = PERC_HLT; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
745 | } else { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
746 | percfase = PERC_REST; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
747 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
748 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
749 | } else if (percfase == PERC_HLT) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
750 | if (percslot > (MLTp + HLTp)) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
751 | device_out(unit->hlt_heater.uuid, 0); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
752 | percfase = PERC_REST; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
753 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
754 | } |
467 | 755 | 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
|
756 | percslot = 0; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
757 | percfase = PERC_INIT; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
758 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
759 | perctimer = nowmillis; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
760 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
761 | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
762 | now = time(NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
763 | if (now != last) { |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
764 | /* |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
765 | * Each second |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
766 | */ |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
767 | last = now; |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
768 | seconds++; |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
769 | |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
770 | if (seconds > 59) { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
771 | seconds = 0; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
772 | minutes++; |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
773 | dosave = 1; |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
774 | } |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
775 | |
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
|
776 | //fprintf(stdout, "%d seconds %d minutes %ld millis\n", seconds, minutes, millis()); |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
777 | |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
778 | 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
|
779 | if (rc == DEVPRESENT_YES) { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
780 | hltInput = temp / 1000.0; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
781 | 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
|
782 | } 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
|
783 | 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
|
784 | } else { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
785 | 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
|
786 | } |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
787 | 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
|
788 | if (rc == DEVPRESENT_YES) { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
789 | mltInput = temp / 1000.0; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
790 | 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
|
791 | } 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
|
792 | 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
|
793 | } else { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
794 | 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
|
795 | } |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
796 | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
797 | 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
|
798 | 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
|
799 | 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
|
800 | 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
|
801 | } |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
802 | |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
803 | } |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
804 | |
441 | 805 | if (brew) { |
806 | /* | |
807 | * Automate mode | |
808 | */ | |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
809 | automatic_brew(unit, brew, recipe, dosave); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
810 | dosave = 0; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
811 | if (brew->brewstep == -1) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
812 | /* |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
813 | * Save session and move it |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
814 | */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
815 | wrsession(brew); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
816 | char *fpath, *tpath; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
817 | fpath = xstrcpy(etcpath); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
818 | fpath = xstrcat(fpath, (char *)"brewing.xml"); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
819 | tpath = xstrcpy(varpath); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
820 | tpath = xstrcat(tpath, (char *)"old/brewing.xml."); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
821 | mkdirs(tpath, 0755); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
822 | tpath = xstrcat(tpath, brew->name); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
823 | if (debug) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
824 | 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
|
825 | file_cp(fpath, tpath); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
826 | unlink(fpath); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
827 | free(fpath); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
828 | free(tpath); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
829 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
830 | /* |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
831 | * Free memory, session is over. |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
832 | */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
833 | if (brew->name) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
834 | free(brew->name); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
835 | if (brew->uuid_recipe) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
836 | free(brew->uuid_recipe); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
837 | if (brew->uuid_unit) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
838 | free(brew->uuid_unit); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
839 | free(brew); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
840 | brew = NULL; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
841 | } |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
842 | |
451 | 843 | } else if (manual != MANUAL_NONE) { |
844 | /* | |
845 | * Manual mode | |
846 | */ | |
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
|
847 | manual_menu(unit, seconds); |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
848 | if (manual == MANUAL_NONE) { |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
849 | /* |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
850 | * Rewrite the display |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
851 | */ |
467 | 852 | prompt(101, NULL); /* " Brewco x.x.x " */ |
853 | prompt(300, NULL); /* " " */ | |
854 | prompt(401, NULL); /* "--- MAN AUTO SETUP" */ | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
855 | } |
441 | 856 | } else { |
857 | /* | |
858 | * Not running. | |
859 | */ | |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
860 | tempstatus(hltInput, mltInput); |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
861 | key = keycheck(); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
862 | if (key == KEY_ENTER) { |
442 | 863 | setup(); |
467 | 864 | prompt(101, NULL); /* " Brewco x.x.x " */ |
865 | prompt(401, NULL); /* "--- MAN AUTO SETUP" */ | |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
866 | } else if (key == KEY_RETURN && ! brew) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
867 | int i, isOk = TRUE; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
868 | char message[41]; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
869 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
870 | tm = localtime(&now); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
871 | 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
|
872 | brew = (brew_session *)malloc(sizeof(brew_session)); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
873 | brew->uuid_recipe = xstrcpy(choose_recipe()); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
874 | brew->uuid_unit = xstrcpy(unit->uuid); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
875 | brew->name = xstrcpy(message); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
876 | brew->brewstep = STEP_NA; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
877 | brew->mashstep = MASH_NA; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
878 | brew->timeout = brew->boiltimer = 0; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
879 | brew->starttime = brew->endtime = (time_t)0; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
880 | /* |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
881 | * Now check if everything is sane |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
882 | */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
883 | 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
|
884 | isOk = FALSE; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
885 | 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
|
886 | if (debug) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
887 | 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
|
888 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
889 | if (isOk) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
890 | isOk = FALSE; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
891 | for (recipe = recipes; recipe; recipe = recipe->next) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
892 | 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
|
893 | isOk = TRUE; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
894 | if (! recipe->boiltime) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
895 | isOk = FALSE; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
896 | for (i = 0; i < 8; i++) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
897 | 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
|
898 | isOk = FALSE; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
899 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
900 | for (i = 0; i < 3; i++) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
901 | 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
|
902 | isOk = FALSE; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
903 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
904 | break; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
905 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
906 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
907 | if (isOk == FALSE) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
908 | 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
|
909 | if (debug) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
910 | fprintf(stdout, "brew init: recipe error\n"); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
911 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
912 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
913 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
914 | if (debug) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
915 | 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
|
916 | |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
917 | if (isOk) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
918 | wrsession(brew); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
919 | } else { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
920 | prompt(300, message); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
921 | prompt(408, NULL); /* "--- --- Ok --- " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
922 | key = keywait(); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
923 | if (brew->name) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
924 | free(brew->name); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
925 | if (brew->uuid_recipe) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
926 | free(brew->uuid_recipe); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
927 | if (brew->uuid_unit) |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
928 | free(brew->uuid_unit); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
929 | free(brew); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
930 | brew = NULL; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
931 | /* |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
932 | * Rewrite the display |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
933 | */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
934 | prompt(101, NULL); /* " Brewco x.x.x " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
935 | prompt(300, NULL); /* " " */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
936 | prompt(401, NULL); /* "--- MAN AUTO SETUP" */ |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
937 | } |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
471
diff
changeset
|
938 | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
939 | } else if (key == KEY_DOWN) { |
451 | 940 | manual = MANUAL_SELHLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
941 | manual_prompt(); |
451 | 942 | } |
441 | 943 | } |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
944 | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
945 | usleep(5000); /* 5 mSec */ |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
946 | |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
947 | } while (run); |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
948 | |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
949 | 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
|
950 | if (debug) |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
951 | 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
|
952 | |
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
|
953 | prompt(0, NULL); |
467 | 954 | prompt(101, NULL); /* " Brewco x.x.x " */ |
955 | prompt(302, NULL); /* " Shutting down " */ | |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
956 | |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
957 | /* |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
958 | * Give threads time to cleanup |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
959 | */ |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
960 | 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
|
961 | 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
|
962 | 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
|
963 | |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
964 | if (sock != -1) { |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
965 | if (shutdown(sock, SHUT_RDWR)) { |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
966 | syslog(LOG_NOTICE, "Can't shutdown socket: %s", strerror(errno)); |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
967 | } |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
968 | sock = -1; |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
969 | } |
467 | 970 | |
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
|
971 | wrrecipes(); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
972 | wrconfig(); |
465 | 973 | ulockprog((char *)"brewco"); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
974 | return 0; |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
975 | } |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
976 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
977 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
978 | |
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
|
979 | 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
|
980 | { |
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
|
981 | 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
|
982 | 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
|
983 | |
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
|
984 | 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
|
985 | 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
|
986 | 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
|
987 | {"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
|
988 | {"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
|
989 | {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
|
990 | }; |
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
|
991 | |
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
|
992 | 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
|
993 | 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
|
994 | 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
|
995 | |
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
|
996 | 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
|
997 | 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
|
998 | 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
|
999 | 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
|
1000 | 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
|
1001 | } |
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
|
1002 | } |
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
|
1003 | |
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
|
1004 | 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
|
1005 | 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
|
1006 | 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
|
1007 | 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
|
1008 | |
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
|
1009 | /* |
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
|
1010 | * 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
|
1011 | */ |
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
|
1012 | 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
|
1013 | 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
|
1014 | } 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
|
1015 | 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
|
1016 | } |
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
|
1017 | 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
|
1018 | 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
|
1019 | 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
|
1020 | 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
|
1021 | 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
|
1022 | 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
|
1023 | |
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
|
1024 | 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
|
1025 | 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
|
1026 | 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
|
1027 | 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
|
1028 | } |
441 | 1029 | if (debug) |
1030 | 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
|
1031 | |
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
|
1032 | 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
|
1033 | 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
|
1034 | 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
|
1035 | 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
|
1036 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
1037 | 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
|
1038 | 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
|
1039 | |
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
|
1040 | /* |
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
|
1041 | * 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
|
1042 | * 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
|
1043 | * 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
|
1044 | */ |
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
|
1045 | 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
|
1046 | 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
|
1047 | 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
|
1048 | } |
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
|
1049 | |
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
|
1050 | #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
|
1051 | 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
|
1052 | 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
|
1053 | #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
|
1054 | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1055 | 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
|
1056 | 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
|
1057 | return 1; |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1058 | } |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1059 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1060 | 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
|
1061 | |
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
|
1062 | syslog(LOG_NOTICE, "Finished, rc=%d", rc); |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1063 | if (debug) |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
1064 | 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
|
1065 | 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
|
1066 | } |
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
|
1067 | |
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
|
1068 |