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