brewco/keyboard.c

Sun, 27 Dec 2015 17:52:26 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 27 Dec 2015 17:52:26 +0100
changeset 477
9167ad4c2e77
parent 468
e8203e891b0e
permissions
-rw-r--r--

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

mercurial