brewco/keyboard.c

changeset 441
bde74a8f2ad7
parent 438
7d1ec160d751
child 451
2247970de278
equal deleted inserted replaced
440:8df3252b688f 441:bde74a8f2ad7
62 62
63 63
64 int keypressed(void); 64 int keypressed(void);
65 65
66 66
67
68 /*
69 * Wait for a key. Return the pressed key.
70 */
71 int keywait(void)
72 {
73 int key;
74
75 do {
76 usleep(50000);
77 slcdDummy(slcdHandle);
78 key = keycheck();
79 if (my_shutdown)
80 return KEY_NONE;
81 } while (key == KEY_NONE);
82
83 fprintf(stdout, "keywait %d\n", key);
84 return key;
85 }
86
87
88
67 /* 89 /*
68 * Check for a key. Return last pressed key or none. 90 * Check for a key. Return last pressed key or none.
69 */ 91 */
70 int keycheck(void) 92 int keycheck(void)
71 { 93 {
97 return KEY_NONE; 119 return KEY_NONE;
98 } 120 }
99 121
100 122
101 #ifdef HAVE_WIRINGPI_H 123 #ifdef HAVE_WIRINGPI_H
102 PI_THREAD (my_panel_loop) 124 PI_THREAD (my_keyboard_loop)
103 #else 125 #else
104 void *my_panel_loop(void *threadid) 126 void *my_keyboard_loop(void *threadid)
105 #endif 127 #endif
106 { 128 {
107 int Return = 0, Enter = 0, Up = 0, Down = 0, Backlight = LCD_SLEEP, AnyKey = FALSE; 129 int Return = 0, Enter = 0, Up = 0, Down = 0, Backlight = LCD_SLEEP, AnyKey = FALSE;
108 time_t Last = (time_t)0, Now; 130 time_t Last = (time_t)0, Now;
109 131
112 pinMode(PANEL_ENTER, INPUT); 134 pinMode(PANEL_ENTER, INPUT);
113 pinMode(PANEL_UP, INPUT); 135 pinMode(PANEL_UP, INPUT);
114 pinMode(PANEL_DOWN, INPUT); 136 pinMode(PANEL_DOWN, INPUT);
115 #endif 137 #endif
116 138
117 syslog(LOG_NOTICE, "Thread my_panel_loop started"); 139 syslog(LOG_NOTICE, "Thread my_keyboard_loop started");
118 if (debug) 140 if (debug)
119 fprintf(stdout, "Thread my_panel_loop started\n"); 141 fprintf(stdout, "Thread my_keyboard_loop started\n");
120 142
121 /* 143 /*
122 * Loop forever until the external shutdown variable is set. 144 * Loop forever until the external shutdown variable is set.
123 */ 145 */
124 for (;;) { 146 for (;;) {
213 #endif 235 #endif
214 } 236 }
215 if (Backlight > 0) { 237 if (Backlight > 0) {
216 Backlight--; 238 Backlight--;
217 } 239 }
218
219 #ifdef HAVE_WIRINGPI_H
220 // piLock(LOCK_MENU);
221 #endif
222 // if (setupmenu != MENU_NONE) {
223 // if (menutimer < MENU_TIMEOUT)
224 // menutimer++;
225 // else {
226 // setupmenu = MENU_NONE;
227 // }
228 // }
229 #ifdef HAVE_WIRINGPI_H
230 // piUnlock(LOCK_MENU);
231 #endif
232 } 240 }
233 } 241 }
234 242
235 /* 243 /*
236 * Loop 10 milliseconds 244 * Loop 10 milliseconds
237 */ 245 */
238 usleep(10000); 246 usleep(10000);
239 } 247 }
240 248
241 syslog(LOG_NOTICE, "Thread my_panel_loop stopped"); 249 syslog(LOG_NOTICE, "Thread my_keyboard_loop stopped");
242 if (debug) 250 if (debug)
243 fprintf(stdout, "Thread my_panel_loop stopped\n"); 251 fprintf(stdout, "Thread my_keyboard_loop stopped\n");
244 return 0; 252 return 0;
245 } 253 }
246 254
247 255

mercurial