brewco/setup.c

Sat, 26 Dec 2015 21:45:44 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 26 Dec 2015 21:45:44 +0100
changeset 473
fdd30e935079
parent 463
a1da58215b65
permissions
-rw-r--r--

The brew state machine is complete, works but is not bugfree

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
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
212 void editName(char *name, char *text)
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
213 {
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
214 char pmpt[81];
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
215 int i, x = 0, key, val;
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
216
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
217 if (debug)
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
218 fprintf(stdout, "editName(%s)\n", name);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
219
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
220 prompt(0, NULL);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
221 prompt(131, NULL); /* " Change Name " */
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
222 prompt(417, NULL); /* " up dwn next ok " */
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
223
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
224 for (;;) {
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
225 snprintf(pmpt, Config.lcd_cols + 1, " ");
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
226 prompt(200, pmpt);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
227 #ifdef HAVE_WIRINGPI_H
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
228 lcdPosition(lcdHandle, x, 1);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
229 lcdPutchar(lcdHandle, '*');
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
230 #endif
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
231 slcdPosition(slcdHandle, x, 1);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
232 slcdPutchar(slcdHandle, '*');
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
233 snprintf(pmpt, Config.lcd_cols + 1, "%s", name);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
234 prompt(300, pmpt);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
235
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
236 key = keywait();
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
237
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
238 if ((key == KEY_ENTER) || my_shutdown) {
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
239 if (debug)
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
240 fprintf(stdout, "End editName(%s)\n", name);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
241 for (i = strlen(name) -1; i > 1; i--) {
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
242 if (name[i] != ' ')
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
243 break;
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
244 name[i] = '\0';
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
245 }
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
246 if (debug)
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
247 fprintf(stdout, "End editName(%s)\n", name);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
248 return;
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
249 }
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
250 if (key == KEY_RETURN) {
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
251 if (x < 19)
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
252 x++;
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
253 else
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
254 x = 0;
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
255 if (debug)
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
256 fprintf(stdout, "editName: strlen=%d x=%d\n", (int)strlen(name) - 1, x);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
257 if (x > ((int)strlen(name) - 1)) {
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
258 name[x + 1] = '\0';
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
259 name[x] = ' ';
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
260 }
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
261 }
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
262 if (key == KEY_UP || key == KEY_DOWN) {
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
263 val = name[x];
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
264 if ((key == KEY_UP) && (val < 126))
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
265 val++;
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
266 if ((key == KEY_DOWN) && (val > 32))
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
267 val--;
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
268 name[x] = val;
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
269 }
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
270 }
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
271 }
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
272
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
273
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
274
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
275 void editPID(pid_var *pid)
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
276 {
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
277 int idx = 1, key, val;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
278 char pmpt[81];
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
279 double Kp, Ki, Kd;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
280
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
281 if (debug)
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
282 fprintf(stdout, "editPID()\n");
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 for (;;) {
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
285 prompt(0, NULL);
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
286 prompt(192, NULL);
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
287
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
288 if (idx == 1)
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
289 prompt(402, NULL);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
290 else if (idx == 5)
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
291 prompt(404, NULL);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
292 else
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
293 prompt(403, NULL);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
294
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
295 switch (idx) {
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
296 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
297 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
298 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
299 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
300 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
301 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
302 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
303 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
304 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
305 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
306 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
307 prompt(200, pmpt);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
308
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
309 key = keywait();
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
310 if ((key == KEY_RETURN) || my_shutdown) {
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
311 if (debug)
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
312 fprintf(stdout, "End editPID\n");
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
313 return;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
314 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
315
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
316 if ((key == KEY_UP) && (idx > 1))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
317 idx--;
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
318 if ((key == KEY_DOWN) && (idx < 5))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
319 idx++;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
320
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
321 if (key == KEY_ENTER) {
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
322
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
323 Kp = PID_getKp(pid);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
324 Ki = PID_getKi(pid);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
325 Kd = PID_getKd(pid);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
326
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
327 switch(idx) {
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
328 case 1: editDouble(&Kp, 0.5, 50, (char *)"PID Kp");
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
329 PID_setTunings(pid, Kp, Ki, Kd);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
330 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
331 case 2: editDouble(&Ki, 0.5, 50, (char *)"PID Ki");
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
332 PID_setTunings(pid, Kp, Ki, Kd);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
333 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
334 case 3: editDouble(&Kd, 0.5, 50, (char *)"PID Kd");
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
335 PID_setTunings(pid, Kp, Ki, Kd);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
336 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
337 case 4: val = PID_getSampleTime(pid);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
338 editInteger(&val, 50, 500, 10, (char *)"SampleTime", (char *)"mSec");
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
339 PID_setSampleTime(pid, val);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
340 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
341 case 5: val = PID_getDirection(pid);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
342 toggleDirection(&val, (char *)"Direction");
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
343 PID_setDirection(pid, val);
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
344 break;
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
345 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
346 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
347 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
348 }
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
349
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
350
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
351
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
352 void editMash(mash_step *mash)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
353 {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
354 int key, idx = 1, lo, hi;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
355 char pmpt[81];
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
356
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
357 for (;;) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
358 prompt(0, NULL);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
359 prompt(194, NULL);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
360
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
361 if (mash->canskip) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
362 lo = 1;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
363 if (mash->skip)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
364 hi = 1;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
365 else
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
366 hi = 3;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
367 } else {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
368 lo = 2;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
369 hi = 3;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
370 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
371 if (idx < lo)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
372 idx = lo;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
373 if (idx > hi)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
374 idx = hi;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
375 if (debug)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
376 fprintf(stdout, "editMash canskip=%d skip=%d lo=%d hi=%d idx=%d\n", mash->canskip, mash->skip, lo, hi, idx);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
377
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
378 switch (idx) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
379 case 1: snprintf(pmpt, Config.lcd_cols + 1, " Mashstep skip: %s", mash->skip ? (char *)"Yes":(char *)"No");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
380 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
381 case 2: snprintf(pmpt, Config.lcd_cols + 1, " Setpoint: %5.1f\001", mash->setpoint);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
382 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
383 case 3: snprintf(pmpt, Config.lcd_cols + 1, " Duration: %3d mins", mash->duration);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
384 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
385 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
386 prompt(200, pmpt);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
387
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
388 if (lo == hi)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
389 prompt(405, NULL); /* "--- --- quit ok " */
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
390 else if (idx == lo)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
391 prompt(402, NULL); /* "--- dwn quit ok " */
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
392 else if (idx == hi)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
393 prompt(404, NULL); /* " up --- quit ok " */
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
394 else
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
395 prompt(403, NULL); /* " up dwn quit ok " */
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
396
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
397 key = keywait();
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
398 if ((key == KEY_RETURN) || my_shutdown)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
399 return;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
400 if ((key == KEY_UP) && (idx > lo))
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
401 idx--;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
402 if ((key == KEY_DOWN) && (idx < hi))
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
403 idx++;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
404 if (key == KEY_ENTER) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
405 switch(idx) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
406 case 1: toggleYesNo(&mash->skip, (char *)" Mashstep skip");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
407 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
408 case 2: editFloat(&mash->setpoint, mash->min, mash->max, (char *)" Setpoint");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
409 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
410 case 3: editInteger(&mash->duration, 1, 120, 1, (char *)" Duration", (char *)"mins");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
411 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
412 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
413 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
414 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
415 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
416
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
417
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
418
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
419 void editHopaddition(hop_addition *hops, int boiltime)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
420 {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
421 int key, idx = 1, hi;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
422 char pmpt[81];
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
423
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
424 for (;;) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
425 prompt(0, NULL);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
426 prompt(195, NULL);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
427
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
428 if (hops->skip)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
429 hi = 1;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
430 else
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
431 hi = 2;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
432 if (idx > hi)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
433 idx = hi;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
434 if (debug)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
435 fprintf(stdout, "editHopaddition skip=%d hi=%d idx=%d\n", hops->skip, hi, idx);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
436
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
437 switch (idx) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
438 case 1: snprintf(pmpt, Config.lcd_cols + 1, "Addition skip: %s", hops->skip ? (char *)"Yes":(char *)"No");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
439 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
440 case 2: snprintf(pmpt, Config.lcd_cols + 1, " Boil for: %3d mins", hops->boiltime);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
441 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
442 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
443 prompt(200, pmpt);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
444
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
445 if (hi == 1)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
446 prompt(405, NULL); /* "--- --- quit ok " */
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
447 else if (idx == 1)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
448 prompt(402, NULL); /* "--- dwn quit ok " */
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
449 else if (idx == hi)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
450 prompt(404, NULL); /* " up --- quit ok " */
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
451 else
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
452 prompt(403, NULL); /* " up dwn quit ok " */
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
453
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
454 key = keywait();
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
455 if ((key == KEY_RETURN) || my_shutdown)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
456 return;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
457 if ((key == KEY_UP) && (idx > 1))
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
458 idx--;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
459 if ((key == KEY_DOWN) && (idx < hi))
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
460 idx++;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
461 if (key == KEY_ENTER) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
462 switch (idx) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
463 case 1: toggleYesNo(&hops->skip, (char *)"Addition skip");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
464 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
465 case 2: editInteger(&hops->boiltime, -1, boiltime, 1, (char *)" Boil for", (char *)"mins");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
466 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
467 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
468 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
469 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
470 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
471
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
472
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
473
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
474 void editHopstand(hop_stand *hops)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
475 {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
476 int key, idx = 1, hi;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
477 char pmpt[81];
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
478
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
479 for (;;) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
480 prompt(0, NULL);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
481 prompt(196, NULL);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
482
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
483 if (hops->skip)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
484 hi = 1;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
485 else
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
486 hi = 4;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
487 if (idx < 1)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
488 idx = 1;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
489 if (idx > hi)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
490 idx = hi;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
491 if (debug)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
492 fprintf(stdout, "editHopstand skip=%d hi=%d idx=%d\n", hops->skip, hi, idx);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
493
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
494 switch (idx) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
495 case 1: snprintf(pmpt, Config.lcd_cols + 1, "Hopstand skip: %s", hops->skip ? (char *)"Yes":(char *)"No");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
496 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
497 case 2: snprintf(pmpt, Config.lcd_cols + 1, "Hold temperature: %s", hops->hold ? (char *)"Yes":(char *)"No");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
498 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
499 case 3: snprintf(pmpt, Config.lcd_cols + 1, " Setpoint: %5.1f\001", hops->setpoint);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
500 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
501 case 4: snprintf(pmpt, Config.lcd_cols + 1, " Duration: %3d mins", hops->duration);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
502 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
503 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
504 prompt(200, pmpt);
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
505
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
506 if (hi == 1)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
507 prompt(405, NULL); /* "--- --- quit ok " */
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
508 else if (idx == 1)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
509 prompt(402, NULL); /* "--- dwn quit ok " */
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
510 else if (idx == hi)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
511 prompt(404, NULL); /* " up --- quit ok " */
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
512 else
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
513 prompt(403, NULL); /* " up dwn quit ok " */
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
514
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
515 key = keywait();
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
516 if ((key == KEY_RETURN) || my_shutdown)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
517 return;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
518 if ((key == KEY_UP) && (idx > 1))
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
519 idx--;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
520 if ((key == KEY_DOWN) && (idx < hi))
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
521 idx++;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
522 if (key == KEY_ENTER) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
523 switch(idx) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
524 case 1: toggleYesNo(&hops->skip, (char *)"Hopstand skip");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
525 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
526 case 2: toggleYesNo(&hops->hold, (char *)"Hold temperature");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
527 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
528 case 3: editFloat(&hops->setpoint, hops->min, hops->max, (char *)" Setpoint");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
529 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
530 case 4: editInteger(&hops->duration, 10, 240, 10, (char *)" Duration", (char *)"mins");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
531 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
532 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
533 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
534 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
535 }
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
536
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
537
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
538
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
539 void editSensor(char *uuid, char *text)
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
540 {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
541 char pmpt[81];
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
542 int i, old, choices, idx = 1, key;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
543 devices_list *device;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
544
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
545 if (debug)
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
546 fprintf(stdout, "editSensor(%s, %s)\n", uuid, text);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
547
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
548 old = 1; // 1d0e5bb8-7408-48b9-abb4-e9041d7b99fe
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
549 if ((i = strcmp((char *)"00000000-0000-0000-0000-000000000000", uuid))) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
550 for (device = Config.devices; device; device = device->next) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
551 if (device->direction == DEVDIR_IN_ANALOG) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
552 old++;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
553 if (strcmp(device->uuid, uuid) == 0)
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
554 break;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
555 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
556 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
557 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
558
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
559 if (debug)
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
560 fprintf(stdout, "editSensor(%s) old sensor index=%d\n", text, old);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
561
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
562 for (;;) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
563 prompt(0, NULL);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
564 snprintf(pmpt, Config.lcd_cols + 1, "Edit %s", text);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
565 prompt(100, pmpt);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
566
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
567 /*
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
568 * Count valid sensors
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
569 */
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
570 choices = 1;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
571 if (old == 1) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
572 snprintf(pmpt, Config.lcd_cols + 1, "N/A");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
573 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
574 for (device = Config.devices; device; device = device->next) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
575 if (device->direction == DEVDIR_IN_ANALOG) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
576 choices++;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
577 if (choices == old) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
578 snprintf(pmpt, Config.lcd_cols + 1, "%s", device->description);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
579 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
580 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
581 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
582 prompt(200, pmpt); /* Display current sensor */
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
583 i = 1;
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
584 if (idx == 1) {
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
585 snprintf(pmpt, Config.lcd_cols + 1, "N/A");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
586 } else {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
587 for (device = Config.devices; device; device = device->next) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
588 if (device->direction == DEVDIR_IN_ANALOG) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
589 i++;
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
590 if (i == idx) {
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
591 snprintf(pmpt, Config.lcd_cols + 1, "%s", device->description);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
592 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
593 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
594 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
595 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
596 prompt(300, pmpt); /* Display possible new sensor */
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
597
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
598
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
599 if (choices == 1)
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
600 prompt(405, NULL);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
601 else if (idx == 1)
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
602 prompt(402, NULL);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
603 else if (idx == choices)
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
604 prompt(404, NULL);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
605 else
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
606 prompt(403, NULL);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
607
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
608 key = keywait();
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
609 if ((key == KEY_RETURN) || my_shutdown) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
610 if (debug)
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
611 fprintf(stdout, "End editSensor\n");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
612 return;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
613 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
614
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
615 if ((key == KEY_UP) && (idx > 1))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
616 idx--;
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
617 if ((key == KEY_DOWN) && (idx < choices))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
618 idx++;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
619
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
620 if ((key == KEY_ENTER) && (idx != old)) {
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
621 /*
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
622 * Select new sensor.
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
623 */
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
624 if (idx == 1) {
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
625 /*
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
626 * Disable the sensor
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
627 */
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
628 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
629 old = idx;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
630 } else {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
631 i = 1;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
632 for (device = Config.devices; device; device = device->next) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
633 if (device->direction == DEVDIR_IN_ANALOG) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
634 i++;
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
635 if (i == idx) {
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
636 strncpy(uuid, device->uuid, 36);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
637 break;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
638 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
639 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
640 }
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
641 old = idx;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
642 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
643 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
644 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
645 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
646
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
647
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
648
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
649 void editRelay(char *uuid, char *text)
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
650 {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
651 char pmpt[81];
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
652 int i, old, choices, idx = 1, key;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
653 devices_list *device;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
654
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
655 if (debug)
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
656 fprintf(stdout, "editRelay(%s, %s)\n", uuid, text);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
657
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
658 old = 1; // 1d0e5bb8-7408-48b9-abb4-e9041d7b99fe
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
659 if ((i = strcmp((char *)"00000000-0000-0000-0000-000000000000", uuid))) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
660 for (device = Config.devices; device; device = device->next) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
661 if (device->direction == DEVDIR_OUT_ANALOG) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
662 old++;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
663 if (strcmp(device->uuid, uuid) == 0)
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
664 break;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
665 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
666 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
667 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
668
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
669 if (debug)
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
670 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
671
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
672 for (;;) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
673 prompt(0, NULL);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
674 snprintf(pmpt, Config.lcd_cols + 1, "Edit %s", text);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
675 prompt(100, pmpt);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
676
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
677 /*
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
678 * Count valid sensors
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
679 */
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
680 choices = 1;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
681 if (old == 1) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
682 snprintf(pmpt, Config.lcd_cols + 1, "N/A");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
683 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
684 for (device = Config.devices; device; device = device->next) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
685 if (device->direction == DEVDIR_OUT_ANALOG) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
686 choices++;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
687 if (choices == old) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
688 snprintf(pmpt, Config.lcd_cols + 1, "%s", device->description);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
689 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
690 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
691 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
692 prompt(200, pmpt); /* Display current relay */
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
693 i = 1;
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
694 if (idx == 1) {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
695 snprintf(pmpt, Config.lcd_cols + 1, "N/A");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
696 } else {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
697 for (device = Config.devices; device; device = device->next) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
698 if (device->direction == DEVDIR_OUT_ANALOG) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
699 i++;
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
700 if (i == idx) {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
701 snprintf(pmpt, Config.lcd_cols + 1, "%s", device->description);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
702 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
703 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
704 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
705 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
706 prompt(300, pmpt); /* Display possible new relay */
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
707
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
708 if (choices == 1)
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
709 prompt(405, NULL);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
710 else if (idx == 1)
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
711 prompt(402, NULL);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
712 else if (idx == choices)
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
713 prompt(404, NULL);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
714 else
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
715 prompt(403, NULL);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
716
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
717 key = keywait();
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
718 if ((key == KEY_RETURN) || my_shutdown) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
719 if (debug)
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
720 fprintf(stdout, "End editRelay\n");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
721 return;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
722 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
723
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
724 if ((key == KEY_UP) && (idx > 1))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
725 idx--;
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
726 if ((key == KEY_DOWN) && (idx < choices))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
727 idx++;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
728
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
729 if ((key == KEY_ENTER) && (idx != old)) {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
730 /*
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
731 * Select new output.
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
732 */
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
733 if (idx == 1) {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
734 /*
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
735 * Disable the output
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
736 */
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
737 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
738 old = idx;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
739 } else {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
740 i = 1;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
741 for (device = Config.devices; device; device = device->next) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
742 if (device->direction == DEVDIR_OUT_ANALOG) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
743 i++;
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
744 if (i == idx) {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
745 strncpy(uuid, device->uuid, 36);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
746 break;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
747 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
748 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
749 }
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
750 old = idx;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
751 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
752 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
753 }
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
754 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
755
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
756
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
757
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
758 /*
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
759 * Edit a single unit
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
760 */
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
761 void editUnit(units_list *unit)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
762 {
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
763 int idx = 1, key;
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
764 char pmpt[81], *uuid, *name;
447
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
765 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
766
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
767 if (debug)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
768 fprintf(stdout, "Start edit brewsystem %d %s\n", unit->number, unit->uuid);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
769
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
770 prompt(0, NULL);
447
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
771 ncrc = ocrc = crc32(0L, Z_NULL, 0);
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
772 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
773
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
774 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
775
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
776 prompt(0, NULL);
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
777 prompt(193, 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
778
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
779 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
780 prompt(402, NULL);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
781 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
782 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
783 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
784 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
785
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
786 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
787 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
788 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
789 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
790 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
791 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
792 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
793 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
794 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
795 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
796 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
797 break;
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
798 case 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
799 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
800 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
801 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
802 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
803 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
804 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
805 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
806 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
807 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
808 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
809 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
810 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
811 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
812 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
813 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
814 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
815 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
816 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
817 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
818 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
819 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
820 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
821 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
822 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
823 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
824 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
825 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
826 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
827 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
828 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
829 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
830 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
831 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
832 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
833 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
834 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
835 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
836 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
837 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
838 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
839 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
840 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
841 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
842 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
843 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
844 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
845 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
846 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
847 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
848 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
849 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
850 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
851 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
852 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
853
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
854 key = keywait();
447
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
855 if ((key == KEY_RETURN) || my_shutdown) {
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
856 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
857 if (ocrc != ncrc)
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
858 wrconfig();
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
859 if (debug)
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
860 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
861 return;
447
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
862 }
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
863
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
864 if ((key == KEY_UP) && (idx > 1))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
865 idx--;
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
866 if ((key == KEY_DOWN) && (idx < 21))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
867 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
868
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
869 if (key == KEY_ENTER) {
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
870 switch(idx) {
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
871 case 1: name = calloc(sizeof(char), 21);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
872 snprintf(name, 21, unit->name);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
873 editName(name, (char *)"Unit name");
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
874 if (unit->name)
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
875 free(unit->name);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
876 unit->name = xstrcpy(name);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
877 free(name);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
878 break;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
879 case 2: uuid = xstrcpy(unit->hlt_sensor.uuid);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
880 editSensor(uuid, (char *)"HLT sensor");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
881 strncpy(unit->hlt_sensor.uuid, uuid, 36);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
882 free(uuid);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
883 break;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
884 case 3: uuid = xstrcpy(unit->hlt_heater.uuid);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
885 editRelay(uuid, (char *)"HLT heater");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
886 strncpy(unit->hlt_heater.uuid, uuid, 36);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
887 free(uuid);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
888 break;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
889 case 4: uuid = xstrcpy(unit->mlt_sensor.uuid);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
890 editSensor(uuid, (char *)"MLT sensor");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
891 strncpy(unit->mlt_sensor.uuid, uuid, 36);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
892 free(uuid);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
893 break;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
894 case 5: uuid = xstrcpy(unit->mlt_heater.uuid);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
895 editRelay(uuid, (char *)"MLT heater");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
896 strncpy(unit->mlt_heater.uuid, uuid, 36);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
897 free(uuid);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
898 break;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
899 case 6: uuid = xstrcpy(unit->mlt_pump.uuid);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
900 editRelay(uuid, (char *)"MLT pump");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
901 strncpy(unit->mlt_pump.uuid, uuid, 36);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
902 free(uuid);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
903 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
904 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
905 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
906 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
907 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
908 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
909 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
910 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
911 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
912 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
913 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
914 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
915 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
916 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
917 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
918 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
919 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
920 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
921 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
922 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
923 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
924 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
925 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
926 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
927 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
928 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
929 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
930 case 20: editPID(unit->PID_hlt);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
931 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
932 case 21: editPID(unit->PID_mlt);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
933 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
934 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
935 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
936 }
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
937 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
938
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
939
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
940
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
941 void addUnit(int number)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
942 {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
943 units_list *tmpu, *unit = (units_list *)malloc(sizeof(units_list));
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
944 char name[81];
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
945 uuid_t uu;
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
946 double Input, Output, Setpoint;
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
947
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
948 if (debug)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
949 fprintf(stdout, "Adding new brewsystem %d\n", number);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
950 unit->next = NULL;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
951 unit->version = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
952 unit->uuid = malloc(37);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
953 uuid_generate(uu);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
954 uuid_unparse(uu, unit->uuid);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
955 snprintf(name, 20, "System %d", number);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
956 unit->name = xstrcpy(name);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
957 unit->number = number;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
958 if (number == 1)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
959 unit->active = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
960 else
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
961 unit->active = 0;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
962 unit->hlt_sensor.uuid = xstrcpy((char *)"00000000-0000-0000-0000-000000000000");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
963 unit->hlt_sensor.state = DEVPRESENT_UNDEF;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
964 unit->hlt_sensor.value = 0;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
965 unit->mlt_sensor.uuid = xstrcpy((char *)"00000000-0000-0000-0000-000000000000");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
966 unit->mlt_sensor.state = DEVPRESENT_UNDEF;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
967 unit->mlt_sensor.value = 0;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
968 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
969 unit->hlt_heater.value = 0;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
970 unit->hlt_heater.delay = 0;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
971 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
972 unit->mlt_heater.value = 0;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
973 unit->mlt_heater.delay = 0;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
974 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
975 unit->mlt_pump.value = 0;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
976 unit->mlt_pump.delay = 0;
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
977 unit->hlt_heater_mltfirst = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
978 unit->pump_cycle = 7;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
979 unit->pump_rest = 2;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
980 unit->pump_premash = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
981 unit->pump_onmash = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
982 unit->pump_mashout = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
983 unit->pump_onboil = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
984 unit->pump_stop = 90;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
985 unit->skip_add = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
986 unit->skip_remove = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
987 unit->skip_iodine = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
988 unit->iodine_time = 90;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
989 unit->whirlpool = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
990 unit->PID_hlt = (pid_var *)malloc(sizeof(pid_var));
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
991 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
992 Input = Setpoint = 20.0;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
993 Output = 0;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
994 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
995 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
996
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
997 editUnit(unit);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
998
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
999 if (Config.units == NULL) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1000 Config.units = unit;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1001 } else {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1002 for (tmpu = Config.units; tmpu; tmpu = tmpu->next) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1003 if (tmpu->next == NULL) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1004 tmpu->next = unit;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1005 break;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1006 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1007 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1008 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1009 syslog(LOG_NOTICE, "Brewsystem %d added to the configuration", number);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1010 if (debug)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1011 fprintf(stdout, "Brewsystem %d added to the configuration\n", number);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1012 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1013
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1014
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1015
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
1016 /*
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 * 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
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 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
1020 {
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1021 int idx = 1, i, key;
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1022 char pmpt[81], *name;
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
1023 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
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 (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
1026 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
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 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
1029 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
1030 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
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 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
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 prompt(0, NULL);
462
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1035 prompt(191, NULL); /* " Edit recipe " */
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
1036
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 if (idx == 1)
462
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1038 prompt(402, NULL); /* "--- dwn quit ok " */
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1039 else if (idx == 24)
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1040 prompt(404, NULL); /* " up --- quit ok " */
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
1041 else
462
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1042 prompt(403, NULL); /* " up dwn quit ok " */
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
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 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
1045 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
1046 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
1047 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
1048 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
1049 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
1050 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
1051 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
1052 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
1053 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
1054 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
1055 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
1056 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
1057 break;
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1058 case 4: snprintf(pmpt, Config.lcd_cols + 1, " Cool to: %5.1f\001", recipe->coolto);
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1059 prompt(200, pmpt);
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1060 break;
462
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1061 case 5:
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1062 case 6:
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1063 case 7:
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1064 case 8:
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1065 case 9:
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1066 case 10:
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1067 case 11:
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1068 case 12: snprintf(pmpt, Config.lcd_cols + 1, "Mash: %s", recipe->mash[idx - 5].name);
462
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1069 prompt(200, pmpt);
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1070 if (recipe->mash[idx - 5].skip)
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1071 snprintf(pmpt, Config.lcd_cols + 1, " Skipped");
462
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1072 else
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1073 snprintf(pmpt, Config.lcd_cols + 1, " Sv %4.1f\001 %3d mins", recipe->mash[idx - 5].setpoint, recipe->mash[idx - 5].duration);
462
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1074 prompt(300, pmpt);
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1075 break;
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1076 case 13:
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1077 case 14:
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1078 case 15:
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1079 case 16:
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1080 case 17:
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1081 case 18:
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1082 case 19:
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1083 case 20:
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1084 case 21:
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1085 case 22: snprintf(pmpt, Config.lcd_cols + 1, "Add: %s", recipe->hops[idx - 13].name);
462
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1086 prompt(200, pmpt);
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1087 if (recipe->hops[idx - 13].skip)
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1088 snprintf(pmpt, Config.lcd_cols + 1, " Skipped");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1089 else {
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1090 if (recipe->hops[idx - 13].boiltime == -1)
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1091 snprintf(pmpt, Config.lcd_cols + 1, " First Wort Hop");
462
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1092 else
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1093 snprintf(pmpt, Config.lcd_cols + 1, " Boil for %3d mins", recipe->hops[idx - 13].boiltime);
462
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1094 }
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1095 prompt(300, pmpt);
462
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1096 break;
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1097 case 23:
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1098 case 24:
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1099 case 25: snprintf(pmpt, Config.lcd_cols + 1, "Hopstand: %s", recipe->hopstand[idx - 23].name);
462
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1100 prompt(200, pmpt);
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1101 if (recipe->hopstand[idx - 23].skip)
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1102 snprintf(pmpt, Config.lcd_cols + 1, " Skipped");
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1103 else if (recipe->hopstand[idx - 23].hold)
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1104 snprintf(pmpt, Config.lcd_cols + 1, "Hold at %4.1f %3d mins", recipe->hopstand[idx - 23].setpoint, recipe->hopstand[idx - 23].duration);
462
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1105 else
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1106 snprintf(pmpt, Config.lcd_cols + 1, "Hold for %3d mins", recipe->hopstand[idx - 23].duration);
462
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1107 prompt(300, pmpt);
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1108 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
1109 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1110
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1111 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
1112 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
1113 ncrc = crc32(ncrc, (const Bytef *)recipe, sizeof(a_recipe));
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1114 if (ocrc != ncrc) {
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1115 /*
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1116 * Fix some user errors
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1117 */
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1118 for (i = 0; i < 8; i++)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1119 if (recipe->hops[i].boiltime > recipe->boiltime)
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1120 recipe->hops[i].boiltime = recipe->boiltime;
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
1121 wrrecipes();
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1122 }
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
1123 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
1124 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
1125 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
1126 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1127
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1128 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
1129 idx--;
462
830ae3c3ef98 Added recipe setup display menu.
Michiel Broek <mbroek@mbse.eu>
parents: 461
diff changeset
1130 if ((key == KEY_DOWN) && (idx < 24))
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
1131 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
1132
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 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
1134 switch(idx) {
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1135 case 1: name = calloc(sizeof(char), 21);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1136 snprintf(name, 21, recipe->name);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1137 editName(name, (char *)"Recipe name");
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1138 if (recipe->name)
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1139 free(recipe->name);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1140 recipe->name = xstrcpy(name);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1141 free(name);
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
1142 break;
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1143 case 2: name = calloc(sizeof(char), 21);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1144 snprintf(name, 21, recipe->code);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1145 editName(name, (char *)"Recipe code");
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1146 if (recipe->code)
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1147 free(recipe->code);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1148 recipe->code = xstrcpy(name);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1149 free(name);
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
1150 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
1151 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
1152 break;
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1153 case 4: editFloat(&recipe->coolto, 10.0, 30.0, (char *)" Cool to");
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1154
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1155 case 5:
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1156 case 6:
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1157 case 7:
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1158 case 8:
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1159 case 9:
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1160 case 10:
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1161 case 11:
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1162 case 12: editMash(&recipe->mash[idx-5]);
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1163 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1164 case 13:
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1165 case 14:
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1166 case 15:
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1167 case 16:
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1168 case 17:
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1169 case 18:
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1170 case 19:
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1171 case 20:
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1172 case 21:
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1173 case 22: editHopaddition(&recipe->hops[idx-13], recipe->boiltime);
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1174 break;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1175 case 23:
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1176 case 24:
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1177 case 25: editHopstand(&recipe->hopstand[idx-23]);
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1178 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
1179 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1180 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1181 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1182 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1183
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1184
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1185
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1186 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
1187 {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1188 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
1189 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
1190 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
1191
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1192 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
1193 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
1194 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
1195 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
1196 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
1197 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
1198 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
1199 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
1200 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
1201 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
1202 recipe->boiltime = 90;
473
fdd30e935079 The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents: 463
diff changeset
1203 recipe->coolto = 20.0;
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
1204 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
1205 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1206 * 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
1207 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1208 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
1209 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
1210 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
1211 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
1212 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
1213 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
1214 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
1215 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
1216 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
1217 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
1218 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
1219 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
1220 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
1221 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
1222 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
1223 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
1224 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
1225 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
1226 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
1227 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
1228 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
1229 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
1230 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
1231 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
1232 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
1233 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
1234 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
1235 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
1236 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
1237 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
1238 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
1239 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
1240 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
1241 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
1242 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
1243 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
1244 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
1245 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
1246 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
1247 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
1248 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
1249 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
1250 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
1251 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
1252 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
1253 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
1254 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
1255 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
1256 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
1257 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
1258 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
1259 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
1260 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
1261 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
1262 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
1263 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
1264
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1265 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1266 * 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
1267 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1268 recipe->hops[0].name = xstrcpy((char *)"Hops 1");
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1269 recipe->hops[0].skip = 0;
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
1270 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
1271 recipe->hops[1].name = xstrcpy((char *)"Hops 2");
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1272 recipe->hops[1].skip = 0;
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
1273 recipe->hops[1].boiltime = 5;
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1274 recipe->hops[2].name = xstrcpy((char *)"Hops 3");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1275 recipe->hops[2].skip = 1;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1276 recipe->hops[2].boiltime = 0;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1277 recipe->hops[3].name = xstrcpy((char *)"Hops 4");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1278 recipe->hops[3].skip = 1;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1279 recipe->hops[3].boiltime = 0;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1280 recipe->hops[4].name = xstrcpy((char *)"Hops 5");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1281 recipe->hops[4].skip = 1;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1282 recipe->hops[4].boiltime = 0;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1283 recipe->hops[5].name = xstrcpy((char *)"Hops 6");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1284 recipe->hops[5].skip = 1;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1285 recipe->hops[5].boiltime = 0;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1286 recipe->hops[6].name = xstrcpy((char *)"Hops 7");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1287 recipe->hops[6].skip = 1;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1288 recipe->hops[6].boiltime = 0;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1289 recipe->hops[7].name = xstrcpy((char *)"Hops 8");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1290 recipe->hops[7].skip = 1;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1291 recipe->hops[7].boiltime = 0;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1292 recipe->hops[8].name = xstrcpy((char *)"Hops 9");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1293 recipe->hops[8].skip = 1;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1294 recipe->hops[8].boiltime = 0;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1295 recipe->hops[9].name = xstrcpy((char *)"Hops 10");
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1296 recipe->hops[9].skip = 1;
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 462
diff changeset
1297 recipe->hops[9].boiltime = 0;
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
1298
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1299 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1300 * 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
1301 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1302 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
1303 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
1304 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
1305 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
1306 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
1307 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
1308 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
1309 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
1310 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
1311 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
1312 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
1313 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
1314 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
1315 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
1316 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
1317 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
1318 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
1319 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
1320 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
1321 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
1322 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
1323
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1324 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
1325
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1326 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
1327 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
1328 } 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
1329 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
1330 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
1331 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
1332 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
1333 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1334 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1335 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1336 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
1337 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
1338 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
1339 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1340
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1341
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1342
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1343 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
1344 {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1345 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
1346 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
1347 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
1348
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1349 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
1350 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
1351 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
1352 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
1353 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
1354 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1355
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1356 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
1357 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
1358
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1359 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
1360 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
1361 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
1362 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
1363 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
1364 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
1365 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1366 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1367
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1368 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
1369 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
1370 if (total) {
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1371 snprintf(pmpt, Config.lcd_cols + 1, "%s %s ", recipe->code, recipe->name);
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
1372 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
1373 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1374 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
1375 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
1376 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
1377 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
1378 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
1379 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
1380 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
1381 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
1382 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
1383 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
1384
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1385 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
1386 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
1387 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
1388 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
1389 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
1390 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
1391 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1392 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
1393 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
1394 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
1395 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
1396 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
1397 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1398 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
1399 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
1400 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1401 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1402
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1403
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1404
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1405 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
1406 {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1407 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
1408 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
1409 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
1410
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1411 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
1412 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
1413 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
1414 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
1415 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
1416 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1417
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1418 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
1419 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
1420
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1421 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
1422 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1423 * 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
1424 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1425 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
1426 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
1427 } 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
1428 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
1429 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
1430 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
1431 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
1432 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
1433 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1434 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
1435 prompt(222, NULL); /* " Select Brewsystem " */
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1436 snprintf(pmpt, Config.lcd_cols + 1, "%s ", unit->name);
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
1437 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
1438 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
1439 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
1440 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
1441 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
1442 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
1443 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
1444 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
1445 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
1446
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1447 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
1448 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
1449 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
1450 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
1451 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
1452 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
1453 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1454 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
1455 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
1456 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
1457 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
1458 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
1459 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1460 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
1461 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
1462 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1463 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1464 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1465
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1466
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1467
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1468 void setup(void)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1469 {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1470 int key, option = 202;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1471
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1472 for (;;) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1473 if (debug)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1474 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
1475 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
1476 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
1477 prompt(option, NULL);
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1478 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
1479 prompt(402, NULL); /* "--- dwn quit ok " */
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1480 #ifdef USE_SIMULATOR
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1481 else if (option == 205)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1482 #else
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1483 else if (option == 204)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1484 #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
1485 prompt(404, NULL); /* " up --- quit ok " */
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1486 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
1487 prompt(403, NULL); /* " up dwn quit ok " */
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1488
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1489 key = keywait();
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1490
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1491 if ((key == KEY_RETURN) || my_shutdown)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1492 return;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1493 if ((key == KEY_UP) && (option > 202)) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1494 option--;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1495 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1496 #ifdef USE_SIMULATOR
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1497 if ((key == KEY_DOWN) && (option < 205)) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1498 #else
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1499 if ((key == KEY_DOWN) && (option < 204)) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1500 #endif
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1501 option++;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1502 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1503
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
1504 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
1505 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
1506 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
1507 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
1508 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
1509 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
1510 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
1511 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
1512 #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
1513 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
1514 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
1515 #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
1516 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
1517 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
1518 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
1519 }
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1520 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1521 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1522
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1523

mercurial