Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2136 | - | 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 | //# HISTORY osd.h |
||
36 | //# |
||
37 | //# 21.06.2014 OG |
||
38 | //# - add: writex_altimeter() |
||
39 | //# - add: draw_icon_mk() |
||
40 | //# |
||
41 | //# 18.06.2014 OG |
||
42 | //# - add: weitere Exporte von Funktionen draw_icon...() |
||
43 | //# - add: MKLiPoCells_Init(), MKLiPoCells_Check() |
||
44 | //# - add: OSD_Element_Battery_Bar() |
||
45 | //# - chg: define ORIENTATION_H, ORIENTATION_V verschoben nach osd.h |
||
46 | //# |
||
47 | //# 01.06.2014 OG |
||
48 | //# Beginn von Auslagerungen von Code alter OSD-Screens nach osdold_screens.c/h |
||
49 | //# |
||
50 | //# 26.05.2014 OG |
||
51 | //# - add: #define OSDSCREEN_WAYPOINTS |
||
52 | //# |
||
53 | //# 24.05.2014 OG |
||
54 | //# - chg: OSD_Element_CompassDirection() - erweitert um xoffs,yoffs |
||
55 | //# |
||
56 | //# 28.04.2014 OG |
||
57 | //# - del: OSD_Timeout() |
||
58 | //# |
||
59 | //# 07.07.2013 OG |
||
60 | //# - add: defines fuer Screen-ID's (verwendet in setup.c, osd.c) |
||
61 | //# |
||
62 | //# 30.06.2013 OG |
||
63 | //# - chg: Benamung Statistik-Var's von mid_* auf avg_* geaendert |
||
64 | //# |
||
65 | //# 31.05.2013 OG |
||
66 | //# Achtung! Aenderung eeprom-Kompatibilitaet wegen typedef Erweiterung! |
||
67 | //# - chg: typedef: osd_statistic_BL_t fuer Mittelwerte |
||
68 | //# - chg: typedef: osd_statistic_t fuer Mittelwerte |
||
69 | //# |
||
70 | //# 15.05.2013 OG |
||
71 | //# - add: calc_BLmax() |
||
72 | //# - add: struct osd_BLmax_t |
||
73 | //# |
||
74 | //# 04.05.2013 OG |
||
75 | //# - chg: aktualisiert Kommentare in 'osd_statistic_t' |
||
76 | //# - del: OSD_Debug_XX() |
||
77 | //# |
||
78 | //# 02.05.2013 OG |
||
79 | //# - fix: struct osd_statistic_t: max_Distance von int16_t nach uint16_t |
||
80 | //# |
||
81 | //# 28.04.2013 OG |
||
82 | //# - chg: osd(OSDMode) -> osd(void) |
||
83 | //# - del: OSDDATA_Statistics() |
||
84 | //# |
||
85 | //# vorheriges: siehe osd.c |
||
86 | //############################################################################ |
||
87 | |||
88 | |||
89 | #ifndef _OSD_H |
||
90 | #define _OSD_H |
||
91 | |||
92 | #include "../mk-data-structs.h" |
||
93 | #include "../timer/timer.h" |
||
94 | |||
95 | #define OSD_MAX_MOTORS 8 // max. Anzahl vom PKT unterstuetzer Motoren (absolut MAX ist 12 da der MK nicht mehr unterstuetzt) |
||
96 | #define MAX_GPS_USER 10 // max. Anzahl der GPS-Positionen durch Benutzer gespeichert |
||
97 | #define MAX_MKERR_LOG 20 // max. Anzahl Eintraege im MK-Error-Log |
||
98 | |||
99 | #define OSD_SCREEN_REFRESH 0 // Screen: Werte anzeigen |
||
100 | #define OSD_SCREEN_REDRAW 1 // Screen: Labels und statischer Elemente neu zeichen, Werte anzeigen |
||
101 | |||
102 | |||
103 | #define ORIENTATION_V 1 // fuer OSD_Element_Battery_Bar() |
||
104 | #define ORIENTATION_H 2 |
||
105 | |||
106 | |||
107 | // OSD-Screen ID's |
||
108 | // maximal: 31 (!) wegen Bitcodierung in Config.OSD_UseScreen |
||
109 | #define OSDSCREEN_GENERAL 0 |
||
110 | #define OSDSCREEN_NAVIGATION 1 |
||
111 | #define OSDSCREEN_ELECTRIC 2 |
||
112 | #define OSDSCREEN_MKSTATUS 3 |
||
113 | #define OSDSCREEN_USERGPS 4 |
||
114 | #define OSDSCREEN_3DLAGE 5 |
||
115 | #define OSDSCREEN_STATISTICS 6 |
||
116 | #define OSDSCREEN_OSD0 7 |
||
117 | #define OSDSCREEN_OSD1 8 |
||
118 | #define OSDSCREEN_OSD2 9 |
||
119 | #define OSDSCREEN_WAYPOINTS 10 |
||
120 | |||
121 | |||
122 | // Flags |
||
123 | #define OSD_FLAG_AH 0 // Altitue Hold |
||
124 | #define OSD_FLAG_PH 1 // Position Hold |
||
125 | #define OSD_FLAG_CF 2 // Care Free |
||
126 | #define OSD_FLAG_CH 3 // Coming Home |
||
127 | #define OSD_FLAG_O1 4 // Out1 (LED 1) |
||
128 | #define OSD_FLAG_O2 5 // Out2 (LED 2) |
||
129 | #define OSD_FLAG_BA 6 // LowBat warning (MK) |
||
130 | #define OSD_FLAG_CA 7 // Calibrate |
||
131 | #define OSD_FLAG_ST 8 // Start |
||
132 | #define OSD_FLAG_MR 9 // Motor Run |
||
133 | #define OSD_FLAG_FY 10 // Fly |
||
134 | #define OSD_FLAG_EL 11 // Emergency Landing |
||
135 | #define OSD_FLAG_FS 12 // RS Failsave Active |
||
136 | #define OSD_FLAG_GP 13 // GPS ok |
||
137 | #define OSD_FLAG_S0 14 // GPS-Sat not ok (GPS NOT ok) |
||
138 | #define OSD_FLAG_TU 15 // Vario Trim Up |
||
139 | #define OSD_FLAG_TD 16 // Vario Trim Down |
||
140 | #define OSD_FLAG_FR 17 // Free |
||
141 | #define OSD_FLAG_RL 18 // Range Limit |
||
142 | #define OSD_FLAG_SL 19 // No Serial Link |
||
143 | #define OSD_FLAG_TR 20 // Target Reached |
||
144 | #define OSD_FLAG_MC 21 // Manual Control |
||
145 | |||
146 | #define OSD_FLAG_COUNT 22 |
||
147 | |||
148 | |||
149 | // Hier Höhenanzeigefehler Korrigieren |
||
150 | #define AltimeterAdjust 1.5 |
||
151 | |||
152 | |||
153 | //----------------------------------------------------------- |
||
154 | // typedef: Statistiken |
||
155 | //----------------------------------------------------------- |
||
156 | typedef struct |
||
157 | { |
||
158 | uint16_t count; // Anzahl Werte BL-Daten (fuer Mittelwertberechnung) |
||
159 | uint8_t max_Current; // in 0.1 A steps |
||
160 | uint16_t avg_Current; // Mittelwert Current (*100 fuer Rechengenauigkeit) |
||
161 | uint8_t max_Temp; // old BL-Ctrl will return a 255 here, the new version (>= V2.0) the temp. in °C |
||
162 | } osd_statistic_BL_t; |
||
163 | |||
164 | |||
165 | typedef struct |
||
166 | { |
||
167 | PKTdatetime_t begin_StatTime; // Datum/Zeit |
||
168 | PKTdatetime_t end_StatTime; // Datum/Zeit |
||
169 | uint16_t total_FlyTime; // gesamt Flugzeit seit Stat-Init |
||
170 | uint16_t last_FlyTime; // letzte Flugzeit |
||
171 | uint16_t count_osd; // TODO: Anzahl Werte OSD-Daten (fuer Mittelwertberechnung) |
||
172 | uint16_t count_Errorcode; // TODO: Anzahl gemeldeter MK-Errors |
||
173 | int16_t max_Altimeter; // max. Hoehe |
||
174 | int16_t avg_Altimeter; // TODO: Mittelwert Hoehe () |
||
175 | s16 max_Variometer; // TODO: ... |
||
176 | uint16_t max_GroundSpeed; // max. Geschwindigkeit |
||
177 | uint16_t avg_GroundSpeed; // TODO: Mittelwert Geschwindigkeit () |
||
178 | s16 max_TopSpeed; // max. velocity in vertical direction in cm/s |
||
179 | uint16_t max_Distance; // max. Entfernung |
||
180 | uint16_t avg_Distance; // TODO: Mittelwert Entfernung () |
||
181 | uint16_t max_Current; // max. Strom |
||
182 | uint16_t avg_Current; // Mittelwert Strom () |
||
183 | u8 max_RCQuality; // max. Empfangsqualitaet |
||
184 | u8 min_RCQuality; // min. Empfangsqualitaet |
||
185 | uint16_t avg_RCQuality; // TODO: Mittelwert Empfangsqualitaet () |
||
186 | uint16_t max_Capacity; // max. entnommene Kapazitaet |
||
187 | s8 max_AngleNick; // max. Nick |
||
188 | s8 min_AngleNick; // min. Nick |
||
189 | s8 max_AngleRoll; // max. Roll |
||
190 | s8 min_AngleRoll; // min. Roll |
||
191 | uint8_t min_UBat; // min. Spannung (V) |
||
192 | uint8_t LiPoCells; // Anzahl der LiPo Zellen |
||
193 | uint8_t BL_Count; // Anzahl erkannter BL's (Motoren) |
||
194 | osd_statistic_BL_t BL[OSD_MAX_MOTORS]; // Werte der einzelnen BL's |
||
195 | } osd_statistic_t; |
||
196 | |||
197 | |||
198 | typedef struct |
||
199 | { |
||
200 | uint8_t max_BL_Current_Index; // BL-Nummer |
||
201 | unsigned char max_BL_Current; // in 0.1 A steps |
||
202 | uint8_t max_BL_Temp_Index; // BL-Nummer |
||
203 | unsigned char max_BL_Temp; // old BL-Ctrl will return a 255 here, the new version (>= V2.0) the temp. in °C |
||
204 | } osd_BLmax_t; |
||
205 | |||
206 | |||
207 | //----------------------------------------------------------- |
||
208 | // typedef: Aufzeichnung von MK-Errors |
||
209 | //----------------------------------------------------------- |
||
210 | typedef struct |
||
211 | { |
||
212 | u8 Errorcode; // 0 --> okay |
||
213 | PKTdatetime_t set_Time; // Datum/Zeit |
||
214 | PKTdatetime_t clear_Time; // Datum/Zeit |
||
215 | } mkerror_t; |
||
216 | |||
217 | |||
218 | |||
219 | //----------------------------------------------------------- |
||
220 | // typedef: PKT GPS-Positionen |
||
221 | //----------------------------------------------------------- |
||
222 | typedef struct |
||
223 | { |
||
224 | PKTdatetime_t timestamp; // Zeitstempel: UTC |
||
225 | s16 Altimeter; // barymetrische Hoehe (entspricht: naviData->Altimeter) |
||
226 | u16 HomeDistance; // distance to home in cm (entspricht: naviData->HomePositionDeviation.Distance) |
||
227 | GPS_Pos_t GPSData; // GPS-Position (mk-data-structs.h) |
||
228 | } pkt_gpspos_t; |
||
229 | |||
230 | |||
231 | |||
232 | //----------------------------------------------------------- |
||
233 | // global var's |
||
234 | //----------------------------------------------------------- |
||
235 | extern volatile uint8_t OSD_active; |
||
236 | extern volatile uint8_t error; |
||
237 | |||
238 | //----------------------------------------------------------- |
||
239 | // strings |
||
240 | //----------------------------------------------------------- |
||
241 | extern const char * const mkerrortext[]; |
||
242 | |||
243 | |||
244 | //----------------------------------------------------------- |
||
245 | // Funktionen |
||
246 | //----------------------------------------------------------- |
||
247 | void osd( void ); |
||
248 | void vario_beep_output (void); |
||
249 | void CheckMKLipo(void); |
||
250 | void STAT_Init(void); |
||
251 | void GPS_User_Init(void); |
||
252 | void MKErr_Log_Init(void); |
||
253 | void calc_BLmax( osd_BLmax_t *blmax ); |
||
254 | |||
255 | |||
256 | void OSD_Element_Flag_Label( uint8_t xC, uint8_t yC, uint8_t item, uint8_t lOn, int8_t xoffs, int8_t yoffs); |
||
257 | void OSD_Element_Flag( uint8_t xC, uint8_t yC, uint8_t item, int8_t xoffs, int8_t yoffs); |
||
258 | void OSD_Element_Altitude( uint8_t x, uint8_t y, uint8_t nStyle ); |
||
259 | void OSD_Element_BattLevel2( uint8_t x, uint8_t y, int8_t xoffs, int8_t yoffs ); |
||
260 | void OSD_Element_BatteryLevel_Bar( uint8_t x, uint8_t y ); |
||
261 | void OSD_Element_BatteryLevel_Text( uint8_t x, uint8_t y, uint8_t nStyle ); |
||
262 | void OSD_Element_BatteryLevel( uint8_t x, uint8_t y, uint8_t nStyle ); |
||
263 | void OSD_Element_Capacity( uint8_t x, uint8_t y ); |
||
264 | void OSD_Element_CompassDegree( uint8_t x, uint8_t y, uint8_t nStyle ); |
||
265 | void OSD_Element_CompassDirection( uint8_t x, uint8_t y, int8_t xoffs, int8_t yoffs ); |
||
266 | void OSD_Element_CompassRose( uint8_t x, uint8_t y ); |
||
267 | void OSD_Element_Current( uint8_t x, uint8_t y ); |
||
268 | void OSD_Element_FlyingTime( uint8_t x, uint8_t y ); |
||
269 | void OSD_Element_GroundSpeed( uint8_t x, uint8_t y ); |
||
270 | void OSD_Element_HomeCircle( uint8_t x, uint8_t y, uint8_t breite, int8_t rOffset, int8_t xoffs, int8_t yoffs ); |
||
271 | void OSD_Element_HomeDegree( uint8_t x, uint8_t y ); |
||
272 | void OSD_Element_HomeDistance( uint8_t x, uint8_t y, uint8_t nStyle ); |
||
273 | void OSD_Element_LEDOutput( uint8_t x, uint8_t y, uint8_t bitmask ); |
||
274 | void OSD_Element_LED1Output( uint8_t x, uint8_t y ); |
||
275 | void OSD_Element_LED2Output( uint8_t x, uint8_t y ); |
||
276 | void OSD_Element_Manuell( uint8_t x, uint8_t y ); |
||
277 | void OSD_Element_RCIntensity( uint8_t x, uint8_t y ); |
||
278 | void OSD_Element_SatsInUse( uint8_t x, uint8_t y, uint8_t nStyle ); |
||
279 | void OSD_Element_Variometer( uint8_t x, uint8_t y ); |
||
280 | void OSD_Element_Target( uint8_t x, uint8_t y, uint8_t nStyle ); |
||
281 | void OSD_Element_VarioWert( uint8_t x, uint8_t y ); |
||
282 | void OSD_Element_WayPoint( uint8_t x, uint8_t y ); |
||
283 | void OSD_Element_TargetDegree( uint8_t x, uint8_t y ); |
||
284 | void OSD_Element_UpDown( uint8_t x, uint8_t y, int8_t xoffs, int8_t yoffs); |
||
285 | void OSD_Element_Battery_Bar( uint8_t x, uint8_t y, uint8_t length, uint8_t width, uint8_t orientation); |
||
286 | |||
287 | void writex_altimeter( uint8_t x, uint8_t y, s32 Altimeter, uint8_t mode, int8_t xoffs, int8_t yoffs ); |
||
288 | |||
289 | void MKLiPoCells_Init( void ); |
||
290 | void MKLiPoCells_Check( void ); |
||
291 | |||
292 | void draw_icon_satmini( uint8_t x, uint8_t y); |
||
293 | void draw_icon_satmini2( uint8_t x, uint8_t y); |
||
294 | void draw_icon_home( uint8_t x, uint8_t y); |
||
295 | void draw_icon_target_diamond( uint8_t x, uint8_t y); |
||
296 | void draw_icon_target_round( uint8_t x, uint8_t y); |
||
297 | void draw_icon_mk( uint8_t x, uint8_t y); |
||
298 | |||
299 | void OSD_MK_ShowTimeout( void ); |
||
300 | |||
301 | |||
302 | //----------------------------------------------------------- |
||
303 | // EXPORTS NUR FUER osdold_screens.c |
||
304 | //----------------------------------------------------------- |
||
305 | extern NaviData_t *naviData; |
||
306 | extern uint8_t OSDScreenRefresh; |
||
307 | |||
308 | |||
309 | #endif // _OSD_H |