Sun, 06 Dec 2015 19:34:39 +0100
Added selecting sensors.
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 | ||
397 | void editRelay(switch_var *relay, char *text) | |
398 | { | |
399 | } | |
400 | ||
401 | ||
402 | ||
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
403 | /* |
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
404 | * Edit a single unit |
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
405 | */ |
442 | 406 | void editUnit(units_list *unit) |
407 | { | |
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
|
408 | int index = 1, key; |
449 | 409 | char pmpt[81], *uuid; |
447
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
410 | 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
|
411 | |
442 | 412 | if (debug) |
413 | fprintf(stdout, "Start edit brewsystem %d %s\n", unit->number, unit->uuid); | |
414 | ||
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
|
415 | prompt(0, NULL); |
447
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
416 | ncrc = ocrc = crc32(0L, Z_NULL, 0); |
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
417 | 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
|
418 | |
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
|
419 | 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
|
420 | |
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
|
421 | 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
|
422 | 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
|
423 | |
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
|
424 | 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
|
425 | 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
|
426 | 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
|
427 | 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
|
428 | 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
|
429 | 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
|
430 | |
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
|
431 | 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
|
432 | 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
|
433 | 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
|
434 | 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
|
435 | 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
|
436 | 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
|
437 | 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
|
438 | 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
|
439 | 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
|
440 | 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
|
441 | 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
|
442 | 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
|
443 | 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
|
444 | 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
|
445 | 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
|
446 | 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
|
447 | 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
|
448 | 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
|
449 | 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
|
450 | 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
|
451 | 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
|
452 | 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
|
453 | 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
|
454 | break; |
448 | 455 | 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
|
456 | 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
|
457 | break; |
448 | 458 | 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
|
459 | 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
|
460 | 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
|
461 | 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
|
462 | 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
|
463 | 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
|
464 | 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
|
465 | 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
|
466 | 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
|
467 | 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
|
468 | 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
|
469 | 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
|
470 | 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
|
471 | 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
|
472 | 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
|
473 | 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
|
474 | 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
|
475 | 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
|
476 | 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
|
477 | 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
|
478 | 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
|
479 | 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
|
480 | 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
|
481 | 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
|
482 | 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
|
483 | 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
|
484 | 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
|
485 | 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
|
486 | 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
|
487 | 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
|
488 | 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
|
489 | 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
|
490 | 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
|
491 | 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
|
492 | 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
|
493 | 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
|
494 | 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
|
495 | 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
|
496 | 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
|
497 | } |
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
|
498 | |
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
|
499 | key = keywait(); |
447
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
500 | if ((key == KEY_RETURN) || my_shutdown) { |
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
501 | 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
|
502 | if (ocrc != ncrc) |
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
503 | wrconfig(); |
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
504 | if (debug) |
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
505 | 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
|
506 | return; |
447
b48368855ec4
Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
507 | } |
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
|
508 | |
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
|
509 | 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
|
510 | 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
|
511 | 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
|
512 | 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
|
513 | |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
514 | 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
|
515 | switch(index) { |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
516 | case 1: // name |
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
517 | break; |
449 | 518 | case 2: uuid = xstrcpy(unit->hlt_sensor.uuid); |
519 | editSensor(uuid, (char *)"HLT sensor"); | |
520 | strncpy(unit->hlt_sensor.uuid, uuid, 36); | |
521 | free(uuid); | |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
522 | break; |
449 | 523 | case 3: editRelay(unit->hlt_heater, (char *)"HLT heater"); |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
524 | break; |
449 | 525 | case 4: uuid = xstrcpy(unit->mlt_sensor.uuid); |
526 | editSensor(uuid, (char *)"MLT sensor"); | |
527 | strncpy(unit->mlt_sensor.uuid, uuid, 36); | |
528 | free(uuid); | |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
529 | break; |
449 | 530 | case 5: editRelay(unit->mlt_heater, (char *)"MLT heater"); |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
531 | break; |
449 | 532 | case 6: editRelay(unit->mlt_pump, (char *)"MLT pump"); |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
533 | 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
|
534 | 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
|
535 | break; |
448 | 536 | 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
|
537 | break; |
448 | 538 | 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
|
539 | 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
|
540 | 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
|
541 | 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
|
542 | 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
|
543 | 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
|
544 | 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
|
545 | 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
|
546 | 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
|
547 | 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
|
548 | 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
|
549 | 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
|
550 | 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
|
551 | 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
|
552 | 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
|
553 | 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
|
554 | 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
|
555 | break; |
448 | 556 | case 18: editInteger(&unit->iodine_time, 10, 240, 10, (char *)"Iodine time", (char *)"min"); |
557 | 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
|
558 | 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
|
559 | break; |
448 | 560 | case 20: editPID(unit->PID_hlt); |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
561 | break; |
448 | 562 | case 21: editPID(unit->PID_mlt); |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
563 | 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
|
564 | } |
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 | } |
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 | } |
442 | 567 | } |
568 | ||
569 | ||
570 | ||
571 | void addUnit(int number) | |
572 | { | |
573 | units_list *tmpu, *unit = (units_list *)malloc(sizeof(units_list)); | |
574 | char name[81]; | |
575 | uuid_t uu; | |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
576 | double Input, Output, Setpoint; |
442 | 577 | |
578 | if (debug) | |
579 | fprintf(stdout, "Adding new brewsystem %d\n", number); | |
580 | unit->next = NULL; | |
581 | unit->version = 1; | |
582 | unit->uuid = malloc(37); | |
583 | uuid_generate(uu); | |
584 | uuid_unparse(uu, unit->uuid); | |
585 | snprintf(name, 20, "System %d", number); | |
586 | unit->name = xstrcpy(name); | |
587 | unit->number = number; | |
588 | if (number == 1) | |
589 | unit->active = 1; | |
590 | else | |
591 | unit->active = 0; | |
449 | 592 | unit->hlt_sensor.uuid = xstrcpy((char *)"00000000-0000-0000-0000-000000000000"); |
593 | unit->hlt_sensor.state = DEVPRESENT_UNDEF; | |
594 | unit->hlt_sensor.value = 0; | |
595 | unit->mlt_sensor.uuid = xstrcpy((char *)"00000000-0000-0000-0000-000000000000"); | |
596 | unit->mlt_sensor.state = DEVPRESENT_UNDEF; | |
597 | unit->mlt_sensor.value = 0; | |
442 | 598 | unit->hlt_heater = unit->mlt_heater = unit->mlt_pump = NULL; |
599 | unit->hlt_heater_mltfirst = 1; | |
600 | unit->pump_cycle = 7; | |
601 | unit->pump_rest = 2; | |
602 | unit->pump_premash = 1; | |
603 | unit->pump_onmash = 1; | |
604 | unit->pump_mashout = 0; | |
605 | unit->pump_onboil = 0; | |
606 | unit->pump_stop = 90; | |
607 | unit->skip_add = 0; | |
608 | unit->skip_remove = 0; | |
609 | unit->skip_iodine = 0; | |
610 | unit->iodine_time = 90; | |
611 | unit->whirlpool = 1; | |
612 | unit->PID_hlt = (pid_var *)malloc(sizeof(pid_var)); | |
613 | 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
|
614 | Input = Setpoint = 20.0; |
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
615 | Output = 0; |
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
445
diff
changeset
|
616 | 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
|
617 | PID_init(unit->PID_mlt, &Input, &Output, &Setpoint, 2, 5, 1, P_DIRECT); |
442 | 618 | |
619 | editUnit(unit); | |
620 | ||
621 | if (Config.units == NULL) { | |
622 | Config.units = unit; | |
623 | } else { | |
624 | for (tmpu = Config.units; tmpu; tmpu = tmpu->next) { | |
625 | if (tmpu->next == NULL) { | |
626 | tmpu->next = unit; | |
627 | break; | |
628 | } | |
629 | } | |
630 | } | |
631 | syslog(LOG_NOTICE, "Brewsystem %d added to the configuration", number); | |
632 | if (debug) | |
633 | fprintf(stdout, "Brewsystem %d added to the configuration\n", number); | |
634 | } | |
635 | ||
636 | ||
637 | ||
638 | void setup(void) | |
639 | { | |
640 | int key, option = 202; | |
641 | ||
642 | for (;;) { | |
643 | if (debug) | |
644 | 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
|
645 | 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
|
646 | 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
|
647 | prompt(option, NULL); |
442 | 648 | 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
|
649 | prompt(402, NULL); |
442 | 650 | #ifdef USE_SIMULATOR |
651 | else if (option == 205) | |
652 | #else | |
653 | else if (option == 204) | |
654 | #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
|
655 | prompt(404, NULL); |
442 | 656 | 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
|
657 | prompt(403, NULL); |
442 | 658 | |
659 | key = keywait(); | |
660 | ||
661 | if ((key == KEY_RETURN) || my_shutdown) | |
662 | return; | |
663 | if ((key == KEY_UP) && (option > 202)) { | |
664 | option--; | |
665 | } | |
666 | #ifdef USE_SIMULATOR | |
667 | if ((key == KEY_DOWN) && (option < 205)) { | |
668 | #else | |
669 | if ((key == KEY_DOWN) && (option < 204)) { | |
670 | #endif | |
671 | option++; | |
672 | } | |
673 | ||
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
|
674 | 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
|
675 | 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
|
676 | 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
|
677 | 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
|
678 | 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
|
679 | 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
|
680 | 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
|
681 | 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
|
682 | #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
|
683 | 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
|
684 | 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
|
685 | #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
|
686 | } |
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
|
687 | 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
|
688 | 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
|
689 | } |
442 | 690 | } |
691 | } | |
692 | ||
693 |