mirror of
https://github.com/opentx/opentx.git
synced 2025-07-19 14:25:11 +03:00
Fixes #1107
This commit is contained in:
parent
0a53e2e6b3
commit
6c17fee19b
10 changed files with 37 additions and 19 deletions
|
@ -408,6 +408,8 @@ QString RawSwitch::toString()
|
|||
return QObject::tr("ON");
|
||||
case SWITCH_TYPE_OFF:
|
||||
return QObject::tr("OFF");
|
||||
case SWITCH_TYPE_ONE:
|
||||
return QObject::tr("One");
|
||||
case SWITCH_TYPE_FLIGHT_MODE:
|
||||
return CHECK_IN_ARRAY(flightModes, index-1);
|
||||
case SWITCH_TYPE_NONE:
|
||||
|
|
|
@ -385,6 +385,7 @@ enum RawSwitchType {
|
|||
SWITCH_TYPE_ROTARY_ENCODER,
|
||||
SWITCH_TYPE_ON,
|
||||
SWITCH_TYPE_OFF,
|
||||
SWITCH_TYPE_ONE,
|
||||
SWITCH_TYPE_FLIGHT_MODE,
|
||||
SWITCH_TYPE_TIMER_MODE
|
||||
};
|
||||
|
|
|
@ -89,14 +89,17 @@ class SwitchesConversionTable: public ConversionTable {
|
|||
if (!(flags & POPULATE_TIMER_MODES)) {
|
||||
addConversion(RawSwitch(SWITCH_TYPE_OFF), -val+offset);
|
||||
addConversion(RawSwitch(SWITCH_TYPE_ON), val++);
|
||||
}
|
||||
|
||||
if (version >= 216) {
|
||||
addConversion(RawSwitch(SWITCH_TYPE_ONE, -1), -val+offset);
|
||||
addConversion(RawSwitch(SWITCH_TYPE_ONE, 1), val++);
|
||||
if (IS_ARM(board)) {
|
||||
for (int i=1; i<=MAX_FLIGHT_MODES(board, version); i++) {
|
||||
addConversion(RawSwitch(SWITCH_TYPE_FLIGHT_MODE, -i), -val+offset);
|
||||
addConversion(RawSwitch(SWITCH_TYPE_FLIGHT_MODE, i), val++);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (version < 216) {
|
||||
// previous "moment" switches
|
||||
|
|
|
@ -400,6 +400,7 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
|
|||
b->clear();
|
||||
|
||||
if (attr & POPULATE_ONOFF) {
|
||||
// !FMx
|
||||
if (IS_ARM(GetCurrentFirmware()->getBoard())) {
|
||||
for (int i=-GetCurrentFirmware()->getCapability(FlightModes); i<0; i++) {
|
||||
item = RawSwitch(SWITCH_TYPE_FLIGHT_MODE, i);
|
||||
|
@ -407,6 +408,11 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
|
|||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
}
|
||||
// !One
|
||||
item = RawSwitch(SWITCH_TYPE_ONE, 1);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
// OFF
|
||||
item = RawSwitch(SWITCH_TYPE_OFF);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
|
@ -494,9 +500,15 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
|
|||
}
|
||||
|
||||
if (attr & POPULATE_ONOFF) {
|
||||
// ON
|
||||
item = RawSwitch(SWITCH_TYPE_ON);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
// One
|
||||
item = RawSwitch(SWITCH_TYPE_ONE, 1);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
// FMx
|
||||
if (IS_ARM(GetCurrentFirmware()->getBoard())) {
|
||||
for (int i=1; i<=GetCurrentFirmware()->getCapability(FlightModes); i++) {
|
||||
item = RawSwitch(SWITCH_TYPE_FLIGHT_MODE, i);
|
||||
|
|
|
@ -307,7 +307,7 @@ void getSwitchAudioFile(char * filename, int index)
|
|||
{
|
||||
char * str = getModelPath(filename);
|
||||
int len = STR_VSWITCHES[0];
|
||||
strncpy(str, &STR_VSWITCHES[1+len*index], len);
|
||||
strncpy(str, &STR_VSWITCHES[1+len*(index+1)], len);
|
||||
str += len-1;
|
||||
if (*str == '\300') {
|
||||
strcpy(str, "-up");
|
||||
|
@ -331,7 +331,7 @@ void getLogicalSwitchAudioFile(char * filename, int index, unsigned int event)
|
|||
{
|
||||
char * str = getModelPath(filename);
|
||||
int len = STR_VSWITCHES[0];
|
||||
strncpy(str, &STR_VSWITCHES[1+len*(index+SWSRC_FIRST_LOGICAL_SWITCH-1)], len);
|
||||
strncpy(str, &STR_VSWITCHES[1+len*(index+SWSRC_FIRST_LOGICAL_SWITCH)], len);
|
||||
str += len;
|
||||
strcpy(str, suffixes[event]);
|
||||
strcat(str, SOUNDS_EXT);
|
||||
|
|
|
@ -1279,7 +1279,7 @@ void menuModelSetup(uint8_t event)
|
|||
else {
|
||||
if ((states & 0x01) && swactive)
|
||||
attr = INVERS;
|
||||
c = pgm_read_byte(STR_VSWITCHES - 2 + 9 + (3*i));
|
||||
c = pgm_read_byte(STR_VSWITCHES - 2 + 9 + (3*(i+1)));
|
||||
states >>= 1;
|
||||
}
|
||||
if (line && (m_posHorz == i)) {
|
||||
|
|
|
@ -1042,22 +1042,18 @@ void putsModelName(xcoord_t x, uint8_t y, char *name, uint8_t id, LcdFlags att)
|
|||
|
||||
void putsSwitches(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att)
|
||||
{
|
||||
if (idx == SWSRC_NONE)
|
||||
return lcd_putsiAtt(x, y, STR_MMMINV, 0, att);
|
||||
if (idx == SWSRC_ON)
|
||||
return lcd_putsiAtt(x, y, STR_OFFON, 1, att);
|
||||
if (idx == SWSRC_OFF)
|
||||
return lcd_putsiAtt(x, y, STR_OFFON, 0, att);
|
||||
if (idx < 0) {
|
||||
lcd_putcAtt(x-2, y, '!', att);
|
||||
idx = -idx;
|
||||
idx = 1-idx;
|
||||
}
|
||||
#if defined(CPUARM) && defined(FLIGHT_MODES)
|
||||
if (idx >= SWSRC_FIRST_FLIGHT_MODE)
|
||||
putsStrIdx(x, y, STR_FP, idx-SWSRC_FIRST_FLIGHT_MODE, att);
|
||||
else
|
||||
#endif
|
||||
lcd_putsiAtt(x, y, STR_VSWITCHES, idx-1, att);
|
||||
lcd_putsiAtt(x, y, STR_VSWITCHES, idx, att);
|
||||
}
|
||||
|
||||
#if defined(FLIGHT_MODES)
|
||||
|
|
|
@ -1389,6 +1389,7 @@ enum SwitchSources {
|
|||
SWSRC_LAST_LOGICAL_SWITCH = SWSRC_FIRST_LOGICAL_SWITCH+NUM_LOGICAL_SWITCH-1,
|
||||
|
||||
SWSRC_ON,
|
||||
SWSRC_One,
|
||||
|
||||
#if defined(CPUARM)
|
||||
SWSRC_FIRST_FLIGHT_MODE,
|
||||
|
|
|
@ -169,7 +169,10 @@ bool getSwitch(int8_t swtch)
|
|||
|
||||
uint8_t cs_idx = abs(swtch);
|
||||
|
||||
if (cs_idx == SWSRC_ON) {
|
||||
if (cs_idx == SWSRC_One) {
|
||||
result = !s_mixer_first_run_done;
|
||||
}
|
||||
else if (cs_idx == SWSRC_ON) {
|
||||
result = true;
|
||||
}
|
||||
else if (cs_idx <= SWSRC_LAST_SWITCH) {
|
||||
|
|
|
@ -412,11 +412,11 @@
|
|||
|
||||
#if defined(PCBTARANIS)
|
||||
#define TR_6POS_POTS "S11""S12""S13""S14""S15""S16""S21""S22""S23""S24""S25""S26""S31""S32""S33""S34""S35""S36"
|
||||
#define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_6POS_POTS TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW
|
||||
#define TR_VSWITCHES "---""SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_6POS_POTS TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW "ON\0" "One"
|
||||
#elif defined(CPUARM)
|
||||
#define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW
|
||||
#define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW "ON\0" "One"
|
||||
#else
|
||||
#define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW
|
||||
#define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW "ON\0" "One"
|
||||
#endif
|
||||
|
||||
#if defined(HELI)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue