1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 16:25:16 +03:00

Issue #592 - 422bytes saved on 9x stock!!!

This commit is contained in:
Bertrand Songis 2014-02-06 15:57:59 +01:00
parent cae4d1ecf6
commit 38129abd43
12 changed files with 121 additions and 106 deletions

View file

@ -268,20 +268,37 @@ QString RawSwitch::toString()
QObject::tr("S21"), QObject::tr("S22"), QObject::tr("S23"), QObject::tr("S24"), QObject::tr("S25"), QObject::tr("S26") QObject::tr("S21"), QObject::tr("S22"), QObject::tr("S23"), QObject::tr("S24"), QObject::tr("S25"), QObject::tr("S26")
}; };
static const QString trimsSwitches[] = {
QObject::tr("RudTrim Left"), QObject::tr("RudTrim Right"),
QObject::tr("EleTrim Down"), QObject::tr("EleTrim Up"),
QObject::tr("ThrTrim Down"), QObject::tr("ThrTrim Up"),
QObject::tr("AilTrim Left"), QObject::tr("AilTrim Right")
};
static const QString rotaryEncoders[] = { static const QString rotaryEncoders[] = {
QObject::tr("REa"), QObject::tr("REb") QObject::tr("REa"), QObject::tr("REb")
}; };
if (index == 0) {
return QObject::tr("----");
}
else if (index < 0) {
return QString("!") + RawSwitch(type, -index).toString();
}
else {
index = index - 1;
switch(type) { switch(type) {
case SWITCH_TYPE_SWITCH: case SWITCH_TYPE_SWITCH:
if (IS_TARANIS(GetEepromInterface()->getBoard())) if (IS_TARANIS(GetEepromInterface()->getBoard()))
return index > 0 ? CHECK_IN_ARRAY(switchesX9D, index-1) : QString("!") + CHECK_IN_ARRAY(switchesX9D, -index-1); return CHECK_IN_ARRAY(switchesX9D, index);
else else
return index > 0 ? CHECK_IN_ARRAY(switches9X, index-1) : QString("!") + CHECK_IN_ARRAY(switches9X, -index-1); return CHECK_IN_ARRAY(switches9X, index);
case SWITCH_TYPE_VIRTUAL: case SWITCH_TYPE_VIRTUAL:
return index > 0 ? CHECK_IN_ARRAY(virtualSwitches, index-1) : QString("!") + CHECK_IN_ARRAY(virtualSwitches, -index-1); return CHECK_IN_ARRAY(virtualSwitches, index);
case SWITCH_TYPE_MULTIPOS_POT: case SWITCH_TYPE_MULTIPOS_POT:
return CHECK_IN_ARRAY(multiposPots, index); return CHECK_IN_ARRAY(multiposPots, index);
case SWITCH_TYPE_TRIM:
return CHECK_IN_ARRAY(trimsSwitches, index);
case SWITCH_TYPE_ROTARY_ENCODER: case SWITCH_TYPE_ROTARY_ENCODER:
return CHECK_IN_ARRAY(rotaryEncoders, index); return CHECK_IN_ARRAY(rotaryEncoders, index);
case SWITCH_TYPE_ON: case SWITCH_TYPE_ON:
@ -291,8 +308,7 @@ QString RawSwitch::toString()
default: default:
break; break;
} }
}
return QObject::tr("----");
} }
QString CurveReference::toString() QString CurveReference::toString()

View file

@ -318,6 +318,7 @@ enum RawSwitchType {
SWITCH_TYPE_SWITCH, SWITCH_TYPE_SWITCH,
SWITCH_TYPE_VIRTUAL, SWITCH_TYPE_VIRTUAL,
SWITCH_TYPE_MULTIPOS_POT, SWITCH_TYPE_MULTIPOS_POT,
SWITCH_TYPE_TRIM,
SWITCH_TYPE_ROTARY_ENCODER, SWITCH_TYPE_ROTARY_ENCODER,
SWITCH_TYPE_ON, SWITCH_TYPE_ON,
SWITCH_TYPE_OFF SWITCH_TYPE_OFF

View file

@ -427,13 +427,12 @@ void populateBacklightCB(QComboBox *b, const uint8_t value)
} }
} }
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, UseContext context) void populateAndSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, UseContext context)
{ {
RawSwitch item; RawSwitch item;
b->clear(); b->clear();
if (attr & POPULATE_AND_SWITCHES) {
if (GetEepromInterface()->getCapability(HasNegAndSwitches)) { if (GetEepromInterface()->getCapability(HasNegAndSwitches)) {
for (int i=-GetEepromInterface()->getCapability(CustomAndSwitches); i<=-1; i++) { for (int i=-GetEepromInterface()->getCapability(CustomAndSwitches); i<=-1; i++) {
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i); item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
@ -448,7 +447,9 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr,
} }
} }
} }
item = RawSwitch(SWITCH_TYPE_NONE); item = RawSwitch(SWITCH_TYPE_NONE);
if (GetEepromInterface()->isAvailable(item, context)) { if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue()); b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1); if (item == value) b->setCurrentIndex(b->count()-1);
@ -465,8 +466,13 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr,
b->addItem(item.toString(), item.toValue()); b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1); if (item == value) b->setCurrentIndex(b->count()-1);
} }
return; }
}
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, UseContext context)
{
RawSwitch item;
b->clear();
if (attr & POPULATE_ONOFF) { if (attr & POPULATE_ONOFF) {
item = RawSwitch(SWITCH_TYPE_OFF); item = RawSwitch(SWITCH_TYPE_OFF);
@ -484,6 +490,24 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr,
} }
} }
for (int i=-GetEepromInterface()->getCapability(RotaryEncoders); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_ROTARY_ENCODER, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=-8; i<0; i++) {
item = RawSwitch(SWITCH_TYPE_TRIM, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=-GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<0; i++) { for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_SWITCH, i); item = RawSwitch(SWITCH_TYPE_SWITCH, i);
if (GetEepromInterface()->isAvailable(item, context)) { if (GetEepromInterface()->isAvailable(item, context)) {
@ -506,13 +530,19 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr,
} }
} }
for (int i=0; i<GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) { for (int i=1; i<=GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) {
item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i); item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i);
b->addItem(item.toString(), item.toValue()); b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1); if (item == value) b->setCurrentIndex(b->count()-1);
} }
for (int i=0; i<GetEepromInterface()->getCapability(RotaryEncoders); i++) { for (int i=1; i<=8; i++) {
item = RawSwitch(SWITCH_TYPE_TRIM, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=1; i<=GetEepromInterface()->getCapability(RotaryEncoders); i++) {
item = RawSwitch(SWITCH_TYPE_ROTARY_ENCODER, i); item = RawSwitch(SWITCH_TYPE_ROTARY_ENCODER, i);
b->addItem(item.toString(), item.toValue()); b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1); if (item == value) b->setCurrentIndex(b->count()-1);

View file

@ -80,7 +80,7 @@ class CurveGroup : public QObject {
}; };
#define POPULATE_ONOFF 0x01 #define POPULATE_ONOFF 0x01
#define POPULATE_AND_SWITCHES 0x02 void populateAndSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0, UseContext context=DefaultContext);
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0, UseContext context=DefaultContext); void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0, UseContext context=DefaultContext);
void populatePhasesCB(QComboBox *b, int value); void populatePhasesCB(QComboBox *b, int value);
void populateTrimUseCB(QComboBox *b, unsigned int phase); void populateTrimUseCB(QComboBox *b, unsigned int phase);

View file

@ -1051,7 +1051,7 @@ void menuModelSetup(uint8_t event)
} }
else { else {
putsStrIdx(0*FW, y, STR_TIMER, k>=ITEM_MODEL_TIMER2 ? 2 : 1); putsStrIdx(0*FW, y, STR_TIMER, k>=ITEM_MODEL_TIMER2 ? 2 : 1);
putsTmrMode(MODEL_SETUP_2ND_COLUMN, y, timer->mode, m_posHorz==0 ? attr : 0); putsTimerMode(MODEL_SETUP_2ND_COLUMN, y, timer->mode, m_posHorz==0 ? attr : 0);
putsTime(MODEL_SETUP_2ND_COLUMN+5*FW-2+5*FWNUM+1, y, timer->start, m_posHorz==1 ? attr : 0, m_posHorz==2 ? attr : 0); putsTime(MODEL_SETUP_2ND_COLUMN+5*FW-2+5*FWNUM+1, y, timer->start, m_posHorz==1 ? attr : 0, m_posHorz==2 ? attr : 0);
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
if (attr && m_posHorz < 0) lcd_filled_rect(MODEL_SETUP_2ND_COLUMN, y, LCD_W-MODEL_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH, 8); if (attr && m_posHorz < 0) lcd_filled_rect(MODEL_SETUP_2ND_COLUMN, y, LCD_W-MODEL_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH, 8);
@ -1060,7 +1060,7 @@ void menuModelSetup(uint8_t event)
div_t qr = div(timer->start, 60); div_t qr = div(timer->start, 60);
switch (m_posHorz) { switch (m_posHorz) {
case 0: case 0:
CHECK_INCDEC_MODELVAR(event, timer->mode, -2*(NUM_PSWITCH+NUM_CSW), TMR_VAROFS-1+2*(NUM_PSWITCH+NUM_CSW)); CHECK_INCDEC_MODELVAR(event, timer->mode, SWSRC_FIRST, TMR_VAROFS+SWSRC_LAST-1/*--- which is OFF*/);
break; break;
case 1: case 1:
CHECK_INCDEC_MODELVAR_ZERO(event, qr.quot, 59); CHECK_INCDEC_MODELVAR_ZERO(event, qr.quot, 59);
@ -1840,7 +1840,7 @@ void menuModelFlightModesAll(uint8_t event)
} }
else { else {
putsSwitches((5+LEN_FP_NAME)*FW+FW/2, y, p->swtch, attr); putsSwitches((5+LEN_FP_NAME)*FW+FW/2, y, p->swtch, attr);
if (active) CHECK_INCDEC_MODELSWITCH(event, p->swtch, -NUM_SWITCH, NUM_SWITCH); if (active) CHECK_INCDEC_MODELSWITCH(event, p->swtch, SWSRC_FIRST, SWSRC_LAST);
} }
break; break;
@ -4298,7 +4298,7 @@ void menuModelCustomSwitchOne(uint8_t event)
case CSW_FIELD_ANDSW: case CSW_FIELD_ANDSW:
lcd_putsLeft(y, STR_AND_SWITCH); lcd_putsLeft(y, STR_AND_SWITCH);
putsSwitches(CSWONE_2ND_COLUMN, y, cs->andsw, attr); putsSwitches(CSWONE_2ND_COLUMN, y, cs->andsw, attr);
if (attr) CHECK_INCDEC_MODELVAR(event, cs->andsw, -NUM_SWITCH, NUM_SWITCH); if (attr) CHECK_INCDEC_MODELVAR(event, cs->andsw, -MAX_CSW_ANDSW, MAX_CSW_ANDSW);
break; break;
case CSW_FIELD_DURATION: case CSW_FIELD_DURATION:
lcd_putsLeft(y, STR_DURATION); lcd_putsLeft(y, STR_DURATION);
@ -4596,7 +4596,9 @@ void menuModelCustomSwitches(uint8_t event)
break; break;
case CSW_FIELD_ANDSW: case CSW_FIELD_ANDSW:
#if defined(CPUARM) #if defined(CPUARM)
CHECK_INCDEC_MODELSWITCH(event, cs->andsw, -MAX_CSW_ANDSW, MAX_CSW_ANDSW); INCDEC_SET_FLAG(INCDEC_SWITCH);
INCDEC_ENABLE_CHECK(isSwitchAvailableInCustomSwitches);
cs->andsw = CHECK_INCDEC_PARAM(event, cs->andsw, -MAX_CSW_ANDSW, MAX_CSW_ANDSW);
#else #else
CHECK_INCDEC_MODELVAR_ZERO(event, cs->andsw, MAX_CSW_ANDSW); CHECK_INCDEC_MODELVAR_ZERO(event, cs->andsw, MAX_CSW_ANDSW);
#endif #endif

View file

@ -228,18 +228,6 @@ int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, ui
#endif #endif
} }
} }
if (event == EVT_KEY_LONG(KEY_ENTER) && i_max > SWSRC_ON) {
s_editMode = !s_editMode;
if (newval > SWSRC_ON)
newval -= (NUM_SWITCH+1);
else if (newval > 0)
newval += (NUM_SWITCH+1);
else if (newval < SWSRC_OFF)
newval += (NUM_SWITCH+1);
else if (newval < 0)
newval -= (NUM_SWITCH+1);
}
} }
#endif #endif
@ -976,7 +964,7 @@ int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, LcdFlags attr, uint8_t
{ {
lcd_putsColumnLeft(x, y, STR_SWITCH); lcd_putsColumnLeft(x, y, STR_SWITCH);
putsSwitches(x, y, value, attr); putsSwitches(x, y, value, attr);
if (attr) CHECK_INCDEC_MODELSWITCH(event, value, -NUM_SWITCH, NUM_SWITCH); if (attr) CHECK_INCDEC_MODELSWITCH(event, value, SWSRC_FIRST, SWSRC_LAST);
return value; return value;
} }

View file

@ -343,7 +343,7 @@ void displayTimers()
if (g_model.timers[0].mode) { if (g_model.timers[0].mode) {
TimerState & timerState = timersStates[0]; TimerState & timerState = timersStates[0];
putsTime(TIMERS_X, TIMER1_Y, timerState.val, MIDSIZE|LEFT, MIDSIZE|LEFT); putsTime(TIMERS_X, TIMER1_Y, timerState.val, MIDSIZE|LEFT, MIDSIZE|LEFT);
putsTmrMode(TIMERS_X, TIMER1_Y-6, g_model.timers[0].mode, STRCONDENSED|SMLSIZE); putsTimerMode(TIMERS_X, TIMER1_Y-6, g_model.timers[0].mode, SMLSIZE);
if (g_model.timers[0].persistent) lcd_putcAtt(TIMERS_R, TIMER1_Y+1, 'P', SMLSIZE); if (g_model.timers[0].persistent) lcd_putcAtt(TIMERS_R, TIMER1_Y+1, 'P', SMLSIZE);
if (timerState.val < 0) { if (timerState.val < 0) {
if (BLINK_ON_PHASE) { if (BLINK_ON_PHASE) {
@ -356,7 +356,7 @@ void displayTimers()
if (g_model.timers[1].mode) { if (g_model.timers[1].mode) {
TimerState & timerState = timersStates[1]; TimerState & timerState = timersStates[1];
putsTime(TIMERS_X, TIMER2_Y, timerState.val, MIDSIZE|LEFT, MIDSIZE|LEFT); putsTime(TIMERS_X, TIMER2_Y, timerState.val, MIDSIZE|LEFT, MIDSIZE|LEFT);
putsTmrMode(TIMERS_X, TIMER2_Y-6, g_model.timers[1].mode, STRCONDENSED|SMLSIZE); putsTimerMode(TIMERS_X, TIMER2_Y-6, g_model.timers[1].mode, SMLSIZE);
if (g_model.timers[1].persistent) lcd_putcAtt(TIMERS_R, TIMER2_Y+1, 'P', SMLSIZE); if (g_model.timers[1].persistent) lcd_putcAtt(TIMERS_R, TIMER2_Y+1, 'P', SMLSIZE);
if (timerState.val < 0) { if (timerState.val < 0) {
if (BLINK_ON_PHASE) { if (BLINK_ON_PHASE) {
@ -373,7 +373,7 @@ void displayTimers()
TimerState & timerState = timersStates[0]; TimerState & timerState = timersStates[0];
uint8_t att = DBLSIZE | (timerState.val<0 ? BLINK|INVERS : 0); uint8_t att = DBLSIZE | (timerState.val<0 ? BLINK|INVERS : 0);
putsTime(12*FW+2+10*FWNUM-4, FH*2, timerState.val, att, att); putsTime(12*FW+2+10*FWNUM-4, FH*2, timerState.val, att, att);
putsTmrMode(timerState.val >= 0 ? 9*FW-FW/2+3 : 9*FW-FW/2-4, FH*3, g_model.timers[0].mode, STRCONDENSED); putsTimerMode(timerState.val >= 0 ? 9*FW-FW/2+3 : 9*FW-FW/2-4, FH*3, g_model.timers[0].mode);
} }
} }
#endif #endif
@ -818,7 +818,7 @@ void menuMainView(uint8_t event)
} }
else { // timer2 else { // timer2
putsTime(33+FW+2+10*FWNUM-4, FH*5, timersStates[1].val, DBLSIZE, DBLSIZE); putsTime(33+FW+2+10*FWNUM-4, FH*5, timersStates[1].val, DBLSIZE, DBLSIZE);
putsTmrMode(timersStates[1].val >= 0 ? 20-FW/2+5 : 20-FW/2-2, FH*6, g_model.timers[1].mode, STRCONDENSED); putsTimerMode(timersStates[1].val >= 0 ? 20-FW/2+5 : 20-FW/2-2, FH*6, g_model.timers[1].mode);
// lcd_outdezNAtt(33+11*FW, FH*6, s_timerVal_10ms[1], LEADING0, 2); // 1/100s // lcd_outdezNAtt(33+11*FW, FH*6, s_timerVal_10ms[1], LEADING0, 2); // 1/100s
} }
#endif // PCBTARANIS #endif // PCBTARANIS

View file

@ -1106,22 +1106,15 @@ void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att)
} }
#endif #endif
void putsTmrMode(xcoord_t x, uint8_t y, int8_t mode, LcdFlags att) void putsTimerMode(xcoord_t x, uint8_t y, int8_t mode, LcdFlags att)
{ {
if (mode < 0) { if (mode >= 0) {
mode = TMR_VAROFS - mode - 1; if (mode < TMR_VAROFS)
lcd_putcAtt(x-1*FW, y, '!', att); return lcd_putsiAtt(x, y, STR_VTMRMODES, mode, att);
else
mode -= (TMR_VAROFS-1);
} }
else if (mode < TMR_VAROFS) { putsSwitches(x, y, mode, att);
lcd_putsiAtt(x, y, STR_VTMRMODES, mode, att);
return;
}
if (mode >= TMR_VAROFS+NUM_PSWITCH+NUM_CSW) {
mode++;
}
putsSwitches(x, y, mode-(TMR_VAROFS-1), att);
} }
void putsTrimMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att) void putsTrimMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att)

View file

@ -83,7 +83,6 @@
/* no 0x80 here because of "GV"1 which is aligned LEFT */ /* no 0x80 here because of "GV"1 which is aligned LEFT */
/* no 0x10 here because of "MODEL"01 which uses LEADING0 */ /* no 0x10 here because of "MODEL"01 which uses LEADING0 */
#define BSS 0x20 #define BSS 0x20
#define STRCONDENSED 0x80 /* means that THRm will be displayed as THR */
#define ZCHAR 0x80 #define ZCHAR 0x80
/* lcd outdez flags */ /* lcd outdez flags */
@ -174,7 +173,7 @@ void putsFlightPhase(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0);
void putsCurveRef(xcoord_t x, uint8_t y, CurveRef &curve, LcdFlags att); void putsCurveRef(xcoord_t x, uint8_t y, CurveRef &curve, LcdFlags att);
#endif #endif
void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0); void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0);
void putsTmrMode(xcoord_t x, uint8_t y, int8_t mode, LcdFlags att); void putsTimerMode(xcoord_t x, uint8_t y, int8_t mode, LcdFlags att=0);
void putsTrimMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att); void putsTrimMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att);
#if defined(ROTARY_ENCODERS) #if defined(ROTARY_ENCODERS)
void putsRotaryEncoderMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att); void putsRotaryEncoderMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att);

View file

@ -671,7 +671,7 @@ PACK( union u_int8int16_t {
#if defined(CPUARM) #if defined(CPUARM)
#define MAX_CSW_DURATION 120 /*60s*/ #define MAX_CSW_DURATION 120 /*60s*/
#define MAX_CSW_DELAY 120 /*60s*/ #define MAX_CSW_DELAY 120 /*60s*/
#define MAX_CSW_ANDSW NUM_SWITCH #define MAX_CSW_ANDSW SWSRC_LAST
typedef int16_t csw_telemetry_value_t; typedef int16_t csw_telemetry_value_t;
PACK(typedef struct t_CustomSwData { // Custom Switches data PACK(typedef struct t_CustomSwData { // Custom Switches data
int16_t v1; int16_t v1;

View file

@ -3885,34 +3885,25 @@ void doMixerCalculations()
timerState->sum = 0; timerState->sum = 0;
} }
uint8_t atm = (tm >= 0 ? tm : TMR_VAROFS-tm-1);
// value for time described in timer->mode // value for time described in timer->mode
// OFFABSTHsTH%THt // OFFABSTHsTH%THt
if (atm == TMRMODE_THR_REL) { if (tm == TMRMODE_THR_REL) {
timerState->cnt++; timerState->cnt++;
timerState->sum+=val; timerState->sum+=val;
} }
if (atm>=(TMR_VAROFS+NUM_SWITCH)){ // toggeled switch
if(!(timerState->toggled | timerState->sum | timerState->cnt | timerState->lastPos)) { timerState->lastPos = tm < 0; timerState->sum = 1; } // if initializing then init the lastPos
uint8_t swPos = getSwitch(tm>0 ? tm-(TMR_VAROFS+NUM_SWITCH-1) : tm+NUM_SWITCH);
if (swPos && !timerState->lastPos) timerState->toggled = !timerState->toggled; // if switch is flipped first time -> change counter state
timerState->lastPos = swPos;
}
if ((timerState->val_10ms += tick10ms) >= 100) { if ((timerState->val_10ms += tick10ms) >= 100) {
timerState->val_10ms -= 100 ; timerState->val_10ms -= 100 ;
int16_t newTimerVal = timerState->val; int16_t newTimerVal = timerState->val;
if (tv) newTimerVal = tv - newTimerVal; if (tv) newTimerVal = tv - newTimerVal;
if (atm==TMRMODE_ABS) { if (tm == TMRMODE_ABS) {
newTimerVal++; newTimerVal++;
} }
else if (atm==TMRMODE_THR) { else if (tm == TMRMODE_THR) {
if (val) newTimerVal++; if (val) newTimerVal++;
} }
else if (atm==TMRMODE_THR_REL) { else if (tm == TMRMODE_THR_REL) {
// @@@ open.20.fsguruh: why so complicated? we have already a s_sum field; use it for the half seconds (not showable) as well // @@@ open.20.fsguruh: why so complicated? we have already a s_sum field; use it for the half seconds (not showable) as well
// check for s_cnt[i]==0 is not needed because we are shure it is at least 1 // check for s_cnt[i]==0 is not needed because we are shure it is at least 1
#if defined(ACCURAT_THROTTLE_TIMER) #if defined(ACCURAT_THROTTLE_TIMER)
@ -3928,19 +3919,17 @@ void doMixerCalculations()
#endif #endif
timerState->cnt=0; timerState->cnt=0;
} }
else if (atm==TMRMODE_THR_TRG) { else if (tm == TMRMODE_THR_TRG) {
if (val || newTimerVal > 0) if (val || newTimerVal > 0)
newTimerVal++; newTimerVal++;
} }
else { else {
if (atm<(TMR_VAROFS+NUM_SWITCH)) if (tm > 0) tm -= (TMR_VAROFS-1);
timerState->toggled = tm>0 ? getSwitch(tm-(TMR_VAROFS-1)) : !getSwitch(-tm); // normal switch if (getSwitch(tm))
if (timerState->toggled)
newTimerVal++; newTimerVal++;
} }
switch(timerState->state) switch (timerState->state) {
{
case TMR_RUNNING: case TMR_RUNNING:
if (tv && newTimerVal>=(int16_t)tv) { if (tv && newTimerVal>=(int16_t)tv) {
AUDIO_TIMER_00(g_model.timers[i].countdownBeep); AUDIO_TIMER_00(g_model.timers[i].countdownBeep);

View file

@ -397,7 +397,6 @@ enum EnumKeys {
#define NUM_PSWITCH (SWSRC_LAST_SWITCH-SWSRC_FIRST_SWITCH+1) #define NUM_PSWITCH (SWSRC_LAST_SWITCH-SWSRC_FIRST_SWITCH+1)
#define NUM_POTSSW (NUM_XPOTS*6) #define NUM_POTSSW (NUM_XPOTS*6)
#define NUM_SWITCH (NUM_PSWITCH+NUM_CSW+NUM_POTSSW)
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
#define KEY_RIGHT KEY_PLUS #define KEY_RIGHT KEY_PLUS
@ -946,10 +945,8 @@ extern uint16_t s_timeCumThr;
extern uint16_t s_timeCum16ThrP; extern uint16_t s_timeCum16ThrP;
struct TimerState { struct TimerState {
uint8_t lastPos;
uint16_t cnt; uint16_t cnt;
uint16_t sum; uint16_t sum;
uint8_t toggled;
uint8_t state; uint8_t state;
int16_t val; int16_t val;
uint8_t val_10ms; uint8_t val_10ms;