@@ -634,22 +634,26 @@ void drawMainControlLabel(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
634
634
lcdDrawSizedText (x, y, getMainControlLabel (idx), UINT8_MAX, att);
635
635
}
636
636
637
- void drawSource (coord_t x, coord_t y, uint32_t idx, LcdFlags att)
637
+ void drawSource (coord_t x, coord_t y, mixsrc_t idx, LcdFlags att)
638
638
{
639
- if (idx == MIXSRC_NONE) {
639
+ uint16_t aidx = abs (idx);
640
+
641
+ // TODO: Handle negative cases
642
+
643
+ if (aidx == MIXSRC_NONE) {
640
644
lcdDrawText (x, y, STR_EMPTY, att);
641
645
}
642
- else if (idx <= MIXSRC_LAST_INPUT) {
646
+ else if (aidx <= MIXSRC_LAST_INPUT) {
643
647
lcdDrawChar (x+2 , y+1 , CHR_INPUT, TINSIZE);
644
648
lcdDrawFilledRect (x, y, 7 , 7 );
645
- if (ZEXIST (g_model.inputNames [idx -MIXSRC_FIRST_INPUT]))
646
- lcdDrawSizedText (x+8 , y, g_model.inputNames [idx -MIXSRC_FIRST_INPUT], LEN_INPUT_NAME, att);
649
+ if (ZEXIST (g_model.inputNames [aidx -MIXSRC_FIRST_INPUT]))
650
+ lcdDrawSizedText (x+8 , y, g_model.inputNames [aidx -MIXSRC_FIRST_INPUT], LEN_INPUT_NAME, att);
647
651
else
648
- lcdDrawNumber (x+8 , y, idx , att|LEADING0|LEFT, 2 );
652
+ lcdDrawNumber (x+8 , y, aidx , att|LEADING0|LEFT, 2 );
649
653
}
650
654
651
- else if (idx <= MIXSRC_LAST_LUA) {
652
- div_t qr = div (idx -MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS);
655
+ else if (aidx <= MIXSRC_LAST_LUA) {
656
+ div_t qr = div (( uint16_t )(aidx -MIXSRC_FIRST_LUA) , MAX_SCRIPT_OUTPUTS);
653
657
#if defined(LUA_MODEL_SCRIPTS)
654
658
if (qr.quot < MAX_SCRIPTS && qr.rem < scriptInputsOutputs[qr.quot ].outputsCount ) {
655
659
lcdDrawChar (x+2 , y+1 , ' 1' +qr.quot , TINSIZE);
@@ -664,34 +668,34 @@ void drawSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att)
664
668
}
665
669
}
666
670
667
- else if (idx <= MIXSRC_LAST_POT) {
671
+ else if (aidx <= MIXSRC_LAST_POT) {
668
672
lcdDrawText (x, y, getSourceString (idx), att);
669
673
}
670
- else if (idx >= MIXSRC_FIRST_SWITCH && idx <= MIXSRC_LAST_SWITCH) {
674
+ else if (aidx >= MIXSRC_FIRST_SWITCH && aidx <= MIXSRC_LAST_SWITCH) {
671
675
lcdDrawText (x, y, getSourceString (idx), att);
672
676
}
673
- else if (idx <= MIXSRC_LAST_LOGICAL_SWITCH) {
674
- idx -= MIXSRC_FIRST_LOGICAL_SWITCH;
675
- drawSwitch (x, y, idx + SWSRC_FIRST_LOGICAL_SWITCH, att);
676
- } else if (idx <= MIXSRC_LAST_TRAINER) {
677
- idx -= MIXSRC_FIRST_TRAINER;
678
- drawStringWithIndex (x, y, STR_PPM_TRAINER, idx + 1 , att);
679
- } else if (idx <= MIXSRC_LAST_CH) {
680
- idx -= MIXSRC_FIRST_CH;
681
- drawStringWithIndex (x, y, STR_CH, idx + 1 , att);
682
- if (ZEXIST (g_model.limitData [idx ].name ) && (att & STREXPANDED)) {
677
+ else if (aidx <= MIXSRC_LAST_LOGICAL_SWITCH) {
678
+ aidx -= MIXSRC_FIRST_LOGICAL_SWITCH;
679
+ drawSwitch (x, y, aidx + SWSRC_FIRST_LOGICAL_SWITCH, att);
680
+ } else if (aidx <= MIXSRC_LAST_TRAINER) {
681
+ aidx -= MIXSRC_FIRST_TRAINER;
682
+ drawStringWithIndex (x, y, STR_PPM_TRAINER, aidx + 1 , att);
683
+ } else if (aidx <= MIXSRC_LAST_CH) {
684
+ aidx -= MIXSRC_FIRST_CH;
685
+ drawStringWithIndex (x, y, STR_CH, aidx + 1 , att);
686
+ if (ZEXIST (g_model.limitData [aidx ].name ) && (att & STREXPANDED)) {
683
687
lcdDrawChar (lcdLastRightPos, y, ' ' , att|SMLSIZE);
684
- lcdDrawSizedText (lcdLastRightPos+3 , y, g_model.limitData [idx ].name , LEN_CHANNEL_NAME, att|SMLSIZE);
688
+ lcdDrawSizedText (lcdLastRightPos+3 , y, g_model.limitData [aidx ].name , LEN_CHANNEL_NAME, att|SMLSIZE);
685
689
}
686
690
}
687
- else if (idx <= MIXSRC_LAST_GVAR) {
688
- idx -= MIXSRC_FIRST_GVAR - 1 ;
689
- drawStringWithIndex (x, y, STR_GV, idx , att);
691
+ else if (aidx <= MIXSRC_LAST_GVAR) {
692
+ aidx -= MIXSRC_FIRST_GVAR - 1 ;
693
+ drawStringWithIndex (x, y, STR_GV, aidx , att);
690
694
}
691
- else if (idx < MIXSRC_FIRST_TIMER) {
695
+ else if (aidx < MIXSRC_FIRST_TIMER) {
692
696
// Built-in sources: TX Voltage, Time, GPS (+ reserved)
693
697
const char * src_str;
694
- switch (idx ) {
698
+ switch (aidx ) {
695
699
case MIXSRC_TX_VOLTAGE:
696
700
src_str = STR_SRC_BATT;
697
701
break ;
@@ -707,18 +711,18 @@ void drawSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att)
707
711
}
708
712
lcdDrawText (x, y, src_str, att);
709
713
}
710
- else if (idx <= MIXSRC_LAST_TIMER) {
711
- idx -= MIXSRC_FIRST_TIMER;
712
- if (g_model.timers [idx ].name [0 ]) {
713
- lcdDrawSizedText (x, y, g_model.timers [idx ].name , LEN_TIMER_NAME, att);
714
+ else if (aidx <= MIXSRC_LAST_TIMER) {
715
+ aidx -= MIXSRC_FIRST_TIMER;
716
+ if (g_model.timers [aidx ].name [0 ]) {
717
+ lcdDrawSizedText (x, y, g_model.timers [aidx ].name , LEN_TIMER_NAME, att);
714
718
}
715
719
else {
716
- drawStringWithIndex (x, y, STR_SRC_TIMER, idx + 1 , att);
720
+ drawStringWithIndex (x, y, STR_SRC_TIMER, aidx + 1 , att);
717
721
}
718
722
}
719
723
else {
720
- idx -= MIXSRC_FIRST_TELEM;
721
- div_t qr = div (idx , 3 );
724
+ aidx -= MIXSRC_FIRST_TELEM;
725
+ div_t qr = div (( uint16_t )aidx , 3 );
722
726
lcdDrawSizedText (x, y, g_model.telemetrySensors [qr.quot ].label , TELEM_LABEL_LEN, att);
723
727
if (qr.rem ) lcdDrawChar (lcdLastRightPos, y, qr.rem ==2 ? ' +' : ' -' , att);
724
728
}
0 commit comments