Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1157 | - | 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 | #include "Wi232.h" |
||
35 | |||
36 | |||
37 | uint8_t spalte; |
||
38 | uint8_t mmode; |
||
39 | uint8_t zeile; |
||
40 | uint8_t edit; |
||
41 | uint8_t MenuItems; |
||
42 | uint8_t LCD_Ausrichtung; |
||
43 | uint8_t edit =0; |
||
44 | uint8_t LCD_Change = 0; |
||
45 | uint8_t Wi_Change =0; |
||
46 | |||
47 | // |
||
48 | |||
49 | #define ITEMS_PKT 7 |
||
50 | |||
51 | prog_char param_menuitems_pkt[ITEMS_PKT][15]= // zeilen,zeichen+1 |
||
52 | { |
||
53 | "LowBat Warn ", |
||
54 | "Displ.Timeout", |
||
55 | "LCD Orient. ", |
||
56 | "Language ", |
||
57 | "Wi TX/RX Chan", |
||
58 | "Wi NetW. Grp.", |
||
59 | "Wi NetW. Mode", |
||
60 | |||
61 | }; |
||
62 | |||
63 | /***********************************************************************************************//***********************************************************************************************/ |
||
64 | uint8_t Edit_Int10th_Value(uint8_t Value, uint8_t min, uint8_t max,const char *Text) |
||
65 | |||
66 | { |
||
67 | lcd_cls(); |
||
68 | lcd_printpns_at (0, 2, Text, 0); |
||
69 | write_ndigit_number_u_10th (16, 2,Value, 3, 0); |
||
70 | lcd_printpns_at (0, 7, PSTR(" \x18 \x19 Back "), 0); |
||
71 | do |
||
72 | { |
||
73 | if ((get_key_press (1 << KEY_PLUS) || get_key_rpt (1 << KEY_PLUS)) && (Value < max)) |
||
74 | { |
||
75 | edit=1; |
||
76 | Value++; |
||
77 | write_ndigit_number_u_10th (16, 2,Value, 3, 0); |
||
78 | } |
||
79 | if ((get_key_press (1 << KEY_MINUS) || get_key_rpt (1 << KEY_MINUS)) && (Value > min)) |
||
80 | { |
||
81 | edit=1; |
||
82 | Value--; |
||
83 | write_ndigit_number_u_10th (16, 2,Value, 3, 0); |
||
84 | } |
||
85 | } |
||
86 | while (!get_key_press (1 << KEY_ESC)); |
||
87 | return Value; |
||
88 | |||
89 | } |
||
90 | |||
91 | |||
92 | /***********************************************************************************************//***********************************************************************************************/ |
||
93 | uint8_t Edit_Int_Value(uint8_t Value, uint8_t min, uint8_t max,const char *Text) |
||
94 | |||
95 | { |
||
96 | lcd_cls(); |
||
97 | lcd_printpns_at (0, 2, Text, 0); |
||
98 | write_ndigit_number_u (16, 2, Value, 3, 0); |
||
99 | lcd_printpns_at (0, 7, PSTR(" \x18 \x19 Back "), 0); |
||
100 | do |
||
101 | { |
||
102 | if ((get_key_press (1 << KEY_PLUS) || get_key_rpt (1 << KEY_PLUS)) && (Value < max)) |
||
103 | { |
||
104 | edit=1; |
||
105 | Value++; |
||
106 | write_ndigit_number_u (16, 2,Value, 3, 0); |
||
107 | } |
||
108 | if ((get_key_press (1 << KEY_MINUS) || get_key_rpt (1 << KEY_MINUS)) && (Value > min)) |
||
109 | { |
||
110 | edit=1; |
||
111 | Value--; |
||
112 | write_ndigit_number_u (16, 2,Value, 3, 0); |
||
113 | } |
||
114 | } |
||
115 | while (!get_key_press (1 << KEY_ESC)); |
||
116 | return Value; |
||
117 | |||
118 | } |
||
119 | |||
120 | /***********************************************************************************************//***********************************************************************************************/ |
||
121 | uint8_t Edit_Wi_NetMode_Value(uint8_t Value, uint8_t min, uint8_t max,const char *Text) |
||
122 | |||
123 | { |
||
124 | lcd_cls(); |
||
125 | lcd_printpns_at (0, 2, Text, 0); |
||
126 | switch (Value) |
||
127 | { |
||
128 | case 0x0 :lcd_printpns_at (15, 2, PSTR("Slave "), 0);break; |
||
129 | case 0x1 :lcd_printpns_at (15, 2, PSTR("Normal"), 0);break; |
||
130 | break; |
||
131 | } |
||
132 | lcd_printpns_at (0, 7, PSTR(" \x18 \x19 Back "), 0); |
||
133 | do |
||
134 | { |
||
135 | if ((get_key_press (1 << KEY_PLUS) || get_key_rpt (1 << KEY_PLUS)) && (Value == 0)) |
||
136 | { |
||
137 | edit=1; |
||
138 | Value=NetMode_Normal; |
||
139 | lcd_printpns_at (15, 2, PSTR("Normal"), 0); |
||
140 | } |
||
141 | if ((get_key_press (1 << KEY_MINUS) || get_key_rpt (1 << KEY_MINUS)) && (Value == 1)) |
||
142 | { |
||
143 | edit=1; |
||
144 | Value=NetMode_Slave; |
||
145 | lcd_printpns_at (15, 2, PSTR("Slave "), 0); |
||
146 | } |
||
147 | } |
||
148 | while (!get_key_press (1 << KEY_ESC)); |
||
149 | return Value; |
||
150 | |||
151 | } |
||
152 | |||
153 | |||
154 | /***********************************************************************************************//***********************************************************************************************/ |
||
155 | uint8_t Edit_Language(uint8_t Value, uint8_t min, uint8_t max,const char *Text) |
||
156 | |||
157 | { |
||
158 | lcd_cls(); |
||
159 | lcd_printpns_at (0, 2, Text, 0); |
||
160 | switch (Value) |
||
161 | { |
||
162 | case 0x0 :lcd_printpns_at (14, 2, PSTR("Deutsch"), 0);break; |
||
163 | case 0x1 :lcd_printpns_at (14, 2, PSTR("France"), 0);break; |
||
164 | case 0x2 :lcd_printpns_at (14, 2, PSTR("English"), 0);break; |
||
165 | break; |
||
166 | } |
||
167 | lcd_printpns_at (0, 7, PSTR(" \x18 \x19 Back "), 0); |
||
168 | do |
||
169 | { |
||
170 | if ((get_key_press (1 << KEY_PLUS) || get_key_rpt (1 << KEY_PLUS)) && (Value < max)) |
||
171 | { |
||
172 | edit=1; |
||
173 | Value++; |
||
174 | switch (Value) |
||
175 | { |
||
176 | case 0x0 :lcd_printpns_at (14, 2, PSTR("Deutsch"), 0);break; |
||
177 | case 0x1 :lcd_printpns_at (14, 2, PSTR("France "), 0);break; |
||
178 | case 0x2 :lcd_printpns_at (14, 2, PSTR("English"), 0);break; |
||
179 | break; |
||
180 | } |
||
181 | } |
||
182 | if ((get_key_press (1 << KEY_MINUS) || get_key_rpt (1 << KEY_MINUS)) && (Value > min)) |
||
183 | { |
||
184 | edit=1; |
||
185 | Value--; |
||
186 | switch (Value) |
||
187 | { |
||
188 | case 0x0 :lcd_printpns_at (14, 2, PSTR("Deutsch"), 0);break; |
||
189 | case 0x1 :lcd_printpns_at (14, 2, PSTR("France "), 0);break; |
||
190 | case 0x2 :lcd_printpns_at (14, 2, PSTR("English"), 0);break; |
||
191 | break; |
||
192 | } |
||
193 | } |
||
194 | } |
||
195 | while (!get_key_press (1 << KEY_ESC)); |
||
196 | return Value; |
||
197 | |||
198 | } |
||
199 | |||
200 | |||
201 | |||
202 | /***********************************************************************************************/ |
||
203 | |||
204 | uint8_t Edit_Orientation(uint8_t Value, uint8_t min, uint8_t max,const char *Text) |
||
205 | |||
206 | { |
||
207 | lcd_cls(); |
||
208 | lcd_printpns_at (0, 2, Text, 0); |
||
209 | switch (Value) |
||
210 | { |
||
211 | case 0x0 :lcd_printpns_at (14, 2, PSTR("Normal "), 0);break; |
||
212 | case 0x4 :lcd_printpns_at (14, 2, PSTR("Reverse"), 0);break; |
||
213 | break; |
||
214 | } |
||
215 | lcd_printpns_at (0, 7, PSTR(" \x18 \x19 Back "), 0); |
||
216 | do |
||
217 | { |
||
218 | if ((get_key_press (1 << KEY_PLUS) || get_key_rpt (1 << KEY_PLUS)) && (Value == 0)) |
||
219 | { |
||
220 | edit=1; |
||
221 | Value=4; |
||
222 | lcd_printpns_at (14, 2, PSTR("Reverse"), 0); |
||
223 | } |
||
224 | if ((get_key_press (1 << KEY_MINUS) || get_key_rpt (1 << KEY_MINUS)) && (Value == 4)) |
||
225 | { |
||
226 | edit=1; |
||
227 | Value=0; |
||
228 | lcd_printpns_at (14, 2, PSTR("Normal "), 0); |
||
229 | } |
||
230 | } |
||
231 | while (!get_key_press (1 << KEY_ESC)); |
||
232 | return Value; |
||
233 | |||
234 | } |
||
235 | |||
236 | |||
237 | |||
238 | |||
239 | |||
240 | void PMK_Setup (void) |
||
241 | { |
||
242 | uint8_t ii = 0; |
||
243 | uint8_t offset = 0; |
||
244 | uint8_t size = 0; |
||
245 | size = ITEMS_PKT ; |
||
246 | uint8_t dmode = 0; |
||
247 | uint8_t target_pos = 1; |
||
248 | uint8_t val; |
||
249 | |||
250 | |||
251 | lcd_cls (); |
||
252 | mmode = 0; |
||
253 | edit=0; |
||
254 | LCD_Change =0; |
||
255 | Wi_Change =0; |
||
256 | zeile = 1; |
||
257 | MenuItems =2; |
||
258 | LCD_Ausrichtung = LCD_ORIENTATION; |
||
259 | val = 0; |
||
260 | |||
261 | |||
262 | while(1) |
||
263 | { |
||
264 | lcd_cls (); |
||
265 | lcd_printp_at (0, 0, PSTR("PMK-Tool Setup"), 0); |
||
266 | lcd_printpns_at (0, 7, PSTR(" \x18 \x19 Back \x0c "), 0); |
||
267 | while(1) |
||
268 | { |
||
269 | ii = 0; |
||
270 | if(offset > 0) |
||
271 | { |
||
272 | lcd_printp_at(1,1, PSTR("\x1a"), 0); |
||
273 | } |
||
274 | for(ii = 0;ii < 6 ; ii++) |
||
275 | { |
||
276 | if((ii+offset) < size) |
||
277 | { |
||
278 | lcd_printp_at(3,ii+1,param_menuitems_pkt[ii+offset], 0); |
||
279 | } |
||
280 | if((ii == 5)&&(ii+offset < (size-1))) |
||
281 | { |
||
282 | lcd_printp_at(1,6, PSTR("\x1b"), 0); |
||
283 | } |
||
284 | } |
||
285 | |||
286 | if(dmode == 0) |
||
287 | { |
||
288 | if(offset == 0) |
||
289 | { |
||
290 | if(size > 6) |
||
291 | { |
||
292 | val = menu_choose2 (1, 5, target_pos,0,1); |
||
293 | } |
||
294 | else |
||
295 | { |
||
296 | val = menu_choose2 (1, size, target_pos,0,0); |
||
297 | } |
||
298 | } |
||
299 | else |
||
300 | { |
||
301 | val = menu_choose2 (2, 5, target_pos,1,1); |
||
302 | } |
||
303 | } |
||
304 | if(dmode == 1) |
||
305 | { |
||
306 | if(offset+7 > size) |
||
307 | { |
||
308 | val = menu_choose2 (2, 6, target_pos,1,0); |
||
309 | } |
||
310 | else |
||
311 | { |
||
312 | val = menu_choose2 (2, 5, target_pos,1,1); |
||
313 | } |
||
314 | } |
||
315 | |||
316 | if(val == 254) |
||
317 | { |
||
318 | offset++; |
||
319 | dmode = 1; |
||
320 | target_pos = 5; |
||
321 | }else if(val == 253) |
||
322 | { |
||
323 | offset--; |
||
324 | dmode = 0; |
||
325 | target_pos = 2; |
||
326 | }else if(val == 255) |
||
327 | { /* Ende mit BACK, speichern */ |
||
328 | if (edit==1) |
||
329 | { |
||
330 | WriteParameter(); |
||
331 | if (LCD_Change) |
||
332 | { |
||
333 | LCD_ORIENTATION = LCD_Ausrichtung; |
||
334 | cli(); |
||
335 | LCD_Init(); |
||
336 | sei(); |
||
337 | } |
||
338 | if (Wi_Change) InitWi232(); |
||
339 | } |
||
340 | return; |
||
341 | } |
||
342 | else |
||
343 | { |
||
344 | break; |
||
345 | } |
||
346 | } |
||
347 | |||
348 | target_pos = val; |
||
349 | |||
350 | if((val+offset) == 1 ) MK_LowBat = Edit_Int10th_Value(MK_LowBat,33,170,PSTR("LowBat Warn V:")); |
||
351 | if((val+offset) == 2 ) DisplayTimeout = Edit_Int_Value(DisplayTimeout,0,254,PSTR("Disp.Timeout :")); |
||
352 | if((val+offset) == 3 ) { |
||
353 | LCD_Ausrichtung = Edit_Orientation(LCD_Ausrichtung,0,4,PSTR("LCD Orient.: ")); |
||
354 | if (edit) if(!LCD_Change) LCD_Change =1; |
||
355 | } |
||
356 | if((val+offset) == 4 ) DisplayLanguage = Edit_Language(DisplayLanguage,0,2,PSTR("Language : ")); |
||
357 | if((val+offset) == 5 ) { |
||
358 | WiTXRXChannel = Edit_Int_Value(WiTXRXChannel,0,0x79,PSTR("Wi TX/RX Chan:")); |
||
359 | if (edit) if(!Wi_Change) Wi_Change =1; |
||
360 | } |
||
361 | if((val+offset) == 6 ) { |
||
362 | WiNetworkGroup = Edit_Int_Value(WiNetworkGroup,0,0x79,PSTR("Wi NetW. Grp.:")); |
||
363 | if (edit) if(!Wi_Change) Wi_Change =1; |
||
364 | } |
||
365 | if((val+offset) == 7 ) { |
||
366 | WiNetworkMode = Edit_Wi_NetMode_Value(WiNetworkMode,0,1,PSTR("Wi NetW. Mode:")); |
||
367 | if (edit) if(!Wi_Change) Wi_Change =1; |
||
368 | } |
||
369 | |||
370 | } |
||
371 | } |
||
372 | |||
373 | |||
374 | |||
375 | |||
376 | |||
377 | |||
378 | |||
379 |