Sun, 10 Aug 2014 13:26:35 +0200
Start initial menu setup
thermferm/lcd-buffer.c | file | annotate | diff | comparison | revisions | |
thermferm/lcd-buffer.h | file | annotate | diff | comparison | revisions | |
thermferm/panel.c | file | annotate | diff | comparison | revisions | |
thermferm/panel.h | file | annotate | diff | comparison | revisions | |
thermferm/thermferm.c | file | annotate | diff | comparison | revisions | |
thermferm/thermferm.h | file | annotate | diff | comparison | revisions |
--- a/thermferm/lcd-buffer.c Sun Aug 10 12:09:07 2014 +0200 +++ b/thermferm/lcd-buffer.c Sun Aug 10 13:26:35 2014 +0200 @@ -88,12 +88,8 @@ -void lcd_buf_step(void) +void lcd_buf_step(int key) { - int key; - - key = keycheck(); - if (key == KEY_DOWN) { if (current_offset < (current_lines - Config.lcd_rows)) current_offset = current_offset + Config.lcd_rows;
--- a/thermferm/lcd-buffer.h Sun Aug 10 12:09:07 2014 +0200 +++ b/thermferm/lcd-buffer.h Sun Aug 10 13:26:35 2014 +0200 @@ -9,7 +9,7 @@ void lcd_buf_write(int, const char *, ...); -void lcd_buf_step(void); +void lcd_buf_step(int); void lcd_buf_show(void); #endif
--- a/thermferm/panel.c Sun Aug 10 12:09:07 2014 +0200 +++ b/thermferm/panel.c Sun Aug 10 13:26:35 2014 +0200 @@ -30,6 +30,7 @@ extern int my_shutdown; extern int debug; +extern int setupmenu; int Key_Enter = FALSE; int Key_Enter_Long = FALSE; @@ -37,6 +38,19 @@ int Key_Down = FALSE; int previous_key = KEY_NONE; +int menutimer = 0; + +int Led_Off = 0; +int Led_On = 100; + + +/* + * LED flash patterns, on, off. Times in 10 mSecs. + */ +const int LED_OFF[2] = { 0, 100 }; +const int LED_ON[2] = { 100, 0 }; +const int LED_WARN[2] = { 5, 95 }; +const int LED_ALARM[2] = { 50, 50 }; @@ -63,7 +77,7 @@ if (Key_Enter && Key_Up && Key_Down) return KEY_ALL; if (Key_Up && Key_Down) - return KEY_UPDOWN; + return KEY_ESCAPE; if (Key_Up) return KEY_UP; if (Key_Down) @@ -137,6 +151,7 @@ if (Backlight == 0) setBacklight(1); Backlight = LCD_SLEEP; + menutimer = 0; } else { /* * No key pressed. @@ -160,8 +175,14 @@ if (Backlight > 0) { Backlight--; } + + if (setupmenu != MENU_NONE) { + if (menutimer < MENU_TIMEOUT) + menutimer++; + else + setupmenu = MENU_NONE; + } } - } /*
--- a/thermferm/panel.h Sun Aug 10 12:09:07 2014 +0200 +++ b/thermferm/panel.h Sun Aug 10 13:26:35 2014 +0200 @@ -34,7 +34,7 @@ #define KEY_NONE 0 #define KEY_UP 1 #define KEY_DOWN 2 -#define KEY_UPDOWN 3 +#define KEY_ESCAPE 3 #define KEY_ENTER 4 #define KEY_CONFIRM 5 /* Long Enter */ #define KEY_ALL 99
--- a/thermferm/thermferm.c Sun Aug 10 12:09:07 2014 +0200 +++ b/thermferm/thermferm.c Sun Aug 10 13:26:35 2014 +0200 @@ -37,9 +37,6 @@ int tempA = 80; int tempB = 80; -key_t key = 5680; /* key to be passed to shmget() */ -int shmid; - int my_shutdown = FALSE; static pid_t pgrp, mypid; @@ -48,6 +45,8 @@ #ifdef HAVE_WIRINGPI_H extern int lcdHandle; extern unsigned char lcdbuf[MAX_LCDS][20][4]; +int setupmenu = MENU_NONE; + #endif int lcdupdate; #ifndef HAVE_WIRINGPI_H @@ -257,7 +256,7 @@ float err = 0.0, sp, pv, P_err, D_err, Out; #ifdef HAVE_WIRINGPI_H struct tm *tm; - int row; + int row, key; #else long t = 0; #endif @@ -565,8 +564,10 @@ } #ifdef HAVE_WIRINGPI_H - lcd_buf_show(); + if (setupmenu == MENU_NONE) + lcd_buf_show(); #endif + if (seconds == 60) { seconds = 0; @@ -625,8 +626,33 @@ } #ifdef HAVE_WIRINGPI_H - // FIXME: not in editmode. - lcd_buf_step(); + /* + * Handle panel key events. + */ + key = keycheck(); + + switch (setupmenu) { + case MENU_NONE: + if ((key == KEY_DOWN) || (key == KEY_UP)) + lcd_buf_step(key); + if ((key == KEY_CONFIRM) && (setupmenu == MENU_NONE)) { + setupmenu = MENU_TOP; + mb_lcdClear(lcdHandle); + lcdPosition(lcdHandle, 0, 0); + mb_lcdPuts(lcdHandle, "Setup mode."); + lcdPosition(lcdHandle, 0, 1); + mb_lcdPuts(lcdHandle, "Up&Down = Escape"); + } + break; + + case MENU_TOP: + if (key == KEY_ESCAPE) { + setupmenu = MENU_NONE; + lcd_buf_show(); + } + break; + } + #endif usleep(100000);