Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1100 | - | 1 | /***************************************************************************** |
2 | * Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
||
3 | * Copyright (C) 2011 Christian Brandtner brandtner@brandtner.net * |
||
4 | * * |
||
5 | * This program is free software; you can redistribute it and/or modify * |
||
6 | * it under the terms of the GNU General Public License as published by * |
||
7 | * the Free Software Foundation; either version 2 of the License. * |
||
8 | * * |
||
9 | * This program is distributed in the hope that it will be useful, * |
||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
12 | * GNU General Public License for more details. * |
||
13 | * * |
||
14 | * You should have received a copy of the GNU General Public License * |
||
15 | * along with this program; if not, write to the * |
||
16 | * Free Software Foundation, Inc., * |
||
17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
||
18 | * * |
||
19 | * Einstellen der Variablen Parameter des P-MKTool * |
||
20 | * * |
||
21 | *****************************************************************************/ |
||
22 | |||
23 | #include <avr/io.h> |
||
24 | #include <avr/interrupt.h> |
||
25 | #include <avr/pgmspace.h> |
||
26 | #include <string.h> |
||
27 | |||
28 | #include "main.h" |
||
29 | #include "setup.h" |
||
30 | #include "lcd.h" |
||
31 | #include "eeprom.h" |
||
32 | #include "timer.h" |
||
33 | #include "menu.h" |
||
34 | |||
35 | |||
36 | uint8_t spalte; |
||
37 | uint8_t mmode; |
||
38 | uint8_t zeile; |
||
39 | uint8_t edit; |
||
40 | uint8_t MenuItems; |
||
41 | uint8_t LCD_Ausrichtung; |
||
42 | uint8_t edit =0; |
||
43 | |||
44 | // |
||
45 | |||
46 | #define ITEMS_PKT 7 |
||
47 | |||
48 | prog_char param_menuitems_pkt[ITEMS_PKT][15]= // zeilen,zeichen+1 |
||
49 | { |
||
50 | "LowBat Warn ", |
||
51 | "Displ.Timeout", |
||
52 | "LCD Orient. ", |
||
53 | "Language ", |
||
54 | "Wi TX/RX Chan", |
||
55 | "Wi NetW. Grp.", |
||
56 | "Wi NetW. Mode", |
||
57 | |||
58 | }; |
||
59 | |||
60 | /***********************************************************************************************//***********************************************************************************************/ |
||
61 | uint8_t Edit_Int10th_Value(uint8_t Value, uint8_t min, uint8_t max,const char *Text) |
||
62 | |||
63 | { |
||
64 | lcd_cls(); |
||
65 | lcd_printpns_at (0, 2, Text, 0); |
||
66 | write_ndigit_number_u_10th (16, 2,Value, 3, 0); |
||
67 | lcd_printpns_at (0, 7, PSTR(" \x18 \x19 Back "), 0); |
||
68 | do |
||
69 | { |
||
70 | if ((get_key_press (1 << KEY_PLUS) || get_key_rpt (1 << KEY_PLUS)) && (Value < max)) |
||
71 | { |
||
72 | edit=1; |
||
73 | Value++; |
||
74 | write_ndigit_number_u_10th (16, 2,Value, 3, 0); |
||
75 | } |
||
76 | if ((get_key_press (1 << KEY_MINUS) || get_key_rpt (1 << KEY_MINUS)) && (Value > min)) |
||
77 | { |
||
78 | edit=1; |
||
79 | Value--; |
||
80 | write_ndigit_number_u_10th (16, 2,Value, 3, 0); |
||
81 | } |
||
82 | } |
||
83 | while (!get_key_press (1 << KEY_ESC)); |
||
84 | return Value; |
||
85 | |||
86 | } |
||
87 | |||
88 | |||
89 | /***********************************************************************************************//***********************************************************************************************/ |
||
90 | uint8_t Edit_Int_Value(uint8_t Value, uint8_t min, uint8_t max,const char *Text) |
||
91 | |||
92 | { |
||
93 | lcd_cls(); |
||
94 | lcd_printpns_at (0, 2, Text, 0); |
||
95 | write_ndigit_number_u (16, 2, Value, 3, 0); |
||
96 | lcd_printpns_at (0, 7, PSTR(" \x18 \x19 Back "), 0); |
||
97 | do |
||
98 | { |
||
99 | if ((get_key_press (1 << KEY_PLUS) || get_key_rpt (1 << KEY_PLUS)) && (Value < max)) |
||
100 | { |
||
101 | edit=1; |
||
102 | Value++; |
||
103 | write_ndigit_number_u (16, 2,Value, 3, 0); |
||
104 | } |
||
105 | if ((get_key_press (1 << KEY_MINUS) || get_key_rpt (1 << KEY_MINUS)) && (Value > min)) |
||
106 | { |
||
107 | edit=1; |
||
108 | Value--; |
||
109 | write_ndigit_number_u (16, 2,Value, 3, 0); |
||
110 | } |
||
111 | } |
||
112 | while (!get_key_press (1 << KEY_ESC)); |
||
113 | return Value; |
||
114 | |||
115 | } |
||
116 | |||
117 | /***********************************************************************************************//***********************************************************************************************/ |
||
118 | uint8_t Edit_Wi_NetMode_Value(uint8_t Value, uint8_t min, uint8_t max,const char *Text) |
||
119 | |||
120 | { |
||
121 | lcd_cls(); |
||
122 | lcd_printpns_at (0, 2, Text, 0); |
||
123 | switch (Value) |
||
124 | { |
||
125 | case 0x0 :lcd_printpns_at (15, 2, PSTR("Slave "), 0);break; |
||
126 | case 0x1 :lcd_printpns_at (15, 2, PSTR("Normal"), 0);break; |
||
127 | break; |
||
128 | } |
||
129 | lcd_printpns_at (0, 7, PSTR(" \x18 \x19 Back "), 0); |
||
130 | do |
||
131 | { |
||
132 | if ((get_key_press (1 << KEY_PLUS) || get_key_rpt (1 << KEY_PLUS)) && (Value == 0)) |
||
133 | { |
||
134 | edit=1; |
||
135 | Value=1; |
||
136 | lcd_printpns_at (15, 2, PSTR("Normal"), 0); |
||
137 | } |
||
138 | if ((get_key_press (1 << KEY_MINUS) || get_key_rpt (1 << KEY_MINUS)) && (Value == 1)) |
||
139 | { |
||
140 | edit=1; |
||
141 | Value=0; |
||
142 | lcd_printpns_at (15, 2, PSTR("Slave "), 0); |
||
143 | } |
||
144 | } |
||
145 | while (!get_key_press (1 << KEY_ESC)); |
||
146 | return Value; |
||
147 | |||
148 | } |
||
149 | |||
150 | |||
151 | /***********************************************************************************************//***********************************************************************************************/ |
||
152 | uint8_t Edit_Language(uint8_t Value, uint8_t min, uint8_t max,const char *Text) |
||
153 | |||
154 | { |
||
155 | lcd_cls(); |
||
156 | lcd_printpns_at (0, 2, Text, 0); |
||
157 | switch (Value) |
||
158 | { |
||
159 | case 0x0 :lcd_printpns_at (14, 2, PSTR("Deutsch"), 0);break; |
||
160 | case 0x1 :lcd_printpns_at (14, 2, PSTR("France"), 0);break; |
||
161 | case 0x2 :lcd_printpns_at (14, 2, PSTR("English"), 0);break; |
||
162 | break; |
||
163 | } |
||
164 | lcd_printpns_at (0, 7, PSTR(" \x18 \x19 Back "), 0); |
||
165 | do |
||
166 | { |
||
167 | if ((get_key_press (1 << KEY_PLUS) || get_key_rpt (1 << KEY_PLUS)) && (Value < max)) |
||
168 | { |
||
169 | edit=1; |
||
170 | Value++; |
||
171 | switch (Value) |
||
172 | { |
||
173 | case 0x0 :lcd_printpns_at (14, 2, PSTR("Deutsch"), 0);break; |
||
174 | case 0x1 :lcd_printpns_at (14, 2, PSTR("France "), 0);break; |
||
175 | case 0x2 :lcd_printpns_at (14, 2, PSTR("English"), 0);break; |
||
176 | break; |
||
177 | } |
||
178 | } |
||
179 | if ((get_key_press (1 << KEY_MINUS) || get_key_rpt (1 << KEY_MINUS)) && (Value > min)) |
||
180 | { |
||
181 | edit=1; |
||
182 | Value--; |
||
183 | switch (Value) |
||
184 | { |
||
185 | case 0x0 :lcd_printpns_at (14, 2, PSTR("Deutsch"), 0);break; |
||
186 | case 0x1 :lcd_printpns_at (14, 2, PSTR("France "), 0);break; |
||
187 | case 0x2 :lcd_printpns_at (14, 2, PSTR("English"), 0);break; |
||
188 | break; |
||
189 | } |
||
190 | } |
||
191 | } |
||
192 | while (!get_key_press (1 << KEY_ESC)); |
||
193 | return Value; |
||
194 | |||
195 | } |
||
196 | |||
197 | |||
198 | |||
199 | /***********************************************************************************************/ |
||
200 | |||
201 | uint8_t Edit_Orientation(uint8_t Value, uint8_t min, uint8_t max,const char *Text) |
||
202 | |||
203 | { |
||
204 | lcd_cls(); |
||
205 | lcd_printpns_at (0, 2, Text, 0); |
||
206 | switch (Value) |
||
207 | { |
||
208 | case 0x0 :lcd_printpns_at (14, 2, PSTR("Normal "), 0);break; |
||
209 | case 0x4 :lcd_printpns_at (14, 2, PSTR("Reverse"), 0);break; |
||
210 | break; |
||
211 | } |
||
212 | lcd_printpns_at (0, 7, PSTR(" \x18 \x19 Back "), 0); |
||
213 | do |
||
214 | { |
||
215 | if ((get_key_press (1 << KEY_PLUS) || get_key_rpt (1 << KEY_PLUS)) && (Value == 0)) |
||
216 | { |
||
217 | edit=2; |
||
218 | Value=4; |
||
219 | lcd_printpns_at (14, 2, PSTR("Reverse"), 0); |
||
220 | } |
||
221 | if ((get_key_press (1 << KEY_MINUS) || get_key_rpt (1 << KEY_MINUS)) && (Value == 4)) |
||
222 | { |
||
223 | edit=2; |
||
224 | Value=0; |
||
225 | lcd_printpns_at (14, 2, PSTR("Normal "), 0); |
||
226 | } |
||
227 | } |
||
228 | while (!get_key_press (1 << KEY_ESC)); |
||
229 | return Value; |
||
230 | |||
231 | } |
||
232 | |||
233 | |||
234 | |||
235 | |||
236 | |||
237 | void PMK_Setup (void) |
||
238 | { |
||
239 | uint8_t ii = 0; |
||
240 | uint8_t offset = 0; |
||
241 | uint8_t size = 0; |
||
242 | size = ITEMS_PKT ; |
||
243 | uint8_t dmode = 0; |
||
244 | uint8_t target_pos = 1; |
||
245 | uint8_t val; |
||
246 | |||
247 | |||
248 | lcd_cls (); |
||
249 | mmode = 0; |
||
250 | edit=0; |
||
251 | zeile = 1; |
||
252 | MenuItems =2; |
||
253 | LCD_Ausrichtung = LCD_ORIENTATION; |
||
254 | val = 0; |
||
255 | |||
256 | |||
257 | while(1) |
||
258 | { |
||
259 | lcd_cls (); |
||
260 | lcd_printp_at (0, 0, PSTR("PMK-Tool Setup"), 0); |
||
261 | lcd_printpns_at (0, 7, PSTR(" \x18 \x19 Back \x0c "), 0); |
||
262 | while(1) |
||
263 | { |
||
264 | ii = 0; |
||
265 | if(offset > 0) |
||
266 | { |
||
267 | lcd_printp_at(1,1, PSTR("\x1a"), 0); |
||
268 | } |
||
269 | for(ii = 0;ii < 6 ; ii++) |
||
270 | { |
||
271 | if((ii+offset) < size) |
||
272 | { |
||
273 | lcd_printp_at(3,ii+1,param_menuitems_pkt[ii+offset], 0); |
||
274 | } |
||
275 | if((ii == 5)&&(ii+offset < (size-1))) |
||
276 | { |
||
277 | lcd_printp_at(1,6, PSTR("\x1b"), 0); |
||
278 | } |
||
279 | } |
||
280 | |||
281 | if(dmode == 0) |
||
282 | { |
||
283 | if(offset == 0) |
||
284 | { |
||
285 | if(size > 6) |
||
286 | { |
||
287 | val = menu_choose2 (1, 5, target_pos,0,1); |
||
288 | } |
||
289 | else |
||
290 | { |
||
291 | val = menu_choose2 (1, size, target_pos,0,0); |
||
292 | } |
||
293 | } |
||
294 | else |
||
295 | { |
||
296 | val = menu_choose2 (2, 5, target_pos,1,1); |
||
297 | } |
||
298 | } |
||
299 | if(dmode == 1) |
||
300 | { |
||
301 | if(offset+7 > size) |
||
302 | { |
||
303 | val = menu_choose2 (2, 6, target_pos,1,0); |
||
304 | } |
||
305 | else |
||
306 | { |
||
307 | val = menu_choose2 (2, 5, target_pos,1,1); |
||
308 | } |
||
309 | } |
||
310 | |||
311 | if(val == 254) |
||
312 | { |
||
313 | offset++; |
||
314 | dmode = 1; |
||
315 | target_pos = 5; |
||
316 | }else if(val == 253) |
||
317 | { |
||
318 | offset--; |
||
319 | dmode = 0; |
||
320 | target_pos = 2; |
||
321 | }else if(val == 255) |
||
322 | { /* Ende mit BACK, speichern */ |
||
323 | if (edit==1) WriteParameter(); |
||
324 | if (edit==2) /* LCD hat sich geƤndert*/ |
||
325 | { |
||
326 | LCD_ORIENTATION = LCD_Ausrichtung; |
||
327 | WriteParameter(); |
||
328 | cli(); |
||
329 | LCD_Init(); |
||
330 | sei(); |
||
331 | } |
||
332 | return; |
||
333 | } |
||
334 | else |
||
335 | { |
||
336 | break; |
||
337 | } |
||
338 | } |
||
339 | |||
340 | target_pos = val; |
||
341 | if((val+offset) == 1 ) MK_LowBat = Edit_Int10th_Value(MK_LowBat,33,170,PSTR("LowBat Warn V:")); |
||
342 | if((val+offset) == 2 ) DisplayTimeout = Edit_Int_Value(DisplayTimeout,0,254,PSTR("Disp.Timeout :")); |
||
343 | if((val+offset) == 3 ) LCD_Ausrichtung = Edit_Orientation(LCD_Ausrichtung,0,4,PSTR("LCD Orient.: ")); |
||
344 | if((val+offset) == 4 ) DisplayLanguage = Edit_Language(DisplayLanguage,0,2,PSTR("Language : ")); |
||
345 | if((val+offset) == 5 ) WiTXRXChannel = Edit_Int_Value(WiTXRXChannel,0,0x79,PSTR("Wi TX/RX Chan:")); |
||
346 | if((val+offset) == 6 ) WiNetworkGroup = Edit_Int_Value(WiNetworkGroup,0,0x79,PSTR("Wi NetW. Grp.:")); |
||
347 | if((val+offset) == 7 ) WiNetworkMode = Edit_Wi_NetMode_Value(WiNetworkMode,0,1,PSTR("Wi NetW. Mode:")); |
||
348 | |||
349 | } |
||
350 | } |
||
351 | |||
352 | |||
353 | |||
354 | |||
355 | |||
356 | |||
357 | |||
358 |