mirror of
https://github.com/opentx/opentx.git
synced 2025-07-24 00:35:18 +03:00
6-pos multiswitches calibration bug fixed!
This commit is contained in:
parent
a257f6f784
commit
c721a16d65
2 changed files with 13 additions and 9 deletions
|
@ -1459,8 +1459,8 @@ void menuGeneralHardware(uint8_t event)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define XPOT_DELTA 7
|
#define XPOT_DELTA 5
|
||||||
#define XPOT_DELAY 15 /* cycles */
|
#define XPOT_DELAY 10 /* cycles */
|
||||||
|
|
||||||
void menuCommonCalib(uint8_t event)
|
void menuCommonCalib(uint8_t event)
|
||||||
{
|
{
|
||||||
|
@ -1474,7 +1474,7 @@ void menuCommonCalib(uint8_t event)
|
||||||
uint8_t idx = i - POT1;
|
uint8_t idx = i - POT1;
|
||||||
int count = reusableBuffer.calib.xpotsCalib[idx].stepsCount;
|
int count = reusableBuffer.calib.xpotsCalib[idx].stepsCount;
|
||||||
if (IS_POT_MULTIPOS(i) && count <= XPOTS_MULTIPOS_COUNT) {
|
if (IS_POT_MULTIPOS(i) && count <= XPOTS_MULTIPOS_COUNT) {
|
||||||
if (reusableBuffer.calib.xpotsCalib[idx].lastCount == 0 || vt < reusableBuffer.calib.xpotsCalib[idx].lastPosition - XPOT_DELTA || vt > reusableBuffer.calib.xpotsCalib[idx].lastPosition + XPOT_DELTA) {
|
if (reusableBuffer.calib.xpotsCalib[idx].lastCount == 0 || vt < reusableBuffer.calib.xpotsCalib[idx].lastPosition - XPOT_DELTA/2 || vt > reusableBuffer.calib.xpotsCalib[idx].lastPosition + XPOT_DELTA/2) {
|
||||||
reusableBuffer.calib.xpotsCalib[idx].lastPosition = vt;
|
reusableBuffer.calib.xpotsCalib[idx].lastPosition = vt;
|
||||||
reusableBuffer.calib.xpotsCalib[idx].lastCount = 1;
|
reusableBuffer.calib.xpotsCalib[idx].lastCount = 1;
|
||||||
}
|
}
|
||||||
|
@ -1485,7 +1485,8 @@ void menuCommonCalib(uint8_t event)
|
||||||
int16_t position = reusableBuffer.calib.xpotsCalib[idx].lastPosition;
|
int16_t position = reusableBuffer.calib.xpotsCalib[idx].lastPosition;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int j=0; j<count; j++) {
|
for (int j=0; j<count; j++) {
|
||||||
if (position >= reusableBuffer.calib.xpotsCalib[idx].steps[j]-XPOT_DELTA && position <= reusableBuffer.calib.xpotsCalib[idx].steps[j]+XPOT_DELTA) {
|
int16_t step = reusableBuffer.calib.xpotsCalib[idx].steps[j];
|
||||||
|
if (position >= step-XPOT_DELTA && position <= step+XPOT_DELTA) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1614,14 +1615,18 @@ void menuCommonCalib(uint8_t event)
|
||||||
|
|
||||||
void menuGeneralCalib(uint8_t event)
|
void menuGeneralCalib(uint8_t event)
|
||||||
{
|
{
|
||||||
SIMPLE_MENU(STR_MENUCALIBRATION, menuTabDiag, e_Calib, 1);
|
if (!check_simple(event, e_Calib, menuTabDiag, DIM(menuTabDiag), 0)) {
|
||||||
|
calibrationState = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TITLE(STR_MENUCALIBRATION);
|
||||||
menuCommonCalib(READ_ONLY() ? 0 : event);
|
menuCommonCalib(READ_ONLY() ? 0 : event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void menuFirstCalib(uint8_t event)
|
void menuFirstCalib(uint8_t event)
|
||||||
{
|
{
|
||||||
if (event == EVT_KEY_BREAK(KEY_EXIT) || reusableBuffer.calib.state == 4) {
|
if (event == EVT_KEY_BREAK(KEY_EXIT) || reusableBuffer.calib.state == 4) {
|
||||||
|
calibrationState = 0;
|
||||||
chainMenu(menuMainView);
|
chainMenu(menuMainView);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -425,13 +425,12 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||||
cc = 0;
|
cc = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (cc != curr) {
|
|
||||||
|
if (!calibrationState && cc != curr) {
|
||||||
chainMenu((MenuFuncP)pgm_read_adr(&menuTab[cc]));
|
chainMenu((MenuFuncP)pgm_read_adr(&menuTab[cc]));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
calibrationState = 0;
|
|
||||||
|
|
||||||
if (!(flags&CHECK_FLAG_NO_SCREEN_INDEX)) {
|
if (!(flags&CHECK_FLAG_NO_SCREEN_INDEX)) {
|
||||||
displayScreenIndex(curr, menuTabSize, attr);
|
displayScreenIndex(curr, menuTabSize, attr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue