Sat, 12 Dec 2015 21:20:46 +0100
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.
442 | 1 | /***************************************************************************** |
2 | * Copyright (C) 2015 | |
3 | * | |
4 | * Michiel Broek <mbroek at mbse dot eu> | |
5 | * | |
6 | * This file is part of the mbsePi-apps | |
7 | * | |
8 | * This is free software; you can redistribute it and/or modify it | |
9 | * under the terms of the GNU General Public License as published by the | |
10 | * Free Software Foundation; either version 2, or (at your option) any | |
11 | * later version. | |
12 | * | |
13 | * mbsePi-apps is distributed in the hope that it will be useful, but | |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with ThermFerm; see the file COPYING. If not, write to the Free | |
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
21 | *****************************************************************************/ | |
22 | ||
23 | #include "brewco.h" | |
24 | #include "slcd.h" | |
25 | #include "setup.h" | |
26 | #include "prompt.h" | |
27 | #include "xutil.h" | |
28 | #include "keyboard.h" | |
447
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
29 | #include "rdconfig.h" |
442 | 30 | |
31 | ||
32 | extern int my_shutdown; | |
33 | extern int debug; | |
34 | extern sys_config Config; | |
35 | extern int lcdHandle; | |
36 | extern int slcdHandle; | |
37 | ||
38 | ||
39 | ||
445
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
40 | void editFloat(float *value, float low, float high, char *text) |
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
|
41 | { |
445
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
42 | int key; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
43 | float new = *value; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
44 | char pmpt[81]; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
45 | |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
46 | prompt(0, NULL); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
47 | prompt(133, NULL); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
48 | |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
49 | for (;;) { |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
50 | snprintf(pmpt, Config.lcd_cols + 1, "%s: %5.1f\001", text, new); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
51 | prompt(200, pmpt); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
52 | if (new == low) |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
53 | prompt(404, NULL); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
54 | else if (new == high) |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
55 | prompt(402, NULL); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
56 | else |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
57 | prompt(403, NULL); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
58 | |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
59 | key = keywait(); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
60 | if ((key == KEY_RETURN) || my_shutdown) |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
61 | return; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
62 | if (key == KEY_UP) { |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
63 | new = new + 0.5; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
64 | if (new > high) |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
65 | new = high; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
66 | } |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
67 | if (key == KEY_DOWN) { |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
68 | new = new - 0.5; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
69 | if (new < low) |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
70 | new = low; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
71 | } |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
72 | if (key == KEY_ENTER) { |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
73 | *value = new; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
74 | return; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
75 | } |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
76 | } |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
77 | } |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
78 | |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
79 | |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
80 | |
448 | 81 | void editDouble(double *value, double low, double high, char *text) |
445
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
82 | { |
448 | 83 | int key; |
84 | double new = *value; | |
445
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
85 | char pmpt[81]; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
86 | |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
87 | prompt(0, NULL); |
448 | 88 | prompt(138, NULL); |
445
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
89 | |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
90 | for (;;) { |
448 | 91 | snprintf(pmpt, Config.lcd_cols + 1, "%s: %5.2lf", text, new); |
445
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
92 | prompt(200, pmpt); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
93 | if (new == low) |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
94 | prompt(404, NULL); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
95 | else if (new == high) |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
96 | prompt(402, NULL); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
97 | else |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
98 | prompt(403, NULL); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
99 | |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
100 | key = keywait(); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
101 | if ((key == KEY_RETURN) || my_shutdown) |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
102 | return; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
103 | if (key == KEY_UP) { |
448 | 104 | new = new + 0.5; |
445
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
105 | if (new > high) |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
106 | new = high; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
107 | } |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
108 | if (key == KEY_DOWN) { |
448 | 109 | new = new - 0.5; |
445
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
110 | if (new < low) |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
111 | new = low; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
112 | } |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
113 | if (key == KEY_ENTER) { |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
114 | *value = new; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
115 | return; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
116 | } |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
117 | } |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
118 | } |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
119 | |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
120 | |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
121 | |
448 | 122 | void editInteger(int *value, int low, int high, int step, char *text, char *text2) |
123 | { | |
124 | int key, new = *value; | |
125 | char pmpt[81]; | |
126 | ||
127 | prompt(0, NULL); | |
128 | prompt(134, NULL); | |
129 | ||
130 | for (;;) { | |
131 | snprintf(pmpt, Config.lcd_cols + 1, "%s: %3d %s", text, new, text2); | |
132 | prompt(200, pmpt); | |
133 | if (new == low) | |
134 | prompt(404, NULL); | |
135 | else if (new == high) | |
136 | prompt(402, NULL); | |
137 | else | |
138 | prompt(403, NULL); | |
139 | ||
140 | key = keywait(); | |
141 | if ((key == KEY_RETURN) || my_shutdown) | |
142 | return; | |
143 | if (key == KEY_UP) { | |
144 | new += step; | |
145 | if (new > high) | |
146 | new = high; | |
147 | } | |
148 | if (key == KEY_DOWN) { | |
149 | new -= step; | |
150 | if (new < low) | |
151 | new = low; | |
152 | } | |
153 | if (key == KEY_ENTER) { | |
154 | *value = new; | |
155 | return; | |
156 | } | |
157 | } | |
158 | } | |
159 | ||
160 | ||
161 | ||
162 | void togglePmpts(int *value, char *text, int pno, char *pmpt1, char *pmpt2) | |
445
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
163 | { |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
164 | int key, new = *value; |
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
|
165 | char pmpt[81]; |
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
|
166 | |
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
|
167 | prompt(0, NULL); |
448 | 168 | prompt(pno, NULL); |
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
|
169 | |
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
|
170 | for (;;) { |
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
|
171 | |
448 | 172 | snprintf(pmpt, Config.lcd_cols + 1, "%s: %s", text, new ? pmpt1:pmpt2); |
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
|
173 | prompt(200, pmpt); |
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
|
174 | if (new) { |
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
|
175 | prompt(404, 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
|
176 | } 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
|
177 | prompt(402, 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
|
178 | } |
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
|
179 | |
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
|
180 | key = keywait(); |
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
|
181 | if ((key == KEY_RETURN) || my_shutdown) |
445
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
182 | return; |
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
|
183 | if ((key == KEY_UP) && new) |
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
|
184 | new = 0; |
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
|
185 | else if ((key == KEY_DOWN) && (new == 0)) |
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
|
186 | new = 1; |
445
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
187 | if (key == KEY_ENTER) { |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
188 | *value = new; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
189 | return; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
190 | } |
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
|
191 | } |
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
|
192 | } |
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
|
193 | |
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
|
194 | |
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
|
195 | |
448 | 196 | void toggleYesNo(int *value, char *text) |
197 | { | |
198 | togglePmpts(value, text, 132, (char *)"Yes", (char *)"No "); | |
199 | } | |
200 | ||
201 | ||
202 | ||
203 | void toggleDirection(int *value, char *text) | |
204 | { | |
205 | togglePmpts(value, text, 137, (char *)"Reverse", (char *)"Direct "); | |
206 | } | |
207 | ||
208 | ||
209 | ||
210 | void editPID(pid_var *pid) | |
211 | { | |
212 | int index = 1, key, val; | |
213 | char pmpt[81]; | |
214 | double Kp, Ki, Kd; | |
215 | ||
216 | if (debug) | |
217 | fprintf(stdout, "editPID()\n"); | |
218 | ||
219 | for (;;) { | |
220 | prompt(0, NULL); | |
221 | prompt(135, NULL); | |
222 | ||
223 | if (index == 1) | |
224 | prompt(402, NULL); | |
225 | else if (index == 5) | |
226 | prompt(404, NULL); | |
227 | else | |
228 | prompt(403, NULL); | |
229 | ||
230 | switch (index) { | |
231 | case 1: snprintf(pmpt, Config.lcd_cols + 1, "PID Kp: %5.2f", PID_getKp(pid)); | |
232 | break; | |
233 | case 2: snprintf(pmpt, Config.lcd_cols + 1, "PID Ki: %5.2f", PID_getKi(pid)); | |
234 | break; | |
235 | case 3: snprintf(pmpt, Config.lcd_cols + 1, "PID Kd: %5.2f", PID_getKd(pid)); | |
236 | break; | |
237 | case 4: snprintf(pmpt, Config.lcd_cols + 1, "SampleTime: %3d mSec", PID_getSampleTime(pid)); | |
238 | break; | |
239 | case 5: snprintf(pmpt, Config.lcd_cols + 1, "Direction: %s", PID_getDirection(pid) ? (char *)"Reverse" : (char *)"Direct"); | |
240 | break; | |
241 | } | |
242 | prompt(200, pmpt); | |
243 | ||
244 | key = keywait(); | |
245 | if ((key == KEY_RETURN) || my_shutdown) { | |
246 | if (debug) | |
247 | fprintf(stdout, "End editPID\n"); | |
248 | return; | |
249 | } | |
250 | ||
251 | if ((key == KEY_UP) && (index > 1)) | |
252 | index--; | |
253 | if ((key == KEY_DOWN) && (index < 5)) | |
254 | index++; | |
255 | ||
256 | if (key == KEY_ENTER) { | |
257 | ||
258 | Kp = PID_getKp(pid); | |
259 | Ki = PID_getKi(pid); | |
260 | Kd = PID_getKd(pid); | |
261 | ||
262 | switch(index) { | |
263 | case 1: editDouble(&Kp, 0.5, 50, (char *)"PID Kp"); | |
264 | PID_setTunings(pid, Kp, Ki, Kd); | |
265 | break; | |
266 | case 2: editDouble(&Ki, 0.5, 50, (char *)"PID Ki"); | |
267 | PID_setTunings(pid, Kp, Ki, Kd); | |
268 | break; | |
269 | case 3: editDouble(&Kd, 0.5, 50, (char *)"PID Kd"); | |
270 | PID_setTunings(pid, Kp, Ki, Kd); | |
271 | break; | |
272 | case 4: val = PID_getSampleTime(pid); | |
273 | editInteger(&val, 50, 500, 10, (char *)"SampleTime", (char *)"mSec"); | |
274 | PID_setSampleTime(pid, val); | |
275 | break; | |
276 | case 5: val = PID_getDirection(pid); | |
277 | toggleDirection(&val, (char *)"Direction"); | |
278 | PID_setDirection(pid, val); | |
279 | break; | |
280 | } | |
281 | } | |
282 | } | |
283 | } | |
284 | ||
285 | ||
286 | ||
449 | 287 | void editSensor(char *uuid, char *text) |
288 | { | |
289 | char pmpt[81]; | |
290 | int i, old, choices, index = 1, key; | |
291 | devices_list *device; | |
292 | ||
293 | if (debug) | |
294 | fprintf(stdout, "editSensor(%s, %s)\n", uuid, text); | |
295 | ||
296 | old = 1; // 1d0e5bb8-7408-48b9-abb4-e9041d7b99fe | |
297 | if ((i = strcmp((char *)"00000000-0000-0000-0000-000000000000", uuid))) { | |
298 | for (device = Config.devices; device; device = device->next) { | |
299 | if (device->direction == DEVDIR_IN_ANALOG) { | |
300 | old++; | |
301 | if (strcmp(device->uuid, uuid) == 0) | |
302 | break; | |
303 | } | |
304 | } | |
305 | } | |
306 | ||
307 | if (debug) | |
308 | fprintf(stdout, "editSensor(%s) old sensor index=%d\n", text, old); | |
309 | ||
310 | for (;;) { | |
311 | prompt(0, NULL); | |
312 | snprintf(pmpt, Config.lcd_cols + 1, "Edit %s", text); | |
313 | prompt(100, pmpt); | |
314 | ||
315 | /* | |
316 | * Count valid sensors | |
317 | */ | |
318 | choices = 1; | |
319 | if (old == 1) { | |
320 | snprintf(pmpt, Config.lcd_cols + 1, "N/A"); | |
321 | } | |
322 | for (device = Config.devices; device; device = device->next) { | |
323 | if (device->direction == DEVDIR_IN_ANALOG) { | |
324 | choices++; | |
325 | if (choices == old) { | |
326 | snprintf(pmpt, Config.lcd_cols + 1, "%s", device->description); | |
327 | } | |
328 | } | |
329 | } | |
330 | prompt(200, pmpt); /* Display current sensor */ | |
331 | i = 1; | |
332 | if (index == 1) { | |
333 | snprintf(pmpt, Config.lcd_cols + 1, "N/A"); | |
334 | } else { | |
335 | for (device = Config.devices; device; device = device->next) { | |
336 | if (device->direction == DEVDIR_IN_ANALOG) { | |
337 | i++; | |
338 | if (i == index) { | |
339 | snprintf(pmpt, Config.lcd_cols + 1, "%s", device->description); | |
340 | } | |
341 | } | |
342 | } | |
343 | } | |
344 | prompt(300, pmpt); /* Display possible new sensor */ | |
345 | ||
346 | ||
347 | if (choices == 1) | |
348 | prompt(405, NULL); | |
349 | else if (index == 1) | |
350 | prompt(402, NULL); | |
351 | else if (index == choices) | |
352 | prompt(404, NULL); | |
353 | else | |
354 | prompt(403, NULL); | |
355 | ||
356 | key = keywait(); | |
357 | if ((key == KEY_RETURN) || my_shutdown) { | |
358 | if (debug) | |
359 | fprintf(stdout, "End editSensor\n"); | |
360 | return; | |
361 | } | |
362 | ||
363 | if ((key == KEY_UP) && (index > 1)) | |
364 | index--; | |
365 | if ((key == KEY_DOWN) && (index < choices)) | |
366 | index++; | |
367 | ||
368 | if ((key == KEY_ENTER) && (index != old)) { | |
369 | /* | |
370 | * Select new sensor. | |
371 | */ | |
372 | if (index == 1) { | |
373 | /* | |
374 | * Disable the sensor | |
375 | */ | |
376 | strncpy(uuid, (char *)"00000000-0000-0000-0000-000000000000", 36); | |
377 | old = index; | |
378 | } else { | |
379 | i = 1; | |
380 | for (device = Config.devices; device; device = device->next) { | |
381 | if (device->direction == DEVDIR_IN_ANALOG) { | |
382 | i++; | |
383 | if (i == index) { | |
384 | strncpy(uuid, device->uuid, 36); | |
385 | break; | |
386 | } | |
387 | } | |
388 | } | |
389 | old = index; | |
390 | } | |
391 | } | |
392 | } | |
393 | } | |
394 | ||
395 | ||
396 | ||
450
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
397 | void editRelay(char *uuid, char *text) |
449 | 398 | { |
450
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
399 | char pmpt[81]; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
400 | int i, old, choices, index = 1, key; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
401 | devices_list *device; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
402 | |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
403 | if (debug) |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
404 | fprintf(stdout, "editRelay(%s, %s)\n", uuid, text); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
405 | |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
406 | old = 1; // 1d0e5bb8-7408-48b9-abb4-e9041d7b99fe |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
407 | if ((i = strcmp((char *)"00000000-0000-0000-0000-000000000000", uuid))) { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
408 | for (device = Config.devices; device; device = device->next) { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
409 | if (device->direction == DEVDIR_OUT_ANALOG) { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
410 | old++; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
411 | if (strcmp(device->uuid, uuid) == 0) |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
412 | break; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
413 | } |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
414 | } |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
415 | } |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
416 | |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
417 | if (debug) |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
418 | fprintf(stdout, "editRelay(%s) old sensor index=%d\n", text, old); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
419 | |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
420 | for (;;) { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
421 | prompt(0, NULL); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
422 | snprintf(pmpt, Config.lcd_cols + 1, "Edit %s", text); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
423 | prompt(100, pmpt); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
424 | |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
425 | /* |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
426 | * Count valid sensors |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
427 | */ |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
428 | choices = 1; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
429 | if (old == 1) { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
430 | snprintf(pmpt, Config.lcd_cols + 1, "N/A"); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
431 | } |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
432 | for (device = Config.devices; device; device = device->next) { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
433 | if (device->direction == DEVDIR_OUT_ANALOG) { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
434 | choices++; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
435 | if (choices == old) { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
436 | snprintf(pmpt, Config.lcd_cols + 1, "%s", device->description); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
437 | } |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
438 | } |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
439 | } |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
440 | prompt(200, pmpt); /* Display current relay */ |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
441 | i = 1; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
442 | if (index == 1) { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
443 | snprintf(pmpt, Config.lcd_cols + 1, "N/A"); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
444 | } else { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
445 | for (device = Config.devices; device; device = device->next) { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
446 | if (device->direction == DEVDIR_OUT_ANALOG) { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
447 | i++; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
448 | if (i == index) { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
449 | snprintf(pmpt, Config.lcd_cols + 1, "%s", device->description); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
450 | } |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
451 | } |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
452 | } |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
453 | } |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
454 | prompt(300, pmpt); /* Display possible new relay */ |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
455 | |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
456 | if (choices == 1) |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
457 | prompt(405, NULL); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
458 | else if (index == 1) |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
459 | prompt(402, NULL); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
460 | else if (index == choices) |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
461 | prompt(404, NULL); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
462 | else |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
463 | prompt(403, NULL); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
464 | |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
465 | key = keywait(); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
466 | if ((key == KEY_RETURN) || my_shutdown) { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
467 | if (debug) |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
468 | fprintf(stdout, "End editRelay\n"); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
469 | return; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
470 | } |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
471 | |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
472 | if ((key == KEY_UP) && (index > 1)) |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
473 | index--; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
474 | if ((key == KEY_DOWN) && (index < choices)) |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
475 | index++; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
476 | |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
477 | if ((key == KEY_ENTER) && (index != old)) { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
478 | /* |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
479 | * Select new output. |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
480 | */ |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
481 | if (index == 1) { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
482 | /* |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
483 | * Disable the output |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
484 | */ |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
485 | strncpy(uuid, (char *)"00000000-0000-0000-0000-000000000000", 36); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
486 | old = index; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
487 | } else { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
488 | i = 1; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
489 | for (device = Config.devices; device; device = device->next) { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
490 | if (device->direction == DEVDIR_OUT_ANALOG) { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
491 | i++; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
492 | if (i == index) { |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
493 | strncpy(uuid, device->uuid, 36); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
494 | break; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
495 | } |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
496 | } |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
497 | } |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
498 | old = index; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
499 | } |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
500 | } |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
501 | } |
449 | 502 | } |
503 | ||
504 | ||
505 | ||
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
506 | /* |
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
507 | * Edit a single unit |
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
508 | */ |
442 | 509 | void editUnit(units_list *unit) |
510 | { | |
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
|
511 | int index = 1, key; |
449 | 512 | char pmpt[81], *uuid; |
447
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
513 | uLong ocrc, ncrc; |
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
|
514 | |
442 | 515 | if (debug) |
516 | fprintf(stdout, "Start edit brewsystem %d %s\n", unit->number, unit->uuid); | |
517 | ||
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
|
518 | prompt(0, NULL); |
447
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
519 | ncrc = ocrc = crc32(0L, Z_NULL, 0); |
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
520 | ocrc = crc32(ocrc, (const Bytef *) unit, sizeof(units_list)); |
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
|
521 | |
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 | for (;;) { |
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 | |
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 | prompt(0, 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
|
525 | prompt(131, 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
|
526 | |
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 | if (index == 1) |
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
|
528 | prompt(402, 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
|
529 | else if (index == 21) |
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
|
530 | prompt(404, 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
|
531 | 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
|
532 | prompt(403, 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
|
533 | |
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
|
534 | switch (index) { // 12345678901234567890 |
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
|
535 | case 1: snprintf(pmpt, Config.lcd_cols + 1, "Unit name:"); |
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
|
536 | prompt(200, pmpt); |
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
|
537 | snprintf(pmpt, Config.lcd_cols + 1, "%s", unit->name); |
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
|
538 | prompt(300, pmpt); |
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
|
539 | break; |
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
|
540 | case 2: snprintf(pmpt, Config.lcd_cols + 1, " HLT sensor setup"); |
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
|
541 | prompt(200, pmpt); |
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
|
542 | break; |
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
|
543 | case 3: snprintf(pmpt, Config.lcd_cols + 1, " HLT heater setup"); |
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
|
544 | prompt(200, pmpt); |
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
|
545 | break; |
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
|
546 | case 4: snprintf(pmpt, Config.lcd_cols + 1, " MLT sensor setup"); |
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
|
547 | prompt(200, pmpt); |
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
|
548 | break; |
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
|
549 | case 5: snprintf(pmpt, Config.lcd_cols + 1, " MLT heater setup"); |
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
|
550 | prompt(200, pmpt); |
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
|
551 | break; |
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
|
552 | case 6: snprintf(pmpt, Config.lcd_cols + 1, " MLT pump setup"); |
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
|
553 | prompt(200, pmpt); |
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
|
554 | break; |
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
|
555 | case 7: snprintf(pmpt, Config.lcd_cols + 1, "MLT heat b4 HLT: %s", unit->hlt_heater_mltfirst ? (char *)"Yes":(char *)"No"); |
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
|
556 | prompt(200, pmpt); |
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
|
557 | break; |
448 | 558 | case 8: snprintf(pmpt, Config.lcd_cols + 1, "Pump cycle: %3d mins", unit->pump_cycle); |
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
|
559 | prompt(200, pmpt); |
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
|
560 | break; |
448 | 561 | case 9: snprintf(pmpt, Config.lcd_cols + 1, "Pump rest : %3d mins", unit->pump_rest); |
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
|
562 | prompt(200, pmpt); |
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
|
563 | break; |
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
|
564 | case 10: snprintf(pmpt, Config.lcd_cols + 1, " Pump pre-mash: %s", unit->pump_premash ? (char *)"Yes":(char *)"No"); |
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
|
565 | prompt(200, pmpt); |
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
|
566 | break; |
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
|
567 | case 11: snprintf(pmpt, Config.lcd_cols + 1, " Pump on-mash: %s", unit->pump_onmash ? (char *)"Yes":(char *)"No"); |
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
|
568 | prompt(200, pmpt); |
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
|
569 | break; |
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
|
570 | case 12: snprintf(pmpt, Config.lcd_cols + 1, " Pump mashout: %s", unit->pump_mashout ? (char *)"Yes":(char *)"No"); |
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
|
571 | prompt(200, pmpt); |
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
|
572 | break; |
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
|
573 | case 13: snprintf(pmpt, Config.lcd_cols + 1, " Pump on-boil: %s", unit->pump_onboil ? (char *)"Yes":(char *)"No"); |
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
|
574 | prompt(200, pmpt); |
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
|
575 | break; |
445
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
576 | case 14: snprintf(pmpt, Config.lcd_cols + 1, " Pump stop: %5.1f\001", unit->pump_stop); |
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
|
577 | prompt(200, pmpt); |
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
|
578 | break; |
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
|
579 | case 15: snprintf(pmpt, Config.lcd_cols + 1, " Skip Add: %s", unit->skip_add ? (char *)"Yes":(char *)"No"); |
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
|
580 | prompt(200, pmpt); |
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
|
581 | break; |
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
|
582 | case 16: snprintf(pmpt, Config.lcd_cols + 1, " Skip Remove: %s", unit->skip_remove ? (char *)"Yes":(char *)"No"); |
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
|
583 | prompt(200, pmpt); |
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
|
584 | break; |
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
|
585 | case 17: snprintf(pmpt, Config.lcd_cols + 1, " Skip Iodine: %s", unit->skip_iodine ? (char *)"Yes":(char *)"No"); |
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
|
586 | prompt(200, pmpt); |
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
|
587 | break; |
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
|
588 | case 18: snprintf(pmpt, Config.lcd_cols + 1, "Iodine time: %3d min", unit->iodine_time); |
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
|
589 | prompt(200, pmpt); |
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
|
590 | break; |
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 | case 19: snprintf(pmpt, Config.lcd_cols + 1, " Whirlpool: %s", unit->whirlpool ? (char *)"Yes":(char *)"No"); |
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
|
592 | prompt(200, pmpt); |
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
|
593 | break; |
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
|
594 | case 20: snprintf(pmpt, Config.lcd_cols + 1, " HLT PID setup"); |
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
|
595 | prompt(200, pmpt); |
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
|
596 | break; |
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
|
597 | case 21: snprintf(pmpt, Config.lcd_cols + 1, " MLT PID setup"); |
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
|
598 | prompt(200, pmpt); |
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
|
599 | break; |
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
|
600 | } |
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
|
601 | |
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
|
602 | key = keywait(); |
447
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
603 | if ((key == KEY_RETURN) || my_shutdown) { |
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
604 | ncrc = crc32(ncrc, (const Bytef *)unit, sizeof(units_list)); |
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
605 | if (ocrc != ncrc) |
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
606 | wrconfig(); |
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
607 | if (debug) |
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
608 | fprintf(stdout, "End edit brewsystem %d %s\n", unit->number, unit->uuid); |
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
|
609 | return; |
447
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
610 | } |
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
|
611 | |
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
|
612 | if ((key == KEY_UP) && (index > 1)) |
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
|
613 | index--; |
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
|
614 | if ((key == KEY_DOWN) && (index < 21)) |
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
|
615 | index++; |
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
|
616 | |
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
|
617 | if (key == KEY_ENTER) { |
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
|
618 | switch(index) { |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
619 | case 1: // name |
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
620 | break; |
449 | 621 | case 2: uuid = xstrcpy(unit->hlt_sensor.uuid); |
622 | editSensor(uuid, (char *)"HLT sensor"); | |
623 | strncpy(unit->hlt_sensor.uuid, uuid, 36); | |
624 | free(uuid); | |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
625 | break; |
450
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
626 | case 3: uuid = xstrcpy(unit->hlt_heater.uuid); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
627 | editRelay(uuid, (char *)"HLT heater"); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
628 | strncpy(unit->hlt_heater.uuid, uuid, 36); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
629 | free(uuid); |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
630 | break; |
449 | 631 | case 4: uuid = xstrcpy(unit->mlt_sensor.uuid); |
632 | editSensor(uuid, (char *)"MLT sensor"); | |
633 | strncpy(unit->mlt_sensor.uuid, uuid, 36); | |
634 | free(uuid); | |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
635 | break; |
450
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
636 | case 5: uuid = xstrcpy(unit->mlt_heater.uuid); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
637 | editRelay(uuid, (char *)"MLT heater"); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
638 | strncpy(unit->mlt_heater.uuid, uuid, 36); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
639 | free(uuid); |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
640 | break; |
450
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
641 | case 6: uuid = xstrcpy(unit->mlt_pump.uuid); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
642 | editRelay(uuid, (char *)"MLT pump"); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
643 | strncpy(unit->mlt_pump.uuid, uuid, 36); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
644 | free(uuid); |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
645 | break; |
445
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
646 | case 7: toggleYesNo(&unit->hlt_heater_mltfirst, (char *)"MLT heat b4 HLT"); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
647 | break; |
448 | 648 | case 8: editInteger(&unit->pump_cycle, 5, 15, 1, (char *)"Pump cycle", (char *)"mins"); |
445
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
649 | break; |
448 | 650 | case 9: editInteger(&unit->pump_rest, 1, 5, 1, (char *)"Pump rest ", (char *)"mins"); |
445
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
651 | break; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
652 | case 10: toggleYesNo(&unit->pump_premash, (char *)" Pump pre-mash"); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
653 | break; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
654 | case 11: toggleYesNo(&unit->pump_onmash, (char *)" Pump on-mash"); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
655 | break; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
656 | case 12: toggleYesNo(&unit->pump_mashout, (char *)" Pump mashout"); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
657 | break; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
658 | case 13: toggleYesNo(&unit->pump_onboil, (char *)" Pump on-boil"); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
659 | break; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
660 | case 14: editFloat(&unit->pump_stop, 80.0, 110.0, (char *)" Pump stop"); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
661 | break; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
662 | case 15: toggleYesNo(&unit->skip_add, (char *)"Skip add water"); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
663 | break; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
664 | case 16: toggleYesNo(&unit->skip_remove, (char *)"Skip remove Mash"); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
665 | break; |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
666 | case 17: toggleYesNo(&unit->skip_iodine, (char *)"Skip iodine test"); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
667 | break; |
448 | 668 | case 18: editInteger(&unit->iodine_time, 10, 240, 10, (char *)"Iodine time", (char *)"min"); |
669 | break; | |
445
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
670 | case 19: toggleYesNo(&unit->whirlpool, (char *)"Do a whirlpool"); |
3ec477cda546
Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents:
443
diff
changeset
|
671 | break; |
448 | 672 | case 20: editPID(unit->PID_hlt); |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
673 | break; |
448 | 674 | case 21: editPID(unit->PID_mlt); |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
675 | break; |
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
|
676 | } |
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
|
677 | } |
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
|
678 | } |
442 | 679 | } |
680 | ||
681 | ||
682 | ||
683 | void addUnit(int number) | |
684 | { | |
685 | units_list *tmpu, *unit = (units_list *)malloc(sizeof(units_list)); | |
686 | char name[81]; | |
687 | uuid_t uu; | |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
688 | double Input, Output, Setpoint; |
442 | 689 | |
690 | if (debug) | |
691 | fprintf(stdout, "Adding new brewsystem %d\n", number); | |
692 | unit->next = NULL; | |
693 | unit->version = 1; | |
694 | unit->uuid = malloc(37); | |
695 | uuid_generate(uu); | |
696 | uuid_unparse(uu, unit->uuid); | |
697 | snprintf(name, 20, "System %d", number); | |
698 | unit->name = xstrcpy(name); | |
699 | unit->number = number; | |
700 | if (number == 1) | |
701 | unit->active = 1; | |
702 | else | |
703 | unit->active = 0; | |
449 | 704 | unit->hlt_sensor.uuid = xstrcpy((char *)"00000000-0000-0000-0000-000000000000"); |
705 | unit->hlt_sensor.state = DEVPRESENT_UNDEF; | |
706 | unit->hlt_sensor.value = 0; | |
707 | unit->mlt_sensor.uuid = xstrcpy((char *)"00000000-0000-0000-0000-000000000000"); | |
708 | unit->mlt_sensor.state = DEVPRESENT_UNDEF; | |
709 | unit->mlt_sensor.value = 0; | |
450
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
710 | unit->hlt_heater.uuid = xstrcpy((char *)"00000000-0000-0000-0000-000000000000"); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
711 | unit->hlt_heater.value = 0; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
712 | unit->hlt_heater.delay = 0; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
713 | unit->mlt_heater.uuid = xstrcpy((char *)"00000000-0000-0000-0000-000000000000"); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
714 | unit->mlt_heater.value = 0; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
715 | unit->mlt_heater.delay = 0; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
716 | unit->mlt_pump.uuid = xstrcpy((char *)"00000000-0000-0000-0000-000000000000"); |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
717 | unit->mlt_pump.value = 0; |
8fe99759c27f
Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
718 | unit->mlt_pump.delay = 0; |
442 | 719 | unit->hlt_heater_mltfirst = 1; |
720 | unit->pump_cycle = 7; | |
721 | unit->pump_rest = 2; | |
722 | unit->pump_premash = 1; | |
723 | unit->pump_onmash = 1; | |
724 | unit->pump_mashout = 0; | |
725 | unit->pump_onboil = 0; | |
726 | unit->pump_stop = 90; | |
727 | unit->skip_add = 0; | |
728 | unit->skip_remove = 0; | |
729 | unit->skip_iodine = 0; | |
730 | unit->iodine_time = 90; | |
731 | unit->whirlpool = 1; | |
732 | unit->PID_hlt = (pid_var *)malloc(sizeof(pid_var)); | |
733 | unit->PID_mlt = (pid_var *)malloc(sizeof(pid_var)); | |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
734 | Input = Setpoint = 20.0; |
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
735 | Output = 0; |
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
736 | PID_init(unit->PID_hlt, &Input, &Output, &Setpoint, 2, 5, 1, P_DIRECT); |
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
737 | PID_init(unit->PID_mlt, &Input, &Output, &Setpoint, 2, 5, 1, P_DIRECT); |
442 | 738 | |
739 | editUnit(unit); | |
740 | ||
741 | if (Config.units == NULL) { | |
742 | Config.units = unit; | |
743 | } else { | |
744 | for (tmpu = Config.units; tmpu; tmpu = tmpu->next) { | |
745 | if (tmpu->next == NULL) { | |
746 | tmpu->next = unit; | |
747 | break; | |
748 | } | |
749 | } | |
750 | } | |
751 | syslog(LOG_NOTICE, "Brewsystem %d added to the configuration", number); | |
752 | if (debug) | |
753 | fprintf(stdout, "Brewsystem %d added to the configuration\n", number); | |
754 | } | |
755 | ||
756 | ||
757 | ||
758 | void setup(void) | |
759 | { | |
760 | int key, option = 202; | |
761 | ||
762 | for (;;) { | |
763 | if (debug) | |
764 | fprintf(stdout, "setup() option=%d\n", option); | |
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
|
765 | prompt(0, 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
|
766 | prompt(102, 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
|
767 | prompt(option, NULL); |
442 | 768 | if (option == 202) |
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
|
769 | prompt(402, NULL); |
442 | 770 | #ifdef USE_SIMULATOR |
771 | else if (option == 205) | |
772 | #else | |
773 | else if (option == 204) | |
774 | #endif | |
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
|
775 | prompt(404, NULL); |
442 | 776 | else |
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
|
777 | prompt(403, NULL); |
442 | 778 | |
779 | key = keywait(); | |
780 | ||
781 | if ((key == KEY_RETURN) || my_shutdown) | |
782 | return; | |
783 | if ((key == KEY_UP) && (option > 202)) { | |
784 | option--; | |
785 | } | |
786 | #ifdef USE_SIMULATOR | |
787 | if ((key == KEY_DOWN) && (option < 205)) { | |
788 | #else | |
789 | if ((key == KEY_DOWN) && (option < 204)) { | |
790 | #endif | |
791 | option++; | |
792 | } | |
793 | ||
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
|
794 | if (key == KEY_ENTER) { |
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
|
795 | switch(option) { |
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
|
796 | case 202: // recipes |
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
|
797 | break; |
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
|
798 | case 203: editUnit(Config.units); /* If more units, via a selector */ |
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
|
799 | break; |
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
|
800 | case 204: // devices |
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
|
801 | break; |
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
|
802 | #ifdef USE_SIMULATOR |
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
|
803 | case 205: // simulator |
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
|
804 | break; |
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
|
805 | #endif |
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
|
806 | } |
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
|
807 | if (my_shutdown) |
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
|
808 | return; |
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
|
809 | } |
442 | 810 | } |
811 | } | |
812 | ||
813 |