Merge pull request #9890 from iNavFlight/MrD_Add-extra-description-to-the-min-ground...
[inav.git] / src / main / io / displayport_msp_bf_compat.c
blob7067ac140f5784e7ff154e7cd59485368bd6f1fd
1 /*
2 * This file is part of INAV Project.
4 * INAV is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #include "platform.h"
20 #if defined(USE_OSD) && defined(USE_MSP_DISPLAYPORT)
22 #ifndef DISABLE_MSP_BF_COMPAT
24 #include "io/displayport_msp_bf_compat.h"
25 #include "io/bf_osd_symbols.h"
26 #include "drivers/osd_symbols.h"
28 uint8_t getBfCharacter(uint8_t ch, uint8_t page)
30 uint16_t ech = ch | (page << 8);
32 if (ech >= 0x20 && ech <= 0x5F) { // ASCII range
33 return ch;
36 if (ech >= SYM_AH_DECORATION_MIN && ech <= SYM_AH_DECORATION_MAX) {
37 return BF_SYM_AH_DECORATION;
40 switch (ech) {
41 case SYM_RSSI:
42 return BF_SYM_RSSI;
44 case SYM_LQ:
45 return BF_SYM_LINK_QUALITY;
47 case SYM_LAT:
48 return BF_SYM_LAT;
50 case SYM_LON:
51 return BF_SYM_LON;
53 case SYM_SAT_L:
54 return BF_SYM_SAT_L;
56 case SYM_SAT_R:
57 return BF_SYM_SAT_R;
59 case SYM_HOME_NEAR:
60 return BF_SYM_HOMEFLAG;
62 case SYM_DEGREES:
63 return BF_SYM_GPS_DEGREE;
66 case SYM_HEADING:
67 return BF_SYM_HEADING;
69 case SYM_SCALE:
70 return BF_SYM_SCALE;
72 case SYM_HDP_L:
73 return BF_SYM_HDP_L;
75 case SYM_HDP_R:
76 return BF_SYM_HDP_R;
78 case SYM_HOME:
79 return BF_SYM_HOMEFLAG;
81 case SYM_2RSS:
82 return BF_SYM_RSSI;
85 case SYM_DB:
86 return BF_SYM_DB
88 case SYM_DBM:
89 return BF_SYM_DBM;
91 case SYM_SNR:
92 return BF_SYM_SNR;
94 case SYM_AH_DECORATION_UP:
95 return BF_SYM_AH_DECORATION_UP;
97 case SYM_AH_DECORATION_DOWN:
98 return BF_SYM_AH_DECORATION_DOWN;
100 case SYM_DIRECTION:
101 return BF_SYM_ARROW_NORTH;
103 case SYM_DIRECTION + 1: // NE pointing arrow
104 return BF_SYM_ARROW_7;
106 case SYM_DIRECTION + 2: // E pointing arrow
107 return BF_SYM_ARROW_EAST;
109 case SYM_DIRECTION + 3: // SE pointing arrow
110 return BF_SYM_ARROW_3;
112 case SYM_DIRECTION + 4: // S pointing arrow
113 return BF_SYM_ARROW_SOUTH;
115 case SYM_DIRECTION + 5: // SW pointing arrow
116 return BF_SYM_ARROW_15;
118 case SYM_DIRECTION + 6: // W pointing arrow
119 return BF_SYM_ARROW_WEST;
121 case SYM_DIRECTION + 7: // NW pointing arrow
122 return BF_SYM_ARROW_11;
124 case SYM_VOLT:
125 return BF_SYM_VOLT;
127 case SYM_MAH:
128 return BF_SYM_MAH;
130 case SYM_AH_KM:
131 return BF_SYM_KM;
133 case SYM_AH_MI:
134 return BF_SYM_MILES;
136 case SYM_VTX_POWER:
137 return BF_SYM_VTX_POWER;
139 case SYM_AH_NM:
140 return BF_SYM_AH_NM;
142 case SYM_MAH_NM_0:
143 return BF_SYM_MAH_NM_0;
145 case SYM_MAH_NM_1:
146 return BF_SYM_MAH_NM_1;
148 case SYM_MAH_KM_0:
149 return BF_SYM_MAH_KM_0;
151 case SYM_MAH_KM_1:
152 return BF_SYM_MAH_KM_1;
154 case SYM_MILLIOHM:
155 return BF_SYM_MILLIOHM;
157 case SYM_BATT_FULL:
158 return BF_SYM_BATT_FULL;
160 case SYM_BATT_5:
161 return BF_SYM_BATT_5;
163 case SYM_BATT_4:
164 return BF_SYM_BATT_4;
166 case SYM_BATT_3:
167 return BF_SYM_BATT_3;
169 case SYM_BATT_2:
170 return BF_SYM_BATT_2;
172 case SYM_BATT_1:
173 return BF_SYM_BATT_1;
175 case SYM_BATT_EMPTY:
176 return BF_SYM_BATT_EMPTY;
178 case SYM_AMP:
179 return BF_SYM_AMP;
181 case SYM_WH:
182 return BF_SYM_WH;
184 case SYM_WH_KM:
185 return BF_SYM_WH_KM;
187 case SYM_WH_MI:
188 return BF_SYM_WH_MI;
190 case SYM_WH_NM:
191 return BF_SYM_WH_NM;
193 case SYM_WATT:
194 return BF_SYM_WATT;
196 case SYM_MW:
197 return BF_SYM_MW;
199 case SYM_KILOWATT:
200 return BF_SYM_KILOWATT;
202 case SYM_FT:
203 return BF_SYM_FT;
205 case SYM_ALT_FT:
206 return BF_SYM_FT;
208 case SYM_ALT_M:
209 return BF_SYM_M;
211 case SYM_TOTAL:
212 return BF_SYM_TOTAL_DISTANCE;
214 case SYM_ALT_KM:
215 return BF_SYM_ALT_KM;
217 case SYM_ALT_KFT:
218 return BF_SYM_ALT_KFT;
220 case SYM_DIST_M:
221 return BF_SYM_DIST_M;
223 case SYM_DIST_KM:
224 return BF_SYM_DIST_KM;
226 case SYM_DIST_FT:
227 return BF_SYM_DIST_FT;
229 case SYM_DIST_MI:
230 return BF_SYM_DIST_MI;
232 case SYM_DIST_NM:
233 return BF_SYM_DIST_NM;
235 case SYM_M:
236 return BF_SYM_M;
238 case SYM_KM:
239 return BF_SYM_KM;
241 case SYM_MI:
242 return BF_SYM_MILES;
244 case SYM_NM:
245 return BF_SYM_NM;
247 case SYM_WIND_HORIZONTAL:
248 return 'W'; // W for wind
251 case SYM_WIND_VERTICAL:
252 return BF_SYM_WIND_VERTICAL;
254 case SYM_3D_KT:
255 return BF_SYM_3D_KT;
257 case SYM_AIR:
258 return 'A'; // A for airspeed
260 case SYM_3D_KMH:
261 return BF_SYM_KPH;
263 case SYM_3D_MPH:
264 return BF_SYM_MPH;
266 case SYM_RPM:
267 return BF_SYM_RPM;
269 case SYM_FTS:
270 return BF_SYM_FTPS;
272 case SYM_100FTM:
273 return BF_SYM_100FTM;
275 case SYM_MS:
276 return BF_SYM_MPS;
278 case SYM_KMH:
279 return BF_SYM_KPH;
281 case SYM_MPH:
282 return BF_SYM_MPH;
284 case SYM_KT:
285 return BF_SYM_KT
287 case SYM_MAH_MI_0:
288 return BF_SYM_MAH_MI_0;
290 case SYM_MAH_MI_1:
291 return BF_SYM_MAH_MI_1;
293 case SYM_THR:
294 return BF_SYM_THR;
296 case SYM_TEMP_F:
297 return BF_SYM_F;
299 case SYM_TEMP_C:
300 return BF_SYM_C;
302 case SYM_BLANK:
303 return BF_SYM_BLANK;
305 case SYM_ON_H:
306 return BF_SYM_ON_H;
308 case SYM_FLY_H:
309 return BF_SYM_FLY_H;
311 case SYM_ON_M:
312 return BF_SYM_ON_M;
314 case SYM_FLY_M:
315 return BF_SYM_FLY_M;
317 case SYM_GLIDESLOPE:
318 return BF_SYM_GLIDESLOPE;
320 case SYM_WAYPOINT:
321 return BF_SYM_WAYPOINT;
323 case SYM_CLOCK:
324 return BF_SYM_CLOCK;
326 case SYM_ZERO_HALF_TRAILING_DOT:
327 return BF_SYM_ZERO_HALF_TRAILING_DOT;
329 case SYM_ZERO_HALF_LEADING_DOT:
330 return BF_SYM_ZERO_HALF_LEADING_DOT;
332 case SYM_AUTO_THR0:
333 return BF_SYM_AUTO_THR0;
335 case SYM_AUTO_THR1:
336 return BF_SYM_AUTO_THR1;
338 case SYM_ROLL_LEFT:
339 return BF_SYM_ROLL_LEFT;
341 case SYM_ROLL_LEVEL:
342 return BF_SYM_ROLL_LEVEL;
344 case SYM_ROLL_RIGHT:
345 return BF_SYM_ROLL_RIGHT;
347 case SYM_PITCH_UP:
348 return BF_SYM_PITCH_UP;
350 case SYM_PITCH_DOWN:
351 return BF_SYM_PITCH_DOWN;
354 case SYM_GFORCE:
355 return 'G';
358 case SYM_GFORCE_X:
359 return BF_SYM_GFORCE_X;
361 case SYM_GFORCE_Y:
362 return BF_SYM_GFORCE_Y;
364 case SYM_GFORCE_Z:
365 return BF_SYM_GFORCE_Z;
367 case SYM_BARO_TEMP:
368 return BF_SYM_BARO_TEMP;
370 case SYM_IMU_TEMP:
371 return BF_SYM_IMU_TEMP;
373 case SYM_TEMP:
374 return BF_SYM_TEMP;
376 case SYM_TEMP_SENSOR_FIRST:
377 return BF_SYM_TEMP_SENSOR_FIRST;
379 case SYM_ESC_TEMP:
380 return BF_SYM_ESC_TEMP;
382 case SYM_TEMP_SENSOR_LAST:
383 return BF_SYM_TEMP_SENSOR_LAST;
385 case TEMP_SENSOR_SYM_COUNT:
386 return BF_TEMP_SENSOR_SYM_COUNT;
388 case SYM_HEADING_N:
389 return BF_SYM_HEADING_N;
391 case SYM_HEADING_S:
392 return BF_SYM_HEADING_S;
394 case SYM_HEADING_E:
395 return BF_SYM_HEADING_E;
397 case SYM_HEADING_W:
398 return BF_SYM_HEADING_W;
400 case SYM_HEADING_DIVIDED_LINE:
401 return BF_SYM_HEADING_DIVIDED_LINE;
403 case SYM_HEADING_LINE:
404 return BF_SYM_HEADING_LINE;
406 case SYM_MAX:
407 return BF_SYM_MAX;
409 case SYM_PROFILE:
410 return BF_SYM_PROFILE;
412 case SYM_SWITCH_INDICATOR_LOW:
413 return BF_SYM_SWITCH_INDICATOR_LOW;
415 case SYM_SWITCH_INDICATOR_MID:
416 return BF_SYM_SWITCH_INDICATOR_MID;
418 case SYM_SWITCH_INDICATOR_HIGH:
419 return BF_SYM_SWITCH_INDICATOR_HIGH;
421 case SYM_AH:
422 return BF_SYM_AH;
424 case SYM_GLIDE_DIST:
425 return BF_SYM_GLIDE_DIST;
427 case SYM_GLIDE_MINS:
428 return BF_SYM_GLIDE_MINS;
430 case SYM_AH_V_FT_0:
431 return BF_SYM_AH_V_FT_0;
433 case SYM_AH_V_FT_1:
434 return BF_SYM_AH_V_FT_1;
436 case SYM_AH_V_M_0:
437 return BF_SYM_AH_V_M_0;
439 case SYM_AH_V_M_1:
440 return BF_SYM_AH_V_M_1;
442 case SYM_FLIGHT_MINS_REMAINING:
443 return BF_SYM_FLIGHT_MINS_REMAINING;
445 case SYM_FLIGHT_HOURS_REMAINING:
446 return BF_SYM_FLIGHT_HOURS_REMAINING;
448 case SYM_GROUND_COURSE:
449 return BF_SYM_GROUND_COURSE;
451 case SYM_CROSS_TRACK_ERROR:
452 return BF_SYM_CROSS_TRACK_ERROR;
454 case SYM_LOGO_START:
455 return BF_SYM_LOGO_START;
457 case SYM_LOGO_WIDTH:
458 return BF_SYM_LOGO_WIDTH;
460 case SYM_LOGO_HEIGHT:
461 return BF_SYM_LOGO_HEIGHT;
463 case SYM_AH_LEFT:
464 return BF_SYM_AH_LEFT;
466 case SYM_AH_RIGHT:
467 return BF_SYM_AH_RIGHT;
470 case SYM_AH_DECORATION_COUNT:
471 return BF_SYM_AH_DECORATION_COUNT;
473 case SYM_AH_CH_LEFT:
474 case SYM_AH_CH_TYPE3:
475 case SYM_AH_CH_TYPE4:
476 case SYM_AH_CH_TYPE5:
477 case SYM_AH_CH_TYPE6:
478 case SYM_AH_CH_TYPE7:
479 case SYM_AH_CH_TYPE8:
480 case SYM_AH_CH_AIRCRAFT1:
481 return BF_SYM_AH_CENTER_LINE;
483 case SYM_AH_CH_RIGHT:
484 case (SYM_AH_CH_TYPE3+2):
485 case (SYM_AH_CH_TYPE4+2):
486 case (SYM_AH_CH_TYPE5+2):
487 case (SYM_AH_CH_TYPE6+2):
488 case (SYM_AH_CH_TYPE7+2):
489 case (SYM_AH_CH_TYPE8+2):
490 case SYM_AH_CH_AIRCRAFT3:
491 return BF_SYM_AH_CENTER_LINE_RIGHT;
493 case SYM_AH_CH_AIRCRAFT0:
494 case SYM_AH_CH_AIRCRAFT4:
495 return ' ';
497 case SYM_ARROW_UP:
498 return BF_SYM_ARROW_NORTH;
500 case SYM_ARROW_2:
501 return BF_SYM_ARROW_8;
503 case SYM_ARROW_3:
504 return BF_SYM_ARROW_7;
506 case SYM_ARROW_4:
507 return BF_SYM_ARROW_6;
509 case SYM_ARROW_RIGHT:
510 return BF_SYM_ARROW_EAST;
512 case SYM_ARROW_6:
513 return BF_SYM_ARROW_4;
515 case SYM_ARROW_7:
516 return BF_SYM_ARROW_3;
518 case SYM_ARROW_8:
519 return BF_SYM_ARROW_2;
521 case SYM_ARROW_DOWN:
522 return BF_SYM_ARROW_SOUTH;
524 case SYM_ARROW_10:
525 return BF_SYM_ARROW_16;
527 case SYM_ARROW_11:
528 return BF_SYM_ARROW_15;
530 case SYM_ARROW_12:
531 return BF_SYM_ARROW_14;
533 case SYM_ARROW_LEFT:
534 return BF_SYM_ARROW_WEST;
536 case SYM_ARROW_14:
537 return BF_SYM_ARROW_12;
539 case SYM_ARROW_15:
540 return BF_SYM_ARROW_11;
542 case SYM_ARROW_16:
543 return BF_SYM_ARROW_10;
545 case SYM_AH_H_START:
546 return BF_SYM_AH_BAR9_0;
548 case (SYM_AH_H_START+1):
549 return BF_SYM_AH_BAR9_1;
551 case (SYM_AH_H_START+2):
552 return BF_SYM_AH_BAR9_2;
554 case (SYM_AH_H_START+3):
555 return BF_SYM_AH_BAR9_3;
557 case (SYM_AH_H_START+4):
558 return BF_SYM_AH_BAR9_4;
560 case (SYM_AH_H_START+5):
561 return BF_SYM_AH_BAR9_5;
563 case (SYM_AH_H_START+6):
564 return BF_SYM_AH_BAR9_6;
566 case (SYM_AH_H_START+7):
567 return BF_SYM_AH_BAR9_7;
569 case (SYM_AH_H_START+8):
570 return BF_SYM_AH_BAR9_8;
572 // BF does not have vertical artificial horizon. replace with middle horizontal one
573 case SYM_AH_V_START:
574 case (SYM_AH_V_START+1):
575 case (SYM_AH_V_START+2):
576 case (SYM_AH_V_START+3):
577 case (SYM_AH_V_START+4):
578 case (SYM_AH_V_START+5):
579 return BF_SYM_AH_BAR9_4;
581 // BF for ESP_RADAR Symbols
582 case SYM_HUD_CARDINAL:
583 return BF_SYM_ARROW_SOUTH;
584 case SYM_HUD_CARDINAL + 1:
585 return BF_SYM_ARROW_16;
586 case SYM_HUD_CARDINAL + 2:
587 return BF_SYM_ARROW_15;
588 case SYM_HUD_CARDINAL + 3:
589 return BF_SYM_ARROW_WEST;
590 case SYM_HUD_CARDINAL + 4:
591 return BF_SYM_ARROW_12;
592 case SYM_HUD_CARDINAL + 5:
593 return BF_SYM_ARROW_11;
594 case SYM_HUD_CARDINAL + 6:
595 return BF_SYM_ARROW_NORTH;
596 case SYM_HUD_CARDINAL + 7:
597 return BF_SYM_ARROW_7;
598 case SYM_HUD_CARDINAL + 8:
599 return BF_SYM_ARROW_6;
600 case SYM_HUD_CARDINAL + 9:
601 return BF_SYM_ARROW_EAST;
602 case SYM_HUD_CARDINAL + 10:
603 return BF_SYM_ARROW_3;
604 case SYM_HUD_CARDINAL + 11:
605 return BF_SYM_ARROW_2;
607 case SYM_HUD_ARROWS_R3:
608 return BF_SYM_AH_RIGHT;
609 case SYM_HUD_ARROWS_L3:
610 return BF_SYM_AH_LEFT;
612 case SYM_HUD_SIGNAL_0:
613 return BF_SYM_AH_BAR9_1;
614 case SYM_HUD_SIGNAL_1:
615 return BF_SYM_AH_BAR9_3;
616 case SYM_HUD_SIGNAL_2:
617 return BF_SYM_AH_BAR9_4;
618 case SYM_HUD_SIGNAL_3:
619 return BF_SYM_AH_BAR9_5;
620 case SYM_HUD_SIGNAL_4:
621 return BF_SYM_AH_BAR9_7;
623 case SYM_VARIO_UP_2A:
624 return BF_SYM_VARIO_UP_2A;
626 case SYM_VARIO_UP_1A:
627 return BF_SYM_VARIO_UP_1A;
629 case SYM_VARIO_DOWN_1A:
630 return BF_SYM_VARIO_DOWN_1A;
632 case SYM_VARIO_DOWN_2A:
633 return BF_SYM_VARIO_DOWN_2A;
635 case SYM_ALT:
636 return BF_SYM_ALTITUDE;
638 case SYM_HUD_SIGNAL_0:
639 return BF_SYM_HUD_SIGNAL_0;
641 case SYM_HUD_SIGNAL_1:
642 return BF_SYM_HUD_SIGNAL_1;
644 case SYM_HUD_SIGNAL_2:
645 return BF_SYM_HUD_SIGNAL_2;
647 case SYM_HUD_SIGNAL_3:
648 return BF_SYM_HUD_SIGNAL_3;
650 case SYM_HUD_SIGNAL_4:
651 return BF_SYM_HUD_SIGNAL_4;
653 case SYM_HOME_DIST:
654 return BF_SYM_HOME_DIST;
657 case SYM_AH_CH_CENTER:
658 case (SYM_AH_CH_TYPE3+1):
659 case (SYM_AH_CH_TYPE4+1):
660 case (SYM_AH_CH_TYPE5+1):
661 case (SYM_AH_CH_TYPE6+1):
662 case (SYM_AH_CH_TYPE7+1):
663 case (SYM_AH_CH_TYPE8+1):
664 case SYM_AH_CH_AIRCRAFT2:
665 return BF_SYM_AH_CENTER;
667 case SYM_FLIGHT_DIST_REMAINING:
668 return BF_SYM_FLIGHT_DIST_REMAINING;
670 case SYM_AH_CH_TYPE3:
671 return BF_SYM_AH_CH_TYPE3;
673 case SYM_AH_CH_TYPE4:
674 return BF_SYM_AH_CH_TYPE4;
676 case SYM_AH_CH_TYPE5:
677 return BF_SYM_AH_CH_TYPE5;
679 case SYM_AH_CH_TYPE6:
680 return BF_SYM_AH_CH_TYPE6;
682 case SYM_AH_CH_TYPE7:
683 return BF_SYM_AH_CH_TYPE7;
685 case SYM_AH_CH_TYPE8:
686 return BF_SYM_AH_CH_TYPE8;
688 case SYM_AH_CH_AIRCRAFT0:
689 return BF_SYM_AH_CH_AIRCRAFT0;
691 case SYM_AH_CH_AIRCRAFT1:
692 return BF_SYM_AH_CH_AIRCRAFT1;
694 case SYM_AH_CH_AIRCRAFT2:
695 return BF_SYM_AH_CH_AIRCRAFT2;
697 case SYM_AH_CH_AIRCRAFT3:
698 return BF_SYM_AH_CH_AIRCRAFT3;
700 case SYM_AH_CH_AIRCRAFT4:
701 return BF_SYM_AH_CH_AIRCRAFT4;
703 case SYM_HUD_ARROWS_L1:
704 return BF_SYM_HUD_ARROWS_L1;
706 case SYM_HUD_ARROWS_L2:
707 return BF_SYM_HUD_ARROWS_L2;
709 case SYM_HUD_ARROWS_L3:
710 return BF_SYM_HUD_ARROWS_L3;
712 case SYM_HUD_ARROWS_R1:
713 return BF_SYM_HUD_ARROWS_R1;
715 case SYM_HUD_ARROWS_R2:
716 return BF_SYM_HUD_ARROWS_R2;
718 case SYM_HUD_ARROWS_R3:
719 return BF_SYM_HUD_ARROWS_R3;
721 case SYM_HUD_ARROWS_U1:
722 return BF_SYM_HUD_ARROWS_U1;
724 case SYM_HUD_ARROWS_U2:
725 return BF_SYM_HUD_ARROWS_U2;
727 case SYM_HUD_ARROWS_U3:
728 return BF_SYM_HUD_ARROWS_U3;
730 case SYM_HUD_ARROWS_D1:
731 return BF_SYM_HUD_ARROWS_D1;
733 case SYM_HUD_ARROWS_D2:
734 return BF_SYM_HUD_ARROWS_D2;
736 case SYM_HUD_ARROWS_D3:
737 return BF_SYM_HUD_ARROWS_D3;
739 default:
740 break;
743 return '?'; // Missing/not mapped character
746 #endif
748 #endif