Go to most recent revision | Details | 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: |
84 | HoTT_printfxy(0,0,"%2i.%1iV ",UBat/10, UBat%10); |
||
85 | if(FC_StatusFlags & FC_STATUS_LOWBAT) HoTT_printfxy_INV(6,0,"!!",UBat/10, UBat%10); |
||
1920 | holgerb | 86 | HoTT_printfxy(6,0,"%4imAh %2i:%02i ",Capacity.UsedCapacity,FlugSekunden/60,FlugSekunden%60); |
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: |
||
1920 | holgerb | 99 | HoTT_printfxy(0,2,"I=%3i.%1iA%4iW ",Capacity.ActualCurrent/10, Capacity.ActualCurrent%10,Capacity.ActualPower); |
1917 | holgerb | 100 | break; |
101 | case 3: |
||
102 | if(NaviDataOkay) |
||
103 | { |
||
1920 | holgerb | 104 | HoTT_printfxy(0,3,"Home:%3dm %3d%c %c", GPSInfo.HomeDistance/10, GPSInfo.HomeBearing, HoTT_GRAD, NC_GPS_ModeCharacter); |
105 | if(FC_StatusFlags2 & FC_STATUS2_CAREFREE) HoTT_printfxy(17,3,"CF") else HoTT_printfxy(17,3," "); |
||
1917 | holgerb | 106 | } |
107 | else |
||
108 | { |
||
109 | Hott_ClearLine(3); |
||
110 | } |
||
111 | break; |
||
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: |
||
1920 | 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); |
1917 | holgerb | 140 | break; |
141 | case 6: |
||
142 | if(RequiredMotors == 4) Hott_ClearLine(6); |
||
143 | else |
||
1920 | holgerb | 144 | if(RequiredMotors == 6) HoTT_printfxy(0,6,"%3i %3i%cC ", Motor[4].Temperature, Motor[5].Temperature,HoTT_GRAD) |
1917 | holgerb | 145 | else |
146 | if(RequiredMotors > 6) HoTT_printfxy(0,6,"%3i %3i %3i %3i%cC ", Motor[4].Temperature, Motor[5].Temperature, Motor[6].Temperature, Motor[7].Temperature,0x6D); |
||
1920 | holgerb | 147 | //HoTT_printfxy(15,6,"%KEY:%02x",HottKeyboard); |
148 | //if(HoTTBlink) HoTT_printfxy_INV(10,6,"BLINK"); |
||
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; |
||
178 | case 2: HoTT_printfxy(0,2,"GPS:"); |
||
179 | if(!(Parameter_GlobalConfig & CFG_GPS_AKTIV)) HoTT_printf("DISABLED") |
||
180 | else |
||
181 | { |
||
182 | CHK_POTI(tmp,EE_Parameter.NaviGpsModeControl); |
||
183 | if(tmp < 50) HoTT_printf("(FREE)") |
||
184 | else |
||
185 | if(tmp >= 180) HoTT_printf("(HOME)") |
||
186 | else |
||
187 | if(EE_Parameter.ExtraConfig & CFG_GPS_AID) HoTT_printf("(AID) ") |
||
188 | else HoTT_printf("(HOLD)") |
||
189 | } |
||
190 | if(EE_Parameter.FailSafeTime) HoTT_printfxy(10,2," FS:%usek ",EE_Parameter.FailSafeTime) |
||
1917 | holgerb | 191 | |
1921 | holgerb | 192 | break; |
193 | case 3: HoTT_printfxy(0,3,"HOME ALT:"); |
||
194 | if(EE_Parameter.ComingHomeAltitude) HoTT_printf("%um",EE_Parameter.ComingHomeAltitude) else HoTT_printf("HOLD "); |
||
195 | break; |
||
196 | case 4: HoTT_printfxy(0,4,"ALT:"); |
||
197 | if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG) |
||
198 | { |
||
199 | if(!(EE_Parameter.GlobalConfig & CFG_HOEHEN_SCHALTER)) HoTT_printf("POTI:%3u ", Parameter_HoehenSchalter) |
||
200 | else |
||
201 | { |
||
202 | if(Parameter_HoehenSchalter > 50) HoTT_printf("(ON) ") else HoTT_printf("(OFF) "); |
||
203 | if((Parameter_ExtraConfig & CFG2_HEIGHT_LIMIT)) HoTT_printf("LIMIT", Parameter_HoehenSchalter) |
||
204 | else HoTT_printf("VARIO", Parameter_HoehenSchalter); |
||
205 | } |
||
206 | } |
||
207 | else |
||
208 | HoTT_printf("DISABLED"); |
||
209 | break; |
||
210 | case 5: HoTT_printfxy(0,5,"CF:"); |
||
211 | if(!EE_Parameter.CareFreeModeControl) HoTT_printf("DISABLED") |
||
212 | else |
||
213 | { |
||
214 | if(CareFree) HoTT_printf(" (ON) ") else HoTT_printf(" (OFF)"); |
||
215 | if(EE_Parameter.ExtraConfig & CFG_LEARNABLE_CAREFREE) HoTT_printf(" TEACH"); |
||
216 | } |
||
217 | break; |
||
218 | case 6: |
||
219 | HoTT_printfxy(0,6,"Ni:%4i Ro:%4i ",PPM_in[EE_Parameter.Kanalbelegung[K_NICK]],PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]); |
||
220 | HoTT_printfxy(0,7,"Gs:%4i Gi:%4i ",PPM_in[EE_Parameter.Kanalbelegung[K_GAS]]+120,PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]); |
||
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 |