mirror of
https://github.com/opentx/opentx.git
synced 2025-07-19 14:25:11 +03:00
Pot warning beta - needs testing, and checkSwitches() needs reviewing!
This commit is contained in:
parent
9a57ec0acc
commit
74918e4d12
2 changed files with 52 additions and 22 deletions
|
@ -953,7 +953,7 @@ void menuModelSetup(uint8_t event)
|
||||||
#define PORT_CHANNELS_ROWS(x) (x==0 ? PORT1_CHANNELS_ROWS() : (x==1 ? PORT2_CHANNELS_ROWS() : TRAINER_CHANNELS_ROWS()))
|
#define PORT_CHANNELS_ROWS(x) (x==0 ? PORT1_CHANNELS_ROWS() : (x==1 ? PORT2_CHANNELS_ROWS() : TRAINER_CHANNELS_ROWS()))
|
||||||
#define FAILSAFE_ROWS(x) ((g_model.moduleData[x].rfProtocol==RF_PROTO_X16 || g_model.moduleData[x].rfProtocol==RF_PROTO_LR12) ? (g_model.moduleData[x].failsafeMode==FAILSAFE_CUSTOM ? (uint8_t)1 : (uint8_t)0) : HIDDEN_ROW)
|
#define FAILSAFE_ROWS(x) ((g_model.moduleData[x].rfProtocol==RF_PROTO_X16 || g_model.moduleData[x].rfProtocol==RF_PROTO_LR12) ? (g_model.moduleData[x].failsafeMode==FAILSAFE_CUSTOM ? (uint8_t)1 : (uint8_t)0) : HIDDEN_ROW)
|
||||||
#define MODEL_SETUP_MAX_LINES (1+ITEM_MODEL_SETUP_MAX)
|
#define MODEL_SETUP_MAX_LINES (1+ITEM_MODEL_SETUP_MAX)
|
||||||
#define POT_WARN_ITEMS() (((g_model.nPotsToWarn >> 6) == 2) ? NUM_POTS+1 : ((g_model.nPotsToWarn >> 6) == 1) ? NUM_POTS : 0)
|
#define POT_WARN_ITEMS() (g_model.nPotsToWarn ? NUM_POTS : 0)
|
||||||
|
|
||||||
bool CURSOR_ON_CELL = (m_posHorz >= 0);
|
bool CURSOR_ON_CELL = (m_posHorz >= 0);
|
||||||
MENU_TAB({ 0, 0, CASE_PCBTARANIS(0) 2, IF_PERSISTENT_TIMERS(0) 0, 0, 2, IF_PERSISTENT_TIMERS(0) 0, 0, 0, 1, 0, 0, 0, 0, 0, 7, POT_WARN_ITEMS(), NAVIGATION_LINE_BY_LINE|(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1), LABEL(InternalModule), 0, IF_PORT1_ON(1), IF_PORT1_ON(IS_D8_RX(0) ? (uint8_t)1 : (uint8_t)2), IF_PORT1_ON(FAILSAFE_ROWS(0)), LABEL(ExternalModule), (g_model.externalModule==MODULE_TYPE_XJT || IS_MODULE_DSM2(EXTERNAL_MODULE)) ? (uint8_t)1 : (uint8_t)0, PORT2_CHANNELS_ROWS(), (IS_MODULE_XJT(1) && IS_D8_RX(1)) ? (uint8_t)1 : (IS_MODULE_PPM(1) || IS_MODULE_XJT(1) || IS_MODULE_DSM2(1)) ? (uint8_t)2 : HIDDEN_ROW, IF_PORT2_XJT(FAILSAFE_ROWS(1)), LABEL(Trainer), 0, TRAINER_CHANNELS_ROWS(), IF_TRAINER_ON(2)});
|
MENU_TAB({ 0, 0, CASE_PCBTARANIS(0) 2, IF_PERSISTENT_TIMERS(0) 0, 0, 2, IF_PERSISTENT_TIMERS(0) 0, 0, 0, 1, 0, 0, 0, 0, 0, 7, POT_WARN_ITEMS(), NAVIGATION_LINE_BY_LINE|(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1), LABEL(InternalModule), 0, IF_PORT1_ON(1), IF_PORT1_ON(IS_D8_RX(0) ? (uint8_t)1 : (uint8_t)2), IF_PORT1_ON(FAILSAFE_ROWS(0)), LABEL(ExternalModule), (g_model.externalModule==MODULE_TYPE_XJT || IS_MODULE_DSM2(EXTERNAL_MODULE)) ? (uint8_t)1 : (uint8_t)0, PORT2_CHANNELS_ROWS(), (IS_MODULE_XJT(1) && IS_D8_RX(1)) ? (uint8_t)1 : (IS_MODULE_PPM(1) || IS_MODULE_XJT(1) || IS_MODULE_DSM2(1)) ? (uint8_t)2 : HIDDEN_ROW, IF_PORT2_XJT(FAILSAFE_ROWS(1)), LABEL(Trainer), 0, TRAINER_CHANNELS_ROWS(), IF_TRAINER_ON(2)});
|
||||||
|
@ -1219,13 +1219,30 @@ void menuModelSetup(uint8_t event)
|
||||||
{
|
{
|
||||||
lcd_putsLeft(y, "Pot Warning");
|
lcd_putsLeft(y, "Pot Warning");
|
||||||
uint8_t potMode = g_model.nPotsToWarn >> 6;
|
uint8_t potMode = g_model.nPotsToWarn >> 6;
|
||||||
|
if(attr) {
|
||||||
|
if (m_posHorz) s_editMode = 0;
|
||||||
|
if (!READ_ONLY() && m_posHorz) {
|
||||||
|
switch(event) {
|
||||||
|
case EVT_KEY_LONG(KEY_ENTER):
|
||||||
|
killEvents(event);
|
||||||
|
g_model.potPosition[m_posHorz-1] = getValue(MIXSRC_FIRST_POT+m_posHorz-1) >> 3;
|
||||||
|
AUDIO_WARNING1();
|
||||||
|
eeDirty(EE_MODEL);
|
||||||
|
break;
|
||||||
|
case EVT_KEY_BREAK(KEY_ENTER):
|
||||||
|
g_model.nPotsToWarn ^= (1 << (m_posHorz-1));
|
||||||
|
eeDirty(EE_MODEL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, PSTR("\004""Off\0""Auto""Man\0"), potMode, attr & ((m_posHorz == 0) ? attr : !INVERS));
|
lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, PSTR("\004""Off\0""Auto""Man\0"), potMode, attr & ((m_posHorz == 0) ? attr : !INVERS));
|
||||||
if (potMode)
|
if (potMode)
|
||||||
for (uint8_t i=0; i<NUM_POTS ; i++) {
|
for (uint8_t i=0; i<NUM_POTS ; i++) {
|
||||||
LcdFlags flags = ((m_posHorz==i+1) && attr) ? BLINK : 0;
|
LcdFlags flags = ((m_posHorz==i+1) && attr) ? BLINK : 0;
|
||||||
flags |= (g_model.nPotsToWarn & (1 << i)) ? INVERS : 0;
|
flags |= (!(g_model.nPotsToWarn & (1 << i))) ? INVERS : 0;
|
||||||
lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN+6*FW+i*2*FW, y, STR_VSRCRAW, NUM_STICKS+1+i, flags);
|
lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN+5*FW+i*3*FW, y, STR_VSRCRAW, NUM_STICKS+1+i, flags);
|
||||||
if (potMode == 2) lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+(14*FW+2), y, "<]", (m_posHorz == NUM_POTS+1 && !s_noHi) ? attr : 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attr && (m_posHorz == 0)) {
|
if (attr && (m_posHorz == 0)) {
|
||||||
|
@ -1233,19 +1250,6 @@ void menuModelSetup(uint8_t event)
|
||||||
g_model.nPotsToWarn = (g_model.nPotsToWarn & 0x3F) | ((potMode << 6) & 0xC0);
|
g_model.nPotsToWarn = (g_model.nPotsToWarn & 0x3F) | ((potMode << 6) & 0xC0);
|
||||||
eeDirty(EE_MODEL);
|
eeDirty(EE_MODEL);
|
||||||
}
|
}
|
||||||
else if (attr && (m_posHorz == NUM_POTS+1)) {
|
|
||||||
if ((potMode == 2) && (event == EVT_KEY_LONG(KEY_ENTER))) {
|
|
||||||
s_noHi = NO_HI_LEN;
|
|
||||||
killEvents(event);
|
|
||||||
g_model.potPosition[m_posHorz-1] = calibratedStick[NUM_STICKS+m_posHorz] >> 3;
|
|
||||||
AUDIO_WARNING1();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (attr) {
|
|
||||||
s_editMode = 0;
|
|
||||||
if (event == EVT_KEY_BREAK(KEY_ENTER))
|
|
||||||
g_model.nPotsToWarn ^= (1 << (m_posHorz-1));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2193,6 +2193,13 @@ void checkSwitches()
|
||||||
warn = true;
|
warn = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
perOut(e_perout_mode_inactive_phase, 0);
|
||||||
|
uint8_t potMode = g_model.nPotsToWarn >> 6;
|
||||||
|
if(potMode)
|
||||||
|
for (uint8_t i=0; i<NUM_POTS; i++)
|
||||||
|
if(!(g_model.nPotsToWarn & (1 << i)) && (abs(g_model.potPosition[i] - (getValue(MIXSRC_FIRST_POT+i) >> 3)) > 2))
|
||||||
|
warn = true;
|
||||||
#else
|
#else
|
||||||
for (uint8_t i=0; i<MAX_PSWITCH-2; i++)
|
for (uint8_t i=0; i<MAX_PSWITCH-2; i++)
|
||||||
if (!(g_model.nSwToWarn & (1<<(i-1))))
|
if (!(g_model.nSwToWarn & (1<<(i-1))))
|
||||||
|
@ -2203,7 +2210,7 @@ void checkSwitches()
|
||||||
if(!warn) return;
|
if(!warn) return;
|
||||||
|
|
||||||
// first - display warning
|
// first - display warning
|
||||||
if (last_bad_switches != switches_states) {
|
// if (last_bad_switches != switches_states) {
|
||||||
MESSAGE(STR_SWITCHWARN, NULL, STR_PRESSANYKEYTOSKIP, last_bad_switches == 0xff ? AU_SWITCH_ALERT : AU_NONE);
|
MESSAGE(STR_SWITCHWARN, NULL, STR_PRESSANYKEYTOSKIP, last_bad_switches == 0xff ? AU_SWITCH_ALERT : AU_NONE);
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
for (uint8_t i=0; i<NUM_SWITCHES-1; i++) {
|
for (uint8_t i=0; i<NUM_SWITCHES-1; i++) {
|
||||||
|
@ -2211,8 +2218,18 @@ void checkSwitches()
|
||||||
swstate_t mask = (0x03 << (i*2));
|
swstate_t mask = (0x03 << (i*2));
|
||||||
uint8_t attr = ((states & mask) == (switches_states & mask)) ? 0 : INVERS;
|
uint8_t attr = ((states & mask) == (switches_states & mask)) ? 0 : INVERS;
|
||||||
char c = "\300-\301"[(states & mask) >> (i*2)];
|
char c = "\300-\301"[(states & mask) >> (i*2)];
|
||||||
lcd_putcAtt(60+i*(2*FW+FW/2), 5*FH, 'A'+i, attr);
|
lcd_putcAtt(60+i*(2*FW+FW/2), 4*FH+3, 'A'+i, attr);
|
||||||
lcd_putcAtt(60+i*(2*FW+FW/2)+FW, 5*FH, c, attr);
|
lcd_putcAtt(60+i*(2*FW+FW/2)+FW, 4*FH+3, c, attr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (uint8_t i=0; i<NUM_POTS; i++) {
|
||||||
|
if (!(g_model.nPotsToWarn & (1 << i))) {
|
||||||
|
uint8_t flags = 0;
|
||||||
|
if (abs(g_model.potPosition[i] - (getValue(MIXSRC_FIRST_POT+i) >> 3)) > 2) {
|
||||||
|
lcd_putc(60+i*(5*FW)+2*FW+2, 6*FH-2, g_model.potPosition[i] > (getValue(MIXSRC_FIRST_POT+i) >> 3) ? 127 : 126);
|
||||||
|
flags = INVERS;
|
||||||
|
}
|
||||||
|
lcd_putsiAtt(60+i*(5*FW), 6*FH-2, STR_VSRCRAW, NUM_STICKS+1+i, flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -2226,7 +2243,7 @@ void checkSwitches()
|
||||||
#endif
|
#endif
|
||||||
lcdRefresh();
|
lcdRefresh();
|
||||||
last_bad_switches = switches_states;
|
last_bad_switches = switches_states;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (pwrCheck()==e_power_off || keyDown()) return; // Usb on or power off
|
if (pwrCheck()==e_power_off || keyDown()) return; // Usb on or power off
|
||||||
|
|
||||||
|
@ -4163,6 +4180,15 @@ void opentxClose()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
if((g_model.nPotsToWarn >> 6) == 1) {
|
||||||
|
for (uint8_t i=0; i<NUM_POTS ; i++)
|
||||||
|
if(!(g_model.nPotsToWarn & (1 << i)))
|
||||||
|
g_model.potPosition[i] = getValue(MIXSRC_FIRST_POT+i) >> 3;
|
||||||
|
eeDirty(EE_MODEL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
saveTimers();
|
saveTimers();
|
||||||
|
|
||||||
#if defined(PCBSKY9X)
|
#if defined(PCBSKY9X)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue