21 *****************************************************************************/ |
21 *****************************************************************************/ |
22 |
22 |
23 #include "thermferm.h" |
23 #include "thermferm.h" |
24 #include "lcd-buffer.h" |
24 #include "lcd-buffer.h" |
25 #include "lcd-pcf8574.h" |
25 #include "lcd-pcf8574.h" |
|
26 #include "panel.h" |
26 |
27 |
27 |
28 |
28 #ifdef HAVE_WIRINGPI_H |
29 #ifdef HAVE_WIRINGPI_H |
29 |
30 |
30 int current_lines = 0; |
31 int current_lines = 0; |
31 int current_offset = 0; |
32 int current_offset = 0; |
32 int current_second = 0; |
33 int first_time = 1; |
|
34 int previous_key = KEY_NONE; |
33 lcd_rows *my_lcd_rows = NULL; |
35 lcd_rows *my_lcd_rows = NULL; |
34 |
36 |
35 extern int lcdHandle; |
37 extern int lcdHandle; |
36 extern sys_config Config; |
38 extern sys_config Config; |
37 |
39 |
87 } |
89 } |
88 |
90 |
89 |
91 |
90 |
92 |
91 /* |
93 /* |
92 * This will be called each second. |
94 * This will be called from the main thread if not in edit mode. |
93 */ |
95 */ |
94 void lcd_buf_show(void) |
96 void lcd_buf_show(void) |
95 { |
97 { |
96 int i = 0, r = 0; |
98 int i = 0, r = 0, key, doit = FALSE; |
97 lcd_rows *tmp; |
99 lcd_rows *tmp; |
|
100 |
|
101 key = keycheck(); |
|
102 |
|
103 if ((key == KEY_NONE) && (previous_key == KEY_DOWN)) { |
|
104 if (current_offset < (current_lines - Config.lcd_rows)) |
|
105 current_offset = current_offset + Config.lcd_rows; |
|
106 else |
|
107 current_offset = 0; |
|
108 doit = TRUE; |
|
109 } |
|
110 if ((key == KEY_NONE) && (previous_key == KEY_UP)) { |
|
111 if (current_offset > Config.lcd_rows) |
|
112 current_offset = current_offset - Config.lcd_rows; |
|
113 else |
|
114 current_offset = (current_lines - Config.lcd_rows); |
|
115 doit = TRUE; |
|
116 } |
|
117 previous_key = key; |
|
118 |
|
119 |
|
120 /* |
|
121 * Make sure the display works when the program starts. |
|
122 */ |
|
123 if (first_time) { |
|
124 first_time = 0; |
|
125 doit = TRUE; |
|
126 } |
|
127 |
|
128 if (! doit) |
|
129 return; |
98 |
130 |
99 for (tmp = my_lcd_rows; tmp; tmp = tmp->next) { |
131 for (tmp = my_lcd_rows; tmp; tmp = tmp->next) { |
100 if (i == current_offset) |
132 if (i == current_offset) |
101 break; |
133 break; |
102 i++; |
134 i++; |