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

Throttle warning screen reworking

This commit is contained in:
Bertrand Songis 2019-06-14 09:18:27 +02:00
parent 998e8b6d3d
commit ce6bf053b8
No known key found for this signature in database
GPG key ID: F189F79290FEC50F
5 changed files with 31 additions and 31 deletions

View file

@ -632,7 +632,7 @@ void menuRadioSetup(event_t event)
else if (reusableBuffer.generalSettings.stickMode != g_eeGeneral.stickMode) { else if (reusableBuffer.generalSettings.stickMode != g_eeGeneral.stickMode) {
pausePulses(); pausePulses();
g_eeGeneral.stickMode = reusableBuffer.generalSettings.stickMode; g_eeGeneral.stickMode = reusableBuffer.generalSettings.stickMode;
checkTHR(); checkThrottleStick();
resumePulses(); resumePulses();
waitKeysReleased(); waitKeysReleased();
} }

View file

@ -500,7 +500,7 @@ void menuRadioSetup(event_t event)
else if (reusableBuffer.generalSettings.stickMode != g_eeGeneral.stickMode) { else if (reusableBuffer.generalSettings.stickMode != g_eeGeneral.stickMode) {
pausePulses(); pausePulses();
g_eeGeneral.stickMode = reusableBuffer.generalSettings.stickMode; g_eeGeneral.stickMode = reusableBuffer.generalSettings.stickMode;
checkTHR(); checkThrottleStick();
resumePulses(); resumePulses();
waitKeysReleased(); waitKeysReleased();
} }

View file

@ -480,7 +480,7 @@ bool menuRadioSetup(event_t event)
else if (reusableBuffer.generalSettings.stickMode != g_eeGeneral.stickMode) { else if (reusableBuffer.generalSettings.stickMode != g_eeGeneral.stickMode) {
pausePulses(); pausePulses();
g_eeGeneral.stickMode = reusableBuffer.generalSettings.stickMode; g_eeGeneral.stickMode = reusableBuffer.generalSettings.stickMode;
checkTHR(); checkThrottleStick();
resumePulses(); resumePulses();
waitKeysReleased(); waitKeysReleased();
} }

View file

@ -57,9 +57,14 @@ const uint8_t bchout_ar[] = {
0x87, 0x8D, 0x93, 0x9C, 0xB1, 0xB4, 0x87, 0x8D, 0x93, 0x9C, 0xB1, 0xB4,
0xC6, 0xC9, 0xD2, 0xD8, 0xE1, 0xE4 }; 0xC6, 0xC9, 0xD2, 0xD8, 0xE1, 0xE4 };
uint8_t channel_order(uint8_t setup, uint8_t x)
{
return ((*(bchout_ar + setup) >> (6 - (x - 1) * 2)) & 3) + 1;
}
uint8_t channel_order(uint8_t x) uint8_t channel_order(uint8_t x)
{ {
return ( ((*(bchout_ar + g_eeGeneral.templateSetup) >> (6-(x-1) * 2)) & 3 ) + 1 ); return channel_order(g_eeGeneral.templateSetup, x);
} }
/* /*
@ -867,9 +872,10 @@ void checkAll()
checkLowEEPROM(); checkLowEEPROM();
#endif #endif
if (g_eeGeneral.chkSum == evalChkSum()) { // we don't check the throttle stick if the radio is not calibrated
checkTHR(); if (g_eeGeneral.chkSum == evalChkSum())
} checkThrottleStick();
checkSwitches(); checkSwitches();
checkFailsafe(); checkFailsafe();
checkRSSIAlarmsDisabled(); checkRSSIAlarmsDisabled();
@ -906,28 +912,32 @@ void checkLowEEPROM()
} }
#endif #endif
void checkTHR() bool isThrottleWarningAlertNeeded()
{ {
uint8_t thrchn = ((g_model.thrTraceSrc==0) || (g_model.thrTraceSrc>NUM_POTS+NUM_SLIDERS)) ? THR_STICK : g_model.thrTraceSrc+NUM_STICKS-1; if (g_model.disableThrottleWarning) {
return false;
}
// throttle channel is either the stick according stick mode (already handled in evalInputs) // throttle channel is either the stick according stick mode (already handled in evalInputs)
// or P1 to P3; // or P1 to P3;
// in case an output channel is choosen as throttle source (thrTraceSrc>NUM_POTS+NUM_SLIDERS) we assume the throttle stick is the input // in case an output channel is choosen as throttle source (thrTraceSrc>NUM_POTS+NUM_SLIDERS) we assume the throttle stick is the input
// no other information available at the moment, and good enough to my option (otherwise too much exceptions...) // no other information available at the moment, and good enough to my option (otherwise too much exceptions...)
uint8_t thrchn = ((g_model.thrTraceSrc==0) || (g_model.thrTraceSrc>NUM_POTS+NUM_SLIDERS)) ? THR_STICK : g_model.thrTraceSrc+NUM_STICKS-1;
if (g_model.disableThrottleWarning) {
return;
}
GET_ADC_IF_MIXER_NOT_RUNNING(); GET_ADC_IF_MIXER_NOT_RUNNING();
evalInputs(e_perout_mode_notrainer); // let do evalInputs do the job evalInputs(e_perout_mode_notrainer); // let do evalInputs do the job
int16_t v = calibratedAnalogs[thrchn]; int16_t v = calibratedAnalogs[thrchn];
if (g_model.thrTraceSrc && g_model.throttleReversed) { //TODO : proper review of THR source definition and handling if (g_model.thrTraceSrc && g_model.throttleReversed) { // TODO : proper review of THR source definition and handling
v = -v; v = -v;
} }
if (v <= THRCHK_DEADBAND-1024) { return v > THRCHK_DEADBAND - 1024;
return; // prevent warning if throttle input OK }
void checkThrottleStick()
{
if (!isThrottleWarningAlertNeeded()) {
return;
} }
// first - display warning; also deletes inputs if any have been before // first - display warning; also deletes inputs if any have been before
@ -938,15 +948,9 @@ void checkTHR()
bool refresh = false; bool refresh = false;
#endif #endif
while (1) { while (!getEvent()) {
if (!isThrottleWarningAlertNeeded()) {
GET_ADC_IF_MIXER_NOT_RUNNING(); return;
evalInputs(e_perout_mode_notrainer); // let do evalInputs do the job
v = calibratedAnalogs[thrchn];
if (g_model.thrTraceSrc && g_model.throttleReversed) { //TODO : proper review of THR source definition and handling
v = -v;
} }
#if defined(PWR_BUTTON_PRESS) #if defined(PWR_BUTTON_PRESS)
@ -967,10 +971,6 @@ void checkTHR()
} }
#endif #endif
if (keyDown() || v <= THRCHK_DEADBAND-1024) {
break;
}
doLoopCommonActions(); doLoopCommonActions();
wdt_reset(); wdt_reset();

View file

@ -616,7 +616,7 @@ extern uint16_t maxMixerDuration;
#endif #endif
void checkLowEEPROM(); void checkLowEEPROM();
void checkTHR(); void checkThrottleStick();
void checkSwitches(); void checkSwitches();
void checkAlarm(); void checkAlarm();
void checkAll(); void checkAll();