brewco/setup.c

Tue, 15 Dec 2015 23:11:42 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 15 Dec 2015 23:11:42 +0100
changeset 459
1f88be70f253
parent 458
43a8ecb53637
child 461
482bab226340
permissions
-rw-r--r--

Added the beginning of the recipes editor. Added load and save of recipes file.

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"
447
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
29 #include "rdconfig.h"
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
30 #include "rdrecipes.h"
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 extern int my_shutdown;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 extern int debug;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 extern sys_config Config;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 extern int lcdHandle;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 extern int slcdHandle;
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
38 extern a_recipe *recipes;
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
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 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
43 {
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
44 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
45 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
46 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
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 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
49 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
50
3ec477cda546 Changed internal storage of temperatures to float. Added 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 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
52 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
53 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
54 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
55 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
56 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
57 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
58 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
59 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
60
3ec477cda546 Changed internal storage of temperatures to float. Added 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 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
62 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
63 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
64 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
65 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
66 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
67 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
68 }
3ec477cda546 Changed internal storage of temperatures to float. Added 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 (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
70 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
71 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
72 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
73 }
3ec477cda546 Changed internal storage of temperatures to float. Added 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 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
75 *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
76 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
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
3ec477cda546 Changed internal storage of temperatures to float. Added 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
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
83 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
84 {
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
85 int key;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
86 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
87 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
88
3ec477cda546 Changed internal storage of temperatures to float. Added 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 prompt(0, NULL);
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
90 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
91
3ec477cda546 Changed internal storage of temperatures to float. Added 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 for (;;) {
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
93 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
94 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
95 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
96 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
97 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
98 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
99 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
100 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
101
3ec477cda546 Changed internal storage of temperatures to float. Added 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 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
103 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
104 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
105 if (key == KEY_UP) {
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
106 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
107 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
108 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
109 }
3ec477cda546 Changed internal storage of temperatures to float. Added 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 (key == KEY_DOWN) {
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
111 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
112 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
113 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
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 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
116 *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
117 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
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
3ec477cda546 Changed internal storage of temperatures to float. Added 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
3ec477cda546 Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
123
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
124 void editInteger(int *value, int low, int high, int step, char *text, char *text2)
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
125 {
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
126 int key, new = *value;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
127 char pmpt[81];
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
128
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
129 prompt(0, NULL);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
130 prompt(134, NULL);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
131
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
132 for (;;) {
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
133 snprintf(pmpt, Config.lcd_cols + 1, "%s: %3d %s", text, new, text2);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
134 prompt(200, pmpt);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
135 if (new == low)
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
136 prompt(404, NULL);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
137 else if (new == high)
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
138 prompt(402, NULL);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
139 else
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
140 prompt(403, NULL);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
141
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
142 key = keywait();
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
143 if ((key == KEY_RETURN) || my_shutdown)
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
144 return;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
145 if (key == KEY_UP) {
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
146 new += step;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
147 if (new > high)
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
148 new = high;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
149 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
150 if (key == KEY_DOWN) {
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
151 new -= step;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
152 if (new < low)
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
153 new = low;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
154 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
155 if (key == KEY_ENTER) {
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
156 *value = new;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
157 return;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
158 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
159 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
160 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
161
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
162
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
163
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
164 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
165 {
3ec477cda546 Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
166 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
167 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
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);
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
170 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
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 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
173
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
174 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
175 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
176 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
177 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
178 } 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
179 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
180 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from 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
6b80a37fdf8d Added programming display CGRAM. Added display of characters from 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 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
183 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
184 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
185 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
186 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
187 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
188 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
189 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
190 *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
191 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
192 }
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
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
6b80a37fdf8d Added programming display CGRAM. Added display of characters from 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
6b80a37fdf8d Added programming display CGRAM. Added display of characters from 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
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
198 void toggleYesNo(int *value, char *text)
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
199 {
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
200 togglePmpts(value, text, 132, (char *)"Yes", (char *)"No ");
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
201 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
202
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
203
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
204
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
205 void toggleDirection(int *value, char *text)
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
206 {
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
207 togglePmpts(value, text, 137, (char *)"Reverse", (char *)"Direct ");
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
208 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
209
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
210
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
211
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
212 void editPID(pid_var *pid)
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
213 {
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
214 int idx = 1, key, val;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
215 char pmpt[81];
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
216 double Kp, Ki, Kd;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
217
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
218 if (debug)
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
219 fprintf(stdout, "editPID()\n");
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
220
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
221 for (;;) {
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
222 prompt(0, NULL);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
223 prompt(135, NULL);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
224
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
225 if (idx == 1)
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
226 prompt(402, NULL);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
227 else if (idx == 5)
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
228 prompt(404, NULL);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
229 else
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
230 prompt(403, NULL);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
231
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
232 switch (idx) {
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
233 case 1: snprintf(pmpt, Config.lcd_cols + 1, "PID Kp: %5.2f", PID_getKp(pid));
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
234 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
235 case 2: snprintf(pmpt, Config.lcd_cols + 1, "PID Ki: %5.2f", PID_getKi(pid));
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
236 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
237 case 3: snprintf(pmpt, Config.lcd_cols + 1, "PID Kd: %5.2f", PID_getKd(pid));
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
238 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
239 case 4: snprintf(pmpt, Config.lcd_cols + 1, "SampleTime: %3d mSec", PID_getSampleTime(pid));
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
240 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
241 case 5: snprintf(pmpt, Config.lcd_cols + 1, "Direction: %s", PID_getDirection(pid) ? (char *)"Reverse" : (char *)"Direct");
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
242 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
243 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
244 prompt(200, pmpt);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
245
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
246 key = keywait();
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
247 if ((key == KEY_RETURN) || my_shutdown) {
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
248 if (debug)
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
249 fprintf(stdout, "End editPID\n");
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
250 return;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
251 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
252
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
253 if ((key == KEY_UP) && (idx > 1))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
254 idx--;
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
255 if ((key == KEY_DOWN) && (idx < 5))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
256 idx++;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
257
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
258 if (key == KEY_ENTER) {
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
259
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
260 Kp = PID_getKp(pid);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
261 Ki = PID_getKi(pid);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
262 Kd = PID_getKd(pid);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
263
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
264 switch(idx) {
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
265 case 1: editDouble(&Kp, 0.5, 50, (char *)"PID Kp");
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
266 PID_setTunings(pid, Kp, Ki, Kd);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
267 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
268 case 2: editDouble(&Ki, 0.5, 50, (char *)"PID Ki");
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
269 PID_setTunings(pid, Kp, Ki, Kd);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
270 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
271 case 3: editDouble(&Kd, 0.5, 50, (char *)"PID Kd");
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
272 PID_setTunings(pid, Kp, Ki, Kd);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
273 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
274 case 4: val = PID_getSampleTime(pid);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
275 editInteger(&val, 50, 500, 10, (char *)"SampleTime", (char *)"mSec");
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
276 PID_setSampleTime(pid, val);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
277 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
278 case 5: val = PID_getDirection(pid);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
279 toggleDirection(&val, (char *)"Direction");
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
280 PID_setDirection(pid, val);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
281 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
282 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
283 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
284 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
285 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
286
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
287
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
288
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
289 void editSensor(char *uuid, char *text)
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
290 {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
291 char pmpt[81];
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
292 int i, old, choices, idx = 1, key;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
293 devices_list *device;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
294
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
295 if (debug)
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
296 fprintf(stdout, "editSensor(%s, %s)\n", uuid, text);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
297
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
298 old = 1; // 1d0e5bb8-7408-48b9-abb4-e9041d7b99fe
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
299 if ((i = strcmp((char *)"00000000-0000-0000-0000-000000000000", uuid))) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
300 for (device = Config.devices; device; device = device->next) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
301 if (device->direction == DEVDIR_IN_ANALOG) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
302 old++;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
303 if (strcmp(device->uuid, uuid) == 0)
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
304 break;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
305 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
306 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
307 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
308
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
309 if (debug)
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
310 fprintf(stdout, "editSensor(%s) old sensor index=%d\n", text, old);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
311
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
312 for (;;) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
313 prompt(0, NULL);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
314 snprintf(pmpt, Config.lcd_cols + 1, "Edit %s", text);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
315 prompt(100, pmpt);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
316
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
317 /*
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
318 * Count valid sensors
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
319 */
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
320 choices = 1;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
321 if (old == 1) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
322 snprintf(pmpt, Config.lcd_cols + 1, "N/A");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
323 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
324 for (device = Config.devices; device; device = device->next) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
325 if (device->direction == DEVDIR_IN_ANALOG) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
326 choices++;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
327 if (choices == old) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
328 snprintf(pmpt, Config.lcd_cols + 1, "%s", device->description);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
329 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
330 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
331 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
332 prompt(200, pmpt); /* Display current sensor */
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
333 i = 1;
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
334 if (idx == 1) {
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
335 snprintf(pmpt, Config.lcd_cols + 1, "N/A");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
336 } else {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
337 for (device = Config.devices; device; device = device->next) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
338 if (device->direction == DEVDIR_IN_ANALOG) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
339 i++;
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
340 if (i == idx) {
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
341 snprintf(pmpt, Config.lcd_cols + 1, "%s", device->description);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
342 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
343 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
344 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
345 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
346 prompt(300, pmpt); /* Display possible new sensor */
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
347
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
348
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
349 if (choices == 1)
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
350 prompt(405, NULL);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
351 else if (idx == 1)
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
352 prompt(402, NULL);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
353 else if (idx == choices)
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
354 prompt(404, NULL);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
355 else
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
356 prompt(403, NULL);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
357
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
358 key = keywait();
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
359 if ((key == KEY_RETURN) || my_shutdown) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
360 if (debug)
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
361 fprintf(stdout, "End editSensor\n");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
362 return;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
363 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
364
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
365 if ((key == KEY_UP) && (idx > 1))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
366 idx--;
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
367 if ((key == KEY_DOWN) && (idx < choices))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
368 idx++;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
369
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
370 if ((key == KEY_ENTER) && (idx != old)) {
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
371 /*
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
372 * Select new sensor.
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
373 */
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
374 if (idx == 1) {
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
375 /*
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
376 * Disable the sensor
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
377 */
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
378 strncpy(uuid, (char *)"00000000-0000-0000-0000-000000000000", 36);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
379 old = idx;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
380 } else {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
381 i = 1;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
382 for (device = Config.devices; device; device = device->next) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
383 if (device->direction == DEVDIR_IN_ANALOG) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
384 i++;
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
385 if (i == idx) {
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
386 strncpy(uuid, device->uuid, 36);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
387 break;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
388 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
389 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
390 }
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
391 old = idx;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
392 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
393 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
394 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
395 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
396
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
397
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
398
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
399 void editRelay(char *uuid, char *text)
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
400 {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
401 char pmpt[81];
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
402 int i, old, choices, idx = 1, key;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
403 devices_list *device;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
404
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
405 if (debug)
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
406 fprintf(stdout, "editRelay(%s, %s)\n", uuid, text);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
407
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
408 old = 1; // 1d0e5bb8-7408-48b9-abb4-e9041d7b99fe
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
409 if ((i = strcmp((char *)"00000000-0000-0000-0000-000000000000", uuid))) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
410 for (device = Config.devices; device; device = device->next) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
411 if (device->direction == DEVDIR_OUT_ANALOG) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
412 old++;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
413 if (strcmp(device->uuid, uuid) == 0)
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
414 break;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
415 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
416 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
417 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
418
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
419 if (debug)
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
420 fprintf(stdout, "editRelay(%s) old sensor index=%d\n", text, old);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
421
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
422 for (;;) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
423 prompt(0, NULL);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
424 snprintf(pmpt, Config.lcd_cols + 1, "Edit %s", text);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
425 prompt(100, pmpt);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
426
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
427 /*
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
428 * Count valid sensors
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
429 */
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
430 choices = 1;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
431 if (old == 1) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
432 snprintf(pmpt, Config.lcd_cols + 1, "N/A");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
433 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
434 for (device = Config.devices; device; device = device->next) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
435 if (device->direction == DEVDIR_OUT_ANALOG) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
436 choices++;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
437 if (choices == old) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
438 snprintf(pmpt, Config.lcd_cols + 1, "%s", device->description);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
439 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
440 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
441 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
442 prompt(200, pmpt); /* Display current relay */
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
443 i = 1;
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
444 if (idx == 1) {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
445 snprintf(pmpt, Config.lcd_cols + 1, "N/A");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
446 } else {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
447 for (device = Config.devices; device; device = device->next) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
448 if (device->direction == DEVDIR_OUT_ANALOG) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
449 i++;
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
450 if (i == idx) {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
451 snprintf(pmpt, Config.lcd_cols + 1, "%s", device->description);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
452 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
453 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
454 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
455 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
456 prompt(300, pmpt); /* Display possible new relay */
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
457
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
458 if (choices == 1)
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
459 prompt(405, NULL);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
460 else if (idx == 1)
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
461 prompt(402, NULL);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
462 else if (idx == choices)
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
463 prompt(404, NULL);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
464 else
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
465 prompt(403, NULL);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
466
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
467 key = keywait();
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
468 if ((key == KEY_RETURN) || my_shutdown) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
469 if (debug)
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
470 fprintf(stdout, "End editRelay\n");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
471 return;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
472 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
473
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
474 if ((key == KEY_UP) && (idx > 1))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
475 idx--;
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
476 if ((key == KEY_DOWN) && (idx < choices))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
477 idx++;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
478
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
479 if ((key == KEY_ENTER) && (idx != old)) {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
480 /*
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
481 * Select new output.
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
482 */
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
483 if (idx == 1) {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
484 /*
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
485 * Disable the output
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
486 */
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
487 strncpy(uuid, (char *)"00000000-0000-0000-0000-000000000000", 36);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
488 old = idx;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
489 } else {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
490 i = 1;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
491 for (device = Config.devices; device; device = device->next) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
492 if (device->direction == DEVDIR_OUT_ANALOG) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
493 i++;
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
494 if (i == idx) {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
495 strncpy(uuid, device->uuid, 36);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
496 break;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
497 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
498 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
499 }
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
500 old = idx;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
501 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
502 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
503 }
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
504 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
505
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
506
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
507
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
508 /*
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
509 * Edit a single unit
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
510 */
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
511 void editUnit(units_list *unit)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
512 {
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
513 int idx = 1, key;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
514 char pmpt[81], *uuid;
447
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
515 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
516
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
517 if (debug)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
518 fprintf(stdout, "Start edit brewsystem %d %s\n", unit->number, unit->uuid);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
519
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
520 prompt(0, NULL);
447
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
521 ncrc = ocrc = crc32(0L, Z_NULL, 0);
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
522 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
523
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
524 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
525
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
526 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
527 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
528
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
529 if (idx == 1)
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
530 prompt(402, NULL);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
531 else if (idx == 21)
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
532 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
533 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
534 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
535
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
536 switch (idx) { // 12345678901234567890
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
537 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
538 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
539 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
540 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
541 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
542 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
543 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
544 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
545 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
546 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
547 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
548 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
549 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
550 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
551 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
552 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
553 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
554 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
555 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
556 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
557 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
558 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
559 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
560 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
561 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
562 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
563 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
564 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
565 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
566 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
567 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
568 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
569 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
570 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
571 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
572 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
573 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
574 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
575 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
576 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
577 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
578 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
579 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
580 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
581 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
582 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
583 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
584 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
585 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
586 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
587 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
588 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
589 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
590 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
591 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
592 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
593 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
594 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
595 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
596 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
597 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
598 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
599 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
600 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
601 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
602 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
603
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
604 key = keywait();
447
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
605 if ((key == KEY_RETURN) || my_shutdown) {
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
606 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
607 if (ocrc != ncrc)
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
608 wrconfig();
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
609 if (debug)
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
610 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
611 return;
447
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
612 }
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
613
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
614 if ((key == KEY_UP) && (idx > 1))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
615 idx--;
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
616 if ((key == KEY_DOWN) && (idx < 21))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
617 idx++;
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
618
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
619 if (key == KEY_ENTER) {
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
620 switch(idx) {
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
621 case 1: // name
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
622 break;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
623 case 2: uuid = xstrcpy(unit->hlt_sensor.uuid);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
624 editSensor(uuid, (char *)"HLT sensor");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
625 strncpy(unit->hlt_sensor.uuid, uuid, 36);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
626 free(uuid);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
627 break;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
628 case 3: uuid = xstrcpy(unit->hlt_heater.uuid);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
629 editRelay(uuid, (char *)"HLT heater");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
630 strncpy(unit->hlt_heater.uuid, uuid, 36);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
631 free(uuid);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
632 break;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
633 case 4: uuid = xstrcpy(unit->mlt_sensor.uuid);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
634 editSensor(uuid, (char *)"MLT sensor");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
635 strncpy(unit->mlt_sensor.uuid, uuid, 36);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
636 free(uuid);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
637 break;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
638 case 5: uuid = xstrcpy(unit->mlt_heater.uuid);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
639 editRelay(uuid, (char *)"MLT heater");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
640 strncpy(unit->mlt_heater.uuid, uuid, 36);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
641 free(uuid);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
642 break;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
643 case 6: uuid = xstrcpy(unit->mlt_pump.uuid);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
644 editRelay(uuid, (char *)"MLT pump");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
645 strncpy(unit->mlt_pump.uuid, uuid, 36);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
646 free(uuid);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
647 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
648 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
649 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
650 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
651 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
652 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
653 break;
3ec477cda546 Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
654 case 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
655 break;
3ec477cda546 Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
656 case 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
657 break;
3ec477cda546 Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
658 case 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
659 break;
3ec477cda546 Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
660 case 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
661 break;
3ec477cda546 Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
662 case 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
663 break;
3ec477cda546 Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
664 case 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
665 break;
3ec477cda546 Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
666 case 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
667 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
668 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
669 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
670 case 18: editInteger(&unit->iodine_time, 10, 240, 10, (char *)"Iodine time", (char *)"min");
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
671 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
672 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
673 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
674 case 20: editPID(unit->PID_hlt);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
675 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
676 case 21: editPID(unit->PID_mlt);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
677 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
678 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from 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 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from 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 }
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
681 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
682
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
683
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
684
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
685 void addUnit(int number)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
686 {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
687 units_list *tmpu, *unit = (units_list *)malloc(sizeof(units_list));
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
688 char name[81];
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
689 uuid_t uu;
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
690 double Input, Output, Setpoint;
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
691
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
692 if (debug)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
693 fprintf(stdout, "Adding new brewsystem %d\n", number);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
694 unit->next = NULL;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
695 unit->version = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
696 unit->uuid = malloc(37);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
697 uuid_generate(uu);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
698 uuid_unparse(uu, unit->uuid);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
699 snprintf(name, 20, "System %d", number);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
700 unit->name = xstrcpy(name);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
701 unit->number = number;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
702 if (number == 1)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
703 unit->active = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
704 else
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
705 unit->active = 0;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
706 unit->hlt_sensor.uuid = xstrcpy((char *)"00000000-0000-0000-0000-000000000000");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
707 unit->hlt_sensor.state = DEVPRESENT_UNDEF;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
708 unit->hlt_sensor.value = 0;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
709 unit->mlt_sensor.uuid = xstrcpy((char *)"00000000-0000-0000-0000-000000000000");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
710 unit->mlt_sensor.state = DEVPRESENT_UNDEF;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
711 unit->mlt_sensor.value = 0;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
712 unit->hlt_heater.uuid = xstrcpy((char *)"00000000-0000-0000-0000-000000000000");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
713 unit->hlt_heater.value = 0;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
714 unit->hlt_heater.delay = 0;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
715 unit->mlt_heater.uuid = xstrcpy((char *)"00000000-0000-0000-0000-000000000000");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
716 unit->mlt_heater.value = 0;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
717 unit->mlt_heater.delay = 0;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
718 unit->mlt_pump.uuid = xstrcpy((char *)"00000000-0000-0000-0000-000000000000");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
719 unit->mlt_pump.value = 0;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
720 unit->mlt_pump.delay = 0;
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
721 unit->hlt_heater_mltfirst = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
722 unit->pump_cycle = 7;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
723 unit->pump_rest = 2;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
724 unit->pump_premash = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
725 unit->pump_onmash = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
726 unit->pump_mashout = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
727 unit->pump_onboil = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
728 unit->pump_stop = 90;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
729 unit->skip_add = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
730 unit->skip_remove = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
731 unit->skip_iodine = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
732 unit->iodine_time = 90;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
733 unit->whirlpool = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
734 unit->PID_hlt = (pid_var *)malloc(sizeof(pid_var));
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
735 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
736 Input = Setpoint = 20.0;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
737 Output = 0;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
738 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
739 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
740
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
741 editUnit(unit);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
742
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
743 if (Config.units == NULL) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
744 Config.units = unit;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
745 } else {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
746 for (tmpu = Config.units; tmpu; tmpu = tmpu->next) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
747 if (tmpu->next == NULL) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
748 tmpu->next = unit;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
749 break;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
750 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
751 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
752 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
753 syslog(LOG_NOTICE, "Brewsystem %d added to the configuration", number);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
754 if (debug)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
755 fprintf(stdout, "Brewsystem %d added to the configuration\n", number);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
756 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
757
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
758
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
759
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
760 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
761 * Edit a single recipe
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
762 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
763 void editRecipe(a_recipe *recipe)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
764 {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
765 int idx = 1, key;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
766 char pmpt[81];
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
767 uLong ocrc, ncrc;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
768
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
769 if (debug)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
770 fprintf(stdout, "Start edit recipe `%s' %s\n", recipe->name, recipe->uuid);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
771
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
772 prompt(0, NULL);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
773 ncrc = ocrc = crc32(0L, Z_NULL, 0);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
774 ocrc = crc32(ocrc, (const Bytef *) recipe, sizeof(a_recipe));
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
775
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
776 for (;;) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
777
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
778 prompt(0, NULL);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
779 prompt(139, NULL);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
780
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
781 if (idx == 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
782 prompt(402, NULL);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
783 else if (idx == 21)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
784 prompt(404, NULL);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
785 else
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
786 prompt(403, NULL);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
787
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
788 switch (idx) { // 12345678901234567890
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
789 case 1: snprintf(pmpt, Config.lcd_cols + 1, "Recipe name:");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
790 prompt(200, pmpt);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
791 snprintf(pmpt, Config.lcd_cols + 1, "%s", recipe->name);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
792 prompt(300, pmpt);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
793 break;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
794 case 2: snprintf(pmpt, Config.lcd_cols + 1, "Recipe code:");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
795 prompt(200, pmpt);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
796 snprintf(pmpt, Config.lcd_cols + 1, "%s", recipe->code);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
797 prompt(300, pmpt);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
798 break;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
799 case 3: snprintf(pmpt, Config.lcd_cols + 1, "Boil time: %3d mins", recipe->boiltime);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
800 prompt(200, pmpt);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
801 break;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
802 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
803
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
804 key = keywait();
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
805 if ((key == KEY_RETURN) || my_shutdown) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
806 ncrc = crc32(ncrc, (const Bytef *)recipe, sizeof(a_recipe));
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
807 if (ocrc != ncrc)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
808 wrrecipes();
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
809 if (debug)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
810 fprintf(stdout, "End edit recipe `%s' %s\n", recipe->name, recipe->uuid);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
811 return;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
812 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
813
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
814 if ((key == KEY_UP) && (idx > 1))
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
815 idx--;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
816 if ((key == KEY_DOWN) && (idx < 6))
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
817 idx++;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
818
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
819 if (key == KEY_ENTER) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
820 switch(idx) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
821 case 1: // name
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
822 break;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
823 case 2: // code
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
824 break;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
825 case 3: editInteger(&recipe->boiltime, 60, 240, 5, (char *)"Boil time:", (char *)"mins");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
826 break;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
827 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
828 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
829 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
830 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
831
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
832
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
833
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
834 void addRecipe(int number)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
835 {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
836 a_recipe *tmpu, *recipe = (a_recipe *)malloc(sizeof(a_recipe));
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
837 char name[81];
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
838 uuid_t uu;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
839 int i;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
840
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
841 if (debug)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
842 fprintf(stdout, "Adding new recipe %d\n", number);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
843 recipe->next = NULL;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
844 recipe->uuid = malloc(37);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
845 uuid_generate(uu);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
846 uuid_unparse(uu, recipe->uuid);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
847 snprintf(name, 21, "New recipe %d", number);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
848 recipe->name = xstrcpy(name);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
849 snprintf(name, 21, "%04d", number);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
850 recipe->code = xstrcpy(name);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
851 recipe->boiltime = 90;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
852 recipe->starttime = recipe->endtime = (time_t)0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
853 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
854 * Initial mash schedule, set a single-step 67 degr. mash
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
855 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
856 recipe->mash[0].name = xstrcpy((char *)"Mash-in");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
857 recipe->mash[0].min = 20;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
858 recipe->mash[0].max = 80;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
859 recipe->mash[0].canskip = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
860 recipe->mash[0].setpoint = 68.0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
861 recipe->mash[0].skip = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
862 recipe->mash[0].duration = 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
863 recipe->mash[1].name = xstrcpy((char *)"Phytase");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
864 recipe->mash[1].min = 25;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
865 recipe->mash[1].max = 55;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
866 recipe->mash[1].canskip = 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
867 recipe->mash[1].setpoint = 40.0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
868 recipe->mash[1].skip = 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
869 recipe->mash[1].duration = 10;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
870 recipe->mash[2].name = xstrcpy((char *)"Glucanase");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
871 recipe->mash[2].min = 35;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
872 recipe->mash[2].max = 50;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
873 recipe->mash[2].canskip = 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
874 recipe->mash[2].setpoint = 45.0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
875 recipe->mash[2].skip = 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
876 recipe->mash[2].duration = 10;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
877 recipe->mash[3].name = xstrcpy((char *)"Protease");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
878 recipe->mash[3].min = 45;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
879 recipe->mash[3].max = 60;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
880 recipe->mash[3].canskip = 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
881 recipe->mash[3].setpoint = 55.0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
882 recipe->mash[3].skip = 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
883 recipe->mash[3].duration = 10;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
884 recipe->mash[4].name = xstrcpy((char *)"B-Amylase");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
885 recipe->mash[4].min = 50;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
886 recipe->mash[4].max = 70;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
887 recipe->mash[4].canskip = 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
888 recipe->mash[4].setpoint = 62.0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
889 recipe->mash[4].skip = 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
890 recipe->mash[4].duration = 30;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
891 recipe->mash[5].name = xstrcpy((char *)"A-Amylase 1");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
892 recipe->mash[5].min = 60;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
893 recipe->mash[5].max = 76;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
894 recipe->mash[5].canskip = 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
895 recipe->mash[5].setpoint = 67.0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
896 recipe->mash[5].skip = 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
897 recipe->mash[5].duration = 30;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
898 recipe->mash[6].name = xstrcpy((char *)"A-Amylase 2");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
899 recipe->mash[6].min = 60;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
900 recipe->mash[6].max = 76;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
901 recipe->mash[6].canskip = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
902 recipe->mash[6].setpoint = 67.0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
903 recipe->mash[6].skip = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
904 recipe->mash[6].duration = 60;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
905 recipe->mash[7].name = xstrcpy((char *)"Mash-out");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
906 recipe->mash[7].min = 75;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
907 recipe->mash[7].max = 80;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
908 recipe->mash[7].canskip = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
909 recipe->mash[7].setpoint = 78.0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
910 recipe->mash[7].skip = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
911 recipe->mash[7].duration = 10;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
912
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
913 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
914 * Add 2 hop additions, maximum 10
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
915 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
916 recipe->hops[0].name = xstrcpy((char *)"Hops 1");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
917 recipe->hops[0].boiltime = 90;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
918 recipe->hops[1].name = xstrcpy((char *)"Hops 2");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
919 recipe->hops[1].boiltime = 5;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
920 for (i = 2; i < 10; i++) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
921 recipe->hops[i].name = NULL;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
922 recipe->hops[i].boiltime = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
923 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
924
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
925
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
926 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
927 * Add 3 hopstands, disabled by default.
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
928 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
929 recipe->hopstand[0].name = xstrcpy((char *)"Hopstand hot");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
930 recipe->hopstand[0].min = 88;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
931 recipe->hopstand[0].max = 100;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
932 recipe->hopstand[0].hold = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
933 recipe->hopstand[0].setpoint = 93.0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
934 recipe->hopstand[0].skip = 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
935 recipe->hopstand[0].duration = 30;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
936 recipe->hopstand[1].name = xstrcpy((char *)"Hopstand default");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
937 recipe->hopstand[1].min = 72;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
938 recipe->hopstand[1].max = 77;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
939 recipe->hopstand[1].hold = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
940 recipe->hopstand[1].setpoint = 75.0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
941 recipe->hopstand[1].skip = 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
942 recipe->hopstand[1].duration = 60;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
943 recipe->hopstand[2].name = xstrcpy((char *)"Hopstand cool");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
944 recipe->hopstand[2].min = 60;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
945 recipe->hopstand[2].max = 66;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
946 recipe->hopstand[2].hold = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
947 recipe->hopstand[2].setpoint = 63.0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
948 recipe->hopstand[2].skip = 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
949 recipe->hopstand[2].duration = 60;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
950
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
951 editRecipe(recipe);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
952
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
953 if (recipes == NULL) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
954 recipes = recipe;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
955 } else {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
956 for (tmpu = recipes; tmpu; tmpu = tmpu->next) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
957 if (tmpu->next == NULL) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
958 tmpu->next = recipe;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
959 break;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
960 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
961 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
962 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
963 syslog(LOG_NOTICE, "Recipe %d added", number);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
964 if (debug)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
965 fprintf(stdout, "Recipe %d added\n", number);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
966 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
967
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
968
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
969
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
970 void editRecipes(void)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
971 {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
972 int total, i, key, choice = 1;;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
973 a_recipe *recipe;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
974 char pmpt[81];
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
975
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
976 prompt(0, NULL);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
977 for (;;) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
978 total = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
979 for (recipe = recipes; recipe; recipe = recipe->next) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
980 total++;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
981 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
982
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
983 if (debug)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
984 fprintf(stdout, "editRecipes total=%d choice=%d\n", total, choice);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
985
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
986 i = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
987 if (total) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
988 for (recipe = recipes; recipe; recipe = recipe->next) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
989 i++;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
990 if (i == choice)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
991 break;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
992 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
993 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
994
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
995 prompt(102, NULL); /* " SETUP MENU " */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
996 prompt(221, NULL); /* " Select Recipe " */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
997 if (total) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
998 snprintf(pmpt, Config.lcd_cols + 1, "%s", recipe->name);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
999 prompt(300, pmpt);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1000 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1001 if (total == 0)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1002 prompt(416, NULL); /* "add --- quit --- " */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1003 else if (total == 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1004 prompt(415, NULL); /* "add --- quit ok " */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1005 else if (total && (choice == 1))
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1006 prompt(414, NULL); /* "add dwn quit ok " */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1007 else if (total && (choice == total))
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1008 prompt(404, NULL); /* " up --- quit ok " */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1009 else
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1010 prompt(403, NULL); /* " up dwn quit ok " */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1011
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1012 key = keywait();
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1013 if ((key == KEY_RETURN) || my_shutdown)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1014 return;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1015 if (total && (key == KEY_ENTER)) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1016 editRecipe(recipe);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1017 prompt(0, NULL);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1018 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1019 if (key == KEY_UP) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1020 if ((total == 1) || (choice == 1))
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1021 addRecipe(total + 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1022 else if (choice > 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1023 choice--;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1024 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1025 if ((key == KEY_DOWN) && (total > 1) && (choice < total))
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1026 choice++;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1027 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1028 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1029
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1030
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1031
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1032 void editUnits(void)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1033 {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1034 int total, i, key, choice = 1;;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1035 units_list *unit;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1036 char pmpt[81];
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1037
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1038 prompt(0, NULL);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1039 for (;;) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1040 total = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1041 for (unit = Config.units; unit; unit = unit->next) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1042 total++;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1043 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1044
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1045 if (debug)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1046 fprintf(stdout, "editUnits total=%d choice=%d\n", total, choice);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1047
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1048 if (total == 0) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1049 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1050 * Impossible unless first setup was skipped
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1051 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1052 addUnit(1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1053 total = 1;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1054 } else {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1055 i = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1056 for (unit = Config.units; unit; unit = unit->next) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1057 i++;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1058 if (i == choice)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1059 break;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1060 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1061 prompt(102, NULL); /* " SETUP MENU " */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1062 prompt(222, NULL); /* " Select Brewsystem " */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1063 snprintf(pmpt, Config.lcd_cols + 1, "%s", unit->name);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1064 prompt(300, pmpt);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1065 if (total == 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1066 prompt(415, NULL); /* "add --- quit ok " */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1067 else if (choice == 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1068 prompt(414, NULL); /* "add dwn quit ok " */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1069 else if (choice == total)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1070 prompt(404, NULL); /* " up --- quit ok " */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1071 else
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1072 prompt(403, NULL); /* " up dwn quit ok " */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1073
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1074 key = keywait();
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1075 if ((key == KEY_RETURN) || my_shutdown)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1076 return;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1077 if (key == KEY_ENTER) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1078 editUnit(unit);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1079 prompt(0, NULL);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1080 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1081 if (key == KEY_UP) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1082 if ((total == 1) || (choice == 1))
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1083 addUnit(total + 1);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1084 else if (choice > 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1085 choice--;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1086 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1087 if ((key == KEY_DOWN) && (total > 1) && (choice < total))
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1088 choice++;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1089 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1090 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1091 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1092
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1093
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1094
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1095 void setup(void)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1096 {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1097 int key, option = 202;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1098
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1099 for (;;) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1100 if (debug)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1101 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
1102 prompt(0, NULL);
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1103 prompt(102, NULL); /* " SETUP MENU " */
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
1104 prompt(option, NULL);
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1105 if (option == 202)
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1106 prompt(402, NULL); /* "--- dwn quit ok " */
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1107 #ifdef USE_SIMULATOR
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1108 else if (option == 205)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1109 #else
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1110 else if (option == 204)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1111 #endif
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1112 prompt(404, NULL); /* " up --- quit ok " */
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1113 else
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1114 prompt(403, NULL); /* " up dwn quit ok " */
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1115
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1116 key = keywait();
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1117
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1118 if ((key == KEY_RETURN) || my_shutdown)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1119 return;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1120 if ((key == KEY_UP) && (option > 202)) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1121 option--;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1122 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1123 #ifdef USE_SIMULATOR
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1124 if ((key == KEY_DOWN) && (option < 205)) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1125 #else
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1126 if ((key == KEY_DOWN) && (option < 204)) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1127 #endif
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1128 option++;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1129 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1130
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
1131 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
1132 switch(option) {
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1133 case 202: editRecipes();
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
1134 break;
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1135 case 203: editUnits();
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
1136 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
1137 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
1138 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
1139 #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
1140 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
1141 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
1142 #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
1143 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
1144 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
1145 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
1146 }
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1147 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1148 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1149
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1150

mercurial