AutoSwitch function in Function Switches, Mixer and Expo.

Small flash saving
This commit is contained in:
bsongis
2012-05-07 07:28:14 +00:00
parent 8f2a091fbe
commit e27629ca98
+24 -31
View File
@@ -1304,13 +1304,28 @@ enum ExposFields {
EXPO_FIELD_WHEN EXPO_FIELD_WHEN
}; };
inline void editExpoVals(uint8_t event, uint8_t which, bool edit, uint8_t y, uint8_t idt) #ifdef FLIGHT_PHASES
#define EXPO_ONE_LINES_COUNT 6
#else
#define EXPO_ONE_LINES_COUNT 5
#endif
void menuProcExpoOne(uint8_t event)
{ {
ExpoData *ed = expoaddress(s_currIdx);
putsChnRaw(7*FW+FW/2,0,ed->chn+1,0);
SIMPLE_SUBMENU(STR_MENUDREXPO, EXPO_ONE_LINES_COUNT);
int8_t sub = m_posVert;
uint8_t y = FH;
for (uint8_t i=0; i<EXPO_ONE_LINES_COUNT+1; i++) {
lcd_putsiAtt(0, y, STR_EXPLABELS, i, 0);
uint8_t edit = (sub==i);
uint8_t invBlk = edit ? INVERS : 0; uint8_t invBlk = edit ? INVERS : 0;
switch(i)
ExpoData *ed = expoaddress(idt); // TODO volatile
switch(which)
{ {
case EXPO_FIELD_WIDTH: case EXPO_FIELD_WIDTH:
{ {
@@ -1347,35 +1362,13 @@ inline void editExpoVals(uint8_t event, uint8_t which, bool edit, uint8_t y, uin
#endif #endif
case EXPO_FIELD_SWITCH: case EXPO_FIELD_SWITCH:
putsSwitches(6*FW+5, y, ed->swtch, invBlk); putsSwitches(6*FW+5, y, ed->swtch, invBlk);
if(edit) CHECK_INCDEC_MODELVAR(event, ed->swtch, -MAX_DRSWITCH, MAX_DRSWITCH); if(edit) CHECK_INCDEC_MODELSWITCH(event, ed->swtch, -MAX_DRSWITCH, MAX_DRSWITCH);
break; break;
case EXPO_FIELD_WHEN: case EXPO_FIELD_WHEN:
lcd_putsiAtt(6*FW+5, y, STR_VWHEN, 3-ed->mode, invBlk); lcd_putsiAtt(6*FW+5, y, STR_VWHEN, 3-ed->mode, invBlk);
if(edit) ed->mode = 4 - checkIncDecModel(event, 4-ed->mode, 1, 3); if(edit) ed->mode = 4 - checkIncDecModel(event, 4-ed->mode, 1, 3);
break; break;
} }
}
#ifdef FLIGHT_PHASES
#define EXPO_ONE_LINES_COUNT 6
#else
#define EXPO_ONE_LINES_COUNT 5
#endif
void menuProcExpoOne(uint8_t event)
{
ExpoData *ed = expoaddress(s_currIdx);
putsChnRaw(7*FW+FW/2,0,ed->chn+1,0);
SIMPLE_SUBMENU(STR_MENUDREXPO, EXPO_ONE_LINES_COUNT);
int8_t sub = m_posVert;
uint8_t y = FH;
for (uint8_t i=0; i<EXPO_ONE_LINES_COUNT+1; i++) {
lcd_putsiAtt(0, y, STR_EXPLABELS, i, 0);
editExpoVals(event, i, sub==i, y, s_currIdx);
y+=FH; y+=FH;
} }
@@ -1466,7 +1459,7 @@ void menuProcMixOne(uint8_t event)
case MIX_FIELD_SWITCH: case MIX_FIELD_SWITCH:
lcd_puts( 2*FW,y,STR_SWITCH); lcd_puts( 2*FW,y,STR_SWITCH);
putsSwitches(10*FW, y,md2->swtch,attr); putsSwitches(10*FW, y,md2->swtch,attr);
if(attr) CHECK_INCDEC_MODELVAR( event, md2->swtch, -MAX_SWITCH, MAX_SWITCH); if(attr) CHECK_INCDEC_MODELSWITCH( event, md2->swtch, -MAX_SWITCH, MAX_SWITCH);
break; break;
#ifdef FLIGHT_PHASES #ifdef FLIGHT_PHASES
case MIX_FIELD_FLIGHT_PHASE: case MIX_FIELD_FLIGHT_PHASE:
@@ -2067,12 +2060,12 @@ void menuProcFunctionSwitches(uint8_t event)
FuncSwData *sd = &g_model.funcSw[k]; FuncSwData *sd = &g_model.funcSw[k];
for (uint8_t j=0; j<3; j++) { for (uint8_t j=0; j<3; j++) {
uint8_t attr = ((sub==k && m_posHorz==j) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); uint8_t attr = ((sub==k && m_posHorz==j) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
uint8_t active = (attr && (s_editMode>0 || p1valdiff)); uint8_t active = (attr && (s_editMode>0 || p1valdiff || !sd->swtch));
switch (j) { switch (j) {
case 0: case 0:
putsSwitches(3, y, sd->swtch, attr); putsSwitches(3, y, sd->swtch, attr);
if (active) { if (active) {
CHECK_INCDEC_MODELVAR( event, sd->swtch, SWITCH_OFF-MAX_SWITCH, SWITCH_ON+MAX_SWITCH); CHECK_INCDEC_MODELSWITCH( event, sd->swtch, SWITCH_OFF-MAX_SWITCH, SWITCH_ON+MAX_SWITCH);
} }
break; break;
case 1: case 1: