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