Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1105 | - | 1 | /***************************************************************************** |
2 | * Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
||
3 | * Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
||
4 | * Copyright (C) 2010 Sebastian Boehm, seb@exse.net * |
||
5 | * * |
||
6 | * This program is free software; you can redistribute it and/or modify * |
||
7 | * it under the terms of the GNU General Public License as published by * |
||
8 | * the Free Software Foundation; either version 2 of the License. * |
||
9 | * * |
||
10 | * This program is distributed in the hope that it will be useful, * |
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
13 | * GNU General Public License for more details. * |
||
14 | * * |
||
15 | * You should have received a copy of the GNU General Public License * |
||
16 | * along with this program; if not, write to the * |
||
17 | * Free Software Foundation, Inc., * |
||
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
||
19 | * * |
||
20 | *****************************************************************************/ |
||
21 | |||
22 | #include <avr/io.h> |
||
23 | #include <avr/pgmspace.h> |
||
24 | #include <util/delay.h> |
||
25 | #include <string.h> |
||
26 | #include <stdlib.h> |
||
27 | |||
28 | #include "main.h" |
||
29 | #include "lcd.h" |
||
30 | #include "timer.h" |
||
31 | #include "usart.h" |
||
32 | #include "mk-data-structs.h" |
||
33 | #include "parameter.h" |
||
34 | #include "menu.h" |
||
35 | #include "eeprom.h" |
||
36 | #include "parameter_names.h" |
||
37 | |||
38 | |||
39 | |||
40 | #define TIMEOUT 500 // 5 sec |
||
41 | |||
42 | uint8_t display_settings_menu (void); |
||
43 | uint8_t display_param_menu (uint8_t); |
||
44 | uint8_t load_setting (uint8_t); |
||
45 | uint8_t write_setting (uint8_t); |
||
46 | uint8_t display_section_menu(void); |
||
47 | void edit_param(uint8_t); |
||
48 | void copy_setting(void); |
||
49 | |||
50 | |||
51 | |||
52 | |||
53 | |||
54 | mk_param_struct_t *mk_param_struct; |
||
55 | |||
56 | uint8_t ii; |
||
57 | volatile uint8_t offset = 0; |
||
58 | volatile uint8_t dmode = 0; |
||
59 | volatile uint8_t target_pos = 1; |
||
60 | |||
61 | volatile uint8_t offset2 = 0; |
||
62 | volatile uint8_t pmode = 0; |
||
63 | volatile uint8_t target_pos2 = 1; |
||
64 | |||
65 | uint8_t changes = 0; |
||
66 | |||
67 | #define OFFSETOF(type, field) ((unsigned int) &(((type *) 0)->field)) |
||
68 | |||
69 | #define MKOSO(field) (uint8_t)OFFSETOF(mk_param_struct_t, field) |
||
70 | |||
71 | // Typ(1=mit Poti,0=ohne Poti,2=bitfield,3=serCh,4=LEDmask,5 Angle,6 Empfaenger ), |
||
72 | // min, |
||
73 | // max, |
||
74 | // struct-name, |
||
75 | // default1, |
||
76 | // default2, |
||
77 | // default3+4+5 |
||
78 | prog_uchar param_config[8*PARAM_COUNT]= |
||
79 | { |
||
80 | // group 0 (kanaele) 15 |
||
81 | 0,0,1,12 ,MKOSO(Kanalbelegung)+2,1,1,1, // gas |
||
82 | 0,0,1,12 ,MKOSO(Kanalbelegung)+3,2,2,2, // gier |
||
83 | 0,0,1,12 ,MKOSO(Kanalbelegung),3,3,3, // nick |
||
84 | 0,0,1,12 ,MKOSO(Kanalbelegung)+1,4,4,4, // roll |
||
85 | 0,3,1,25 ,MKOSO(Kanalbelegung)+4,5,5,5, // poti1 |
||
86 | 0,3,1,25 ,MKOSO(Kanalbelegung)+5,6,6,6, // poti2 |
||
87 | 0,3,1,25 ,MKOSO(Kanalbelegung)+6,7,7,7, // poti3 |
||
88 | 0,3,1,25 ,MKOSO(Kanalbelegung)+7,8,8,8, // poti4 |
||
89 | 0,3,1,25 ,MKOSO(Kanalbelegung)+8,9,9,9, // poti5 |
||
90 | 0,3,1,25 ,MKOSO(Kanalbelegung)+9,10,10,10, // poti6 |
||
91 | 0,3,1,25 ,MKOSO(Kanalbelegung)+10,11,11,11, // poti7 |
||
92 | 0,3,1,25 ,MKOSO(Kanalbelegung)+11,12,12,12, // poti8 |
||
93 | //26.3.2011 0.82 CB |
||
94 | 0,0,0,12 ,MKOSO(MotorSafetySwitch),0,0,0, // Motor Sicherungsswitch |
||
95 | // |
||
96 | 0,2,0,0x04,MKOSO(ExtraConfig),0,0,0, //erweiterte signal pruefung |
||
97 | 0,6,0,5 ,MKOSO(Receiver),1,1,1, |
||
98 | |||
99 | // group 1 (main) 8 |
||
100 | |||
101 | 1,2,0,0x01,MKOSO(GlobalConfig),0,0,1, //hoehenregler |
||
102 | 1,2,0,0x20,MKOSO(GlobalConfig),1,1,1, //gps |
||
103 | 1,2,0,0x08,MKOSO(GlobalConfig),1,1,1, //kompass |
||
104 | 1,2,0,0x10,MKOSO(GlobalConfig),0,0,0, //feste ausrichtung |
||
105 | 1,2,0,0x04,MKOSO(ExtraConfig),0,0,0, //erweiterte signal pruefung |
||
106 | 1,2,0,0x40,MKOSO(GlobalConfig),1,1,1, //achsentkopplung |
||
107 | 1,2,0,0x80,MKOSO(GlobalConfig),0,0,0, //drehratenbregrenzung |
||
108 | 1,2,0,0x04,MKOSO(GlobalConfig),0,0,0, //heading hold |
||
109 | |||
110 | // group 2 (stick) 4 |
||
111 | 2,0,0,20 ,MKOSO(Stick_P),8,8,8, |
||
112 | 2,0,0,20 ,MKOSO(Stick_D),16,16,16, |
||
113 | 2,1,0,247 ,MKOSO(Gier_P),6,6,6, |
||
114 | 2,1,0,247 ,MKOSO(ExternalControl),0,0,0, |
||
115 | |||
116 | |||
117 | |||
118 | // group3 : looping 9 |
||
119 | |||
120 | 3,2,0,0x01,MKOSO(BitConfig),0,0,0, //oben |
||
121 | 3,2,0,0x02,MKOSO(BitConfig),0,0,0, //unten |
||
122 | 3,2,0,0x04,MKOSO(BitConfig),0,0,0, //links |
||
123 | 3,2,0,0x08,MKOSO(BitConfig),0,0,0, //rechts |
||
124 | 3,1,0,247 ,MKOSO(LoopGasLimit),50,50,50, |
||
125 | 3,0,0,247 ,MKOSO(LoopThreshold),90,90,90, |
||
126 | 3,0,0,247 ,MKOSO(LoopHysterese),50,50,50, |
||
127 | 3,0,0,247 ,MKOSO(WinkelUmschlagNick),78,78,78, |
||
128 | 3,0,0,247 ,MKOSO(WinkelUmschlagRoll),78,78,78, |
||
129 | |||
130 | |||
131 | |||
132 | |||
133 | // group 4 (hoehe) 13 |
||
134 | |||
135 | 4,2,0,0x01,MKOSO(GlobalConfig),1,1,1, //hoehenrelger |
||
136 | 4,2,0,0x01,MKOSO(ExtraConfig),0,0,0, //vario oder hoeenbergenzung |
||
137 | 4,2,0,0x02,MKOSO(GlobalConfig),1,1,1, //hoehenschalter |
||
138 | 4,2,0,0x02,MKOSO(ExtraConfig),1,1,1, //variobeep |
||
139 | 4,1,0,247 ,MKOSO(MaxHoehe),255,255,255, |
||
140 | 4,0,0,247 ,MKOSO(Hoehe_MinGas),30,30,30, |
||
141 | 4,1,0,247 ,MKOSO(Hoehe_P),15,15,15, |
||
142 | 4,1,0,247 ,MKOSO(Luftdruck_D),30,30,30, |
||
143 | 4,1,0,247 ,MKOSO(Hoehe_ACC_Wirkung),0,0,0, |
||
144 | 4,0,0,247 ,MKOSO(Hoehe_Verstaerkung),15,15,15, |
||
145 | 4,0,0,247 ,MKOSO(Hoehe_HoverBand),8,8,8, |
||
146 | 4,1,0,247 ,MKOSO(Hoehe_GPS_Z),64,64,64, |
||
147 | 4,0,0,247 ,MKOSO(Hoehe_StickNeutralPoint),0,0,0, |
||
148 | |||
149 | // Typ(1=mit Poti,0=ohne Poti,2=bitfield,3=serCh,4=LEDmask,5 Angle,6 Empfaenger), |
||
150 | // min, |
||
151 | // max, |
||
152 | // struct-name, |
||
153 | // default1, |
||
154 | // default2, |
||
155 | // default3+4+5 |
||
156 | |||
157 | // group 5 : kamera 16 |
||
158 | |||
159 | 5,1,0,247,MKOSO(ServoNickControl),100,100,100, |
||
160 | 5,0,0,247,MKOSO(ServoNickComp),40,40,40, |
||
161 | 5,2,0,0x01,MKOSO(ServoCompInvert),1,1,1, |
||
162 | 5,0,0,247,MKOSO(ServoNickMin),0,0,0, |
||
163 | 5,0,0,247,MKOSO(ServoNickMax),247,247,247, |
||
164 | |||
165 | 5,1,0,247,MKOSO(ServoRollControl),100,100,100, |
||
166 | 5,0,0,247,MKOSO(ServoRollComp),40,40,40, |
||
167 | 5,2,0,0x01,MKOSO(ServoCompInvert),0,0,0, |
||
168 | 5,0,0,247,MKOSO(ServoRollMin),0,0,0, |
||
169 | 5,0,0,247,MKOSO(ServoRollMax),247,247,247, |
||
170 | |||
171 | |||
172 | 5,0,2,8 ,MKOSO(ServoNickRefresh),6,6,6, |
||
173 | //26.3.2011 0.82 CB |
||
174 | 5,0,0,247 ,MKOSO(ServoManualControlSpeed),40,40,40, |
||
175 | 5,5,0,247 ,MKOSO(CamOrientation),0,0,0, |
||
176 | // |
||
177 | 5,1,0,247,MKOSO(Servo3),125,125,125, |
||
178 | 5,1,0,247,MKOSO(Servo4),125,125,125, |
||
179 | 5,1,0,247,MKOSO(Servo5),125,125,125, |
||
180 | |||
181 | |||
182 | // group 6 : navictrl 17 |
||
183 | |||
184 | 6,2,0,0x20,MKOSO(GlobalConfig),1,1,1, //gps |
||
185 | 6,1,0,247,MKOSO(NaviGpsModeControl),254,254,254, |
||
186 | 6,1,0,247,MKOSO(NaviGpsGain),100,100,100, |
||
187 | 6,0,0,247,MKOSO(NaviStickThreshold),8,8,8, |
||
188 | 6,0,0,247,MKOSO(NaviGpsMinSat),6,6,6, |
||
189 | 6,1,0,247,MKOSO(NaviGpsP),90,90,90, |
||
190 | 6,1,0,247,MKOSO(NaviGpsI),90,90,90, |
||
191 | 6,1,0,247,MKOSO(NaviGpsD),90,90,90, |
||
192 | 6,1,0,247,MKOSO(NaviGpsPLimit),75,75,75, |
||
193 | 6,1,0,247,MKOSO(NaviGpsILimit),75,75,75, |
||
194 | 6,1,0,247,MKOSO(NaviGpsDLimit),75,75,75, |
||
195 | 6,1,0,247,MKOSO(NaviGpsACC),0,0,0, |
||
196 | // |
||
197 | 6,1,0,247,MKOSO(NaviWindCorrection),90,90,90, |
||
198 | 6,1,0,247,MKOSO(NaviSpeedCompensation),30,30,30, |
||
199 | 6,1,0,247,MKOSO(NaviOperatingRadius),100,100,100, |
||
200 | 6,1,0,247,MKOSO(NaviAngleLimitation),100,100,100, |
||
201 | 6,0,0,247,MKOSO(NaviPH_LoginTime),2,2,2, |
||
202 | |||
203 | |||
204 | |||
205 | // group 7 : ausgaenge 9 |
||
206 | |||
207 | 7,4,0,255,MKOSO(J16Bitmask),95,95,95, |
||
208 | 7,1,0,247,MKOSO(J16Timing),30,30,30, |
||
209 | 7,4,0,255,MKOSO(J17Bitmask),243,243,243, |
||
210 | 7,1,0,247,MKOSO(J17Timing),30,30,30, |
||
211 | 7,2,0,0x10,MKOSO(BitConfig),0,0,0,//CFG_MOTOR_BLINK |
||
212 | 7,4,0,255,MKOSO(WARN_J16_Bitmask),170,170,170, |
||
213 | 7,2,0,0x20,MKOSO(BitConfig),1,1,1,//CFG_MOTOR_OFF_LED1 |
||
214 | 7,4,0,255,MKOSO(WARN_J17_Bitmask),170,170,170, |
||
215 | 7,2,0,0x40,MKOSO(BitConfig),1,1,1,//CFG_MOTOR_OFF_LED2 |
||
216 | |||
217 | |||
218 | |||
219 | // group 8 : versch. 7 |
||
220 | |||
221 | 8,0,0,247,MKOSO(Gas_Min),8,8,8, |
||
222 | 8,0,0,247,MKOSO(Gas_Max),230,230,230, |
||
223 | 8,1,0,247,MKOSO(KompassWirkung),128,128,128, |
||
224 | 8,1,0,247,MKOSO(OrientationModeControl),0,0,0, |
||
225 | 8,0,0,247,MKOSO(UnterspannungsWarnung),33,33,33, |
||
226 | 8,0,0,247,MKOSO(NotGasZeit),90,90,90, |
||
227 | 8,0,0,247,MKOSO(NotGas),45,45,45, |
||
228 | |||
229 | |||
230 | // group 9 : gyro 12 |
||
231 | |||
232 | 9,1,0,247,MKOSO(Gyro_P),100,100,100, |
||
233 | 9,1,0,247,MKOSO(Gyro_I),120,120,120, |
||
234 | 9,1,0,247,MKOSO(Gyro_D),10,10,10, |
||
235 | 9,1,0,247,MKOSO(Gyro_Gier_P),100,100,100, |
||
236 | 9,1,0,247,MKOSO(Gyro_Gier_I),120,120,120, |
||
237 | 9,1,0,247,MKOSO(DynamicStability),70,70,70, |
||
238 | 9,2,0,0x80,MKOSO(GlobalConfig),0,0,0, //drehratenbregrenzung |
||
239 | 9,0,0,247,MKOSO(GyroAccFaktor),27,27,27, |
||
240 | 9,0,0,247,MKOSO(GyroAccAbgleich),32,32,32, |
||
241 | 9,1,0,247,MKOSO(I_Faktor),16,16,16, |
||
242 | 9,0,0,247,MKOSO(Driftkomp),0,0,0, |
||
243 | 9,0,0,8,MKOSO(Gyro_Stability),100,100,100, |
||
244 | |||
245 | |||
246 | // group 10: benutzer 8 |
||
247 | |||
248 | 10,1,0,247,MKOSO(UserParam1),0,0,0, |
||
249 | 10,1,0,247,MKOSO(UserParam2),0,0,0, |
||
250 | 10,1,0,247,MKOSO(UserParam3),0,0,0, |
||
251 | 10,1,0,247,MKOSO(UserParam4),0,0,0, |
||
252 | 10,1,0,247,MKOSO(UserParam5),0,0,0, |
||
253 | 10,1,0,247,MKOSO(UserParam6),0,0,0, |
||
254 | 10,1,0,247,MKOSO(UserParam7),0,0,0, |
||
255 | 10,1,0,247,MKOSO(UserParam8),0,0,0, |
||
256 | |||
257 | |||
258 | // group 11: achskoppl 4 |
||
259 | |||
260 | 11,2,0,0x40,MKOSO(GlobalConfig),0,0,0, //achsentkopplung |
||
261 | 11,1,0,247,MKOSO(AchsKopplung1),90,90,90, |
||
262 | 11,1,0,247,MKOSO(AchsKopplung2),80,80,80, |
||
263 | 11,1,0,247,MKOSO(CouplingYawCorrection),70,70,70, |
||
264 | |||
265 | |||
266 | |||
267 | // group 12: mixer |
||
268 | |||
269 | 12,5,0,23,MKOSO(OrientationAngle),0,0,0, |
||
270 | |||
271 | }; |
||
272 | |||
273 | |||
274 | |||
275 | |||
276 | |||
277 | |||
278 | void edit_parameter (void) |
||
279 | { |
||
280 | SwitchToFC(); |
||
281 | |||
282 | |||
283 | uint8_t setting; |
||
284 | |||
285 | |||
286 | setting = display_settings_menu(); |
||
287 | |||
288 | if(setting == 6) |
||
289 | { |
||
290 | copy_setting(); |
||
291 | return; |
||
292 | } |
||
293 | |||
294 | |||
295 | if(setting == 255) return; |
||
296 | uint8_t setting_loaded = load_setting(setting); |
||
297 | if(setting_loaded == 255) return; |
||
298 | |||
299 | offset = 0; |
||
300 | dmode = 0; |
||
301 | target_pos = 1; |
||
302 | changes =0; |
||
303 | |||
304 | |||
305 | uint8_t group =0; |
||
306 | do |
||
307 | { |
||
308 | |||
309 | group = display_section_menu(); |
||
310 | |||
311 | if(group != 255) |
||
312 | { |
||
313 | offset2 = 0; |
||
314 | pmode = 0; |
||
315 | target_pos2 = 1; |
||
316 | uint8_t param; |
||
317 | do |
||
318 | { |
||
319 | param = display_param_menu(group); |
||
320 | |||
321 | if(param != 255) |
||
322 | { |
||
323 | edit_param(param); |
||
324 | } |
||
325 | |||
326 | } |
||
327 | while(param != 255); |
||
328 | } |
||
329 | |||
330 | |||
331 | } |
||
332 | while(group != 255); |
||
333 | |||
334 | if(changes == 1) |
||
335 | { |
||
336 | lcd_cls(); |
||
337 | lcd_printp_at (0, 0, PSTR("Save Setting x?"), 0); |
||
338 | write_ndigit_number_u(13,0,setting, 1,0); |
||
339 | lcd_printp_at (3, 1, PSTR("yes"), 0); |
||
340 | lcd_printp_at (3, 2, PSTR("no"), 0); |
||
341 | lcd_printpns_at (0, 7, PSTR(" \x1a \x1b Exit \x0c"), 0); |
||
342 | |||
343 | uint8_t val = menu_choose2 (1, 2, 2,0,0); |
||
344 | |||
345 | if(val == 1) |
||
346 | { |
||
347 | uint8_t setting_written = write_setting(setting); |
||
348 | |||
349 | if(setting_written == setting) |
||
350 | { |
||
351 | lcd_printp_at (0, 4, PSTR("saved and"), 0); |
||
352 | lcd_printp_at (0, 5, PSTR("activated"), 0); |
||
353 | } |
||
354 | else |
||
355 | { |
||
356 | lcd_printp_at (0, 4, PSTR("ERROR"), 0); |
||
357 | } |
||
358 | timer = 100; |
||
359 | while (timer > 0); |
||
360 | |||
361 | } |
||
362 | |||
363 | } |
||
364 | |||
365 | |||
366 | |||
367 | |||
368 | } |
||
369 | |||
370 | |||
371 | void copy_setting(void) |
||
372 | { |
||
373 | uint8_t fromsetting = 3; |
||
374 | uint8_t tosetting = 5; |
||
375 | |||
376 | lcd_cls(); |
||
377 | |||
378 | lcd_printp_at (0, 0, PSTR("Copy Setting:"), 0); |
||
379 | lcd_printp_at (3, 2, PSTR("From Setting:"), 0); |
||
380 | lcd_printp_at (3, 3, PSTR(" To Setting:"), 0); |
||
381 | |||
382 | // 123456789012345678901 |
||
383 | // x x x |
||
384 | lcd_printpns_at (0, 7, PSTR("From To Back Do"), 0); |
||
385 | |||
386 | |||
387 | do |
||
388 | { |
||
389 | write_ndigit_number_u(17,2,fromsetting, 1,0); |
||
390 | write_ndigit_number_u(17,3,tosetting, 1,0); |
||
391 | |||
392 | if(get_key_press (1 << KEY_MINUS)) |
||
393 | { |
||
394 | fromsetting++; |
||
395 | if(fromsetting == 6) fromsetting = 1; |
||
396 | } |
||
397 | if(get_key_press (1 << KEY_PLUS)) |
||
398 | { |
||
399 | tosetting++; |
||
400 | if(tosetting == 6) tosetting = 1; |
||
401 | } |
||
402 | if(get_key_press (1 << KEY_ENTER)) |
||
403 | { |
||
404 | lcd_printp_at (0, 5, PSTR("Really want to copy?"), 0); |
||
405 | do |
||
406 | { |
||
407 | |||
408 | if(get_key_press (1 << KEY_ENTER)) |
||
409 | { |
||
410 | uint8_t loaded = load_setting(fromsetting); |
||
411 | if(loaded == fromsetting) |
||
412 | { |
||
413 | uint8_t written = write_setting(tosetting); |
||
414 | if(written == tosetting) |
||
415 | { |
||
416 | lcd_printp_at (0, 5, PSTR("written and activated"), 0); |
||
417 | |||
418 | } |
||
419 | else |
||
420 | { |
||
421 | lcd_printp_at (0, 5, PSTR("ERROR "), 0); |
||
422 | } |
||
423 | } |
||
424 | else |
||
425 | { |
||
426 | lcd_printp_at (0, 5, PSTR("ERROR "), 0); |
||
427 | } |
||
428 | timer = 100; |
||
429 | while (timer > 0); |
||
430 | return; |
||
431 | } |
||
432 | |||
433 | |||
434 | }while (!get_key_short (1 << KEY_ESC)); |
||
435 | lcd_printp_at (0, 5, PSTR(" "), 0); |
||
436 | |||
437 | } |
||
438 | |||
439 | |||
440 | |||
441 | } |
||
442 | while (!get_key_short (1 << KEY_ESC)); |
||
443 | } |
||
444 | |||
445 | |||
446 | // write_ndigit_number_u (0,0, *(((uint8_t*)mk_param_struct) + OFFSETOF(mk_param_struct_t, GlobalConfig)) , 6, 0);//evtl. den cast auf uint16_t machen |
||
447 | |||
448 | // lcd_printp_at (pos, before, PSTR(" "), 0); |
||
449 | // |
||
450 | // oben \x1a unten \x1b |
||
451 | // lcd_printp_at (pos, line, PSTR("\x1D"), 0); |
||
452 | |||
453 | |||
454 | void edit_param(uint8_t param) |
||
455 | { |
||
456 | lcd_cls(); |
||
457 | uint8_t type = pgm_read_byte(param_config+(8*param)+1); |
||
458 | lcd_printp_at (0, 0, PSTR("Edit Setting:"), 0); |
||
459 | if (type != 6) lcd_printp_at(0,2,param_names[param][DisplayLanguage], 0); |
||
460 | |||
461 | |||
462 | |||
463 | if(type == 2)// ja/nein |
||
464 | { |
||
465 | lcd_printpns_at (0, 7, PSTR(" \x1a \x1b Back \x0c"), 0); |
||
466 | lcd_printp_at (3, 4, PSTR("Y"), 0); |
||
467 | lcd_printp_at (3, 5, PSTR("N"), 0); |
||
468 | |||
469 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
||
470 | uint8_t defaultvalue = pgm_read_byte(param_config+(8*param)+5); |
||
471 | uint8_t bitmap = pgm_read_byte(param_config+(8*param)+3); |
||
472 | uint8_t newvalue = value; |
||
473 | |||
474 | if(defaultvalue == 1) lcd_printp_at (4, 4, PSTR("*"), 0); |
||
475 | if(defaultvalue == 0) lcd_printp_at (4, 5, PSTR("*"), 0); |
||
476 | |||
477 | do |
||
478 | { |
||
479 | |||
480 | if(newvalue & bitmap) |
||
481 | { |
||
482 | lcd_printp_at (1, 4, PSTR("\x1D"), 0); |
||
483 | lcd_printp_at (1, 5, PSTR(" "), 0); |
||
484 | } |
||
485 | else |
||
486 | { |
||
487 | lcd_printp_at (1, 4, PSTR(" "), 0); |
||
488 | lcd_printp_at (1, 5, PSTR("\x1D"), 0); |
||
489 | } |
||
490 | |||
491 | |||
492 | if(get_key_press (1 << KEY_MINUS)) |
||
493 | { |
||
494 | newvalue ^= bitmap; |
||
495 | } |
||
496 | |||
497 | if(get_key_press (1 << KEY_PLUS)) |
||
498 | { |
||
499 | newvalue ^= bitmap; |
||
500 | } |
||
501 | |||
502 | if(get_key_press (1 << KEY_ENTER)) |
||
503 | { |
||
504 | if(newvalue != value) |
||
505 | { |
||
506 | *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
||
507 | changes=1; |
||
508 | } |
||
509 | break; |
||
510 | |||
511 | } |
||
512 | |||
513 | if(get_key_long (1 << KEY_ESC)) |
||
514 | { |
||
515 | if(defaultvalue == 1) |
||
516 | { |
||
517 | newvalue |= bitmap; |
||
518 | } |
||
519 | else |
||
520 | { |
||
521 | newvalue &= ~bitmap; |
||
522 | } |
||
523 | } |
||
524 | |||
525 | |||
526 | }while (!get_key_short (1 << KEY_ESC)); |
||
527 | } |
||
528 | if(type == 0)// ohne poti |
||
529 | { |
||
530 | lcd_printpns_at (0, 7, PSTR(" \x18 \x19 Back \x0c"), 0); |
||
531 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
||
532 | uint8_t min =pgm_read_byte(param_config+(8*param)+2); |
||
533 | uint8_t max = pgm_read_byte(param_config+(8*param)+3); |
||
534 | uint8_t defaultvalue = pgm_read_byte(param_config+(8*param)+5); |
||
535 | lcd_printpns_at (4, 4, PSTR("( - ) (d: )"), 0); |
||
536 | write_ndigit_number_u (5, 4, min, 3, 0); |
||
537 | write_ndigit_number_u (9, 4, max, 3, 0); |
||
538 | write_ndigit_number_u (17, 4, defaultvalue, 3, 0); |
||
539 | |||
540 | |||
541 | uint8_t newvalue = value; |
||
542 | |||
543 | do |
||
544 | { |
||
545 | write_ndigit_number_u (0, 4, newvalue, 3, 0); |
||
546 | lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 1); |
||
547 | |||
548 | |||
549 | if(get_key_press (1 << KEY_PLUS) || get_key_rpt (1 << KEY_PLUS)) |
||
550 | { |
||
551 | if((newvalue+1) <= max) |
||
552 | { |
||
553 | newvalue++; |
||
554 | //lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 1); |
||
555 | } |
||
556 | } |
||
557 | |||
558 | if(get_key_press (1 << KEY_MINUS) || get_key_rpt (1 << KEY_MINUS)) |
||
559 | { |
||
560 | if((newvalue-1)>=min) |
||
561 | { |
||
562 | lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 0); |
||
563 | newvalue--; |
||
564 | //lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 1); |
||
565 | } |
||
566 | } |
||
567 | |||
568 | |||
569 | if(get_key_press (1 << KEY_ENTER)) |
||
570 | { |
||
571 | if(newvalue != value) |
||
572 | { |
||
573 | *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
||
574 | changes=1; |
||
575 | } |
||
576 | break; |
||
577 | |||
578 | } |
||
579 | if(get_key_long (1 << KEY_ESC)) |
||
580 | { |
||
581 | lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 0); |
||
582 | newvalue = defaultvalue; |
||
583 | //lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 1); |
||
584 | |||
585 | } |
||
586 | |||
587 | }while (!get_key_short (1 << KEY_ESC)); |
||
588 | } |
||
589 | |||
590 | if(type == 1)// mit poti |
||
591 | { |
||
592 | lcd_printpns_at (0, 7, PSTR(" \x18 \x19 Back \x0c\x0c"), 0); |
||
593 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
||
594 | uint8_t min =pgm_read_byte(param_config+(8*param)+2); |
||
595 | uint8_t max = pgm_read_byte(param_config+(8*param)+3); |
||
596 | uint8_t defaultvalue = pgm_read_byte(param_config+(8*param)+5); |
||
597 | lcd_printpns_at (4, 4, PSTR("( - ) (d:Po )"), 0); |
||
598 | write_ndigit_number_u (5, 4, min, 3, 0); |
||
599 | write_ndigit_number_u (9, 4, max, 3, 0); |
||
600 | if(defaultvalue > 247) |
||
601 | { |
||
602 | write_ndigit_number_u (19, 4, 256-defaultvalue, 1, 0); |
||
603 | } |
||
604 | else |
||
605 | { |
||
606 | write_ndigit_number_u (17, 4, defaultvalue, 3, 0); |
||
607 | } |
||
608 | |||
609 | |||
610 | uint8_t newvalue = value; |
||
611 | |||
612 | uint8_t mode = 0; |
||
613 | if(value > 247) |
||
614 | { |
||
615 | mode=1; |
||
616 | } |
||
617 | else |
||
618 | { |
||
619 | } |
||
620 | |||
621 | uint8_t tempv = 255; |
||
622 | |||
623 | do |
||
624 | { |
||
625 | |||
626 | if(get_key_long (1 << KEY_ENTER)) |
||
627 | { |
||
628 | if(mode == 0) |
||
629 | { |
||
630 | mode = 1; |
||
631 | lcd_frect ((8*0), (8*5), 128, 6, 0); |
||
632 | tempv = newvalue; |
||
633 | newvalue = 255; |
||
634 | } |
||
635 | else |
||
636 | { |
||
637 | mode = 0; |
||
638 | if(tempv == 255) |
||
639 | { |
||
640 | if (defaultvalue > 247) |
||
641 | { |
||
642 | newvalue = min; |
||
643 | } |
||
644 | else |
||
645 | { |
||
646 | newvalue = defaultvalue; |
||
647 | } |
||
648 | } |
||
649 | else |
||
650 | { |
||
651 | newvalue = tempv; |
||
652 | } |
||
653 | } |
||
654 | } |
||
655 | |||
656 | |||
657 | if(mode==0) |
||
658 | { |
||
659 | |||
660 | write_ndigit_number_u (0, 4, newvalue, 3, 0); |
||
661 | lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 1); |
||
662 | |||
663 | |||
664 | |||
665 | if(get_key_press (1 << KEY_PLUS) || get_key_rpt (1 << KEY_PLUS)) |
||
666 | { |
||
667 | if((newvalue+1) <= max) |
||
668 | { |
||
669 | newvalue++; |
||
670 | //lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 1); |
||
671 | } |
||
672 | } |
||
673 | |||
674 | if(get_key_press (1 << KEY_MINUS) || get_key_rpt (1 << KEY_MINUS)) |
||
675 | { |
||
676 | if((newvalue-1)>=min) |
||
677 | { |
||
678 | lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 0); |
||
679 | newvalue--; |
||
680 | //lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 1); |
||
681 | } |
||
682 | } |
||
683 | } |
||
684 | else |
||
685 | { |
||
686 | lcd_printpns_at (0, 4, PSTR("Po"), 0); |
||
687 | write_ndigit_number_u (2, 4, 256-newvalue, 1, 0); |
||
688 | if(get_key_press (1 << KEY_PLUS)) |
||
689 | { |
||
690 | if(newvalue > 248) |
||
691 | { |
||
692 | newvalue--; |
||
693 | } |
||
694 | } |
||
695 | |||
696 | if(get_key_press (1 << KEY_MINUS)) |
||
697 | { |
||
698 | if(newvalue < 255) |
||
699 | { |
||
700 | newvalue++; |
||
701 | } |
||
702 | } |
||
703 | } |
||
704 | |||
705 | |||
706 | if(get_key_short (1 << KEY_ENTER)) |
||
707 | { |
||
708 | if(newvalue != value) |
||
709 | { |
||
710 | *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
||
711 | changes=1; |
||
712 | } |
||
713 | break; |
||
714 | |||
715 | } |
||
716 | if(get_key_long (1 << KEY_ESC)) |
||
717 | { |
||
718 | lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 0); |
||
719 | newvalue = defaultvalue; |
||
720 | if(newvalue > 247) |
||
721 | { |
||
722 | mode =1; |
||
723 | } |
||
724 | else |
||
725 | { |
||
726 | //lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 1); |
||
727 | mode =0; |
||
728 | } |
||
729 | |||
730 | |||
731 | } |
||
732 | |||
733 | }while (!get_key_short (1 << KEY_ESC)); |
||
734 | } |
||
735 | |||
736 | if(type == 3)// serCH |
||
737 | { |
||
738 | lcd_printpns_at (0, 7, PSTR(" \x18 \x19 Back \x0c"), 0); |
||
739 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
||
740 | uint8_t min =pgm_read_byte(param_config+(8*param)+2); |
||
741 | uint8_t max = pgm_read_byte(param_config+(8*param)+3); |
||
742 | uint8_t defaultvalue = pgm_read_byte(param_config+(8*param)+5); |
||
743 | lcd_printpns_at (4, 4, PSTR("(1-S12/W) (d: )"), 0); |
||
744 | // write_ndigit_number_u (5, 4, min, 3, 0); |
||
745 | // write_ndigit_number_u (9, 4, max, 3, 0); |
||
746 | write_ndigit_number_u (17, 4, defaultvalue, 3, 0); |
||
747 | |||
748 | |||
749 | uint8_t newvalue = value; |
||
750 | |||
751 | do |
||
752 | { |
||
753 | if (newvalue<=(max-13)) |
||
754 | { |
||
755 | write_ndigit_number_u (0, 4, newvalue, 3, 0); |
||
756 | } |
||
757 | else |
||
758 | if (newvalue<=(max-1)) |
||
759 | { |
||
760 | lcd_printpns_at (0, 4, PSTR("S"), 0); |
||
761 | write_ndigit_number_u (1, 4, (newvalue-12), 2, 0); |
||
762 | } |
||
763 | if (newvalue==max) |
||
764 | { |
||
765 | lcd_printpns_at (0, 4, PSTR("WPE"), 0); |
||
766 | } |
||
767 | |||
768 | lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 1); |
||
769 | |||
770 | |||
771 | if(get_key_press (1 << KEY_PLUS) || get_key_rpt (1 << KEY_PLUS)) |
||
772 | { |
||
773 | if((newvalue+1) <= max) |
||
774 | { |
||
775 | newvalue++; |
||
776 | //lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 1); |
||
777 | } |
||
778 | } |
||
779 | |||
780 | if(get_key_press (1 << KEY_MINUS) || get_key_rpt (1 << KEY_MINUS)) |
||
781 | { |
||
782 | if((newvalue-1)>=min) |
||
783 | { |
||
784 | lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 0); |
||
785 | newvalue--; |
||
786 | //lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 1); |
||
787 | } |
||
788 | } |
||
789 | |||
790 | |||
791 | if(get_key_press (1 << KEY_ENTER)) |
||
792 | { |
||
793 | if(newvalue != value) |
||
794 | { |
||
795 | *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
||
796 | changes=1; |
||
797 | } |
||
798 | break; |
||
799 | |||
800 | } |
||
801 | if(get_key_long (1 << KEY_ESC)) |
||
802 | { |
||
803 | lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 0); |
||
804 | newvalue = defaultvalue; |
||
805 | //lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 1); |
||
806 | |||
807 | } |
||
808 | |||
809 | }while (!get_key_short (1 << KEY_ESC)); |
||
810 | } |
||
811 | |||
812 | |||
813 | if(type == 4) // led bitfeld |
||
814 | { |
||
815 | lcd_printpns_at (0, 7, PSTR(" \x19 Set Back \x0c"), 0); |
||
816 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
||
817 | uint8_t defaultvalue = pgm_read_byte(param_config+(8*param)+5); |
||
818 | |||
819 | |||
820 | |||
821 | uint8_t pos = 0; |
||
822 | uint8_t newvalue = value; |
||
823 | do |
||
824 | { |
||
825 | |||
826 | for(ii=0;ii<8;ii++) |
||
827 | { |
||
828 | if(newvalue & (1 << ii)) |
||
829 | { |
||
830 | lcd_printpns_at (8-ii, 4,PSTR("X"),0); |
||
831 | } |
||
832 | else |
||
833 | { |
||
834 | lcd_printpns_at (8-ii, 4,PSTR("O"),0); |
||
835 | } |
||
836 | } |
||
837 | lcd_printpns_at (pos+1, 5,PSTR("\x1a"),0); |
||
838 | if(get_key_press (1 << KEY_MINUS)) |
||
839 | { |
||
840 | lcd_printpns_at (pos+1, 5,PSTR(" "),0); |
||
841 | pos++; |
||
842 | if(pos == 8) pos = 0; |
||
843 | } |
||
844 | if(get_key_press (1 << KEY_PLUS)) |
||
845 | { |
||
846 | newvalue ^= (1<<(7-pos)); |
||
847 | } |
||
848 | if(get_key_press (1 << KEY_ENTER)) |
||
849 | { |
||
850 | if(newvalue != value) |
||
851 | { |
||
852 | *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
||
853 | changes=1; |
||
854 | } |
||
855 | break; |
||
856 | } |
||
857 | |||
858 | if(get_key_long (1 << KEY_ESC)) |
||
859 | { |
||
860 | newvalue = defaultvalue; |
||
861 | } |
||
862 | |||
863 | |||
864 | }while (!get_key_short (1 << KEY_ESC)); |
||
865 | } |
||
866 | |||
867 | if(type == 6) // receiver |
||
868 | { |
||
869 | lcd_printpns_at (0, 7, PSTR(" \x1a \x1b Back \x0c"), 0); |
||
870 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
||
871 | uint8_t defaultvalue = pgm_read_byte(param_config+(8*param)+5); |
||
872 | |||
873 | lcd_printpns_at (3, 1,PSTR("PPM"),0); |
||
874 | lcd_printpns_at (3, 2,PSTR("Spektrum"),0); |
||
875 | lcd_printpns_at (3, 3,PSTR("Spektrum HiRes"),0); |
||
876 | lcd_printpns_at (3, 4,PSTR("Spektrum LoRes"),0); |
||
877 | lcd_printpns_at (3, 5,PSTR("Jeti"),0); |
||
878 | lcd_printpns_at (3, 6,PSTR("ACT DSL"),0); |
||
879 | |||
880 | uint8_t newvalue = value; |
||
881 | do |
||
882 | { |
||
883 | |||
884 | for(ii=0;ii<6;ii++) |
||
885 | { |
||
886 | if(newvalue == ii) |
||
887 | { |
||
888 | lcd_printpns_at (1, ii+1,PSTR(">"),0); |
||
889 | } |
||
890 | else |
||
891 | { |
||
892 | lcd_printpns_at (1, ii+1,PSTR(" "),0); |
||
893 | } |
||
894 | |||
895 | |||
896 | } |
||
897 | |||
898 | if(get_key_press (1 << KEY_PLUS)) |
||
899 | { |
||
900 | newvalue++; |
||
901 | if(newvalue == 6) newvalue = 0; |
||
902 | } |
||
903 | if(get_key_press (1 << KEY_MINUS)) |
||
904 | { |
||
905 | if(newvalue == 0) newvalue = 6; |
||
906 | newvalue--; |
||
907 | } |
||
908 | if(get_key_press (1 << KEY_ENTER)) |
||
909 | { |
||
910 | if(newvalue != value) |
||
911 | { |
||
912 | *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
||
913 | changes=1; |
||
914 | } |
||
915 | break; |
||
916 | } |
||
917 | |||
918 | if(get_key_long (1 << KEY_ESC)) |
||
919 | { |
||
920 | newvalue = defaultvalue; |
||
921 | } |
||
922 | |||
923 | |||
924 | }while (!get_key_short (1 << KEY_ESC)); |
||
925 | } |
||
926 | |||
927 | if(type == 5) // Angle |
||
928 | { |
||
929 | lcd_printpns_at (0, 7, PSTR(" \x1a \x1b Back \x0c"), 0); |
||
930 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
||
931 | uint8_t defaultvalue = pgm_read_byte(param_config+(8*param)+5); |
||
932 | |||
933 | lcd_ecircle(102, 35, 16, 1); |
||
934 | |||
935 | uint8_t newvalue = value; |
||
936 | uint8_t oldvalue = newvalue; |
||
937 | do |
||
938 | { |
||
939 | |||
940 | if(oldvalue != newvalue) lcd_ecirc_line (102, 35, 15, oldvalue*15, 0); |
||
941 | oldvalue = newvalue; |
||
942 | lcd_ecirc_line (102, 35, 15, newvalue*15, 1); |
||
943 | |||
944 | |||
945 | if(get_key_press (1 << KEY_PLUS)) |
||
946 | { |
||
947 | newvalue++; |
||
948 | if(newvalue == 24) newvalue = 0; |
||
949 | } |
||
950 | if(get_key_press (1 << KEY_MINUS)) |
||
951 | { |
||
952 | if(newvalue == 0) newvalue = 24; |
||
953 | newvalue--; |
||
954 | } |
||
955 | if(get_key_press (1 << KEY_ENTER)) |
||
956 | { |
||
957 | if(newvalue != value) |
||
958 | { |
||
959 | *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
||
960 | changes=1; |
||
961 | } |
||
962 | break; |
||
963 | } |
||
964 | |||
965 | if(get_key_long (1 << KEY_ESC)) |
||
966 | { |
||
967 | newvalue = defaultvalue; |
||
968 | } |
||
969 | |||
970 | |||
971 | }while (!get_key_short (1 << KEY_ESC)); |
||
972 | } |
||
973 | |||
974 | |||
975 | |||
976 | |||
977 | // while (!get_key_press (1 << KEY_ESC)); |
||
978 | } |
||
979 | |||
980 | |||
981 | |||
982 | |||
983 | uint8_t display_param_menu(uint8_t group) |
||
984 | { |
||
985 | uint8_t items[20]; |
||
986 | |||
987 | uint8_t size=0; |
||
988 | for(ii = 0;ii < PARAM_COUNT; ii++) |
||
989 | { |
||
990 | if(pgm_read_byte(param_config+(8*ii)) == (group-1)) |
||
991 | { |
||
992 | items[size] = ii; |
||
993 | size++; |
||
994 | } |
||
995 | } |
||
996 | |||
997 | |||
998 | // offset2=0; |
||
999 | // target_pos2=1; |
||
1000 | // pmode =0; |
||
1001 | |||
1002 | uint8_t val =0 ; |
||
1003 | |||
1004 | |||
1005 | |||
1006 | while(1) |
||
1007 | { |
||
1008 | lcd_cls (); |
||
1009 | lcd_printp_at (0, 0, PSTR("Choose Parameter:"), 0); |
||
1010 | lcd_printpns_at (0, 7, PSTR(" \x1a \x1b Back \x0c"), 0); |
||
1011 | |||
1012 | ii = 0; |
||
1013 | if(offset2 > 0) |
||
1014 | { |
||
1015 | lcd_printp_at(1,1, PSTR("\x1a"), 0); |
||
1016 | } |
||
1017 | for(ii = 0;ii < 6 ; ii++) |
||
1018 | { |
||
1019 | if((ii+offset2) < size) |
||
1020 | { |
||
1021 | lcd_printp_at(3,ii+1,param_names[items[ii+offset2]][DisplayLanguage], 0); |
||
1022 | // this reads the the offset in the struct from the pgm configuration table and then reads the value from the struct |
||
1023 | |||
1024 | uint8_t type = pgm_read_byte(param_config+(8*items[ii+offset2])+1); |
||
1025 | |||
1026 | if(type == 0) |
||
1027 | { |
||
1028 | write_ndigit_number_u (18, ii+1, *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)), 3, 0); |
||
1029 | } |
||
1030 | if(type == 1) |
||
1031 | { |
||
1032 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)); |
||
1033 | |||
1034 | if(value < 248) |
||
1035 | write_ndigit_number_u (18, ii+1, value, 3, 0); |
||
1036 | if(value >= 248) |
||
1037 | { |
||
1038 | lcd_printp_at (18, ii+1, PSTR(" P"), 0); |
||
1039 | write_ndigit_number_u (20, ii+1, 256-value, 1, 0); |
||
1040 | } |
||
1041 | } |
||
1042 | if(type == 2) |
||
1043 | { |
||
1044 | |||
1045 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)); |
||
1046 | uint8_t bitmap = pgm_read_byte(param_config+(8*items[ii+offset2])+3); |
||
1047 | if(value & bitmap) |
||
1048 | { |
||
1049 | lcd_printp_at (18, ii+1, PSTR(" Y"), 0); |
||
1050 | } |
||
1051 | else |
||
1052 | { |
||
1053 | lcd_printp_at (18, ii+1, PSTR(" N"), 0); |
||
1054 | } |
||
1055 | } |
||
1056 | if(type == 3) |
||
1057 | { |
||
1058 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)); |
||
1059 | if (value<=12) |
||
1060 | // write_ndigit_number_u (18, ii+1, *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)), 3, 0); |
||
1061 | write_ndigit_number_u (18, ii+1, value, 3, 0); |
||
1062 | else |
||
1063 | if (value<=(24)) |
||
1064 | { |
||
1065 | lcd_printpns_at (18, ii+1, PSTR("S"), 0); |
||
1066 | write_ndigit_number_u (19, ii+1, (value-12), 2, 0); |
||
1067 | } |
||
1068 | if (value==25) |
||
1069 | lcd_printpns_at (18, ii+1, PSTR("WPE"), 0); |
||
1070 | } |
||
1071 | |||
1072 | |||
1073 | |||
1074 | if(type == 4) |
||
1075 | { |
||
1076 | write_ndigit_number_u (18, ii+1, *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)), 3, 0); |
||
1077 | } |
||
1078 | if(type == 5) |
||
1079 | { |
||
1080 | write_ndigit_number_u (18, ii+1, (*(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)))*15, 3, 0); |
||
1081 | } |
||
1082 | if(type == 6) |
||
1083 | { |
||
1084 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)); |
||
1085 | if(value == 0) |
||
1086 | { |
||
1087 | lcd_printp_at (18, ii+1, PSTR("PPM"), 0); |
||
1088 | } |
||
1089 | else if(value == 1) |
||
1090 | { |
||
1091 | lcd_printp_at (18, ii+1, PSTR(" SP"), 0); |
||
1092 | } |
||
1093 | else if(value == 2) |
||
1094 | { |
||
1095 | lcd_printp_at (18, ii+1, PSTR("SPh"), 0); |
||
1096 | } |
||
1097 | else if(value == 3) |
||
1098 | { |
||
1099 | lcd_printp_at (18, ii+1, PSTR("SPl"), 0); |
||
1100 | } |
||
1101 | else if(value == 4) |
||
1102 | { |
||
1103 | lcd_printp_at (18, ii+1, PSTR("Jet"), 0); |
||
1104 | } |
||
1105 | else if(value == 5) |
||
1106 | { |
||
1107 | lcd_printp_at (18, ii+1, PSTR("ACT"), 0); |
||
1108 | } |
||
1109 | else |
||
1110 | { |
||
1111 | write_ndigit_number_u (18, ii+1, *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)), 3, 0); |
||
1112 | } |
||
1113 | } |
||
1114 | |||
1115 | } |
||
1116 | if((ii == 5)&&(ii+offset2 < (size-1))) |
||
1117 | { |
||
1118 | lcd_printp_at(1,6, PSTR("\x1b"), 0); |
||
1119 | } |
||
1120 | |||
1121 | } |
||
1122 | |||
1123 | /* write_ndigit_number_u (0, 0,offset2, 3, 0); |
||
1124 | write_ndigit_number_u (4, 0,target_pos2, 3, 0); |
||
1125 | write_ndigit_number_u (7, 0,pmode, 3, 0); |
||
1126 | write_ndigit_number_u (10, 0,size, 3, 0); |
||
1127 | write_ndigit_number_u (14, 0,val, 3, 0); |
||
1128 | write_ndigit_number_u (17, 0,group, 3, 0); |
||
1129 | */ |
||
1130 | |||
1131 | if(pmode == 0) |
||
1132 | { |
||
1133 | if(offset2 == 0) |
||
1134 | { |
||
1135 | if(size > 6) |
||
1136 | { |
||
1137 | val = menu_choose2 (1, 5, target_pos2,0,1); |
||
1138 | } |
||
1139 | else |
||
1140 | { |
||
1141 | val = menu_choose2 (1, size, target_pos2,0,0); |
||
1142 | } |
||
1143 | |||
1144 | } |
||
1145 | else |
||
1146 | { |
||
1147 | val = menu_choose2 (2, 5, target_pos2,1,1); |
||
1148 | } |
||
1149 | } |
||
1150 | if(pmode == 1) |
||
1151 | { |
||
1152 | if(offset2+7 > size) |
||
1153 | { |
||
1154 | val = menu_choose2 (2, 6, target_pos2,1,0); |
||
1155 | } |
||
1156 | else |
||
1157 | { |
||
1158 | val = menu_choose2 (2, 5, target_pos2,1,1); |
||
1159 | } |
||
1160 | } |
||
1161 | |||
1162 | if(val == 254) |
||
1163 | { |
||
1164 | offset2++; |
||
1165 | pmode = 1; |
||
1166 | target_pos2 = 5; |
||
1167 | }else if(val == 253) |
||
1168 | { |
||
1169 | offset2--; |
||
1170 | pmode = 0; |
||
1171 | target_pos2 = 2; |
||
1172 | } |
||
1173 | else |
||
1174 | { |
||
1175 | break; |
||
1176 | } |
||
1177 | } |
||
1178 | |||
1179 | if(val != 255) |
||
1180 | { |
||
1181 | target_pos2=val; |
||
1182 | return items[val+offset2-1]; |
||
1183 | } |
||
1184 | else |
||
1185 | { |
||
1186 | return val; |
||
1187 | } |
||
1188 | |||
1189 | } |
||
1190 | |||
1191 | |||
1192 | uint8_t display_section_menu(void) |
||
1193 | { |
||
1194 | uint8_t size = PAGES; |
||
1195 | |||
1196 | uint8_t val =0; |
||
1197 | |||
1198 | |||
1199 | while(1) |
||
1200 | { |
||
1201 | lcd_cls (); |
||
1202 | lcd_printp_at (0, 0, PSTR("Choose Section:"), 0); |
||
1203 | lcd_printpns_at (0, 7, PSTR(" \x1a \x1b Back \x0c"), 0); |
||
1204 | // write_ndigit_number_u(0,0,dmode,2,0); |
||
1205 | // write_ndigit_number_u(2,0,offset,2,0); |
||
1206 | // write_ndigit_number_u(4,0,target_pos,2,0); |
||
1207 | |||
1208 | ii = 0; |
||
1209 | if(offset > 0) |
||
1210 | { |
||
1211 | lcd_printp_at(1,1, PSTR("\x1a"), 0); |
||
1212 | } |
||
1213 | for(ii = 0;ii < 6 ; ii++) |
||
1214 | { |
||
1215 | if((ii+offset) < size) |
||
1216 | { |
||
1217 | lcd_printp_at(3,ii+1,param_pages[ii+offset][DisplayLanguage], 0); |
||
1218 | } |
||
1219 | if((ii == 5)&&(ii+offset < (size-1))) |
||
1220 | { |
||
1221 | lcd_printp_at(1,6, PSTR("\x1b"), 0); |
||
1222 | } |
||
1223 | |||
1224 | } |
||
1225 | |||
1226 | |||
1227 | |||
1228 | if(dmode == 0) |
||
1229 | { |
||
1230 | if(offset == 0) |
||
1231 | { |
||
1232 | if(size > 6) |
||
1233 | { |
||
1234 | val = menu_choose2 (1, 5, target_pos,0,1); |
||
1235 | } |
||
1236 | else |
||
1237 | { |
||
1238 | val = menu_choose2 (1, size, target_pos,0,0); |
||
1239 | } |
||
1240 | } |
||
1241 | else |
||
1242 | { |
||
1243 | val = menu_choose2 (2, 5, target_pos,1,1); |
||
1244 | } |
||
1245 | } |
||
1246 | if(dmode == 1) |
||
1247 | { |
||
1248 | if(offset+7 > size) |
||
1249 | { |
||
1250 | val = menu_choose2 (2, 6, target_pos,1,0); |
||
1251 | } |
||
1252 | else |
||
1253 | { |
||
1254 | val = menu_choose2 (2, 5, target_pos,1,1); |
||
1255 | } |
||
1256 | } |
||
1257 | |||
1258 | |||
1259 | |||
1260 | if(val == 254) |
||
1261 | { |
||
1262 | offset++; |
||
1263 | dmode = 1; |
||
1264 | target_pos = 5; |
||
1265 | }else if(val == 253) |
||
1266 | { |
||
1267 | offset--; |
||
1268 | dmode = 0; |
||
1269 | target_pos = 2; |
||
1270 | } |
||
1271 | else |
||
1272 | { |
||
1273 | break; |
||
1274 | } |
||
1275 | } |
||
1276 | |||
1277 | // write_ndigit_number_u(0,0,val,2,0); |
||
1278 | // menu_choose2 (2, 5, target_pos,1,1); |
||
1279 | if(val != 255) |
||
1280 | { |
||
1281 | target_pos=val; |
||
1282 | return val+offset; |
||
1283 | } |
||
1284 | else |
||
1285 | { |
||
1286 | return val; |
||
1287 | } |
||
1288 | |||
1289 | } |
||
1290 | |||
1291 | |||
1292 | uint8_t display_settings_menu (void) |
||
1293 | { |
||
1294 | uint8_t status; |
||
1295 | |||
1296 | lcd_cls (); |
||
1297 | |||
1298 | uint8_t setting = 0; |
||
1299 | lcd_printp_at (0, 0, PSTR("Edit Setting:"), 0); |
||
1300 | lcd_printpns_at (0, 7, PSTR(" \x1a \x1b Back \x0c"), 0); |
||
1301 | |||
1302 | |||
1303 | for(setting=1;setting<6;setting++) |
||
1304 | { |
||
1305 | status = load_setting(setting); |
||
1306 | if(status == 255) return 255; |
||
1307 | |||
1308 | write_ndigit_number_u (3, setting, status, 1, 0); |
||
1309 | lcd_print_at (5,setting,(uint8_t*)mk_param_struct->Name, 0); |
||
1310 | } |
||
1311 | lcd_printp_at (3, 6, PSTR("Copy Setting"), 0); |
||
1312 | |||
1313 | |||
1314 | status = load_setting(0xff); |
||
1315 | if(status == 255) return 255; |
||
1316 | |||
1317 | setting = menu_choose (1, 6, 1,status); |
||
1318 | |||
1319 | return setting; |
||
1320 | } |
||
1321 | |||
1322 | |||
1323 | |||
1324 | uint8_t load_setting(uint8_t setting) |
||
1325 | { |
||
1326 | mode = 'Q'; // Settings |
||
1327 | uint8_t timeout = 50; |
||
1328 | rxd_buffer_locked = FALSE; |
||
1329 | |||
1330 | while (!rxd_buffer_locked && timeout) |
||
1331 | { |
||
1332 | SendOutData ('q', ADDRESS_FC, 1, &setting, 1); |
||
1333 | // _delay_ms(50); |
||
1334 | timer = 20; |
||
1335 | while (timer > 0); |
||
1336 | timeout--; |
||
1337 | } |
||
1338 | |||
1339 | if (timeout != 0) |
||
1340 | { |
||
1341 | Decode64 (); |
||
1342 | setting = *pRxData; |
||
1343 | mk_param_struct = (mk_param_struct_t *) (pRxData + 1) ; |
||
1344 | } |
||
1345 | else |
||
1346 | { // timeout occured |
||
1347 | lcd_printp_at (0, 2, PSTR("ERROR: no data"), 0); |
||
1348 | |||
1349 | timer = 100; |
||
1350 | while (timer > 0); |
||
1351 | setting = 255; |
||
1352 | } |
||
1353 | |||
1354 | return setting; |
||
1355 | } |
||
1356 | |||
1357 | uint8_t write_setting(uint8_t setting) |
||
1358 | { |
||
1359 | mode = 'S'; // Settings |
||
1360 | uint8_t timeout = 50; |
||
1361 | rxd_buffer_locked = FALSE; |
||
1362 | |||
1363 | while (!rxd_buffer_locked && timeout) |
||
1364 | { |
||
1365 | SendOutData ('s', ADDRESS_FC, 2, &setting, 1, mk_param_struct, sizeof(mk_param_struct_t)); |
||
1366 | // _delay_ms(50); |
||
1367 | timer = 20; |
||
1368 | while (timer > 0); |
||
1369 | timeout--; |
||
1370 | } |
||
1371 | |||
1372 | if (timeout != 0) |
||
1373 | { |
||
1374 | Decode64 (); |
||
1375 | setting = *pRxData; |
||
1376 | } |
||
1377 | else |
||
1378 | { // timeout occured |
||
1379 | lcd_printp_at (0, 2, PSTR("ERROR: no data"), 0); |
||
1380 | |||
1381 | timer = 100; |
||
1382 | while (timer > 0); |
||
1383 | setting = 255; |
||
1384 | } |
||
1385 | |||
1386 | return setting; |
||
1387 | } |
||
1388 |