Thu, 14 Mar 2024 19:37:53 +0100
Create installation directories
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; |
427
e8e548922e31
Initial part of LEDs and backlight implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
426
diff
changeset
|
52 | extern uint16_t leds; |
e8e548922e31
Initial part of LEDs and backlight implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
426
diff
changeset
|
53 | extern int slcdHandle; |
199 | 54 | |
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
|
55 | 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
|
56 | 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
|
57 | 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
|
58 | 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
|
59 | |
204
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
60 | int previous_key = KEY_NONE; |
205 | 61 | int menutimer = 0; |
62 | ||
204
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
63 | |
229
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
64 | int keypressed(void); |
5f93b61adb34
Move some public functions to private functions
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
65 | |
204
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
66 | |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
67 | /* |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
68 | * 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
|
69 | */ |
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
|
70 | 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
|
71 | { |
204
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
72 | int key, retkey = KEY_NONE; |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
73 | |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
74 | key = keypressed(); |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
75 | 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
|
76 | retkey = previous_key; |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
77 | } |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
78 | |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
79 | previous_key = key; |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
80 | return retkey; |
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 | |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
84 | |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
85 | int keypressed(void) |
9a14d6b2de7f
Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
86 | { |
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
|
87 | 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
|
88 | 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
|
89 | if (Key_Up && Key_Down) |
205 | 90 | 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
|
91 | 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
|
92 | 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
|
93 | 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
|
94 | 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
|
95 | 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
|
96 | 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
|
97 | 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
|
98 | 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
|
99 | 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
|
100 | } |
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
|
101 | |
199 | 102 | |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
103 | #ifdef HAVE_WIRINGPI_H |
199 | 104 | 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
|
105 | #else |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
106 | 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
|
107 | #endif |
199 | 108 | { |
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
|
109 | 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
|
110 | 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
|
111 | |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
112 | #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
|
113 | 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
|
114 | 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
|
115 | 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
|
116 | pinMode(PANEL_DOWN, INPUT); |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
117 | #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
|
118 | |
199 | 119 | syslog(LOG_NOTICE, "Thread my_panel_loop started"); |
120 | ||
121 | /* | |
122 | * Loop forever until the external shutdown variable is set. | |
123 | */ | |
124 | for (;;) { | |
125 | if (my_shutdown) | |
126 | break; | |
127 | ||
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
128 | #ifdef HAVE_WIRINGPI_H |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
129 | 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
|
130 | #else |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
131 | if ((keys & 0x0001) == 0) { |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
132 | #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
|
133 | 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
|
134 | 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
|
135 | 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
|
136 | } 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
|
137 | 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
|
138 | 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
|
139 | 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
|
140 | 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
|
141 | Key_Enter_Long = TRUE; |
427
e8e548922e31
Initial part of LEDs and backlight implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
426
diff
changeset
|
142 | if (Enter == PRESS_LONG) { |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
143 | #ifdef HAVE_WIRINGPI_H |
216
d734255e66a0
LED flash when panel enter key is pressed long.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
144 | digitalWrite(PANEL_LED, 1); |
427
e8e548922e31
Initial part of LEDs and backlight implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
426
diff
changeset
|
145 | #endif |
e8e548922e31
Initial part of LEDs and backlight implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
426
diff
changeset
|
146 | leds |= SLED_TFLED; |
e8e548922e31
Initial part of LEDs and backlight implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
426
diff
changeset
|
147 | slcdLEDs(slcdHandle); |
e8e548922e31
Initial part of LEDs and backlight implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
426
diff
changeset
|
148 | } |
e8e548922e31
Initial part of LEDs and backlight implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
426
diff
changeset
|
149 | if (Enter == (PRESS_LONG + 10)) { |
e8e548922e31
Initial part of LEDs and backlight implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
426
diff
changeset
|
150 | #ifdef HAVE_WIRINGPI_H |
216
d734255e66a0
LED flash when panel enter key is pressed long.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
151 | digitalWrite(PANEL_LED, 0); |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
152 | #endif |
427
e8e548922e31
Initial part of LEDs and backlight implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
426
diff
changeset
|
153 | leds &= ~SLED_TFLED; |
e8e548922e31
Initial part of LEDs and backlight implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
426
diff
changeset
|
154 | slcdLEDs(slcdHandle); |
e8e548922e31
Initial part of LEDs and backlight implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
426
diff
changeset
|
155 | } |
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
|
156 | } |
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 | |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
158 | #ifdef HAVE_WIRINGPI_H |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
159 | 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
|
160 | #else |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
161 | if ((keys & 0x0008) == 0) { |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
162 | #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
|
163 | 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
|
164 | 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
|
165 | } 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
|
166 | 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
|
167 | 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
|
168 | 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
|
169 | } |
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 | |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
171 | #ifdef HAVE_WIRINGPI_H |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
172 | 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
|
173 | #else |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
174 | if ((keys & 0x0004) == 0) { |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
175 | #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
|
176 | 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
|
177 | 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
|
178 | } 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
|
179 | 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
|
180 | 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
|
181 | 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
|
182 | } |
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
|
183 | |
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
|
184 | 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
|
185 | 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
|
186 | /* |
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
|
187 | * 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
|
188 | */ |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
189 | #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
|
190 | piLock(LOCK_LCD); |
426
e54611453d29
Moved global bit defines to config.h
Michiel Broek <mbroek@mbse.eu>
parents:
422
diff
changeset
|
191 | #endif |
228
11655e7124c5
Fixed stepping down in LCD screens.
Michiel Broek <mbroek@mbse.eu>
parents:
219
diff
changeset
|
192 | setBacklight(1); |
426
e54611453d29
Moved global bit defines to config.h
Michiel Broek <mbroek@mbse.eu>
parents:
422
diff
changeset
|
193 | #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
|
194 | piUnlock(LOCK_LCD); |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
195 | #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
|
196 | Backlight = LCD_SLEEP; |
205 | 197 | 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
|
198 | } 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
|
199 | /* |
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
|
200 | * 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
|
201 | */ |
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
|
202 | 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
|
203 | } |
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 | |
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
|
205 | 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
|
206 | 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
|
207 | 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
|
208 | |
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 (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
|
210 | if (Backlight == 1) { |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
211 | #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
|
212 | piLock(LOCK_LCD); |
426
e54611453d29
Moved global bit defines to config.h
Michiel Broek <mbroek@mbse.eu>
parents:
422
diff
changeset
|
213 | #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
|
214 | setBacklight(0); |
426
e54611453d29
Moved global bit defines to config.h
Michiel Broek <mbroek@mbse.eu>
parents:
422
diff
changeset
|
215 | #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
|
216 | piUnlock(LOCK_LCD); |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
217 | #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
|
218 | } |
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
|
219 | 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
|
220 | 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
|
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 | piLock(LOCK_MENU); |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
225 | #endif |
205 | 226 | if (setupmenu != MENU_NONE) { |
227 | if (menutimer < MENU_TIMEOUT) | |
228 | menutimer++; | |
238 | 229 | else { |
205 | 230 | setupmenu = MENU_NONE; |
238 | 231 | } |
205 | 232 | } |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
233 | #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
|
234 | piUnlock(LOCK_MENU); |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
235 | #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
|
236 | } |
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
|
237 | } |
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
|
238 | |
199 | 239 | /* |
240 | * Loop 10 milliseconds | |
241 | */ | |
242 | usleep(10000); | |
243 | } | |
244 | ||
245 | syslog(LOG_NOTICE, "Thread my_panel_loop stopped"); | |
246 | return 0; | |
247 | } | |
197 | 248 | |
249 |