mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 09:15:38 +03:00
Fixes #1646
This commit is contained in:
parent
adacee2060
commit
c2166c8a67
2 changed files with 37 additions and 37 deletions
|
@ -4431,6 +4431,22 @@ enum LogicalSwitchFields {
|
||||||
#define CHECK_INCDEC_PARAM(event, var, min, max) checkIncDec(event, var, min, max, incdecFlag)
|
#define CHECK_INCDEC_PARAM(event, var, min, max) checkIncDec(event, var, min, max, incdecFlag)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CPUARM)
|
||||||
|
void putsEdgeDelayParam(coord_t x, coord_t y, LogicalSwitchData *cs, uint8_t lattr, uint8_t rattr)
|
||||||
|
{
|
||||||
|
lcd_putc(x-4, y, '[');
|
||||||
|
lcd_outdezAtt(x, y, lswTimerValue(cs->v2), LEFT|PREC1|lattr);
|
||||||
|
lcd_putc(lcdLastPos, y, ':');
|
||||||
|
if (cs->v3 < 0)
|
||||||
|
lcd_putsAtt(lcdLastPos+3, y, "<<", rattr);
|
||||||
|
else if (cs->v3 == 0)
|
||||||
|
lcd_putsAtt(lcdLastPos+3, y, "--", rattr);
|
||||||
|
else
|
||||||
|
lcd_outdezAtt(lcdLastPos+3, y, lswTimerValue(cs->v2+cs->v3), LEFT|PREC1|rattr);
|
||||||
|
lcd_putc(lcdLastPos, y, ']');
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CPUARM) && LCD_W < 212
|
#if defined(CPUARM) && LCD_W < 212
|
||||||
|
|
||||||
#define CSWONE_2ND_COLUMN (11*FW)
|
#define CSWONE_2ND_COLUMN (11*FW)
|
||||||
|
@ -4512,17 +4528,10 @@ void menuModelLogicalSwitchOne(uint8_t event)
|
||||||
v2_max = 99;
|
v2_max = 99;
|
||||||
}
|
}
|
||||||
else if (cstate == LS_FAMILY_STAY) {
|
else if (cstate == LS_FAMILY_STAY) {
|
||||||
lcd_putc(CSWONE_2ND_COLUMN-4, y, '[');
|
putsEdgeDelayParam(CSWONE_2ND_COLUMN, y, cs, m_posHorz==0 ? attr : 0, m_posHorz==1 ? attr : 0);
|
||||||
lcd_outdezAtt(CSWONE_2ND_COLUMN, y, lswTimerValue(cs->v2), LEFT|PREC1|(m_posHorz==0 ? attr : 0));
|
|
||||||
lcd_putc(lcdLastPos, y, ':');
|
|
||||||
if (cs->v3 == 0)
|
|
||||||
lcd_putsAtt(lcdLastPos+3, y, "--", (m_posHorz==1 ? attr : 0));
|
|
||||||
else
|
|
||||||
lcd_outdezAtt(lcdLastPos+3, y, lswTimerValue(cs->v2+cs->v3), LEFT|PREC1|(m_posHorz==1 ? attr : 0));
|
|
||||||
lcd_putc(lcdLastPos, y, ']');
|
|
||||||
if (s_editMode <= 0) continue;
|
if (s_editMode <= 0) continue;
|
||||||
if (attr && m_posHorz==1) {
|
if (attr && m_posHorz==1) {
|
||||||
CHECK_INCDEC_MODELVAR(event, cs->v3, 0, 222 - cs->v2);
|
CHECK_INCDEC_MODELVAR(event, cs->v3, -1, 222 - cs->v2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
v2_min = -129; v2_max = 122;
|
v2_min = -129; v2_max = 122;
|
||||||
|
@ -4635,14 +4644,7 @@ void menuModelLogicalSwitches(uint8_t event)
|
||||||
}
|
}
|
||||||
else if (cstate == LS_FAMILY_STAY) {
|
else if (cstate == LS_FAMILY_STAY) {
|
||||||
putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0);
|
putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0);
|
||||||
lcd_putc(CSW_3RD_COLUMN-4, y, '[');
|
putsEdgeDelayParam(CSW_3RD_COLUMN, y, cs, 0, 0);
|
||||||
lcd_outdezAtt(CSW_3RD_COLUMN, y, lswTimerValue(cs->v2), LEFT|PREC1);
|
|
||||||
lcd_putc(lcdLastPos, y, ':');
|
|
||||||
if (cs->v3 == 0)
|
|
||||||
lcd_puts(lcdLastPos+3, y, "--");
|
|
||||||
else
|
|
||||||
lcd_outdezAtt(lcdLastPos+3, y, lswTimerValue(cs->v2+cs->v3), LEFT|PREC1);
|
|
||||||
lcd_putc(lcdLastPos-1, y, ']');
|
|
||||||
}
|
}
|
||||||
else if (cstate == LS_FAMILY_TIMER) {
|
else if (cstate == LS_FAMILY_TIMER) {
|
||||||
lcd_outdezAtt(CSW_2ND_COLUMN, y, cs->v1+1, LEFT);
|
lcd_outdezAtt(CSW_2ND_COLUMN, y, cs->v1+1, LEFT);
|
||||||
|
@ -4753,7 +4755,7 @@ void menuModelLogicalSwitches(uint8_t event)
|
||||||
uint8_t cstate = lswFamily(cs->func);
|
uint8_t cstate = lswFamily(cs->func);
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
int16_t v1_val=cs->v1, v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM;
|
int16_t v1_val=cs->v1, v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM;
|
||||||
int16_t v3_min=0, v3_max=100;
|
int16_t v3_min=-1, v3_max=100;
|
||||||
#else
|
#else
|
||||||
int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM;
|
int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM;
|
||||||
#define v1_val cs->v1
|
#define v1_val cs->v1
|
||||||
|
@ -4770,14 +4772,7 @@ void menuModelLogicalSwitches(uint8_t event)
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
else if (cstate == LS_FAMILY_STAY) {
|
else if (cstate == LS_FAMILY_STAY) {
|
||||||
putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1);
|
putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1);
|
||||||
lcd_putc(CSW_3RD_COLUMN-4, y, '[');
|
putsEdgeDelayParam(CSW_3RD_COLUMN, y, cs, attr2, horz==LS_FIELD_V3 ? attr : 0);
|
||||||
lcd_outdezAtt(CSW_3RD_COLUMN, y, lswTimerValue(cs->v2), LEFT|PREC1|attr2);
|
|
||||||
lcd_putc(lcdLastPos, y, ':');
|
|
||||||
if (cs->v3 == 0)
|
|
||||||
lcd_putsAtt(lcdLastPos+3, y, "--", (horz==LS_FIELD_V3 ? attr : 0));
|
|
||||||
else
|
|
||||||
lcd_outdezAtt(lcdLastPos+3, y, lswTimerValue(cs->v2+cs->v3), LEFT|PREC1|(horz==LS_FIELD_V3 ? attr : 0));
|
|
||||||
lcd_putc(lcdLastPos, y, ']');
|
|
||||||
v1_min = SWSRC_FIRST_IN_LOGICAL_SWITCHES; v1_max = SWSRC_LAST_IN_LOGICAL_SWITCHES;
|
v1_min = SWSRC_FIRST_IN_LOGICAL_SWITCHES; v1_max = SWSRC_LAST_IN_LOGICAL_SWITCHES;
|
||||||
v2_min=-129; v2_max = 122;
|
v2_min=-129; v2_max = 122;
|
||||||
v3_max = 222 - cs->v2;
|
v3_max = 222 - cs->v2;
|
||||||
|
|
|
@ -191,6 +191,16 @@ getvalue_t getValueForLogicalSwitch(uint8_t i)
|
||||||
#define getValueForLogicalSwitch(i) getValue(i)
|
#define getValueForLogicalSwitch(i) getValue(i)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
PACK(typedef struct {
|
||||||
|
uint8_t state;
|
||||||
|
uint8_t last;
|
||||||
|
}) ls_sticky_struct;
|
||||||
|
|
||||||
|
PACK(typedef struct {
|
||||||
|
uint16_t state:1;
|
||||||
|
uint16_t duration:15;
|
||||||
|
}) ls_stay_struct;
|
||||||
|
|
||||||
bool getLogicalSwitch(uint8_t idx)
|
bool getLogicalSwitch(uint8_t idx)
|
||||||
{
|
{
|
||||||
LogicalSwitchData * ls = lswAddress(idx);
|
LogicalSwitchData * ls = lswAddress(idx);
|
||||||
|
@ -379,6 +389,10 @@ DurationAndDelayProcessing:
|
||||||
|
|
||||||
if (context.timerState == SWITCH_ENABLE) {
|
if (context.timerState == SWITCH_ENABLE) {
|
||||||
result = (ls->duration==0 || context.timer>0); // return false after duration timer runs out
|
result = (ls->duration==0 || context.timer>0); // return false after duration timer runs out
|
||||||
|
if (!result && ls->func == LS_FUNC_STICKY) {
|
||||||
|
ls_sticky_struct & lastValue = (ls_sticky_struct &)context.lastValue;
|
||||||
|
lastValue.state = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (context.timerState == SWITCH_ENABLE && ls->duration > 0 && context.timer > 0) {
|
else if (context.timerState == SWITCH_ENABLE && ls->duration > 0 && context.timer > 0) {
|
||||||
|
@ -733,10 +747,6 @@ void logicalSwitchesTimerTick()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ls->func == LS_FUNC_STICKY) {
|
else if (ls->func == LS_FUNC_STICKY) {
|
||||||
PACK(typedef struct {
|
|
||||||
uint8_t state;
|
|
||||||
uint8_t last;
|
|
||||||
}) ls_sticky_struct;
|
|
||||||
ls_sticky_struct & lastValue = (ls_sticky_struct &)LS_LAST_VALUE(fm, i);
|
ls_sticky_struct & lastValue = (ls_sticky_struct &)LS_LAST_VALUE(fm, i);
|
||||||
bool before = lastValue.last & 0x01;
|
bool before = lastValue.last & 0x01;
|
||||||
if (lastValue.state) {
|
if (lastValue.state) {
|
||||||
|
@ -760,22 +770,17 @@ void logicalSwitchesTimerTick()
|
||||||
}
|
}
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
else if (ls->func == LS_FUNC_STAY) {
|
else if (ls->func == LS_FUNC_STAY) {
|
||||||
PACK(typedef struct {
|
|
||||||
uint16_t state:1;
|
|
||||||
uint16_t duration:15;
|
|
||||||
}) ls_stay_struct;
|
|
||||||
|
|
||||||
ls_stay_struct & lastValue = (ls_stay_struct &)LS_LAST_VALUE(fm, i);
|
ls_stay_struct & lastValue = (ls_stay_struct &)LS_LAST_VALUE(fm, i);
|
||||||
lastValue.state = false;
|
lastValue.state = false;
|
||||||
bool state = getSwitch(ls->v1);
|
bool state = getSwitch(ls->v1);
|
||||||
if (state) {
|
if (state) {
|
||||||
if (ls->v3 == 0 && lastValue.duration == lswTimerValue(ls->v2))
|
if (ls->v3 == -1 && lastValue.duration == lswTimerValue(ls->v2))
|
||||||
lastValue.state = true;
|
lastValue.state = true;
|
||||||
if (lastValue.duration < 1000)
|
if (lastValue.duration < 1000)
|
||||||
lastValue.duration++;
|
lastValue.duration++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (lastValue.duration > lswTimerValue(ls->v2) && lastValue.duration <= lswTimerValue(ls->v2+ls->v3))
|
if (lastValue.duration > lswTimerValue(ls->v2) && (ls->v3 == 0 || lastValue.duration <= lswTimerValue(ls->v2+ls->v3)))
|
||||||
lastValue.state = true;
|
lastValue.state = true;
|
||||||
lastValue.duration = 0;
|
lastValue.duration = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue