brewco/setup.c

Wed, 16 Dec 2015 22:06:11 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 16 Dec 2015 22:06:11 +0100
changeset 461
482bab226340
parent 459
1f88be70f253
child 462
830ae3c3ef98
permissions
-rw-r--r--

Changed some prompt numbers. Added name editor.

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
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
352 void editSensor(char *uuid, char *text)
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
353 {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
354 char pmpt[81];
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
355 int i, old, choices, idx = 1, key;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
356 devices_list *device;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
357
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
358 if (debug)
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
359 fprintf(stdout, "editSensor(%s, %s)\n", uuid, text);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
360
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
361 old = 1; // 1d0e5bb8-7408-48b9-abb4-e9041d7b99fe
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
362 if ((i = strcmp((char *)"00000000-0000-0000-0000-000000000000", uuid))) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
363 for (device = Config.devices; device; device = device->next) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
364 if (device->direction == DEVDIR_IN_ANALOG) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
365 old++;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
366 if (strcmp(device->uuid, uuid) == 0)
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
367 break;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
368 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
369 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
370 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
371
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
372 if (debug)
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
373 fprintf(stdout, "editSensor(%s) old sensor index=%d\n", text, old);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
374
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
375 for (;;) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
376 prompt(0, NULL);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
377 snprintf(pmpt, Config.lcd_cols + 1, "Edit %s", text);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
378 prompt(100, pmpt);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
379
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
380 /*
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
381 * Count valid sensors
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
382 */
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
383 choices = 1;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
384 if (old == 1) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
385 snprintf(pmpt, Config.lcd_cols + 1, "N/A");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
386 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
387 for (device = Config.devices; device; device = device->next) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
388 if (device->direction == DEVDIR_IN_ANALOG) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
389 choices++;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
390 if (choices == old) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
391 snprintf(pmpt, Config.lcd_cols + 1, "%s", device->description);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
392 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
393 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
394 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
395 prompt(200, pmpt); /* Display current sensor */
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
396 i = 1;
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
397 if (idx == 1) {
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
398 snprintf(pmpt, Config.lcd_cols + 1, "N/A");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
399 } else {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
400 for (device = Config.devices; device; device = device->next) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
401 if (device->direction == DEVDIR_IN_ANALOG) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
402 i++;
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
403 if (i == idx) {
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
404 snprintf(pmpt, Config.lcd_cols + 1, "%s", device->description);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
405 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
406 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
407 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
408 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
409 prompt(300, pmpt); /* Display possible new sensor */
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
410
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
411
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
412 if (choices == 1)
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
413 prompt(405, NULL);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
414 else if (idx == 1)
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
415 prompt(402, NULL);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
416 else if (idx == choices)
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
417 prompt(404, NULL);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
418 else
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
419 prompt(403, NULL);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
420
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
421 key = keywait();
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
422 if ((key == KEY_RETURN) || my_shutdown) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
423 if (debug)
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
424 fprintf(stdout, "End editSensor\n");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
425 return;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
426 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
427
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
428 if ((key == KEY_UP) && (idx > 1))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
429 idx--;
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
430 if ((key == KEY_DOWN) && (idx < choices))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
431 idx++;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
432
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
433 if ((key == KEY_ENTER) && (idx != old)) {
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
434 /*
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
435 * Select new sensor.
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
436 */
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
437 if (idx == 1) {
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
438 /*
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
439 * Disable the sensor
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
440 */
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
441 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
442 old = idx;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
443 } else {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
444 i = 1;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
445 for (device = Config.devices; device; device = device->next) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
446 if (device->direction == DEVDIR_IN_ANALOG) {
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
447 i++;
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
448 if (i == idx) {
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
449 strncpy(uuid, device->uuid, 36);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
450 break;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
451 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
452 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
453 }
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
454 old = idx;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
455 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
456 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
457 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
458 }
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
459
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
460
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
461
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
462 void editRelay(char *uuid, char *text)
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
463 {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
464 char pmpt[81];
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
465 int i, old, choices, idx = 1, key;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
466 devices_list *device;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
467
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
468 if (debug)
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
469 fprintf(stdout, "editRelay(%s, %s)\n", uuid, text);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
470
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
471 old = 1; // 1d0e5bb8-7408-48b9-abb4-e9041d7b99fe
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
472 if ((i = strcmp((char *)"00000000-0000-0000-0000-000000000000", uuid))) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
473 for (device = Config.devices; device; device = device->next) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
474 if (device->direction == DEVDIR_OUT_ANALOG) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
475 old++;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
476 if (strcmp(device->uuid, uuid) == 0)
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
477 break;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
478 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
479 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
480 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
481
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
482 if (debug)
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
483 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
484
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
485 for (;;) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
486 prompt(0, NULL);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
487 snprintf(pmpt, Config.lcd_cols + 1, "Edit %s", text);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
488 prompt(100, pmpt);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
489
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
490 /*
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
491 * Count valid sensors
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
492 */
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
493 choices = 1;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
494 if (old == 1) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
495 snprintf(pmpt, Config.lcd_cols + 1, "N/A");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
496 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
497 for (device = Config.devices; device; device = device->next) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
498 if (device->direction == DEVDIR_OUT_ANALOG) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
499 choices++;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
500 if (choices == old) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
501 snprintf(pmpt, Config.lcd_cols + 1, "%s", device->description);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
502 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
503 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
504 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
505 prompt(200, pmpt); /* Display current relay */
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
506 i = 1;
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
507 if (idx == 1) {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
508 snprintf(pmpt, Config.lcd_cols + 1, "N/A");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
509 } else {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
510 for (device = Config.devices; device; device = device->next) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
511 if (device->direction == DEVDIR_OUT_ANALOG) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
512 i++;
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
513 if (i == idx) {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
514 snprintf(pmpt, Config.lcd_cols + 1, "%s", device->description);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
515 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
516 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
517 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
518 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
519 prompt(300, pmpt); /* Display possible new relay */
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
520
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
521 if (choices == 1)
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
522 prompt(405, NULL);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
523 else if (idx == 1)
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
524 prompt(402, NULL);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
525 else if (idx == choices)
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
526 prompt(404, NULL);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
527 else
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
528 prompt(403, NULL);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
529
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
530 key = keywait();
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
531 if ((key == KEY_RETURN) || my_shutdown) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
532 if (debug)
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
533 fprintf(stdout, "End editRelay\n");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
534 return;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
535 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
536
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
537 if ((key == KEY_UP) && (idx > 1))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
538 idx--;
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
539 if ((key == KEY_DOWN) && (idx < choices))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
540 idx++;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
541
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
542 if ((key == KEY_ENTER) && (idx != old)) {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
543 /*
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
544 * Select new output.
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
545 */
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
546 if (idx == 1) {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
547 /*
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
548 * Disable the output
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
549 */
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
550 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
551 old = idx;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
552 } else {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
553 i = 1;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
554 for (device = Config.devices; device; device = device->next) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
555 if (device->direction == DEVDIR_OUT_ANALOG) {
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
556 i++;
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
557 if (i == idx) {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
558 strncpy(uuid, device->uuid, 36);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
559 break;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
560 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
561 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
562 }
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
563 old = idx;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
564 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
565 }
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
566 }
449
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
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
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
571 /*
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
572 * Edit a single unit
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
573 */
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
574 void editUnit(units_list *unit)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
575 {
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
576 int idx = 1, key;
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
577 char pmpt[81], *uuid, *name;
447
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
578 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
579
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
580 if (debug)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
581 fprintf(stdout, "Start edit brewsystem %d %s\n", unit->number, unit->uuid);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
582
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
583 prompt(0, NULL);
447
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
584 ncrc = ocrc = crc32(0L, Z_NULL, 0);
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
585 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
586
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
587 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
588
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
589 prompt(0, NULL);
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
590 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
591
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
592 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
593 prompt(402, NULL);
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
594 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
595 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
596 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
597 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
598
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
599 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
600 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
601 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
602 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
603 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
604 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
605 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
606 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
607 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
608 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
609 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
610 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
611 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
612 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
613 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
614 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
615 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
616 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
617 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
618 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
619 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
620 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
621 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
622 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
623 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
624 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
625 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
626 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
627 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
628 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
629 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
630 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
631 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
632 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
633 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
634 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
635 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
636 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
637 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
638 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
639 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
640 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
641 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
642 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
643 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
644 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
645 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
646 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
647 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
648 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
649 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
650 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
651 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
652 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
653 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
654 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
655 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
656 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
657 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
658 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
659 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
660 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
661 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
662 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
663 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
664 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
665 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
666
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
667 key = keywait();
447
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
668 if ((key == KEY_RETURN) || my_shutdown) {
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
669 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
670 if (ocrc != ncrc)
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
671 wrconfig();
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
672 if (debug)
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
673 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
674 return;
447
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 446
diff changeset
675 }
443
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
676
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
677 if ((key == KEY_UP) && (idx > 1))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
678 idx--;
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
679 if ((key == KEY_DOWN) && (idx < 21))
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
680 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
681
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
682 if (key == KEY_ENTER) {
458
43a8ecb53637 Fixes for compiling on Raspberry.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
683 switch(idx) {
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
684 case 1: name = calloc(sizeof(char), 21);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
685 snprintf(name, 21, unit->name);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
686 editName(name, (char *)"Unit name");
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
687 if (unit->name)
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
688 free(unit->name);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
689 unit->name = xstrcpy(name);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
690 free(name);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
691 break;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
692 case 2: uuid = xstrcpy(unit->hlt_sensor.uuid);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
693 editSensor(uuid, (char *)"HLT sensor");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
694 strncpy(unit->hlt_sensor.uuid, uuid, 36);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
695 free(uuid);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
696 break;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
697 case 3: uuid = xstrcpy(unit->hlt_heater.uuid);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
698 editRelay(uuid, (char *)"HLT heater");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
699 strncpy(unit->hlt_heater.uuid, uuid, 36);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
700 free(uuid);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
701 break;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
702 case 4: uuid = xstrcpy(unit->mlt_sensor.uuid);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
703 editSensor(uuid, (char *)"MLT sensor");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
704 strncpy(unit->mlt_sensor.uuid, uuid, 36);
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
705 free(uuid);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
706 break;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
707 case 5: uuid = xstrcpy(unit->mlt_heater.uuid);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
708 editRelay(uuid, (char *)"MLT heater");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
709 strncpy(unit->mlt_heater.uuid, uuid, 36);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
710 free(uuid);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
711 break;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
712 case 6: uuid = xstrcpy(unit->mlt_pump.uuid);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
713 editRelay(uuid, (char *)"MLT pump");
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
714 strncpy(unit->mlt_pump.uuid, uuid, 36);
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
715 free(uuid);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
716 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
717 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
718 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
719 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
720 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
721 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
722 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
723 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
724 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
725 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
726 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
727 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
728 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
729 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
730 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
731 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
732 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
733 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
734 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
735 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
736 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
737 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
738 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
739 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
740 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
741 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
742 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
743 case 20: editPID(unit->PID_hlt);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
744 break;
448
7fe45f6e4f48 Added PID editor.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
745 case 21: editPID(unit->PID_mlt);
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
746 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
747 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
748 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
749 }
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
750 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
751
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
752
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
753
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
754 void addUnit(int number)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
755 {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
756 units_list *tmpu, *unit = (units_list *)malloc(sizeof(units_list));
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
757 char name[81];
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
758 uuid_t uu;
446
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
759 double Input, Output, Setpoint;
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
760
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
761 if (debug)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
762 fprintf(stdout, "Adding new brewsystem %d\n", number);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
763 unit->next = NULL;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
764 unit->version = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
765 unit->uuid = malloc(37);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
766 uuid_generate(uu);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
767 uuid_unparse(uu, unit->uuid);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
768 snprintf(name, 20, "System %d", number);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
769 unit->name = xstrcpy(name);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
770 unit->number = number;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
771 if (number == 1)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
772 unit->active = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
773 else
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
774 unit->active = 0;
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
775 unit->hlt_sensor.uuid = xstrcpy((char *)"00000000-0000-0000-0000-000000000000");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
776 unit->hlt_sensor.state = DEVPRESENT_UNDEF;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
777 unit->hlt_sensor.value = 0;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
778 unit->mlt_sensor.uuid = xstrcpy((char *)"00000000-0000-0000-0000-000000000000");
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
779 unit->mlt_sensor.state = DEVPRESENT_UNDEF;
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 448
diff changeset
780 unit->mlt_sensor.value = 0;
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
781 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
782 unit->hlt_heater.value = 0;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
783 unit->hlt_heater.delay = 0;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
784 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
785 unit->mlt_heater.value = 0;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
786 unit->mlt_heater.delay = 0;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
787 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
788 unit->mlt_pump.value = 0;
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
789 unit->mlt_pump.delay = 0;
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
790 unit->hlt_heater_mltfirst = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
791 unit->pump_cycle = 7;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
792 unit->pump_rest = 2;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
793 unit->pump_premash = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
794 unit->pump_onmash = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
795 unit->pump_mashout = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
796 unit->pump_onboil = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
797 unit->pump_stop = 90;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
798 unit->skip_add = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
799 unit->skip_remove = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
800 unit->skip_iodine = 0;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
801 unit->iodine_time = 90;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
802 unit->whirlpool = 1;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
803 unit->PID_hlt = (pid_var *)malloc(sizeof(pid_var));
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
804 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
805 Input = Setpoint = 20.0;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
806 Output = 0;
78e9d5234d15 Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
807 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
808 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
809
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
810 editUnit(unit);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
811
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
812 if (Config.units == NULL) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
813 Config.units = unit;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
814 } else {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
815 for (tmpu = Config.units; tmpu; tmpu = tmpu->next) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
816 if (tmpu->next == NULL) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
817 tmpu->next = unit;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
818 break;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
819 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
820 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
821 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
822 syslog(LOG_NOTICE, "Brewsystem %d added to the configuration", number);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
823 if (debug)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
824 fprintf(stdout, "Brewsystem %d added to the configuration\n", number);
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
825 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
826
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
827
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
828
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
829 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
830 * 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
831 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
832 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
833 {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
834 int idx = 1, key;
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
835 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
836 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
837
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
838 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
839 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
840
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
841 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
842 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
843 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
844
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
845 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
846
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
847 prompt(0, NULL);
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
848 prompt(191, 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
849
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
850 if (idx == 1)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
851 prompt(402, NULL);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
852 else if (idx == 21)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
853 prompt(404, NULL);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
854 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
855 prompt(403, NULL);
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
856
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
857 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
858 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
859 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
860 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
861 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
862 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
863 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
864 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
865 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
866 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
867 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
868 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
869 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
870 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
871 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
872
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
873 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
874 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
875 ncrc = crc32(ncrc, (const Bytef *)recipe, sizeof(a_recipe));
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
876 if (ocrc != ncrc)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
877 wrrecipes();
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
878 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
879 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
880 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
881 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
882
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
883 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
884 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
885 if ((key == KEY_DOWN) && (idx < 6))
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
886 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
887
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
888 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
889 switch(idx) {
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
890 case 1: name = calloc(sizeof(char), 21);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
891 snprintf(name, 21, recipe->name);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
892 editName(name, (char *)"Recipe name");
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
893 if (recipe->name)
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
894 free(recipe->name);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
895 recipe->name = xstrcpy(name);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
896 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
897 break;
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
898 case 2: name = calloc(sizeof(char), 21);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
899 snprintf(name, 21, recipe->code);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
900 editName(name, (char *)"Recipe code");
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
901 if (recipe->code)
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
902 free(recipe->code);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
903 recipe->code = xstrcpy(name);
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
904 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
905 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
906 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
907 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
908 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
909 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
910 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
911 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
912
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
913
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
914
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
915 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
916 {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
917 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
918 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
919 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
920 int i;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
921
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
922 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
923 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
924 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
925 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
926 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
927 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
928 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
929 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
930 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
931 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
932 recipe->boiltime = 90;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
933 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
934 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
935 * 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
936 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
937 recipe->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
938 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
939 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
940 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
941 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
942 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
943 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
944 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
945 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
946 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
947 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
948 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
949 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
950 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
951 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
952 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
953 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
954 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
955 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
956 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
957 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
958 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
959 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
960 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
961 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
962 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
963 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
964 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
965 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
966 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
967 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
968 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
969 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
970 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
971 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
972 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
973 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
974 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
975 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
976 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
977 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
978 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
979 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
980 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
981 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
982 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
983 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
984 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
985 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
986 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
987 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
988 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
989 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
990 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
991 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
992 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
993
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
994 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
995 * 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
996 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
997 recipe->hops[0].name = xstrcpy((char *)"Hops 1");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
998 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
999 recipe->hops[1].name = xstrcpy((char *)"Hops 2");
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1000 recipe->hops[1].boiltime = 5;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1001 for (i = 2; i < 10; i++) {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1002 recipe->hops[i].name = NULL;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1003 recipe->hops[i].boiltime = 0;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1004 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1005
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1006
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1007 /*
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1008 * 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
1009 */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1010 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
1011 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
1012 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
1013 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
1014 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
1015 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
1016 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
1017 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
1018 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
1019 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
1020 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
1021 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
1022 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
1023 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
1024 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
1025 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
1026 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
1027 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
1028 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
1029 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
1030 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
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 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
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 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
1035 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
1036 } 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
1037 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
1038 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
1039 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
1040 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
1041 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1042 }
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 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
1045 if (debug)
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1046 fprintf(stdout, "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
1047 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1048
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1049
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1050
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 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
1052 {
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 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
1054 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
1055 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
1056
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 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
1058 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
1059 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
1060 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
1061 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
1062 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1063
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1064 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
1065 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
1066
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1067 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
1068 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
1069 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
1070 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
1071 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
1072 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
1073 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1074 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1075
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1076 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
1077 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
1078 if (total) {
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1079 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
1080 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
1081 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1082 if (total == 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
1083 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
1084 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
1085 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
1086 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
1087 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
1088 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
1089 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
1090 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
1091 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
1092
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1093 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
1094 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
1095 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
1096 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
1097 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
1098 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
1099 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1100 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
1101 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
1102 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
1103 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
1104 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
1105 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1106 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
1107 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
1108 }
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
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
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 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
1114 {
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1115 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
1116 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
1117 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
1118
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1119 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
1120 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
1121 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
1122 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
1123 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
1124 }
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
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 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
1127 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
1128
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 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
1130 /*
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 * 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
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 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
1134 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
1135 } 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
1136 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
1137 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
1138 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
1139 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
1140 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
1141 }
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 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
1143 prompt(222, NULL); /* " Select Brewsystem " */
461
482bab226340 Changed some prompt numbers. Added name editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
1144 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
1145 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
1146 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
1147 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
1148 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
1149 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
1150 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
1151 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
1152 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
1153 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
1154
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1155 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
1156 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
1157 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
1158 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
1159 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
1160 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
1161 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1162 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
1163 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
1164 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
1165 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
1166 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
1167 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1168 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
1169 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
1170 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1171 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1172 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1173
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1174
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
1175
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1176 void setup(void)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1177 {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1178 int key, option = 202;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1179
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1180 for (;;) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1181 if (debug)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1182 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
1183 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
1184 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
1185 prompt(option, NULL);
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1186 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
1187 prompt(402, NULL); /* "--- dwn quit ok " */
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1188 #ifdef USE_SIMULATOR
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1189 else if (option == 205)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1190 #else
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1191 else if (option == 204)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1192 #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
1193 prompt(404, NULL); /* " up --- quit ok " */
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1194 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
1195 prompt(403, NULL); /* " up dwn quit ok " */
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1196
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1197 key = keywait();
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1198
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1199 if ((key == KEY_RETURN) || my_shutdown)
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1200 return;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1201 if ((key == KEY_UP) && (option > 202)) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1202 option--;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1203 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1204 #ifdef USE_SIMULATOR
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1205 if ((key == KEY_DOWN) && (option < 205)) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1206 #else
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1207 if ((key == KEY_DOWN) && (option < 204)) {
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1208 #endif
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1209 option++;
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1210 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1211
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
1212 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
1213 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
1214 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
1215 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
1216 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
1217 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
1218 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
1219 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
1220 #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
1221 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
1222 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
1223 #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
1224 }
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
1225 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
1226 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
1227 }
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1228 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1229 }
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1230
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1231

mercurial