Thu, 19 Nov 2015 21:17:26 +0100
Moved global bit defines to config.h
197 | 1 | /***************************************************************************** |
2 | * Copyright (C) 2014 | |
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 "thermferm.h" | |
200
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
24 | #include "lcd-pcf8574.h" |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
25 | #include "slcd.h" |
197 | 26 | #include "panel.h" |
27 | ||
200
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
28 | |
197 | 29 | |
229
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
30 | /* |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
31 | * 10 Milliseconds counts for a key to be short or long pressed. |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
32 | */ |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
33 | #define PRESS_NORMAL 5 |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
34 | #define PRESS_LONG 200 |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
35 | |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
36 | /* |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
37 | * LCD timeout in seconds |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
38 | */ |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
39 | #define LCD_SLEEP 120 |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
40 | |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
41 | /* |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
42 | * Menu timeout in seconds |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
43 | */ |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
44 | #define MENU_TIMEOUT 60 |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
45 | |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
46 | |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
47 | |
199 | 48 | extern int my_shutdown; |
49 | extern int debug; | |
205 | 50 | extern int setupmenu; |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
51 | extern uint16_t keys; |
199 | 52 | |
200
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
53 | int Key_Enter = FALSE; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
54 | int Key_Enter_Long = FALSE; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
55 | int Key_Up = FALSE; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
56 | int Key_Down = FALSE; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
57 | |
204
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
58 | int previous_key = KEY_NONE; |
205 | 59 | int menutimer = 0; |
60 | ||
204
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
61 | |
229
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
62 | int keypressed(void); |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
63 | |
204
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
64 | |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
65 | /* |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
66 | * Check for a key. Return last pressed key or none. |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
67 | */ |
200
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
68 | int keycheck(void) |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
69 | { |
204
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
70 | int key, retkey = KEY_NONE; |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
71 | |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
72 | key = keypressed(); |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
73 | if ((key == KEY_NONE) && (previous_key != KEY_NONE)) { |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
74 | retkey = previous_key; |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
75 | } |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
76 | |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
77 | previous_key = key; |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
78 | return retkey; |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
79 | } |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
80 | |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
81 | |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
82 | |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
83 | int keypressed(void) |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
84 | { |
200
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
85 | if (Key_Enter && Key_Up && Key_Down) |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
86 | return KEY_ALL; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
87 | if (Key_Up && Key_Down) |
205 | 88 | return KEY_ESCAPE; |
200
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
89 | if (Key_Up) |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
90 | return KEY_UP; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
91 | if (Key_Down) |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
92 | return KEY_DOWN; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
93 | if (Key_Enter_Long) |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
94 | return KEY_CONFIRM; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
95 | if (Key_Enter) |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
96 | return KEY_ENTER; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
97 | return KEY_NONE; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
98 | } |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
99 | |
199 | 100 | |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
101 | #ifdef HAVE_WIRINGPI_H |
199 | 102 | PI_THREAD (my_panel_loop) |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
103 | #else |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
104 | void *my_panel_loop(void *threadid) |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
105 | #endif |
199 | 106 | { |
200
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
107 | int Enter = 0, Up = 0, Down = 0, Backlight = LCD_SLEEP, AnyKey = FALSE; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
108 | time_t Last = (time_t)0, Now; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
109 | |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
110 | #ifdef HAVE_WIRINGPI_H |
200
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
111 | pinMode(PANEL_LED, OUTPUT); |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
112 | pinMode(PANEL_ENTER, INPUT); |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
113 | pinMode(PANEL_UP, INPUT); |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
114 | pinMode(PANEL_DOWN, INPUT); |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
115 | #endif |
200
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
116 | |
199 | 117 | syslog(LOG_NOTICE, "Thread my_panel_loop started"); |
118 | ||
119 | /* | |
120 | * Loop forever until the external shutdown variable is set. | |
121 | */ | |
122 | for (;;) { | |
123 | if (my_shutdown) | |
124 | break; | |
125 | ||
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
126 | #ifdef HAVE_WIRINGPI_H |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
127 | if (digitalRead(PANEL_ENTER) && ((keys & 0x0001) == 0)) { |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
128 | #else |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
129 | if ((keys & 0x0001) == 0) { |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
130 | #endif |
200
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
131 | Enter = 0; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
132 | Key_Enter = FALSE; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
133 | Key_Enter_Long = FALSE; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
134 | } else { |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
135 | Enter++; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
136 | if (Enter > PRESS_NORMAL) |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
137 | Key_Enter = TRUE; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
138 | if (Enter > PRESS_LONG) |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
139 | Key_Enter_Long = TRUE; |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
140 | #ifdef HAVE_WIRINGPI_H |
216
d734255e66a0
LED flash when panel enter key is pressed long.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
141 | if (Enter == PRESS_LONG) |
d734255e66a0
LED flash when panel enter key is pressed long.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
142 | digitalWrite(PANEL_LED, 1); |
d734255e66a0
LED flash when panel enter key is pressed long.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
143 | if (Enter == (PRESS_LONG + 10)) |
d734255e66a0
LED flash when panel enter key is pressed long.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
144 | digitalWrite(PANEL_LED, 0); |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
145 | #endif |
200
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
146 | } |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
147 | |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
148 | #ifdef HAVE_WIRINGPI_H |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
149 | if (digitalRead(PANEL_UP) && ((keys & 0x0008) == 0)) { |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
150 | #else |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
151 | if ((keys & 0x0008) == 0) { |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
152 | #endif |
200
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
153 | Up = 0; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
154 | Key_Up = FALSE; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
155 | } else { |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
156 | Up++; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
157 | if (Up > PRESS_NORMAL) |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
158 | Key_Up = TRUE; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
159 | } |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
160 | |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
161 | #ifdef HAVE_WIRINGPI_H |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
162 | if (digitalRead(PANEL_DOWN) && ((keys & 0x0004) == 0)) { |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
163 | #else |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
164 | if ((keys & 0x0004) == 0) { |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
165 | #endif |
200
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
166 | Down = 0; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
167 | Key_Down = FALSE; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
168 | } else { |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
169 | Down++; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
170 | if (Down > PRESS_NORMAL) |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
171 | Key_Down = TRUE; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
172 | } |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
173 | |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
174 | if (Key_Enter || Key_Up || Key_Down) { |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
175 | AnyKey = TRUE; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
176 | /* |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
177 | * Any key is pressed. |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
178 | */ |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
179 | #ifdef HAVE_WIRINGPI_H |
241
4ba138737bf4
Added thread locks to all LCD access functions. This seems to have fixed the LCD corruption problems.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
180 | piLock(LOCK_LCD); |
426
e54611453d29
Moved global bit defines to config.h
Michiel Broek <mbroek@mbse.eu>
parents:
422
diff
changeset
|
181 | #endif |
228
11655e7124c5
Fixed stepping down in LCD screens.
Michiel Broek <mbroek@mbse.eu>
parents:
219
diff
changeset
|
182 | setBacklight(1); |
426
e54611453d29
Moved global bit defines to config.h
Michiel Broek <mbroek@mbse.eu>
parents:
422
diff
changeset
|
183 | #ifdef HAVE_WIRINGPI_H |
241
4ba138737bf4
Added thread locks to all LCD access functions. This seems to have fixed the LCD corruption problems.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
184 | piUnlock(LOCK_LCD); |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
185 | #endif |
200
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
186 | Backlight = LCD_SLEEP; |
205 | 187 | menutimer = 0; |
200
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
188 | } else { |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
189 | /* |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
190 | * No key pressed. |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
191 | */ |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
192 | AnyKey = FALSE; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
193 | } |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
194 | |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
195 | Now = time(NULL); |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
196 | if (Now != Last) { |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
197 | Last = Now; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
198 | |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
199 | if (AnyKey == FALSE) { |
241
4ba138737bf4
Added thread locks to all LCD access functions. This seems to have fixed the LCD corruption problems.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
200 | if (Backlight == 1) { |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
201 | #ifdef HAVE_WIRINGPI_H |
241
4ba138737bf4
Added thread locks to all LCD access functions. This seems to have fixed the LCD corruption problems.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
202 | piLock(LOCK_LCD); |
426
e54611453d29
Moved global bit defines to config.h
Michiel Broek <mbroek@mbse.eu>
parents:
422
diff
changeset
|
203 | #endif |
200
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
204 | setBacklight(0); |
426
e54611453d29
Moved global bit defines to config.h
Michiel Broek <mbroek@mbse.eu>
parents:
422
diff
changeset
|
205 | #ifdef HAVE_WIRINGPI_H |
241
4ba138737bf4
Added thread locks to all LCD access functions. This seems to have fixed the LCD corruption problems.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
206 | piUnlock(LOCK_LCD); |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
207 | #endif |
241
4ba138737bf4
Added thread locks to all LCD access functions. This seems to have fixed the LCD corruption problems.
Michiel Broek <mbroek@mbse.eu>
parents:
238
diff
changeset
|
208 | } |
200
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
209 | if (Backlight > 0) { |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
210 | Backlight--; |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
211 | } |
205 | 212 | |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
213 | #ifdef HAVE_WIRINGPI_H |
244
2f868eaefec2
Selecting units in setup does now work. Menu select variables are protected with thread locking.
Michiel Broek <mbroek@mbse.eu>
parents:
241
diff
changeset
|
214 | piLock(LOCK_MENU); |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
215 | #endif |
205 | 216 | if (setupmenu != MENU_NONE) { |
217 | if (menutimer < MENU_TIMEOUT) | |
218 | menutimer++; | |
238 | 219 | else { |
205 | 220 | setupmenu = MENU_NONE; |
238 | 221 | } |
205 | 222 | } |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
223 | #ifdef HAVE_WIRINGPI_H |
244
2f868eaefec2
Selecting units in setup does now work. Menu select variables are protected with thread locking.
Michiel Broek <mbroek@mbse.eu>
parents:
241
diff
changeset
|
224 | piUnlock(LOCK_MENU); |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
225 | #endif |
200
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
226 | } |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
227 | } |
a215ddaabbe2
Added first panel key routines. The LCD display steps manual only and has a 2 minutes backlight timeout.
Michiel Broek <mbroek@mbse.eu>
parents:
199
diff
changeset
|
228 | |
199 | 229 | /* |
230 | * Loop 10 milliseconds | |
231 | */ | |
232 | usleep(10000); | |
233 | } | |
234 | ||
235 | syslog(LOG_NOTICE, "Thread my_panel_loop stopped"); | |
236 | return 0; | |
237 | } | |
197 | 238 | |
239 |