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