Fix WS2812 led definition
[inav.git] / src / main / io / displayport_msp_bf_compat.c
blobb6b1fe9d81f1272d3bb165efc5ee278077700cc5
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 #ifdef 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 switch (ech) {
37 case SYM_RSSI:
38 return BF_SYM_RSSI;
40 case SYM_LQ:
41 return BF_SYM_LINK_QUALITY;
43 case SYM_LAT:
44 return BF_SYM_LAT;
46 case SYM_LON:
47 return BF_SYM_LON;
49 case SYM_SAT_L:
50 return BF_SYM_SAT_L;
52 case SYM_SAT_R:
53 return BF_SYM_SAT_R;
55 case SYM_HOME_NEAR:
56 return BF_SYM_HOMEFLAG;
58 case SYM_DEGREES:
59 return BF_SYM_GPS_DEGREE;
62 case SYM_HEADING:
63 return BF_SYM_HEADING;
65 case SYM_SCALE:
66 return BF_SYM_SCALE;
68 case SYM_HDP_L:
69 return BF_SYM_HDP_L;
71 case SYM_HDP_R:
72 return BF_SYM_HDP_R;
74 case SYM_HOME:
75 return BF_SYM_HOMEFLAG;
77 case SYM_2RSS:
78 return BF_SYM_RSSI;
81 case SYM_DB:
82 return BF_SYM_DB
84 case SYM_DBM:
85 return BF_SYM_DBM;
87 case SYM_SNR:
88 return BF_SYM_SNR;
90 case SYM_AH_DECORATION_UP:
91 return BF_SYM_AH_DECORATION_UP;
93 case SYM_AH_DECORATION_DOWN:
94 return BF_SYM_AH_DECORATION_DOWN;
96 case SYM_DIRECTION:
97 return BF_SYM_DIRECTION;
99 case SYM_VOLT:
100 return BF_SYM_VOLT;
102 case SYM_MAH:
103 return BF_SYM_MAH;
105 case SYM_AH_KM:
106 return BF_SYM_KM;
108 case SYM_AH_MI:
109 return BF_SYM_MILES;
111 case SYM_VTX_POWER:
112 return BF_SYM_VTX_POWER;
114 case SYM_AH_NM:
115 return BF_SYM_AH_NM;
117 case SYM_MAH_NM_0:
118 return BF_SYM_MAH_NM_0;
120 case SYM_MAH_NM_1:
121 return BF_SYM_MAH_NM_1;
123 case SYM_MAH_KM_0:
124 return BF_SYM_MAH_KM_0;
126 case SYM_MAH_KM_1:
127 return BF_SYM_MAH_KM_1;
129 case SYM_MILLIOHM:
130 return BF_SYM_MILLIOHM;
132 case SYM_BATT_FULL:
133 return BF_SYM_BATT_FULL;
135 case SYM_BATT_5:
136 return BF_SYM_BATT_5;
138 case SYM_BATT_4:
139 return BF_SYM_BATT_4;
141 case SYM_BATT_3:
142 return BF_SYM_BATT_3;
144 case SYM_BATT_2:
145 return BF_SYM_BATT_2;
147 case SYM_BATT_1:
148 return BF_SYM_BATT_1;
150 case SYM_BATT_EMPTY:
151 return BF_SYM_BATT_EMPTY;
153 case SYM_AMP:
154 return BF_SYM_AMP;
156 case SYM_WH:
157 return BF_SYM_WH;
159 case SYM_WH_KM:
160 return BF_SYM_WH_KM;
162 case SYM_WH_MI:
163 return BF_SYM_WH_MI;
165 case SYM_WH_NM:
166 return BF_SYM_WH_NM;
168 case SYM_WATT:
169 return BF_SYM_WATT;
171 case SYM_MW:
172 return BF_SYM_MW;
174 case SYM_KILOWATT:
175 return BF_SYM_KILOWATT;
177 case SYM_FT:
178 return BF_SYM_FT;
180 case SYM_TRIP_DIST:
181 return BF_SYM_TRIP_DIST;
183 case SYM_TOTAL:
184 return BF_SYM_TOTAL;
186 case SYM_ALT_M:
187 return BF_SYM_ALT_M;
189 case SYM_ALT_KM:
190 return BF_SYM_ALT_KM;
192 case SYM_ALT_FT:
193 return BF_SYM_ALT_FT;
195 case SYM_ALT_KFT:
196 return BF_SYM_ALT_KFT;
198 case SYM_DIST_M:
199 return BF_SYM_DIST_M;
201 case SYM_DIST_KM:
202 return BF_SYM_DIST_KM;
204 case SYM_DIST_FT:
205 return BF_SYM_DIST_FT;
207 case SYM_DIST_MI:
208 return BF_SYM_DIST_MI;
210 case SYM_DIST_NM:
211 return BF_SYM_DIST_NM;
213 case SYM_M:
214 return BF_SYM_M;
216 case SYM_KM:
217 return BF_SYM_KM;
219 case SYM_MI:
220 return BF_SYM_MILES;
222 case SYM_NM:
223 return BF_SYM_NM;
225 case SYM_WIND_HORIZONTAL:
226 return BF_SYM_WIND_HORIZONTAL;
228 case SYM_WIND_VERTICAL:
229 return BF_SYM_WIND_VERTICAL;
231 case SYM_3D_KT:
232 return BF_SYM_3D_KT;
235 case SYM_AIR:
236 return BF_SYM_AIR;
239 case SYM_3D_KMH:
240 return BF_SYM_KPH;
242 case SYM_3D_MPH:
243 return BF_SYM_MPH;
245 case SYM_RPM:
246 return BF_SYM_RPM;
248 case SYM_FTS:
249 return BF_SYM_FTPS;
251 case SYM_100FTM:
252 return BF_SYM_100FTM;
254 case SYM_MS:
255 return BF_SYM_MPS;
257 case SYM_KMH:
258 return BF_SYM_KPH;
260 case SYM_MPH:
261 return BF_SYM_MPH;
263 case SYM_KT:
264 return BF_SYM_KT
266 case SYM_MAH_MI_0:
267 return BF_SYM_MAH_MI_0;
269 case SYM_MAH_MI_1:
270 return BF_SYM_MAH_MI_1;
272 case SYM_THR:
273 return BF_SYM_THR;
276 case SYM_TEMP_F:
277 return BF_SYM_TEMP_F;
279 case SYM_TEMP_C:
280 return BF_SYM_TEMP_C;
282 case SYM_BLANK:
283 return BF_SYM_BLANK;
285 case SYM_ON_H:
286 return BF_SYM_ON_H;
288 case SYM_FLY_H:
289 return BF_SYM_FLY_H;
291 case SYM_ON_M:
292 return BF_SYM_ON_M;
294 case SYM_FLY_M:
295 return BF_SYM_FLY_M;
297 case SYM_GLIDESLOPE:
298 return BF_SYM_GLIDESLOPE;
300 case SYM_WAYPOINT:
301 return BF_SYM_WAYPOINT;
303 case SYM_CLOCK:
304 return BF_SYM_CLOCK;
306 case SYM_ZERO_HALF_TRAILING_DOT:
307 return BF_SYM_ZERO_HALF_TRAILING_DOT;
309 case SYM_ZERO_HALF_LEADING_DOT:
310 return BF_SYM_ZERO_HALF_LEADING_DOT;
312 case SYM_AUTO_THR0:
313 return BF_SYM_AUTO_THR0;
315 case SYM_AUTO_THR1:
316 return BF_SYM_AUTO_THR1;
318 case SYM_ROLL_LEFT:
319 return BF_SYM_ROLL_LEFT;
321 case SYM_ROLL_LEVEL:
322 return BF_SYM_ROLL_LEVEL;
324 case SYM_ROLL_RIGHT:
325 return BF_SYM_ROLL_RIGHT;
327 case SYM_PITCH_UP:
328 return BF_SYM_PITCH_UP;
330 case SYM_PITCH_DOWN:
331 return BF_SYM_PITCH_DOWN;
333 case SYM_GFORCE:
334 return BF_SYM_GFORCE;
336 case SYM_GFORCE_X:
337 return BF_SYM_GFORCE_X;
339 case SYM_GFORCE_Y:
340 return BF_SYM_GFORCE_Y;
342 case SYM_GFORCE_Z:
343 return BF_SYM_GFORCE_Z;
345 case SYM_BARO_TEMP:
346 return BF_SYM_BARO_TEMP;
348 case SYM_IMU_TEMP:
349 return BF_SYM_IMU_TEMP;
351 case SYM_TEMP:
352 return BF_SYM_TEMP;
354 case SYM_TEMP_SENSOR_FIRST:
355 return BF_SYM_TEMP_SENSOR_FIRST;
357 case SYM_ESC_TEMP:
358 return BF_SYM_ESC_TEMP;
360 case SYM_TEMP_SENSOR_LAST:
361 return BF_SYM_TEMP_SENSOR_LAST;
363 case TEMP_SENSOR_SYM_COUNT:
364 return BF_TEMP_SENSOR_SYM_COUNT;
366 case SYM_HEADING_N:
367 return BF_SYM_HEADING_N;
369 case SYM_HEADING_S:
370 return BF_SYM_HEADING_S;
372 case SYM_HEADING_E:
373 return BF_SYM_HEADING_E;
375 case SYM_HEADING_W:
376 return BF_SYM_HEADING_W;
378 case SYM_HEADING_DIVIDED_LINE:
379 return BF_SYM_HEADING_DIVIDED_LINE;
381 case SYM_HEADING_LINE:
382 return BF_SYM_HEADING_LINE;
384 case SYM_MAX:
385 return BF_SYM_MAX;
387 case SYM_PROFILE:
388 return BF_SYM_PROFILE;
390 case SYM_SWITCH_INDICATOR_LOW:
391 return BF_SYM_SWITCH_INDICATOR_LOW;
393 case SYM_SWITCH_INDICATOR_MID:
394 return BF_SYM_SWITCH_INDICATOR_MID;
396 case SYM_SWITCH_INDICATOR_HIGH:
397 return BF_SYM_SWITCH_INDICATOR_HIGH;
399 case SYM_AH:
400 return BF_SYM_AH;
402 case SYM_GLIDE_DIST:
403 return BF_SYM_GLIDE_DIST;
405 case SYM_GLIDE_MINS:
406 return BF_SYM_GLIDE_MINS;
408 case SYM_AH_V_FT_0:
409 return BF_SYM_AH_V_FT_0;
411 case SYM_AH_V_FT_1:
412 return BF_SYM_AH_V_FT_1;
414 case SYM_AH_V_M_0:
415 return BF_SYM_AH_V_M_0;
417 case SYM_AH_V_M_1:
418 return BF_SYM_AH_V_M_1;
420 case SYM_FLIGHT_MINS_REMAINING:
421 return BF_SYM_FLIGHT_MINS_REMAINING;
423 case SYM_FLIGHT_HOURS_REMAINING:
424 return BF_SYM_FLIGHT_HOURS_REMAINING;
426 case SYM_GROUND_COURSE:
427 return BF_SYM_GROUND_COURSE;
429 case SYM_CROSS_TRACK_ERROR:
430 return BF_SYM_CROSS_TRACK_ERROR;
432 case SYM_LOGO_START:
433 return BF_SYM_LOGO_START;
435 case SYM_LOGO_WIDTH:
436 return BF_SYM_LOGO_WIDTH;
438 case SYM_LOGO_HEIGHT:
439 return BF_SYM_LOGO_HEIGHT;
441 case SYM_AH_LEFT:
442 return BF_SYM_AH_LEFT;
444 case SYM_AH_RIGHT:
445 return BF_SYM_AH_RIGHT;
447 case SYM_AH_DECORATION_MIN:
448 return BF_SYM_AH_DECORATION_MIN;
450 case SYM_AH_DECORATION:
451 return BF_SYM_AH_DECORATION;
453 case SYM_AH_DECORATION_MAX:
454 return BF_SYM_AH_DECORATION_MAX;
456 case SYM_AH_DECORATION_COUNT:
457 return BF_SYM_AH_DECORATION_COUNT;
459 case SYM_AH_CH_LEFT:
460 case SYM_AH_CH_TYPE3:
461 case SYM_AH_CH_TYPE4:
462 case SYM_AH_CH_TYPE5:
463 case SYM_AH_CH_TYPE6:
464 case SYM_AH_CH_TYPE7:
465 case SYM_AH_CH_TYPE8:
466 case SYM_AH_CH_AIRCRAFT1:
467 return BF_SYM_AH_CENTER_LINE;
469 case SYM_AH_CH_RIGHT:
470 case (SYM_AH_CH_TYPE3+2):
471 case (SYM_AH_CH_TYPE4+2):
472 case (SYM_AH_CH_TYPE5+2):
473 case (SYM_AH_CH_TYPE6+2):
474 case (SYM_AH_CH_TYPE7+2):
475 case (SYM_AH_CH_TYPE8+2):
476 case SYM_AH_CH_AIRCRAFT3:
477 return BF_SYM_AH_CENTER_LINE_RIGHT;
479 case SYM_AH_CH_AIRCRAFT0:
480 case SYM_AH_CH_AIRCRAFT4:
481 return ' ';
483 case SYM_ARROW_UP:
484 return BF_SYM_ARROW_NORTH;
486 case SYM_ARROW_2:
487 return BF_SYM_ARROW_8;
489 case SYM_ARROW_3:
490 return BF_SYM_ARROW_7;
492 case SYM_ARROW_4:
493 return BF_SYM_ARROW_6;
495 case SYM_ARROW_RIGHT:
496 return BF_SYM_ARROW_EAST;
498 case SYM_ARROW_6:
499 return BF_SYM_ARROW_4;
501 case SYM_ARROW_7:
502 return BF_SYM_ARROW_3;
504 case SYM_ARROW_8:
505 return BF_SYM_ARROW_2;
507 case SYM_ARROW_DOWN:
508 return BF_SYM_ARROW_SOUTH;
510 case SYM_ARROW_10:
511 return BF_SYM_ARROW_16;
513 case SYM_ARROW_11:
514 return BF_SYM_ARROW_15;
516 case SYM_ARROW_12:
517 return BF_SYM_ARROW_14;
519 case SYM_ARROW_LEFT:
520 return BF_SYM_ARROW_WEST;
522 case SYM_ARROW_14:
523 return BF_SYM_ARROW_12;
525 case SYM_ARROW_15:
526 return BF_SYM_ARROW_11;
528 case SYM_ARROW_16:
529 return BF_SYM_ARROW_10;
531 case SYM_AH_H_START:
532 return BF_SYM_AH_BAR9_0;
534 case (SYM_AH_H_START+1):
535 return BF_SYM_AH_BAR9_1;
537 case (SYM_AH_H_START+2):
538 return BF_SYM_AH_BAR9_2;
540 case (SYM_AH_H_START+3):
541 return BF_SYM_AH_BAR9_3;
543 case (SYM_AH_H_START+4):
544 return BF_SYM_AH_BAR9_4;
546 case (SYM_AH_H_START+5):
547 return BF_SYM_AH_BAR9_5;
549 case (SYM_AH_H_START+6):
550 return BF_SYM_AH_BAR9_6;
552 case (SYM_AH_H_START+7):
553 return BF_SYM_AH_BAR9_7;
555 case (SYM_AH_H_START+8):
556 return BF_SYM_AH_BAR9_8;
558 // BF does not have vertical artificial horizon. replace with middle horizontal one
559 case SYM_AH_V_START:
560 case (SYM_AH_V_START+1):
561 case (SYM_AH_V_START+2):
562 case (SYM_AH_V_START+3):
563 case (SYM_AH_V_START+4):
564 case (SYM_AH_V_START+5):
565 return BF_SYM_AH_BAR9_4;
567 case SYM_VARIO_UP_2A:
568 return BF_SYM_VARIO_UP_2A;
570 case SYM_VARIO_UP_1A:
571 return BF_SYM_VARIO_UP_1A;
573 case SYM_VARIO_DOWN_1A:
574 return BF_SYM_VARIO_DOWN_1A;
576 case SYM_VARIO_DOWN_2A:
577 return BF_SYM_VARIO_DOWN_2A;
579 case SYM_ALT:
580 return BF_SYM_ALTITUDE;
582 case SYM_HUD_SIGNAL_0:
583 return BF_SYM_HUD_SIGNAL_0;
585 case SYM_HUD_SIGNAL_1:
586 return BF_SYM_HUD_SIGNAL_1;
588 case SYM_HUD_SIGNAL_2:
589 return BF_SYM_HUD_SIGNAL_2;
591 case SYM_HUD_SIGNAL_3:
592 return BF_SYM_HUD_SIGNAL_3;
594 case SYM_HUD_SIGNAL_4:
595 return BF_SYM_HUD_SIGNAL_4;
597 case SYM_HOME_DIST:
598 return BF_SYM_HOME_DIST;
601 case SYM_AH_CH_CENTER:
602 case (SYM_AH_CH_TYPE3+1):
603 case (SYM_AH_CH_TYPE4+1):
604 case (SYM_AH_CH_TYPE5+1):
605 case (SYM_AH_CH_TYPE6+1):
606 case (SYM_AH_CH_TYPE7+1):
607 case (SYM_AH_CH_TYPE8+1):
608 case SYM_AH_CH_AIRCRAFT2:
609 return BF_SYM_AH_CENTER;
611 case SYM_FLIGHT_DIST_REMAINING:
612 return BF_SYM_FLIGHT_DIST_REMAINING;
614 case SYM_AH_CH_TYPE3:
615 return BF_SYM_AH_CH_TYPE3;
617 case SYM_AH_CH_TYPE4:
618 return BF_SYM_AH_CH_TYPE4;
620 case SYM_AH_CH_TYPE5:
621 return BF_SYM_AH_CH_TYPE5;
623 case SYM_AH_CH_TYPE6:
624 return BF_SYM_AH_CH_TYPE6;
626 case SYM_AH_CH_TYPE7:
627 return BF_SYM_AH_CH_TYPE7;
629 case SYM_AH_CH_TYPE8:
630 return BF_SYM_AH_CH_TYPE8;
632 case SYM_AH_CH_AIRCRAFT0:
633 return BF_SYM_AH_CH_AIRCRAFT0;
635 case SYM_AH_CH_AIRCRAFT1:
636 return BF_SYM_AH_CH_AIRCRAFT1;
638 case SYM_AH_CH_AIRCRAFT2:
639 return BF_SYM_AH_CH_AIRCRAFT2;
641 case SYM_AH_CH_AIRCRAFT3:
642 return BF_SYM_AH_CH_AIRCRAFT3;
644 case SYM_AH_CH_AIRCRAFT4:
645 return BF_SYM_AH_CH_AIRCRAFT4;
647 case SYM_HUD_ARROWS_L1:
648 return BF_SYM_HUD_ARROWS_L1;
650 case SYM_HUD_ARROWS_L2:
651 return BF_SYM_HUD_ARROWS_L2;
653 case SYM_HUD_ARROWS_L3:
654 return BF_SYM_HUD_ARROWS_L3;
656 case SYM_HUD_ARROWS_R1:
657 return BF_SYM_HUD_ARROWS_R1;
659 case SYM_HUD_ARROWS_R2:
660 return BF_SYM_HUD_ARROWS_R2;
662 case SYM_HUD_ARROWS_R3:
663 return BF_SYM_HUD_ARROWS_R3;
665 case SYM_HUD_ARROWS_U1:
666 return BF_SYM_HUD_ARROWS_U1;
668 case SYM_HUD_ARROWS_U2:
669 return BF_SYM_HUD_ARROWS_U2;
671 case SYM_HUD_ARROWS_U3:
672 return BF_SYM_HUD_ARROWS_U3;
674 case SYM_HUD_ARROWS_D1:
675 return BF_SYM_HUD_ARROWS_D1;
677 case SYM_HUD_ARROWS_D2:
678 return BF_SYM_HUD_ARROWS_D2;
680 case SYM_HUD_ARROWS_D3:
681 return BF_SYM_HUD_ARROWS_D3;
683 default:
684 break;
687 return '?'; // Missing/not mapped character
690 #endif
692 #endif