mirror of
https://github.com/opentx/opentx.git
synced 2025-07-15 12:25:12 +03:00
[X7] Pots calibration fix - #4143
This commit is contained in:
parent
880216c544
commit
d52f89674c
8 changed files with 33 additions and 28 deletions
|
@ -45,7 +45,7 @@ void drawPotsBars()
|
||||||
{
|
{
|
||||||
// Optimization by Mike Blandford
|
// Optimization by Mike Blandford
|
||||||
for (uint8_t x=LCD_W/2 - (NUM_POTS+NUM_SLIDERS-1) * 5 / 2, i=NUM_STICKS; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; x+=5, i++) {
|
for (uint8_t x=LCD_W/2 - (NUM_POTS+NUM_SLIDERS-1) * 5 / 2, i=NUM_STICKS; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; x+=5, i++) {
|
||||||
if (IS_POT_OR_SLIDER_AVAILABLE(i)) {
|
if (IS_POT_SLIDER_AVAILABLE(i)) {
|
||||||
uint8_t len = ((calibratedStick[i]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
|
uint8_t len = ((calibratedStick[i]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
|
||||||
V_BAR(x, LCD_H-8, len);
|
V_BAR(x, LCD_H-8, len);
|
||||||
}
|
}
|
||||||
|
|
|
@ -573,7 +573,7 @@ void menuModelSetup(event_t event)
|
||||||
if (g_model.potsWarnMode) {
|
if (g_model.potsWarnMode) {
|
||||||
coord_t x = MODEL_SETUP_2ND_COLUMN+28;
|
coord_t x = MODEL_SETUP_2ND_COLUMN+28;
|
||||||
for (int i=0; i<NUM_POTS+NUM_SLIDERS; ++i) {
|
for (int i=0; i<NUM_POTS+NUM_SLIDERS; ++i) {
|
||||||
if (i<NUM_XPOTS && !IS_POT_OR_SLIDER_AVAILABLE(POT1+i)) {
|
if (i<NUM_XPOTS && !IS_POT_SLIDER_AVAILABLE(POT1+i)) {
|
||||||
if (attr && (menuHorizontalPosition==i+1)) REPEAT_LAST_CURSOR_MOVE();
|
if (attr && (menuHorizontalPosition==i+1)) REPEAT_LAST_CURSOR_MOVE();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -608,7 +608,7 @@ void menuModelSetup(event_t event)
|
||||||
lcdDrawTextAlignedLeft(y, STR_BEEPCTR);
|
lcdDrawTextAlignedLeft(y, STR_BEEPCTR);
|
||||||
coord_t x = MODEL_SETUP_2ND_COLUMN;
|
coord_t x = MODEL_SETUP_2ND_COLUMN;
|
||||||
for (int i=0; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS+NUM_ROTARY_ENCODERS; i++) {
|
for (int i=0; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS+NUM_ROTARY_ENCODERS; i++) {
|
||||||
if (i>=POT1 && i<POT1+NUM_XPOTS && !IS_POT_OR_SLIDER_AVAILABLE(i)) {
|
if (i>=POT1 && i<POT1+NUM_XPOTS && !IS_POT_SLIDER_AVAILABLE(i)) {
|
||||||
if (attr && menuHorizontalPosition == i) REPEAT_LAST_CURSOR_MOVE();
|
if (attr && menuHorizontalPosition == i) REPEAT_LAST_CURSOR_MOVE();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ void drawPotsBars()
|
||||||
{
|
{
|
||||||
// Optimization by Mike Blandford
|
// Optimization by Mike Blandford
|
||||||
for (uint8_t x=LCD_W/2-(NUM_POTS+NUM_SLIDERS)/2*BAR_SPACING+BAR_SPACING/2, i=NUM_STICKS; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; x+=BAR_SPACING, i++) {
|
for (uint8_t x=LCD_W/2-(NUM_POTS+NUM_SLIDERS)/2*BAR_SPACING+BAR_SPACING/2, i=NUM_STICKS; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; x+=BAR_SPACING, i++) {
|
||||||
if (IS_POT_OR_SLIDER_AVAILABLE(i)) {
|
if (IS_POT_SLIDER_AVAILABLE(i)) {
|
||||||
uint8_t len = ((calibratedStick[i]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
|
uint8_t len = ((calibratedStick[i]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
|
||||||
V_BAR(x, LCD_H-8, len);
|
V_BAR(x, LCD_H-8, len);
|
||||||
putsStickName(x-2, LCD_H-6, i, TINSIZE);
|
putsStickName(x-2, LCD_H-6, i, TINSIZE);
|
||||||
|
|
|
@ -162,7 +162,7 @@ bool isSourceAvailable(int source)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (source>=MIXSRC_FIRST_POT && source<=MIXSRC_LAST_POT) {
|
if (source>=MIXSRC_FIRST_POT && source<=MIXSRC_LAST_POT) {
|
||||||
return IS_POT_OR_SLIDER_AVAILABLE(POT1+source-MIXSRC_FIRST_POT);
|
return IS_POT_SLIDER_AVAILABLE(POT1+source-MIXSRC_FIRST_POT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source>=MIXSRC_FIRST_SWITCH && source<=MIXSRC_LAST_SWITCH) {
|
if (source>=MIXSRC_FIRST_SWITCH && source<=MIXSRC_LAST_SWITCH) {
|
||||||
|
@ -227,7 +227,7 @@ bool isSourceAvailableInCustomSwitches(int source)
|
||||||
bool isInputSourceAvailable(int source)
|
bool isInputSourceAvailable(int source)
|
||||||
{
|
{
|
||||||
if (source>=MIXSRC_FIRST_POT && source<=MIXSRC_LAST_POT) {
|
if (source>=MIXSRC_FIRST_POT && source<=MIXSRC_LAST_POT) {
|
||||||
return IS_POT_OR_SLIDER_AVAILABLE(POT1+source-MIXSRC_FIRST_POT);
|
return IS_POT_SLIDER_AVAILABLE(POT1+source-MIXSRC_FIRST_POT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source>=MIXSRC_Rud && source<=MIXSRC_MAX)
|
if (source>=MIXSRC_Rud && source<=MIXSRC_MAX)
|
||||||
|
@ -401,7 +401,7 @@ bool isSwitchAvailableInTimers(int swtch)
|
||||||
|
|
||||||
bool isThrottleSourceAvailable(int source)
|
bool isThrottleSourceAvailable(int source)
|
||||||
{
|
{
|
||||||
if (source >= THROTTLE_SOURCE_FIRST_POT && source < THROTTLE_SOURCE_FIRST_POT+NUM_POTS+NUM_SLIDERS && !IS_POT_OR_SLIDER_AVAILABLE(POT1+source-THROTTLE_SOURCE_FIRST_POT))
|
if (source >= THROTTLE_SOURCE_FIRST_POT && source < THROTTLE_SOURCE_FIRST_POT+NUM_POTS+NUM_SLIDERS && !IS_POT_SLIDER_AVAILABLE(POT1+source-THROTTLE_SOURCE_FIRST_POT))
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -464,7 +464,7 @@ void evalInputs(uint8_t mode)
|
||||||
if (tmp==0 || (tmp==1 && (bpanaCenter & mask))) {
|
if (tmp==0 || (tmp==1 && (bpanaCenter & mask))) {
|
||||||
anaCenter |= mask;
|
anaCenter |= mask;
|
||||||
if ((g_model.beepANACenter & mask) && !(bpanaCenter & mask) && !menuCalibrationState) {
|
if ((g_model.beepANACenter & mask) && !(bpanaCenter & mask) && !menuCalibrationState) {
|
||||||
if (!IS_POT(i) || IS_POT_OR_SLIDER_AVAILABLE(i)) {
|
if (!IS_POT(i) || IS_POT_SLIDER_AVAILABLE(i)) {
|
||||||
AUDIO_POT_MIDDLE(i);
|
AUDIO_POT_MIDDLE(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,7 +291,7 @@
|
||||||
#include "myeeprom.h"
|
#include "myeeprom.h"
|
||||||
|
|
||||||
#if defined(CPUM64)
|
#if defined(CPUM64)
|
||||||
void memclear(void *ptr, uint8_t size);
|
void memclear(void * ptr, uint8_t size);
|
||||||
#else
|
#else
|
||||||
#define memclear(p, s) memset(p, 0, s)
|
#define memclear(p, s) memset(p, 0, s)
|
||||||
#endif
|
#endif
|
||||||
|
@ -299,23 +299,28 @@
|
||||||
void memswap(void * a, void * b, uint8_t size);
|
void memswap(void * a, void * b, uint8_t size);
|
||||||
|
|
||||||
#if defined(PCBX9D) || defined(PCBX9DP) || defined(PCBX9E) || defined(PCBHORUS)
|
#if defined(PCBX9D) || defined(PCBX9DP) || defined(PCBX9E) || defined(PCBHORUS)
|
||||||
#define POT_CONFIG(x) ((g_eeGeneral.potsConfig >> (2*((x)-POT1)))&0x03)
|
#define POT_CONFIG(x) ((g_eeGeneral.potsConfig >> (2*((x)-POT1)))&0x03)
|
||||||
#define IS_POT_MULTIPOS(x) (IS_POT(x) && POT_CONFIG(x)==POT_MULTIPOS_SWITCH)
|
#define IS_POT_MULTIPOS(x) (IS_POT(x) && POT_CONFIG(x)==POT_MULTIPOS_SWITCH)
|
||||||
#define IS_POT_WITHOUT_DETENT(x) (IS_POT(x) && POT_CONFIG(x)==POT_WITHOUT_DETENT)
|
#define IS_POT_WITHOUT_DETENT(x) (IS_POT(x) && POT_CONFIG(x)==POT_WITHOUT_DETENT)
|
||||||
#define IS_SLIDER_AVAILABLE(x) ((x) == SLIDER1 || (x) == SLIDER2 || (IS_SLIDER(x) && (g_eeGeneral.slidersConfig & (0x01 << ((x)-SLIDER1)))))
|
#define IS_SLIDER_AVAILABLE(x) ((x) == SLIDER1 || (x) == SLIDER2 || (IS_SLIDER(x) && (g_eeGeneral.slidersConfig & (0x01 << ((x)-SLIDER1)))))
|
||||||
#define IS_POT_AVAILABLE(x) (IS_POT(x) && POT_CONFIG(x)!=POT_NONE)
|
#define IS_POT_AVAILABLE(x) (IS_POT(x) && POT_CONFIG(x)!=POT_NONE)
|
||||||
#define IS_POT_OR_SLIDER_AVAILABLE(x) (IS_POT_AVAILABLE(x) || IS_SLIDER_AVAILABLE(x))
|
#define IS_POT_SLIDER_AVAILABLE(x) (IS_POT_AVAILABLE(x) || IS_SLIDER_AVAILABLE(x))
|
||||||
#define IS_MULTIPOS_CALIBRATED(cal) (cal->count>0 && cal->count<XPOTS_MULTIPOS_COUNT)
|
#define IS_MULTIPOS_CALIBRATED(cal) (cal->count>0 && cal->count<XPOTS_MULTIPOS_COUNT)
|
||||||
|
#elif defined(PCBX7)
|
||||||
|
#define IS_POT_MULTIPOS(x) (false)
|
||||||
|
#define IS_POT_WITHOUT_DETENT(x) (false)
|
||||||
|
#define IS_POT_SLIDER_AVAILABLE(x) (true)
|
||||||
|
#define IS_MULTIPOS_CALIBRATED(cal) (false)
|
||||||
#elif defined(PCBFLAMENCO)
|
#elif defined(PCBFLAMENCO)
|
||||||
#define IS_POT_MULTIPOS(x) (false)
|
#define IS_POT_MULTIPOS(x) (false)
|
||||||
#define IS_POT_WITHOUT_DETENT(x) (false)
|
#define IS_POT_WITHOUT_DETENT(x) (false)
|
||||||
#define IS_POT_OR_SLIDER_AVAILABLE(x) (true)
|
#define IS_POT_SLIDER_AVAILABLE(x) (true)
|
||||||
#define IS_MULTIPOS_CALIBRATED(cal) (false)
|
#define IS_MULTIPOS_CALIBRATED(cal) (false)
|
||||||
#else
|
#else
|
||||||
#define IS_POT_MULTIPOS(x) (false)
|
#define IS_POT_MULTIPOS(x) (false)
|
||||||
#define IS_POT_WITHOUT_DETENT(x) (true)
|
#define IS_POT_WITHOUT_DETENT(x) (true)
|
||||||
#define IS_POT_OR_SLIDER_AVAILABLE(x) (true)
|
#define IS_POT_SLIDER_AVAILABLE(x) (true)
|
||||||
#define IS_MULTIPOS_CALIBRATED(cal) (false)
|
#define IS_MULTIPOS_CALIBRATED(cal) (false)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBFLAMENCO) || defined(PCBHORUS) || defined(PCBX9E) || defined(PCBX7)
|
#if defined(PCBFLAMENCO) || defined(PCBHORUS) || defined(PCBX9E) || defined(PCBX7)
|
||||||
|
|
|
@ -765,7 +765,7 @@ void checkSwitches()
|
||||||
evalFlightModeMixes(e_perout_mode_normal, 0);
|
evalFlightModeMixes(e_perout_mode_normal, 0);
|
||||||
bad_pots = 0;
|
bad_pots = 0;
|
||||||
for (int i=0; i<NUM_POTS+NUM_SLIDERS; i++) {
|
for (int i=0; i<NUM_POTS+NUM_SLIDERS; i++) {
|
||||||
if (!IS_POT_OR_SLIDER_AVAILABLE(POT1+i)) {
|
if (!IS_POT_SLIDER_AVAILABLE(POT1+i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!(g_model.potsWarnEnabled & (1 << i)) && (abs(g_model.potsWarnPosition[i] - GET_LOWRES_POT_POSITION(i)) > 1)) {
|
if (!(g_model.potsWarnEnabled & (1 << i)) && (abs(g_model.potsWarnPosition[i] - GET_LOWRES_POT_POSITION(i)) > 1)) {
|
||||||
|
@ -787,7 +787,7 @@ void checkSwitches()
|
||||||
evalFlightModeMixes(e_perout_mode_normal, 0);
|
evalFlightModeMixes(e_perout_mode_normal, 0);
|
||||||
bad_pots = 0;
|
bad_pots = 0;
|
||||||
for (int i=0; i<NUM_POTS+NUM_SLIDERS; i++) {
|
for (int i=0; i<NUM_POTS+NUM_SLIDERS; i++) {
|
||||||
if (!IS_POT_OR_SLIDER_AVAILABLE(POT1+i)) {
|
if (!IS_POT_SLIDER_AVAILABLE(POT1+i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!(g_model.potsWarnEnabled & (1 << i)) && (abs(g_model.potsWarnPosition[i] - GET_LOWRES_POT_POSITION(i)) > 1)) {
|
if (!(g_model.potsWarnEnabled & (1 << i)) && (abs(g_model.potsWarnPosition[i] - GET_LOWRES_POT_POSITION(i)) > 1)) {
|
||||||
|
@ -871,7 +871,7 @@ void checkSwitches()
|
||||||
x = 60;
|
x = 60;
|
||||||
}
|
}
|
||||||
for (int i=0; i<NUM_POTS+NUM_SLIDERS; i++) {
|
for (int i=0; i<NUM_POTS+NUM_SLIDERS; i++) {
|
||||||
if (!IS_POT_OR_SLIDER_AVAILABLE(POT1+i)) {
|
if (!IS_POT_SLIDER_AVAILABLE(POT1+i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!(g_model.potsWarnEnabled & (1 << i))) {
|
if (!(g_model.potsWarnEnabled & (1 << i))) {
|
||||||
|
|
|
@ -178,7 +178,7 @@ void adcStop()
|
||||||
#if !defined(SIMU)
|
#if !defined(SIMU)
|
||||||
uint16_t getAnalogValue(uint8_t index)
|
uint16_t getAnalogValue(uint8_t index)
|
||||||
{
|
{
|
||||||
if (IS_POT(index) && !IS_POT_OR_SLIDER_AVAILABLE(index)) {
|
if (IS_POT(index) && !IS_POT_SLIDER_AVAILABLE(index)) {
|
||||||
// Use fixed analog value for non-existing and/or non-connected pots.
|
// Use fixed analog value for non-existing and/or non-connected pots.
|
||||||
// Non-connected analog inputs will slightly follow the adjacent connected analog inputs,
|
// Non-connected analog inputs will slightly follow the adjacent connected analog inputs,
|
||||||
// which produces ghost readings on these inputs.
|
// which produces ghost readings on these inputs.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue