Adding more servos
[inav.git] / src / main / io / displayport_msp_dji_compat.c
blobfbd7445f650c822fcf0a1d546d1fd7ec4f30e0ef
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_DJI_COMPAT
24 #include "io/displayport_msp_dji_compat.h"
25 #include "io/dji_osd_symbols.h"
26 #include "drivers/osd_symbols.h"
28 uint8_t getDJICharacter(uint8_t ch, uint8_t page)
30 uint16_t ech = ch | ((page & 0x3)<< 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 DJI_SYM_AH_DECORATION;
40 switch (ech) {
41 case SYM_RSSI:
42 return DJI_SYM_RSSI;
44 case SYM_LQ:
45 return 'Q';
47 case SYM_LAT:
48 return DJI_SYM_LAT;
50 case SYM_LON:
51 return DJI_SYM_LON;
53 case SYM_SAT_L:
54 return DJI_SYM_SAT_L;
56 case SYM_SAT_R:
57 return DJI_SYM_SAT_R;
59 case SYM_HOME_NEAR:
60 return DJI_SYM_HOMEFLAG;
62 case SYM_DEGREES:
63 return DJI_SYM_GPS_DEGREE;
66 case SYM_HEADING:
67 return DJI_SYM_HEADING;
69 case SYM_SCALE:
70 return DJI_SYM_SCALE;
72 case SYM_HDP_L:
73 return DJI_SYM_HDP_L;
75 case SYM_HDP_R:
76 return DJI_SYM_HDP_R;
78 case SYM_HOME:
79 return DJI_SYM_HOMEFLAG;
81 case SYM_2RSS:
82 return DJI_SYM_RSSI;
85 case SYM_DB:
86 return DJI_SYM_DB
88 case SYM_DBM:
89 return DJI_SYM_DBM;
91 case SYM_SNR:
92 return DJI_SYM_SNR;
95 case SYM_AH_DECORATION_UP:
96 return DJI_SYM_ARROW_SMALL_UP;
98 case SYM_AH_DECORATION_DOWN:
99 return DJI_SYM_ARROW_SMALL_DOWN;
101 case SYM_DECORATION:
102 return DJI_SYM_ARROW_SMALL_UP;
104 case SYM_DECORATION + 1: // NE pointing arrow
105 return DJI_SYM_ARROW_7;
107 case SYM_DECORATION + 2: // E pointing arrow
108 return DJI_SYM_ARROW_EAST;
110 case SYM_DECORATION + 3: // SE pointing arrow
111 return DJI_SYM_ARROW_3;
113 case SYM_DECORATION + 4: // S pointing arrow
114 return DJI_SYM_ARROW_SOUTH;
116 case SYM_DECORATION + 5: // SW pointing arrow
117 return DJI_SYM_ARROW_15;
119 case SYM_DECORATION + 6: // W pointing arrow
120 return DJI_SYM_ARROW_WEST;
122 case SYM_DECORATION + 7: // NW pointing arrow
123 return DJI_SYM_ARROW_11;
125 case SYM_VOLT:
126 return DJI_SYM_VOLT;
128 case SYM_MAH:
129 return DJI_SYM_MAH;
131 case SYM_AH_KM:
132 return 'K';
134 case SYM_AH_MI:
135 return 'M';
137 case SYM_VTX_POWER:
138 return DJI_SYM_VTX_POWER;
140 case SYM_AH_NM:
141 return DJI_SYM_AH_NM;
143 case SYM_MAH_NM_0:
144 return DJI_SYM_MAH_NM_0;
146 case SYM_MAH_NM_1:
147 return DJI_SYM_MAH_NM_1;
149 case SYM_MAH_KM_0:
150 return DJI_SYM_MAH_KM_0;
152 case SYM_MAH_KM_1:
153 return DJI_SYM_MAH_KM_1;
155 case SYM_MILLIOHM:
156 return DJI_SYM_MILLIOHM;
158 case SYM_BATT_FULL:
159 return DJI_SYM_BATT_FULL;
161 case SYM_BATT_5:
162 return DJI_SYM_BATT_5;
164 case SYM_BATT_4:
165 return DJI_SYM_BATT_4;
167 case SYM_BATT_3:
168 return DJI_SYM_BATT_3;
170 case SYM_BATT_2:
171 return DJI_SYM_BATT_2;
173 case SYM_BATT_1:
174 return DJI_SYM_BATT_1;
176 case SYM_BATT_EMPTY:
177 return DJI_SYM_BATT_EMPTY;
179 case SYM_AMP:
180 return DJI_SYM_AMP;
182 case SYM_WH:
183 return DJI_SYM_WH;
185 case SYM_WH_KM:
186 return DJI_SYM_WH_KM;
188 case SYM_WH_MI:
189 return DJI_SYM_WH_MI;
191 case SYM_WH_NM:
192 return DJI_SYM_WH_NM;
194 case SYM_WATT:
195 return DJI_SYM_WATT;
197 case SYM_MW:
198 return DJI_SYM_MW;
200 case SYM_KILOWATT:
201 return DJI_SYM_KILOWATT;
203 case SYM_FT:
204 return DJI_SYM_FT;
206 case SYM_ALT_FT:
207 return DJI_SYM_FT;
209 case SYM_ALT_M:
210 return DJI_SYM_M;
212 case SYM_TOTAL:
213 return DJI_SYM_FLY_H;
216 case SYM_ALT_KM:
217 return DJI_SYM_ALT_KM;
219 case SYM_ALT_KFT:
220 return DJI_SYM_ALT_KFT;
222 case SYM_DIST_M:
223 return DJI_SYM_DIST_M;
225 case SYM_DIST_KM:
226 return DJI_SYM_DIST_KM;
228 case SYM_DIST_FT:
229 return DJI_SYM_DIST_FT;
231 case SYM_DIST_MI:
232 return DJI_SYM_DIST_MI;
234 case SYM_DIST_NM:
235 return DJI_SYM_DIST_NM;
237 case SYM_M:
238 return DJI_SYM_M;
240 case SYM_KM:
241 return 'K';
243 case SYM_MI:
244 return 'M';
246 case SYM_NM:
247 return DJI_SYM_NM;
249 case SYM_WIND_HORIZONTAL:
250 return 'W'; // W for wind
253 case SYM_WIND_VERTICAL:
254 return DJI_SYM_WIND_VERTICAL;
256 case SYM_3D_KT:
257 return DJI_SYM_3D_KT;
259 case SYM_AIR:
260 return 'A'; // A for airspeed
262 case SYM_3D_KMH:
263 return DJI_SYM_KPH;
265 case SYM_3D_MPH:
266 return DJI_SYM_MPH;
268 case SYM_RPM:
269 return DJI_SYM_RPM;
271 case SYM_FTS:
272 return DJI_SYM_FTPS;
274 case SYM_100FTM:
275 return DJI_SYM_100FTM;
277 case SYM_MS:
278 return DJI_SYM_MPS;
280 case SYM_KMH:
281 return DJI_SYM_KPH;
283 case SYM_MPH:
284 return DJI_SYM_MPH;
286 case SYM_KT:
287 return DJI_SYM_KT
289 case SYM_MAH_MI_0:
290 return DJI_SYM_MAH_MI_0;
292 case SYM_MAH_MI_1:
293 return DJI_SYM_MAH_MI_1;
295 case SYM_THR:
296 return DJI_SYM_THR;
298 case SYM_TEMP_F:
299 return DJI_SYM_F;
301 case SYM_TEMP_C:
302 return DJI_SYM_C;
304 case SYM_BLANK:
305 return DJI_SYM_BLANK;
307 case SYM_ON_H:
308 return DJI_SYM_ON_H;
310 case SYM_FLY_H:
311 return DJI_SYM_FLY_H;
313 case SYM_ON_M:
314 return DJI_SYM_ON_M;
316 case SYM_FLY_M:
317 return DJI_SYM_FLY_M;
319 case SYM_GLIDESLOPE:
320 return DJI_SYM_GLIDESLOPE;
322 case SYM_WAYPOINT:
323 return DJI_SYM_WAYPOINT;
325 case SYM_CLOCK:
326 return DJI_SYM_CLOCK;
328 case SYM_ZERO_HALF_TRAILING_DOT:
329 return DJI_SYM_ZERO_HALF_TRAILING_DOT;
331 case SYM_ZERO_HALF_LEADING_DOT:
332 return DJI_SYM_ZERO_HALF_LEADING_DOT;
335 case SYM_AUTO_THR0:
336 return 'A';
338 case SYM_AUTO_THR1:
339 return DJI_SYM_THR;
341 case SYM_ROLL_LEFT:
342 return DJI_SYM_ROLL;
344 case SYM_ROLL_LEVEL:
345 return DJI_SYM_ROLL;
347 case SYM_ROLL_RIGHT:
348 return DJI_SYM_ROLL;
350 case SYM_PITCH_UP:
351 return DJI_SYM_PITCH;
353 case SYM_PITCH_DOWN:
354 return DJI_SYM_PITCH;
356 case SYM_GFORCE:
357 return 'G';
360 case SYM_GFORCE_X:
361 return DJI_SYM_GFORCE_X;
363 case SYM_GFORCE_Y:
364 return DJI_SYM_GFORCE_Y;
366 case SYM_GFORCE_Z:
367 return DJI_SYM_GFORCE_Z;
369 case SYM_BARO_TEMP:
370 return DJI_SYM_TEMPERATURE;
372 case SYM_IMU_TEMP:
373 return DJI_SYM_TEMPERATURE;
375 case SYM_TEMP:
376 return DJI_SYM_TEMPERATURE;
378 case SYM_ESC_TEMP:
379 return DJI_SYM_TEMPERATURE;
381 case SYM_TEMP_SENSOR_FIRST:
382 return DJI_SYM_TEMP_SENSOR_FIRST;
384 case SYM_TEMP_SENSOR_LAST:
385 return DJI_SYM_TEMP_SENSOR_LAST;
387 case TEMP_SENSOR_SYM_COUNT:
388 return DJI_TEMP_SENSOR_SYM_COUNT;
390 case SYM_HEADING_N:
391 return DJI_SYM_HEADING_N;
393 case SYM_HEADING_S:
394 return DJI_SYM_HEADING_S;
396 case SYM_HEADING_E:
397 return DJI_SYM_HEADING_E;
399 case SYM_HEADING_W:
400 return DJI_SYM_HEADING_W;
402 case SYM_HEADING_DIVIDED_LINE:
403 return DJI_SYM_HEADING_DIVIDED_LINE;
405 case SYM_HEADING_LINE:
406 return DJI_SYM_HEADING_LINE;
408 case SYM_MAX:
409 return DJI_SYM_MAX;
411 case SYM_PROFILE:
412 return DJI_SYM_PROFILE;
414 case SYM_SWITCH_INDICATOR_LOW:
415 return DJI_SYM_STICK_OVERLAY_SPRITE_LOW;
417 case SYM_SWITCH_INDICATOR_MID:
418 return DJI_SYM_STICK_OVERLAY_SPRITE_MID;
420 case SYM_SWITCH_INDICATOR_HIGH:
421 return DJI_SYM_STICK_OVERLAY_SPRITE_HIGH;
423 case SYM_AH:
424 return DJI_SYM_AH;
426 case SYM_GLIDE_DIST:
427 return DJI_SYM_GLIDE_DIST;
429 case SYM_GLIDE_MINS:
430 return DJI_SYM_GLIDE_MINS;
432 case SYM_AH_V_FT_0:
433 return DJI_SYM_AH_V_FT_0;
435 case SYM_AH_V_FT_1:
436 return DJI_SYM_AH_V_FT_1;
438 case SYM_AH_V_M_0:
439 return DJI_SYM_AH_V_M_0;
441 case SYM_AH_V_M_1:
442 return DJI_SYM_AH_V_M_1;
444 case SYM_FLIGHT_MINS_REMAINING:
445 return DJI_SYM_FLIGHT_MINS_REMAINING;
447 case SYM_FLIGHT_HOURS_REMAINING:
448 return DJI_SYM_FLIGHT_HOURS_REMAINING;
450 case SYM_GROUND_COURSE:
451 return DJI_SYM_GROUND_COURSE;
453 case SYM_CROSS_TRACK_ERROR:
454 return DJI_SYM_CROSS_TRACK_ERROR;
456 case SYM_LOGO_START:
457 return DJI_SYM_LOGO_START;
459 case SYM_LOGO_WIDTH:
460 return DJI_SYM_LOGO_WIDTH;
462 case SYM_LOGO_HEIGHT:
463 return DJI_SYM_LOGO_HEIGHT;
465 case SYM_AH_LEFT:
466 return DJI_SYM_AH_LEFT;
468 case SYM_AH_RIGHT:
469 return DJI_SYM_AH_RIGHT;
471 case SYM_AH_DECORATION_COUNT:
472 return DJI_SYM_AH_DECORATION_COUNT;
474 case SYM_AH_CH_LEFT:
475 case SYM_AH_CH_AIRCRAFT1:
476 return DJI_SYM_CROSSHAIR_LEFT;
477 case SYM_AH_CH_CENTER:
478 case SYM_AH_CH_AIRCRAFT2:
479 return DJI_SYM_CROSSHAIR_CENTRE;
480 case SYM_AH_CH_RIGHT:
481 case SYM_AH_CH_AIRCRAFT3:
482 return DJI_SYM_CROSSHAIR_RIGHT;
484 case SYM_AH_CH_AIRCRAFT0:
485 case SYM_AH_CH_AIRCRAFT4:
486 return DJI_SYM_BLANK;
488 case SYM_AH_CH_TYPE3:
489 return DJI_SYM_NONE;
490 case (SYM_AH_CH_TYPE3+1):
491 return DJI_SYM_SMALL_CROSSHAIR;
492 case (SYM_AH_CH_TYPE3+2):
493 return DJI_SYM_NONE;
495 case SYM_AH_CH_TYPE4:
496 return DJI_SYM_HYPHEN;
497 case (SYM_AH_CH_TYPE4+1):
498 return DJI_SYM_SMALL_CROSSHAIR;
499 case (SYM_AH_CH_TYPE4+2):
500 return DJI_SYM_HYPHEN;
502 case SYM_AH_CH_TYPE5:
503 return DJI_SYM_STICK_OVERLAY_HORIZONTAL;
504 case (SYM_AH_CH_TYPE5+1):
505 return DJI_SYM_SMALL_CROSSHAIR;
506 case (SYM_AH_CH_TYPE5+2):
507 return DJI_SYM_STICK_OVERLAY_HORIZONTAL;
509 case SYM_AH_CH_TYPE6:
510 return DJI_SYM_NONE;
511 case (SYM_AH_CH_TYPE6+1):
512 return DJI_SYM_STICK_OVERLAY_SPRITE_MID;
513 case (SYM_AH_CH_TYPE6+2):
514 return DJI_SYM_NONE;
516 case SYM_AH_CH_TYPE7:
517 return DJI_SYM_ARROW_SMALL_LEFT;
518 case (SYM_AH_CH_TYPE7+1):
519 return DJI_SYM_SMALL_CROSSHAIR;
520 case (SYM_AH_CH_TYPE7+2):
521 return DJI_SYM_ARROW_SMALL_RIGHT;
523 case SYM_AH_CH_TYPE8:
524 return DJI_SYM_AH_LEFT;
525 case (SYM_AH_CH_TYPE8+1):
526 return DJI_SYM_SMALL_CROSSHAIR;
527 case (SYM_AH_CH_TYPE8+2):
528 return DJI_SYM_AH_RIGHT;
530 case SYM_ARROW_UP:
531 return DJI_SYM_ARROW_NORTH;
533 case SYM_ARROW_2:
534 return DJI_SYM_ARROW_8;
536 case SYM_ARROW_3:
537 return DJI_SYM_ARROW_7;
539 case SYM_ARROW_4:
540 return DJI_SYM_ARROW_6;
542 case SYM_ARROW_RIGHT:
543 return DJI_SYM_ARROW_EAST;
545 case SYM_ARROW_6:
546 return DJI_SYM_ARROW_4;
548 case SYM_ARROW_7:
549 return DJI_SYM_ARROW_3;
551 case SYM_ARROW_8:
552 return DJI_SYM_ARROW_2;
554 case SYM_ARROW_DOWN:
555 return DJI_SYM_ARROW_SOUTH;
557 case SYM_ARROW_10:
558 return DJI_SYM_ARROW_16;
560 case SYM_ARROW_11:
561 return DJI_SYM_ARROW_15;
563 case SYM_ARROW_12:
564 return DJI_SYM_ARROW_14;
566 case SYM_ARROW_LEFT:
567 return DJI_SYM_ARROW_WEST;
569 case SYM_ARROW_14:
570 return DJI_SYM_ARROW_12;
572 case SYM_ARROW_15:
573 return DJI_SYM_ARROW_11;
575 case SYM_ARROW_16:
576 return DJI_SYM_ARROW_10;
578 case SYM_AH_H_START:
579 return DJI_SYM_AH_BAR9_0;
581 case (SYM_AH_H_START+1):
582 return DJI_SYM_AH_BAR9_1;
584 case (SYM_AH_H_START+2):
585 return DJI_SYM_AH_BAR9_2;
587 case (SYM_AH_H_START+3):
588 return DJI_SYM_AH_BAR9_3;
590 case (SYM_AH_H_START+4):
591 return DJI_SYM_AH_BAR9_4;
593 case (SYM_AH_H_START+5):
594 return DJI_SYM_AH_BAR9_5;
596 case (SYM_AH_H_START+6):
597 return DJI_SYM_AH_BAR9_6;
599 case (SYM_AH_H_START+7):
600 return DJI_SYM_AH_BAR9_7;
602 case (SYM_AH_H_START+8):
603 return DJI_SYM_AH_BAR9_8;
605 // DJI does not have vertical artificial horizon. replace with middle horizontal one
606 case SYM_AH_V_START:
607 case (SYM_AH_V_START+1):
608 case (SYM_AH_V_START+2):
609 case (SYM_AH_V_START+3):
610 case (SYM_AH_V_START+4):
611 case (SYM_AH_V_START+5):
612 return DJI_SYM_AH_BAR9_4;
614 // DJI for ESP_RADAR Symbols
615 case SYM_HUD_CARDINAL:
616 return DJI_SYM_ARROW_SOUTH;
617 case SYM_HUD_CARDINAL + 1:
618 return DJI_SYM_ARROW_16;
619 case SYM_HUD_CARDINAL + 2:
620 return DJI_SYM_ARROW_15;
621 case SYM_HUD_CARDINAL + 3:
622 return DJI_SYM_ARROW_WEST;
623 case SYM_HUD_CARDINAL + 4:
624 return DJI_SYM_ARROW_12;
625 case SYM_HUD_CARDINAL + 5:
626 return DJI_SYM_ARROW_11;
627 case SYM_HUD_CARDINAL + 6:
628 return DJI_SYM_ARROW_NORTH;
629 case SYM_HUD_CARDINAL + 7:
630 return DJI_SYM_ARROW_7;
631 case SYM_HUD_CARDINAL + 8:
632 return DJI_SYM_ARROW_6;
633 case SYM_HUD_CARDINAL + 9:
634 return DJI_SYM_ARROW_EAST;
635 case SYM_HUD_CARDINAL + 10:
636 return DJI_SYM_ARROW_3;
637 case SYM_HUD_CARDINAL + 11:
638 return DJI_SYM_ARROW_2;
640 case SYM_HUD_SIGNAL_0:
641 return DJI_SYM_AH_BAR9_1;
642 case SYM_HUD_SIGNAL_1:
643 return DJI_SYM_AH_BAR9_3;
644 case SYM_HUD_SIGNAL_2:
645 return DJI_SYM_AH_BAR9_4;
646 case SYM_HUD_SIGNAL_3:
647 return DJI_SYM_AH_BAR9_5;
648 case SYM_HUD_SIGNAL_4:
649 return DJI_SYM_AH_BAR9_7;
651 case SYM_VARIO_UP_2A:
652 return DJI_SYM_ARROW_SMALL_UP;
654 case SYM_VARIO_UP_1A:
655 return DJI_SYM_ARROW_SMALL_UP;
657 case SYM_VARIO_DOWN_1A:
658 return DJI_SYM_ARROW_SMALL_DOWN;
660 case SYM_VARIO_DOWN_2A:
661 return DJI_SYM_ARROW_SMALL_DOWN;
663 case SYM_ALT:
664 return DJI_SYM_ALTITUDE;
666 case SYM_HUD_SIGNAL_0:
667 return DJI_SYM_HUD_SIGNAL_0;
669 case SYM_HUD_SIGNAL_1:
670 return DJI_SYM_HUD_SIGNAL_1;
672 case SYM_HUD_SIGNAL_2:
673 return DJI_SYM_HUD_SIGNAL_2;
675 case SYM_HUD_SIGNAL_3:
676 return DJI_SYM_HUD_SIGNAL_3;
678 case SYM_HUD_SIGNAL_4:
679 return DJI_SYM_HUD_SIGNAL_4;
681 case SYM_HOME_DIST:
682 return DJI_SYM_HOME_DIST;
684 case SYM_FLIGHT_DIST_REMAINING:
685 return DJI_SYM_FLIGHT_DIST_REMAINING;
687 case SYM_HUD_ARROWS_L1:
688 return DJI_SYM_ARROW_SMALL_LEFT;
690 case SYM_HUD_ARROWS_L2:
691 return DJI_SYM_ARROW_SMALL_LEFT;
693 case SYM_HUD_ARROWS_L3:
694 return DJI_SYM_ARROW_SMALL_LEFT;
696 case SYM_HUD_ARROWS_R1:
697 return DJI_SYM_ARROW_SMALL_RIGHT;
699 case SYM_HUD_ARROWS_R2:
700 return DJI_SYM_ARROW_SMALL_RIGHT;
702 case SYM_HUD_ARROWS_R3:
703 return DJI_SYM_ARROW_SMALL_RIGHT;
705 case SYM_HUD_ARROWS_U1:
706 return DJI_SYM_ARROW_SMALL_UP;
708 case SYM_HUD_ARROWS_U2:
709 return DJI_SYM_ARROW_SMALL_UP;
711 case SYM_HUD_ARROWS_U3:
712 return DJI_SYM_ARROW_SMALL_UP;
714 case SYM_HUD_ARROWS_D1:
715 return DJI_SYM_ARROW_SMALL_DOWN;
717 case SYM_HUD_ARROWS_D2:
718 return DJI_SYM_ARROW_SMALL_DOWN;
720 case SYM_HUD_ARROWS_D3:
721 return DJI_SYM_ARROW_SMALL_DOWN;
723 default:
724 break;
727 return (osdConfig()->highlight_djis_missing_characters) ? '?' : SYM_BLANK; // Missing/not mapped character
730 #endif
732 #endif