brewco/setup.c

Sat, 05 Dec 2015 21:46:22 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 05 Dec 2015 21:46:22 +0100
changeset 446
78e9d5234d15
parent 445
3ec477cda546
child 447
b48368855ec4
permissions
-rw-r--r--

Switched to PID code from Arduino

442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*****************************************************************************
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * Copyright (C) 2015
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Michiel Broek <mbroek at mbse dot eu>
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * This file is part of the mbsePi-apps
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 *
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * This is free software; you can redistribute it and/or modify it
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * under the terms of the GNU General Public License as published by the
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * Free Software Foundation; either version 2, or (at your option) any
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * later version.
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 *
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * mbsePi-apps is distributed in the hope that it will be useful, but
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * General Public License for more details.
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 *
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 * along with ThermFerm; see the file COPYING. If not, write to the Free
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 *****************************************************************************/
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 #include "brewco.h"
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 #include "slcd.h"
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 #include "setup.h"
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 #include "prompt.h"
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 #include "xutil.h"
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 #include "keyboard.h"
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 extern int my_shutdown;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 extern int debug;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 extern sys_config Config;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 extern int lcdHandle;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 extern int slcdHandle;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38
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
39 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
40 {
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
41 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
42 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
43 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
44
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 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
46 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
47
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 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
49 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
50 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
51 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
52 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
53 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
54 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
55 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
56 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
57
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 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
59 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
60 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
61 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
62 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
63 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
64 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 }
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 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
67 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
68 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
69 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 }
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 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
72 *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
73 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
74 }
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 void editInteger(int *value, int low, int high, char *text)
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
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
82 int key, 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
83 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
84
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 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
86 prompt(134, 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
87
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
88 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
89 snprintf(pmpt, Config.lcd_cols + 1, "%s: %2d mins", 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
90 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
91 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
92 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
93 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
94 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
95 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
96 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
97
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 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
99 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
100 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
101 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
102 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
103 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
104 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
105 }
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 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
107 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
108 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
109 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
110 }
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 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
112 *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
113 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
114 }
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 }
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 void toggleYesNo(int *value, char *text)
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 {
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
122 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
123 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
124
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
125 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
126 prompt(132, 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
127
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
128 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
129
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
130 snprintf(pmpt, Config.lcd_cols + 1, "%s: %s", text, new ? (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
131 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
132 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
133 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
134 } 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
135 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
136 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
137
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
138 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
139 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
140 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
141 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
142 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
143 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
144 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
145 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
146 *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
147 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
148 }
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
149 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
150 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
151
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
152
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
153
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
154 /*
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
155 * Edit a single unit
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
156 */
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 void editUnit(units_list *unit)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 {
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
159 int index = 1, key;
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
160 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
161
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 if (debug)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 fprintf(stdout, "Start edit brewsystem %d %s\n", unit->number, unit->uuid);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164
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 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
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 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
168
6b80a37fdf8d Added programming display CGRAM. Added display of characters from 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 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
170 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
171
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
172 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
173 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
174 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
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(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
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 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
180 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
181 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
182 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
183 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
184 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
185 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
186 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
187 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
188 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
189 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
190 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
191 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
192 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
193 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
194 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
195 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
196 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
197 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
198 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
199 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
200 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
201 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
202 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
203 case 8: snprintf(pmpt, Config.lcd_cols + 1, "Pump cycle: %2d mins", unit->pump_cycle);
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
204 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
205 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
206 case 9: snprintf(pmpt, Config.lcd_cols + 1, "Pump rest : %2d mins", unit->pump_rest);
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
207 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
208 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
209 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
210 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
211 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
212 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
213 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
214 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
215 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
216 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
217 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
218 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
219 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
220 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
221 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
222 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
223 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
224 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
225 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
226 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
227 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
228 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
229 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
230 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
231 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
232 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
233 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
234 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
235 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
236 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
237 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
238 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
239 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
240 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
241 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
242 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
243 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
244 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
245 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
246
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
247 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
248 if ((key == KEY_RETURN) || 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
249 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
250
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
251 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
252 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
253 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
254 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
255
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
256 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
257 switch(index) {
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
258 case 1: // name
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
259 break;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
260 case 2: // HLT sensor
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
261 break;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
262 case 3: // HLT heater
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
263 break;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
264 case 4: // MLT sensor
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
265 break;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
266 case 5: // MLT heater
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
267 break;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
268 case 6: // MLT pump
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
269 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
270 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
271 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
272 case 8: editInteger(&unit->pump_cycle, 5, 15, (char *)"Pump cycle");
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
273 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
274 case 9: editInteger(&unit->pump_rest, 1, 5, (char *)"Pump rest ");
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
275 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
276 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
277 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
278 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
279 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
280 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
281 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
282 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
283 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
284 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
285 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
286 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
287 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
288 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
289 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
290 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
291 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
292 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
293 break;
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
294 case 20: // PID_hlt
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
295 break;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
296 case 21: // PID_mlt
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
297 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
298 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
299 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
300 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
301
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
302 if (debug)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
303 fprintf(stdout, "End edit brewsystem %d %s\n", unit->number, unit->uuid);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
304 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
305
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
306
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
307
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
308 void addUnit(int number)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
309 {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
310 units_list *tmpu, *unit = (units_list *)malloc(sizeof(units_list));
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
311 char name[81];
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
312 uuid_t uu;
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
313 double Input, Output, Setpoint;
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
314
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
315 if (debug)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
316 fprintf(stdout, "Adding new brewsystem %d\n", number);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
317 unit->next = NULL;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
318 unit->version = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
319 unit->uuid = malloc(37);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
320 uuid_generate(uu);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
321 uuid_unparse(uu, unit->uuid);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
322 snprintf(name, 20, "System %d", number);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
323 unit->name = xstrcpy(name);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
324 unit->number = number;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
325 if (number == 1)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
326 unit->active = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
327 else
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
328 unit->active = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
329 unit->hlt_sensor = unit->mlt_sensor = NULL;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
330 unit->hlt_heater = unit->mlt_heater = unit->mlt_pump = NULL;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
331 unit->hlt_heater_mltfirst = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
332 unit->pump_cycle = 7;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
333 unit->pump_rest = 2;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
334 unit->pump_premash = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
335 unit->pump_onmash = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
336 unit->pump_mashout = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
337 unit->pump_onboil = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
338 unit->pump_stop = 90;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
339 unit->skip_add = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
340 unit->skip_remove = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
341 unit->skip_iodine = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
342 unit->iodine_time = 90;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
343 unit->whirlpool = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
344 unit->PID_hlt = (pid_var *)malloc(sizeof(pid_var));
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
345 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
346 Input = Setpoint = 20.0;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
347 Output = 0;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
348 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
349 PID_init(unit->PID_mlt, &Input, &Output, &Setpoint, 2, 5, 1, P_DIRECT);
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
350
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
351 editUnit(unit);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
352
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
353 if (Config.units == NULL) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
354 Config.units = unit;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
355 } else {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
356 for (tmpu = Config.units; tmpu; tmpu = tmpu->next) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
357 if (tmpu->next == NULL) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
358 tmpu->next = unit;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
359 break;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
360 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
361 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
362 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
363 syslog(LOG_NOTICE, "Brewsystem %d added to the configuration", number);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
364 if (debug)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
365 fprintf(stdout, "Brewsystem %d added to the configuration\n", number);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
366 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
367
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
368
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
369
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
370 void setup(void)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
371 {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
372 int key, option = 202;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
373
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
374 for (;;) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
375 if (debug)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
376 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
377 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
378 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
379 prompt(option, NULL);
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
380 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
381 prompt(402, NULL);
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
382 #ifdef USE_SIMULATOR
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
383 else if (option == 205)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
384 #else
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
385 else if (option == 204)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
386 #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
387 prompt(404, NULL);
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
388 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
389 prompt(403, NULL);
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
390
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
391 key = keywait();
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
392
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
393 if ((key == KEY_RETURN) || my_shutdown)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
394 return;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
395 if ((key == KEY_UP) && (option > 202)) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
396 option--;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
397 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
398 #ifdef USE_SIMULATOR
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
399 if ((key == KEY_DOWN) && (option < 205)) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
400 #else
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
401 if ((key == KEY_DOWN) && (option < 204)) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
402 #endif
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
403 option++;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
404 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
405
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
406 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
407 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
408 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
409 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
410 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
411 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
412 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
413 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
414 #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
415 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
416 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
417 #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
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 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
420 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
421 }
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
422 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
423 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
424
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
425

mercurial