Sun, 27 Dec 2015 17:52:26 +0100
Renamed Mash-in step to Prepare on the display. Don't run the pump when the mash is added. When preparing the mash, first heat the HLT, and then the MLT so that both have the chance to reach their target temperatures.
435 | 1 | /***************************************************************************** |
2 | * Copyright (C) 2015 | |
3 | * | |
4 | * Michiel Broek <mbroek at mbse dot eu> | |
5 | * | |
6 | * This file is part of the mbsePi-apps | |
7 | * | |
8 | * This is free software; you can redistribute it and/or modify it | |
9 | * under the terms of the GNU General Public License as published by the | |
10 | * Free Software Foundation; either version 2, or (at your option) any | |
11 | * later version. | |
12 | * | |
13 | * mbsePi-apps is distributed in the hope that it will be useful, but | |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with ThermFerm; see the file COPYING. If not, write to the Free | |
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
21 | *****************************************************************************/ | |
22 | ||
23 | #include "brewco.h" | |
24 | #include "lcd-pcf8574.h" | |
25 | #include "slcd.h" | |
26 | #include "keyboard.h" | |
27 | ||
28 | ||
29 | ||
30 | /* | |
31 | * 10 Milliseconds counts for a key to be short or long pressed. | |
32 | */ | |
33 | #define PRESS_NORMAL 5 | |
34 | #define PRESS_LONG 200 | |
35 | ||
36 | ||
37 | ||
38 | extern int my_shutdown; | |
39 | extern int debug; | |
40 | extern int setupmenu; | |
41 | extern uint16_t keys; | |
42 | extern uint16_t leds; | |
43 | extern int slcdHandle; | |
44 | ||
45 | int Key_Enter = FALSE; | |
46 | int Key_Return = FALSE; | |
47 | int Key_Up = FALSE; | |
48 | int Key_Down = FALSE; | |
49 | ||
50 | int previous_key = KEY_NONE; | |
51 | ||
52 | ||
53 | int keypressed(void); | |
54 | ||
55 | ||
441 | 56 | |
57 | /* | |
58 | * Wait for a key. Return the pressed key. | |
59 | */ | |
60 | int keywait(void) | |
61 | { | |
62 | int key; | |
63 | ||
64 | do { | |
65 | usleep(50000); | |
66 | slcdDummy(slcdHandle); | |
67 | key = keycheck(); | |
68 | if (my_shutdown) | |
69 | return KEY_NONE; | |
70 | } while (key == KEY_NONE); | |
71 | ||
72 | fprintf(stdout, "keywait %d\n", key); | |
73 | return key; | |
74 | } | |
75 | ||
76 | ||
77 | ||
435 | 78 | /* |
79 | * Check for a key. Return last pressed key or none. | |
80 | */ | |
81 | int keycheck(void) | |
82 | { | |
83 | int key, retkey = KEY_NONE; | |
84 | ||
85 | key = keypressed(); | |
86 | if ((key == KEY_NONE) && (previous_key != KEY_NONE)) { | |
87 | retkey = previous_key; | |
88 | } | |
89 | ||
90 | previous_key = key; | |
91 | return retkey; | |
92 | } | |
93 | ||
94 | ||
95 | ||
96 | int keypressed(void) | |
97 | { | |
98 | if (Key_Enter && Key_Up && Key_Down && Key_Return) | |
99 | return KEY_ALL; | |
451 | 100 | if (Key_Up && Key_Down) |
101 | return KEY_ESCAPE; | |
435 | 102 | if (Key_Up) |
103 | return KEY_UP; | |
104 | if (Key_Down) | |
105 | return KEY_DOWN; | |
106 | if (Key_Enter) | |
107 | return KEY_ENTER; | |
108 | if (Key_Return) | |
109 | return KEY_RETURN; | |
110 | return KEY_NONE; | |
111 | } | |
112 | ||
113 | ||
114 | #ifdef HAVE_WIRINGPI_H | |
441 | 115 | PI_THREAD (my_keyboard_loop) |
435 | 116 | #else |
441 | 117 | void *my_keyboard_loop(void *threadid) |
435 | 118 | #endif |
119 | { | |
468
e8203e891b0e
Removed LCD auto dim mode, the display is allways on if this program runs.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
120 | int Return = 0, Enter = 0, Up = 0, Down = 0; |
435 | 121 | time_t Last = (time_t)0, Now; |
122 | ||
123 | #ifdef HAVE_WIRINGPI_H | |
124 | pinMode(PANEL_RETURN, INPUT); | |
125 | pinMode(PANEL_ENTER, INPUT); | |
126 | pinMode(PANEL_UP, INPUT); | |
127 | pinMode(PANEL_DOWN, INPUT); | |
128 | #endif | |
129 | ||
441 | 130 | syslog(LOG_NOTICE, "Thread my_keyboard_loop started"); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
435
diff
changeset
|
131 | if (debug) |
441 | 132 | fprintf(stdout, "Thread my_keyboard_loop started\n"); |
435 | 133 | |
134 | /* | |
135 | * Loop forever until the external shutdown variable is set. | |
136 | */ | |
137 | for (;;) { | |
138 | if (my_shutdown) | |
139 | break; | |
140 | ||
141 | #ifdef HAVE_WIRINGPI_H | |
142 | if (digitalRead(PANEL_ENTER) && ((keys & 0x0001) == 0)) { | |
143 | #else | |
144 | if ((keys & 0x0001) == 0) { | |
145 | #endif | |
146 | Enter = 0; | |
147 | Key_Enter = FALSE; | |
148 | } else { | |
149 | Enter++; | |
150 | if (Enter > PRESS_NORMAL) | |
151 | Key_Enter = TRUE; | |
152 | } | |
153 | ||
154 | #ifdef HAVE_WIRINGPI_H | |
155 | if (digitalRead(PANEL_RETURN) && ((keys & 0x0002) == 0)) { | |
156 | #else | |
157 | if ((keys & 0x0002) == 0) { | |
158 | #endif | |
159 | Return = 0; | |
160 | Key_Return = FALSE; | |
161 | } else { | |
162 | Return++; | |
163 | if (Return > PRESS_NORMAL) | |
164 | Key_Return = TRUE; | |
165 | } | |
166 | ||
167 | #ifdef HAVE_WIRINGPI_H | |
168 | if (digitalRead(PANEL_UP) && ((keys & 0x0008) == 0)) { | |
169 | #else | |
170 | if ((keys & 0x0008) == 0) { | |
171 | #endif | |
172 | Up = 0; | |
173 | Key_Up = FALSE; | |
174 | } else { | |
175 | Up++; | |
176 | if (Up > PRESS_NORMAL) | |
177 | Key_Up = TRUE; | |
178 | } | |
179 | ||
180 | #ifdef HAVE_WIRINGPI_H | |
181 | if (digitalRead(PANEL_DOWN) && ((keys & 0x0004) == 0)) { | |
182 | #else | |
183 | if ((keys & 0x0004) == 0) { | |
184 | #endif | |
185 | Down = 0; | |
186 | Key_Down = FALSE; | |
187 | } else { | |
188 | Down++; | |
189 | if (Down > PRESS_NORMAL) | |
190 | Key_Down = TRUE; | |
191 | } | |
192 | ||
193 | Now = time(NULL); | |
194 | if (Now != Last) { | |
195 | Last = Now; | |
196 | } | |
197 | ||
198 | /* | |
199 | * Loop 10 milliseconds | |
200 | */ | |
201 | usleep(10000); | |
202 | } | |
203 | ||
441 | 204 | syslog(LOG_NOTICE, "Thread my_keyboard_loop stopped"); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
435
diff
changeset
|
205 | if (debug) |
441 | 206 | fprintf(stdout, "Thread my_keyboard_loop stopped\n"); |
435 | 207 | return 0; |
208 | } | |
209 | ||
210 |