Issue #592 - 422bytes saved on 9x stock!!!
This commit is contained in:
@@ -1051,7 +1051,7 @@ void menuModelSetup(uint8_t event)
|
||||
}
|
||||
else {
|
||||
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);
|
||||
#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);
|
||||
@@ -1060,7 +1060,7 @@ void menuModelSetup(uint8_t event)
|
||||
div_t qr = div(timer->start, 60);
|
||||
switch (m_posHorz) {
|
||||
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;
|
||||
case 1:
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, qr.quot, 59);
|
||||
@@ -1840,7 +1840,7 @@ void menuModelFlightModesAll(uint8_t event)
|
||||
}
|
||||
else {
|
||||
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;
|
||||
|
||||
@@ -4298,7 +4298,7 @@ void menuModelCustomSwitchOne(uint8_t event)
|
||||
case CSW_FIELD_ANDSW:
|
||||
lcd_putsLeft(y, STR_AND_SWITCH);
|
||||
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;
|
||||
case CSW_FIELD_DURATION:
|
||||
lcd_putsLeft(y, STR_DURATION);
|
||||
@@ -4596,7 +4596,9 @@ void menuModelCustomSwitches(uint8_t event)
|
||||
break;
|
||||
case CSW_FIELD_ANDSW:
|
||||
#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
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, cs->andsw, MAX_CSW_ANDSW);
|
||||
#endif
|
||||
|
||||
+1
-13
@@ -228,18 +228,6 @@ int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, ui
|
||||
#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
|
||||
|
||||
@@ -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);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -343,7 +343,7 @@ void displayTimers()
|
||||
if (g_model.timers[0].mode) {
|
||||
TimerState & timerState = timersStates[0];
|
||||
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 (timerState.val < 0) {
|
||||
if (BLINK_ON_PHASE) {
|
||||
@@ -356,7 +356,7 @@ void displayTimers()
|
||||
if (g_model.timers[1].mode) {
|
||||
TimerState & timerState = timersStates[1];
|
||||
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 (timerState.val < 0) {
|
||||
if (BLINK_ON_PHASE) {
|
||||
@@ -373,7 +373,7 @@ void displayTimers()
|
||||
TimerState & timerState = timersStates[0];
|
||||
uint8_t att = DBLSIZE | (timerState.val<0 ? BLINK|INVERS : 0);
|
||||
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
|
||||
@@ -818,7 +818,7 @@ void menuMainView(uint8_t event)
|
||||
}
|
||||
else { // timer2
|
||||
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
|
||||
}
|
||||
#endif // PCBTARANIS
|
||||
|
||||
+7
-14
@@ -1106,22 +1106,15 @@ void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att)
|
||||
}
|
||||
#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) {
|
||||
mode = TMR_VAROFS - mode - 1;
|
||||
lcd_putcAtt(x-1*FW, y, '!', att);
|
||||
if (mode >= 0) {
|
||||
if (mode < TMR_VAROFS)
|
||||
return lcd_putsiAtt(x, y, STR_VTMRMODES, mode, att);
|
||||
else
|
||||
mode -= (TMR_VAROFS-1);
|
||||
}
|
||||
else if (mode < TMR_VAROFS) {
|
||||
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);
|
||||
putsSwitches(x, y, mode, att);
|
||||
}
|
||||
|
||||
void putsTrimMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att)
|
||||
|
||||
+1
-2
@@ -83,7 +83,6 @@
|
||||
/* no 0x80 here because of "GV"1 which is aligned LEFT */
|
||||
/* no 0x10 here because of "MODEL"01 which uses LEADING0 */
|
||||
#define BSS 0x20
|
||||
#define STRCONDENSED 0x80 /* means that THRm will be displayed as THR */
|
||||
#define ZCHAR 0x80
|
||||
|
||||
/* 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);
|
||||
#endif
|
||||
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);
|
||||
#if defined(ROTARY_ENCODERS)
|
||||
void putsRotaryEncoderMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att);
|
||||
|
||||
@@ -671,7 +671,7 @@ PACK( union u_int8int16_t {
|
||||
#if defined(CPUARM)
|
||||
#define MAX_CSW_DURATION 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;
|
||||
PACK(typedef struct t_CustomSwData { // Custom Switches data
|
||||
int16_t v1;
|
||||
|
||||
+8
-19
@@ -3885,34 +3885,25 @@ void doMixerCalculations()
|
||||
timerState->sum = 0;
|
||||
}
|
||||
|
||||
uint8_t atm = (tm >= 0 ? tm : TMR_VAROFS-tm-1);
|
||||
|
||||
// value for time described in timer->mode
|
||||
// OFFABSTHsTH%THt
|
||||
if (atm == TMRMODE_THR_REL) {
|
||||
if (tm == TMRMODE_THR_REL) {
|
||||
timerState->cnt++;
|
||||
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) {
|
||||
timerState->val_10ms -= 100 ;
|
||||
int16_t newTimerVal = timerState->val;
|
||||
if (tv) newTimerVal = tv - newTimerVal;
|
||||
|
||||
if (atm==TMRMODE_ABS) {
|
||||
if (tm == TMRMODE_ABS) {
|
||||
newTimerVal++;
|
||||
}
|
||||
else if (atm==TMRMODE_THR) {
|
||||
else if (tm == TMRMODE_THR) {
|
||||
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
|
||||
// check for s_cnt[i]==0 is not needed because we are shure it is at least 1
|
||||
#if defined(ACCURAT_THROTTLE_TIMER)
|
||||
@@ -3928,19 +3919,17 @@ void doMixerCalculations()
|
||||
#endif
|
||||
timerState->cnt=0;
|
||||
}
|
||||
else if (atm==TMRMODE_THR_TRG) {
|
||||
else if (tm == TMRMODE_THR_TRG) {
|
||||
if (val || newTimerVal > 0)
|
||||
newTimerVal++;
|
||||
}
|
||||
else {
|
||||
if (atm<(TMR_VAROFS+NUM_SWITCH))
|
||||
timerState->toggled = tm>0 ? getSwitch(tm-(TMR_VAROFS-1)) : !getSwitch(-tm); // normal switch
|
||||
if (timerState->toggled)
|
||||
if (tm > 0) tm -= (TMR_VAROFS-1);
|
||||
if (getSwitch(tm))
|
||||
newTimerVal++;
|
||||
}
|
||||
|
||||
switch(timerState->state)
|
||||
{
|
||||
switch (timerState->state) {
|
||||
case TMR_RUNNING:
|
||||
if (tv && newTimerVal>=(int16_t)tv) {
|
||||
AUDIO_TIMER_00(g_model.timers[i].countdownBeep);
|
||||
|
||||
@@ -397,7 +397,6 @@ enum EnumKeys {
|
||||
|
||||
#define NUM_PSWITCH (SWSRC_LAST_SWITCH-SWSRC_FIRST_SWITCH+1)
|
||||
#define NUM_POTSSW (NUM_XPOTS*6)
|
||||
#define NUM_SWITCH (NUM_PSWITCH+NUM_CSW+NUM_POTSSW)
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#define KEY_RIGHT KEY_PLUS
|
||||
@@ -946,10 +945,8 @@ extern uint16_t s_timeCumThr;
|
||||
extern uint16_t s_timeCum16ThrP;
|
||||
|
||||
struct TimerState {
|
||||
uint8_t lastPos;
|
||||
uint16_t cnt;
|
||||
uint16_t sum;
|
||||
uint8_t toggled;
|
||||
uint8_t state;
|
||||
int16_t val;
|
||||
uint8_t val_10ms;
|
||||
|
||||
Reference in New Issue
Block a user