Rev 1933 | Rev 1937 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1917 | holgerb | 1 | #include "libfc.h" |
2 | #include "printf_P.h" |
||
3 | #include "main.h" |
||
4 | #include "spi.h" |
||
5 | #include "capacity.h" |
||
6 | |||
1925 | holgerb | 7 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
8 | |||
1920 | holgerb | 9 | #define HoTT_printf(format, args...) { _printf_P(&LIBFC_HoTT_Putchar, PSTR(format) , ## args);} |
10 | #define HoTT_printfxy(x,y,format, args...) { LIBFC_HoTT_SetPos(y * 21 + x); _printf_P(&LIBFC_HoTT_Putchar, PSTR(format) , ## args);} |
||
11 | #define HoTT_printfxy_INV(x,y,format, args...) { LIBFC_HoTT_SetPos(y * 21 + x); _printf_P(&LIBFC_HoTT_Putchar_INV, PSTR(format) , ## args);} |
||
12 | #define HoTT_printfxy_BLINK(x,y,format, args...) { LIBFC_HoTT_SetPos(y * 21 + x); _printf_P(&LIBFC_HoTT_Putchar_BLINK, PSTR(format) , ## args);} |
||
1921 | holgerb | 13 | #define HoTT_printf_BLINK(format, args...) { _printf_P(&LIBFC_HoTT_Putchar_BLINK, PSTR(format) , ## args);} |
14 | #define HoTT_printf_INV(format, args...) { _printf_P(&LIBFC_HoTT_Putchar_INV, PSTR(format) , ## args);} |
||
1917 | holgerb | 15 | |
1919 | holgerb | 16 | #define VOICE_MINIMALE_EINGANSSPANNUNG 16 |
17 | #define VOICE_BEEP 5 |
||
1920 | holgerb | 18 | #define HoTT_GRAD 96 |
19 | #define HoTT_LINKS 123 |
||
20 | #define HoTT_RECHTS 124 |
||
21 | #define HoTT_OBEN 125 |
||
22 | #define HoTT_UNTEN 126 |
||
1917 | holgerb | 23 | |
1930 | holgerb | 24 | const char PROGMEM NC_ERROR_TEXT[MAX_ERR_NUMBER][17] = |
25 | { |
||
26 | //0123456789123456 |
||
27 | "No Error \0", // 0 |
||
28 | "Not compatible \0", // 1 |
||
29 | "MK3Mag not compa\0", // 2 |
||
30 | "No FC communicat\0", // 3 |
||
31 | "MK3Mag communica\0", // 4 |
||
32 | "GPS communicatio\0", // 5 |
||
33 | "compass value \0", // 6 |
||
34 | "RC Signal lost \0", // 7 |
||
35 | "FC spi rx error \0", // 8 |
||
36 | "No NC communicat\0", // 9 |
||
37 | "FC Nick Gyro \0", // 10 |
||
38 | "FC Roll Gyro \0", // 11 |
||
39 | "FC Yaw Gyro \0", // 12 |
||
40 | "FC Nick ACC \0", // 13 |
||
41 | "FC Roll ACC \0", // 14 |
||
42 | "FC Z-ACC \0", // 15 |
||
43 | "Pressure sensor \0", // 16 |
||
1936 | holgerb | 44 | "I2C FC->BL-Ctrl \0", // 17 |
1930 | holgerb | 45 | "Bl Missing \0", // 18 |
46 | "Mixer Error \0", // 19 |
||
47 | "Carefree Error \0" // 20 |
||
48 | }; |
||
1919 | holgerb | 49 | |
50 | //--------------------------------------------------------------- |
||
1917 | holgerb | 51 | void Hott_ClearLine(unsigned char line) |
52 | { |
||
53 | HoTT_printfxy(0,line," "); |
||
54 | } |
||
1919 | holgerb | 55 | //--------------------------------------------------------------- |
1917 | holgerb | 56 | |
1919 | holgerb | 57 | unsigned char HoTT_Waring(void) |
58 | { |
||
59 | if(FC_StatusFlags & FC_STATUS_LOWBAT) return(VOICE_MINIMALE_EINGANSSPANNUNG); |
||
1933 | holgerb | 60 | if(MotorenEin && NC_ErrorCode) return(VOICE_BEEP); |
1919 | holgerb | 61 | return(0); |
62 | } |
||
63 | |||
64 | //--------------------------------------------------------------- |
||
65 | unsigned char HoTT_Telemety(unsigned char packet_request) |
||
66 | { |
||
67 | switch(packet_request) |
||
68 | { |
||
69 | case HOTT_VARIO_PACKET_ID: |
||
1921 | holgerb | 70 | VarioPacket.Altitude = HoehenWert/100 + 500; |
1919 | holgerb | 71 | if (VarioPacket.Altitude < VarioPacket.MinAltitude) VarioPacket.MinAltitude = VarioPacket.Altitude; |
72 | if (VarioPacket.Altitude > VarioPacket.MaxAltitude) VarioPacket.MaxAltitude = VarioPacket.Altitude; |
||
73 | VarioPacket.WarnBeep = HoTT_Waring(); |
||
74 | HoTT_DataPointer = (unsigned char *) &VarioPacket; |
||
75 | return(sizeof(VarioPacket)); |
||
76 | break; |
||
1921 | holgerb | 77 | |
1919 | holgerb | 78 | case HOTT_GPS_PACKET_ID: |
1921 | holgerb | 79 | GPSPacket.Altitude = HoehenWert/100 + 500; |
1919 | holgerb | 80 | GPSPacket.Distance = GPSInfo.HomeDistance/10; |
1921 | holgerb | 81 | GPSPacket.Heading = KompassValue/2; |
82 | GPSPacket.Speed = (GPSInfo.Speed * 36) / 10; |
||
83 | GPSPacket.m_sec = GPSInfo.Speed+120; |
||
84 | GPSPacket.m_3sec = 120; |
||
85 | GPSPacket.m_10sec = 0; |
||
1919 | holgerb | 86 | GPSPacket.WarnBeep = HoTT_Waring(); |
87 | HoTT_DataPointer = (unsigned char *) &GPSPacket; |
||
88 | return(sizeof(GPSPacket)); |
||
89 | break; |
||
90 | case HOTT_ELECTRIC_AIR_PACKET_ID: |
||
1921 | holgerb | 91 | ElectricAirPacket.Altitude = HoehenWert/1000 + 500; ; |
92 | ElectricAirPacket.Battery1 = UBat; |
||
93 | ElectricAirPacket.Capacity = Capacity.UsedCapacity; |
||
1919 | holgerb | 94 | ElectricAirPacket.WarnBeep = HoTT_Waring(); |
95 | HoTT_DataPointer = (unsigned char *) &ElectricAirPacket; |
||
96 | return(sizeof(ElectricAirPacket)); |
||
97 | break; |
||
98 | default: return(0); |
||
99 | } |
||
100 | } |
||
101 | |||
102 | //--------------------------------------------------------------- |
||
1917 | holgerb | 103 | void HoTT_Menu(void) |
104 | { |
||
1933 | holgerb | 105 | static unsigned char line, page = 0; |
1921 | holgerb | 106 | unsigned char tmp; |
107 | if(page == 0) |
||
1933 | holgerb | 108 | switch(line++) |
1917 | holgerb | 109 | { |
1919 | holgerb | 110 | case 0: |
1923 | holgerb | 111 | if(FC_StatusFlags & FC_STATUS_LOWBAT) |
112 | HoTT_printfxy_BLINK(0,0," %2i:%02i %2i.%1iV %4imAh",FlugSekunden/60,FlugSekunden%60,UBat/10, UBat%10,Capacity.UsedCapacity) |
||
113 | else HoTT_printfxy(0,0," %2i:%02i %2i.%1iV %4imAh",FlugSekunden/60,FlugSekunden%60,UBat/10, UBat%10,Capacity.UsedCapacity); |
||
1917 | holgerb | 114 | break; |
115 | case 1: |
||
1921 | holgerb | 116 | HoTT_printfxy(0,1,"DIR:%3d%c",KompassValue, HoTT_GRAD); |
1917 | holgerb | 117 | if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG) |
1920 | holgerb | 118 | { |
119 | if(HoehenReglerAktiv) HoTT_printfxy_INV(10,1,"ALT:%4im", (int16_t)(HoehenWert/100)) |
||
120 | else HoTT_printfxy(10,1,"ALT:%4im", (int16_t)(HoehenWert/100)) |
||
121 | } |
||
122 | else HoTT_printfxy(10,1,"ALT:---- "); |
||
123 | HoTT_printfxy(20,1,"%c",VarioCharacter); |
||
1917 | holgerb | 124 | break; |
125 | case 2: |
||
126 | if(NaviDataOkay) |
||
127 | { |
||
1923 | holgerb | 128 | HoTT_printfxy(1,2,"HM:%3d%c DIST:%3dm %c", GPSInfo.HomeBearing, HoTT_GRAD, GPSInfo.HomeDistance/10, NC_GPS_ModeCharacter); |
1917 | holgerb | 129 | } |
130 | else |
||
131 | { |
||
1923 | holgerb | 132 | Hott_ClearLine(2); |
1917 | holgerb | 133 | } |
134 | break; |
||
1923 | holgerb | 135 | case 3: |
136 | HoTT_printfxy(0,3,"PWR:%2i.%1iA (%iW) ",Capacity.ActualCurrent/10, Capacity.ActualCurrent%10,Capacity.ActualPower); |
||
137 | break; |
||
1917 | holgerb | 138 | case 4: |
139 | if(NaviDataOkay) |
||
140 | { |
||
1919 | holgerb | 141 | HoTT_printfxy(0,4,"GPS:%2um/s SAT:%d ",GPSInfo.Speed,GPSInfo.NumOfSats); |
1917 | holgerb | 142 | switch (GPSInfo.SatFix) |
143 | { |
||
144 | case SATFIX_3D: |
||
145 | HoTT_printfxy(16,4," 3D "); |
||
146 | break; |
||
1925 | holgerb | 147 | //case SATFIX_2D: |
148 | //case SATFIX_NONE: |
||
1917 | holgerb | 149 | default: |
1925 | holgerb | 150 | HoTT_printfxy_BLINK(16,4,"NOFIX"); |
1917 | holgerb | 151 | break; |
152 | } |
||
153 | if(GPSInfo.Flags & FLAG_DIFFSOLN) |
||
154 | { |
||
155 | HoTT_printfxy(16,4,"DGPS "); |
||
156 | } |
||
157 | } |
||
158 | else |
||
159 | { //012345678901234567890 |
||
1930 | holgerb | 160 | HoTT_printfxy(0,4," No NaviCtrl "); |
1917 | holgerb | 161 | } |
162 | break; |
||
163 | case 5: |
||
1923 | holgerb | 164 | HoTT_printfxy(0,5,"%3i %3i %3i %3i%cC", Motor[0].Temperature, Motor[1].Temperature, Motor[2].Temperature, Motor[3].Temperature,HoTT_GRAD); |
165 | if(FC_StatusFlags2 & FC_STATUS2_CAREFREE) HoTT_printfxy_INV(18,5,"CF") else HoTT_printfxy(18,5," "); |
||
1917 | holgerb | 166 | break; |
167 | case 6: |
||
168 | if(RequiredMotors == 4) Hott_ClearLine(6); |
||
169 | else |
||
1923 | holgerb | 170 | if(RequiredMotors == 6) HoTT_printfxy(0,6,"%3i %3i%cC ", Motor[4].Temperature, Motor[5].Temperature,HoTT_GRAD) |
1917 | holgerb | 171 | else |
1923 | holgerb | 172 | if(RequiredMotors > 6) HoTT_printfxy(0,6,"%3i %3i %3i %3i%cC", Motor[4].Temperature, Motor[5].Temperature, Motor[6].Temperature, Motor[7].Temperature,HoTT_GRAD); |
1920 | holgerb | 173 | //HoTT_printfxy(15,6,"%KEY:%02x",HottKeyboard); |
1917 | holgerb | 174 | break; |
1930 | holgerb | 175 | case 7: if(NC_ErrorCode) |
176 | { |
||
177 | if(HoTTBlink && NC_ErrorCode < MAX_ERR_NUMBER) |
||
178 | { |
||
179 | Hott_ClearLine(7); |
||
180 | HoTT_printfxy_INV(0,7,"ERR: %2d !",NC_ErrorCode); |
||
181 | } |
||
182 | else |
||
183 | { |
||
184 | HoTT_printfxy(0,7,"ERR: "); _printf_P(&LIBFC_HoTT_Putchar, NC_ERROR_TEXT[NC_ErrorCode] , 0);}; |
||
185 | } |
||
1917 | holgerb | 186 | else HoTT_printfxy(0,7," www.MikroKopter.de "); |
187 | break; |
||
1919 | holgerb | 188 | case 8: ASCIIPacket.WarnBeep = HoTT_Waring(); |
189 | // ASCIIPacket.WarnBeep = Parameter_UserParam1; |
||
1921 | holgerb | 190 | case 9: |
1917 | holgerb | 191 | case 10: |
192 | case 11: |
||
193 | case 12: |
||
194 | case 13: |
||
1919 | holgerb | 195 | case 14: |
196 | case 15: |
||
197 | case 16: |
||
1933 | holgerb | 198 | if(HottKeyboard == 8) { LIBFC_HoTT_Clear(); page = 1; line = 0;}; |
1921 | holgerb | 199 | HottKeyboard = 0; |
200 | break; |
||
1933 | holgerb | 201 | default: line = 0; |
1921 | holgerb | 202 | break; |
203 | } |
||
204 | else |
||
205 | if(page == 1) |
||
1933 | holgerb | 206 | switch(line++) |
1921 | holgerb | 207 | { |
208 | case 0: |
||
209 | HoTT_printfxy_INV(0,0,"Setting:%u %s ",GetActiveParamSet(),EE_Parameter.Name); |
||
210 | break; |
||
211 | case 1: HoTT_printfxy(0,1,"Min:%2i.%1iV %s ",BattLowVoltageWarning/10, BattLowVoltageWarning%10, Mixer.Name); |
||
212 | break; |
||
1923 | holgerb | 213 | case 2: HoTT_printfxy(0,2,"ALT:"); |
1921 | holgerb | 214 | if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG) |
215 | { |
||
216 | if(!(EE_Parameter.GlobalConfig & CFG_HOEHEN_SCHALTER)) HoTT_printf("POTI:%3u ", Parameter_HoehenSchalter) |
||
217 | else |
||
218 | { |
||
219 | if(Parameter_HoehenSchalter > 50) HoTT_printf("(ON) ") else HoTT_printf("(OFF) "); |
||
220 | if((Parameter_ExtraConfig & CFG2_HEIGHT_LIMIT)) HoTT_printf("LIMIT", Parameter_HoehenSchalter) |
||
221 | else HoTT_printf("VARIO", Parameter_HoehenSchalter); |
||
222 | } |
||
223 | } |
||
224 | else |
||
225 | HoTT_printf("DISABLED"); |
||
226 | break; |
||
1923 | holgerb | 227 | case 3: HoTT_printfxy(0,3,"CF:"); |
1921 | holgerb | 228 | if(!EE_Parameter.CareFreeModeControl) HoTT_printf("DISABLED") |
229 | else |
||
230 | { |
||
231 | if(CareFree) HoTT_printf(" (ON) ") else HoTT_printf(" (OFF)"); |
||
232 | if(EE_Parameter.ExtraConfig & CFG_LEARNABLE_CAREFREE) HoTT_printf(" TEACH"); |
||
233 | } |
||
234 | break; |
||
1923 | holgerb | 235 | case 4: HoTT_printfxy(0,4,"GPS:"); |
236 | if(!(Parameter_GlobalConfig & CFG_GPS_AKTIV)) HoTT_printf("DISABLED") |
||
237 | else |
||
238 | { |
||
239 | CHK_POTI(tmp,EE_Parameter.NaviGpsModeControl); |
||
240 | if(tmp < 50) HoTT_printf("(FREE)") |
||
241 | else |
||
242 | if(tmp >= 180) HoTT_printf("(HOME)") |
||
243 | else |
||
244 | if(EE_Parameter.ExtraConfig & CFG_GPS_AID) HoTT_printf("(AID) ") |
||
245 | else HoTT_printf("(HOLD)") |
||
246 | } |
||
247 | if(EE_Parameter.FailSafeTime) HoTT_printfxy(10,4," FS:%usek ",EE_Parameter.FailSafeTime) |
||
248 | |||
249 | break; |
||
250 | case 5: HoTT_printfxy(0,5,"HOME ALT:"); |
||
251 | if(EE_Parameter.ComingHomeAltitude) HoTT_printf("%um",EE_Parameter.ComingHomeAltitude) else HoTT_printf("HOLD "); |
||
252 | break; |
||
1921 | holgerb | 253 | case 6: |
1923 | holgerb | 254 | HoTT_printfxy(0,6,"Ni:%4i Ro:%4i C:%3i",PPM_in[EE_Parameter.Kanalbelegung[K_NICK]],PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]], Parameter_ServoNickControl); |
1933 | holgerb | 255 | HoTT_printfxy(0,7,"Gs:%4i Ya:%4i ",PPM_in[EE_Parameter.Kanalbelegung[K_GAS]]+127,PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]); |
1921 | holgerb | 256 | break; |
257 | case 7: //HoTT_printfxy(0,6,"WARNINGS:"); |
||
258 | if(HoTTBlink) |
||
259 | { |
||
260 | LIBFC_HoTT_SetPos(6 * 21); |
||
261 | if(!(Parameter_GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV)) HoTT_printf_BLINK("COUPLING OFF! "); |
||
262 | if(EE_Parameter.BitConfig & (CFG_LOOP_LINKS | CFG_LOOP_RECHTS | CFG_LOOP_UNTEN | CFG_LOOP_OBEN)) HoTT_printf_BLINK("LOOPING! "); |
||
263 | if(Parameter_GlobalConfig & CFG_HEADING_HOLD) HoTT_printf_BLINK("HH! "); |
||
264 | if(!(Parameter_GlobalConfig & CFG_KOMPASS_AKTIV)) HoTT_printf_BLINK("COMPASS OFF! "); |
||
265 | } |
||
266 | break; |
||
267 | case 8: ASCIIPacket.WarnBeep = HoTT_Waring(); |
||
268 | break; |
||
269 | case 9: |
||
270 | case 10: |
||
271 | case 11: |
||
272 | case 12: |
||
273 | case 13: |
||
274 | case 14: |
||
275 | case 15: |
||
276 | case 16: |
||
1933 | holgerb | 277 | if(HottKeyboard == 1) { LIBFC_HoTT_Clear(); page = 0; line = 0;}; |
1921 | holgerb | 278 | HottKeyboard = 0; |
279 | break; |
||
1933 | holgerb | 280 | default: line = 0; |
1917 | holgerb | 281 | break; |
282 | } |
||
1921 | holgerb | 283 | else page = 0; |
1917 | holgerb | 284 | } |
285 | |||
1925 | holgerb | 286 | #endif |
1917 | holgerb | 287 | |
288 | |||
289 |