thermferm/panel.c

Sun, 10 Aug 2014 13:26:35 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 10 Aug 2014 13:26:35 +0200
changeset 205
ca18ff45deba
parent 204
9a14d6b2de7f
child 213
2317b8d644fa
permissions
-rw-r--r--

Start initial menu setup

197
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*****************************************************************************
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * Copyright (C) 2014
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Michiel Broek <mbroek at mbse dot eu>
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * This file is part of the mbsePi-apps
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 *
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * This is free software; you can redistribute it and/or modify it
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * under the terms of the GNU General Public License as published by the
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * Free Software Foundation; either version 2, or (at your option) any
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * later version.
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 *
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * mbsePi-apps is distributed in the hope that it will be useful, but
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * General Public License for more details.
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 *
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 * along with ThermFerm; see the file COPYING. If not, write to the Free
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 *****************************************************************************/
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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"
197
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 #include "panel.h"
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26
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
27
197
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 #ifdef HAVE_WIRINGPI_H
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
199
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
31 extern int my_shutdown;
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
32 extern int debug;
205
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
33 extern int setupmenu;
199
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
34
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
35 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
36 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
37 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
38 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
39
204
9a14d6b2de7f Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
40 int previous_key = KEY_NONE;
205
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
41 int menutimer = 0;
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
42
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
43 int Led_Off = 0;
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
44 int Led_On = 100;
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
45
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
46
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
47 /*
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
48 * LED flash patterns, on, off. Times in 10 mSecs.
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
49 */
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
50 const int LED_OFF[2] = { 0, 100 };
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
51 const int LED_ON[2] = { 100, 0 };
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
52 const int LED_WARN[2] = { 5, 95 };
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
53 const int LED_ALARM[2] = { 50, 50 };
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
54
204
9a14d6b2de7f Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
55
9a14d6b2de7f Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
56
9a14d6b2de7f Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
57 /*
9a14d6b2de7f Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
58 * 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
59 */
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
60 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
61 {
204
9a14d6b2de7f Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
62 int key, retkey = KEY_NONE;
9a14d6b2de7f Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
63
9a14d6b2de7f Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
64 key = keypressed();
9a14d6b2de7f Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
65 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
66 retkey = previous_key;
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
9a14d6b2de7f Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
69 previous_key = key;
9a14d6b2de7f Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
70 return retkey;
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
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
9a14d6b2de7f Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
75 int keypressed(void)
9a14d6b2de7f Fixed LCD display updates. Better key routines.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
76 {
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
77 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
78 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
79 if (Key_Up && Key_Down)
205
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
80 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
81 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
82 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
83 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
84 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
85 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
86 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
87 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
88 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
89 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
90 }
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
199
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
92
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
93
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
94 PI_THREAD (my_panel_loop)
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
95 {
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
96 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
97 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
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 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
100 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
101 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
102 pinMode(PANEL_DOWN, 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
103
199
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
104
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
105 syslog(LOG_NOTICE, "Thread my_panel_loop started");
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
106 if (debug)
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
107 fprintf(stdout, "Thread my_panel_loop started\n");
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
108
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
109 /*
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
110 * Loop forever until the external shutdown variable is set.
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
111 */
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
112 for (;;) {
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
113 if (my_shutdown)
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
114 break;
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
115
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 if (digitalRead(PANEL_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
117 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
118 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
119 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
120 } 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
121 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
122 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
123 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
124 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
125 Key_Enter_Long = 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
126 }
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
127
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
128 if (digitalRead(PANEL_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
129 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
130 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
131 } 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
132 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
133 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
134 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
135 }
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
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 if (digitalRead(PANEL_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
138 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
139 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
140 } 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
141 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
142 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
143 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
144 }
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
145
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 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
147 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
148 /*
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
149 * 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
150 */
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
151 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
152 setBacklight(1);
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 Backlight = LCD_SLEEP;
205
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
154 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
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 /*
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 * 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
158 */
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 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
160 }
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
161
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
162 // if (debug && AnyKey)
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 // fprintf(stdout, "keys Enter=%d,%s,%s Up=%d,%s Down=%d,%s\n",
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 // Enter, Key_Enter ?"True":"False", Key_Enter_Long ?"True":"False", Up, Key_Up ?"True":"False", Down, Key_Down ?"True":"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
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 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
167 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
168 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
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 // if (debug)
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 // fprintf(stdout, "AnyKey=%s Backlight=%d\n", AnyKey ?"True":"False", 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
172 if (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
173 if (Backlight == 1)
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 setBacklight(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
175 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
176 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
177 }
205
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
178
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
179 if (setupmenu != MENU_NONE) {
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
180 if (menutimer < MENU_TIMEOUT)
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
181 menutimer++;
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
182 else
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
183 setupmenu = MENU_NONE;
ca18ff45deba Start initial menu setup
Michiel Broek <mbroek@mbse.eu>
parents: 204
diff changeset
184 }
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
185 }
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
199
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
188 /*
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
189 * Loop 10 milliseconds
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
190 */
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
191 usleep(10000);
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
192 }
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
193
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
194 syslog(LOG_NOTICE, "Thread my_panel_loop stopped");
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
195 if (debug)
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
196 fprintf(stdout, "Thread my_panel_loop stopped\n");
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
197
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
198 return 0;
3f5d277a69e3 Added panel thread
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
199 }
197
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201
531725a09012 Added panel sourcecode files
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202 #endif

mercurial