mirror of
https://github.com/opentx/opentx.git
synced 2025-07-16 12:55:12 +03:00
[Horus] Mouse analogs now OK
This commit is contained in:
parent
88511c1ba9
commit
4cc49d0d30
10 changed files with 80 additions and 68 deletions
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 902 B After Width: | Height: | Size: 902 B |
|
@ -983,7 +983,7 @@ PACK(struct TrainerData {
|
||||||
PACK(struct RadioData {
|
PACK(struct RadioData {
|
||||||
NOBACKUP(uint8_t version);
|
NOBACKUP(uint8_t version);
|
||||||
NOBACKUP(uint16_t variant);
|
NOBACKUP(uint16_t variant);
|
||||||
CalibData calib[NUM_STICKS+NUM_POTS];
|
CalibData calib[NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS];
|
||||||
NOBACKUP(uint16_t chkSum);
|
NOBACKUP(uint16_t chkSum);
|
||||||
N_HORUS_FIELD(int8_t currModel);
|
N_HORUS_FIELD(int8_t currModel);
|
||||||
N_HORUS_FIELD(uint8_t contrast);
|
N_HORUS_FIELD(uint8_t contrast);
|
||||||
|
@ -1103,7 +1103,7 @@ static inline void check_struct()
|
||||||
CHKSIZE(FrSkyTelemetryData, 7);
|
CHKSIZE(FrSkyTelemetryData, 7);
|
||||||
CHKSIZE(ModelHeader, 27);
|
CHKSIZE(ModelHeader, 27);
|
||||||
CHKSIZE(CurveData, 4);
|
CHKSIZE(CurveData, 4);
|
||||||
CHKSIZE(RadioData, 835);
|
CHKSIZE(RadioData, 847);
|
||||||
CHKSIZE(ModelData, 9380);
|
CHKSIZE(ModelData, 9380);
|
||||||
|
|
||||||
#elif defined(PCBSKY9X)
|
#elif defined(PCBSKY9X)
|
||||||
|
|
|
@ -22,10 +22,8 @@
|
||||||
|
|
||||||
#define XPOT_DELTA 10
|
#define XPOT_DELTA 10
|
||||||
#define XPOT_DELAY 10 /* cycles */
|
#define XPOT_DELAY 10 /* cycles */
|
||||||
#define POT_BAR_INTERVAL 20
|
|
||||||
#define POT_BAR_BOTTOM 200
|
|
||||||
#define STICKS_WIDTH 90
|
#define STICKS_WIDTH 90
|
||||||
#define STICKS_Y 110
|
#define STICKS_Y 60
|
||||||
#define STICK_LEFT_X 25
|
#define STICK_LEFT_X 25
|
||||||
#define STICK_RIGHT_X (LCD_W-STICK_LEFT_X-STICKS_WIDTH)
|
#define STICK_RIGHT_X (LCD_W-STICK_LEFT_X-STICKS_WIDTH)
|
||||||
|
|
||||||
|
@ -37,6 +35,17 @@ enum CalibrationState {
|
||||||
CALIB_FINISHED
|
CALIB_FINISHED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define STICK_PANEL_WIDTH 68
|
||||||
|
|
||||||
|
void drawStick(coord_t x, coord_t y, int16_t xval, int16_t yval)
|
||||||
|
{
|
||||||
|
static const BitmapBuffer * stick_background = BitmapBuffer::load(getThemePath("stick_background.png"));
|
||||||
|
static const BitmapBuffer * stick_pointer = BitmapBuffer::load(getThemePath("stick_pointer.png"));
|
||||||
|
|
||||||
|
lcd->drawBitmap(x, y, stick_background);
|
||||||
|
lcd->drawBitmap(x + 2 + STICK_PANEL_WIDTH/2 + STICK_PANEL_WIDTH/2 * xval/RESX, y + 2 + STICK_PANEL_WIDTH/2 - STICK_PANEL_WIDTH/2 * yval/RESX, stick_pointer);
|
||||||
|
}
|
||||||
|
|
||||||
void drawSticks()
|
void drawSticks()
|
||||||
{
|
{
|
||||||
int16_t calibStickVert = calibratedStick[CONVERT_MODE(1)];
|
int16_t calibStickVert = calibratedStick[CONVERT_MODE(1)];
|
||||||
|
@ -63,12 +72,17 @@ void drawPots()
|
||||||
OPTION_SLIDER_SQUARE_BUTTON);
|
OPTION_SLIDER_SQUARE_BUTTON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void drawMouse()
|
||||||
|
{
|
||||||
|
drawStick(STICK_LEFT_X, STICKS_Y+100, calibratedStick[11], calibratedStick[12]);
|
||||||
|
}
|
||||||
|
|
||||||
bool menuCommonCalib(evt_t event)
|
bool menuCommonCalib(evt_t event)
|
||||||
{
|
{
|
||||||
drawMenuTemplate(NULL, ICON_RADIO_CALIBRATION, NULL, OPTION_MENU_NO_FOOTER);
|
drawMenuTemplate(NULL, ICON_RADIO_CALIBRATION, NULL, OPTION_MENU_NO_FOOTER);
|
||||||
|
|
||||||
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS; i++) { // get low and high vals for sticks and trims
|
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS; i++) { // get low and high vals for sticks and trims
|
||||||
int16_t vt = anaIn(i);
|
int16_t vt = i<NUM_STICKS+NUM_POTS ? anaIn(i) : anaIn(MOUSE1+i-NUM_STICKS-NUM_POTS);
|
||||||
reusableBuffer.calib.loVals[i] = min(vt, reusableBuffer.calib.loVals[i]);
|
reusableBuffer.calib.loVals[i] = min(vt, reusableBuffer.calib.loVals[i]);
|
||||||
reusableBuffer.calib.hiVals[i] = max(vt, reusableBuffer.calib.hiVals[i]);
|
reusableBuffer.calib.hiVals[i] = max(vt, reusableBuffer.calib.hiVals[i]);
|
||||||
if (i >= POT1 && i <= POT_LAST) {
|
if (i >= POT1 && i <= POT_LAST) {
|
||||||
|
@ -141,10 +155,10 @@ bool menuCommonCalib(evt_t event)
|
||||||
// SET MIDPOINT
|
// SET MIDPOINT
|
||||||
lcdDrawText(50, 3, STR_MENUCALIBRATION, MENU_TITLE_COLOR);
|
lcdDrawText(50, 3, STR_MENUCALIBRATION, MENU_TITLE_COLOR);
|
||||||
lcdDrawText(50, 3+FH, STR_SETMIDPOINT, MENU_TITLE_COLOR);
|
lcdDrawText(50, 3+FH, STR_SETMIDPOINT, MENU_TITLE_COLOR);
|
||||||
for (int i=0; i<NUM_STICKS+NUM_POTS; i++) {
|
for (int i=0; i<NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS; i++) {
|
||||||
reusableBuffer.calib.loVals[i] = 15000;
|
reusableBuffer.calib.loVals[i] = 15000;
|
||||||
reusableBuffer.calib.hiVals[i] = -15000;
|
reusableBuffer.calib.hiVals[i] = -15000;
|
||||||
reusableBuffer.calib.midVals[i] = anaIn(i);
|
reusableBuffer.calib.midVals[i] = i<NUM_STICKS+NUM_POTS ? anaIn(i) : anaIn(MOUSE1+i-NUM_STICKS-NUM_POTS);
|
||||||
if (i < NUM_XPOTS) {
|
if (i < NUM_XPOTS) {
|
||||||
reusableBuffer.calib.xpotsCalib[i].stepsCount = 0;
|
reusableBuffer.calib.xpotsCalib[i].stepsCount = 0;
|
||||||
reusableBuffer.calib.xpotsCalib[i].lastCount = 0;
|
reusableBuffer.calib.xpotsCalib[i].lastCount = 0;
|
||||||
|
@ -156,7 +170,7 @@ bool menuCommonCalib(evt_t event)
|
||||||
// MOVE STICKS/POTS
|
// MOVE STICKS/POTS
|
||||||
lcdDrawText(50, 3, STR_MENUCALIBRATION, MENU_TITLE_COLOR);
|
lcdDrawText(50, 3, STR_MENUCALIBRATION, MENU_TITLE_COLOR);
|
||||||
lcdDrawText(50, 3+FH, STR_MOVESTICKSPOTS, MENU_TITLE_COLOR);
|
lcdDrawText(50, 3+FH, STR_MOVESTICKSPOTS, MENU_TITLE_COLOR);
|
||||||
for (int i=0; i<NUM_STICKS+NUM_POTS; i++) {
|
for (int i=0; i<NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS; i++) {
|
||||||
if (abs(reusableBuffer.calib.loVals[i]-reusableBuffer.calib.hiVals[i]) > 50) {
|
if (abs(reusableBuffer.calib.loVals[i]-reusableBuffer.calib.hiVals[i]) > 50) {
|
||||||
g_eeGeneral.calib[i].mid = reusableBuffer.calib.midVals[i];
|
g_eeGeneral.calib[i].mid = reusableBuffer.calib.midVals[i];
|
||||||
int16_t v = reusableBuffer.calib.midVals[i] - reusableBuffer.calib.loVals[i];
|
int16_t v = reusableBuffer.calib.midVals[i] - reusableBuffer.calib.loVals[i];
|
||||||
|
@ -205,8 +219,10 @@ bool menuCommonCalib(evt_t event)
|
||||||
if (horus) {
|
if (horus) {
|
||||||
lcd->drawBitmap((LCD_W-horus->getWidth())/2, LCD_H-20-horus->getHeight(), horus);
|
lcd->drawBitmap((LCD_W-horus->getWidth())/2, LCD_H-20-horus->getHeight(), horus);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawSticks();
|
drawSticks();
|
||||||
drawPots();
|
drawPots();
|
||||||
|
drawMouse();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,10 @@ bool menuStatsAnalogs(evt_t event)
|
||||||
lcdDrawNumber(x+140, y, avgJitter[i].get());
|
lcdDrawNumber(x+140, y, avgJitter[i].get());
|
||||||
lcdDrawNumber(x+180, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*250/256, PREC1);
|
lcdDrawNumber(x+180, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*250/256, PREC1);
|
||||||
#else
|
#else
|
||||||
|
if (i < NUM_STICKS+NUM_POTS)
|
||||||
lcdDrawNumber(x+100, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*25/256);
|
lcdDrawNumber(x+100, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*25/256);
|
||||||
|
else if (i >= MOUSE1)
|
||||||
|
lcdDrawNumber(x+100, y, (int16_t)calibratedStick[NUM_STICKS+NUM_POTS+i-MOUSE1]*25/256);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,15 +34,6 @@ void drawColumnHeader(const char * const * headers, const char * const * descrip
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "alpha_stick_background.lbm"
|
|
||||||
#include "alpha_stick_pointer.lbm"
|
|
||||||
#define STICK_PANEL_WIDTH 68
|
|
||||||
void drawStick(coord_t x, coord_t y, int16_t xval, int16_t yval)
|
|
||||||
{
|
|
||||||
lcd->drawBitmap(x, y, &ALPHA_STICK_BACKGROUND);
|
|
||||||
lcd->drawBitmap(x + 2 + STICK_PANEL_WIDTH/2 + STICK_PANEL_WIDTH/2 * xval/RESX, y + 2 + STICK_PANEL_WIDTH/2 - STICK_PANEL_WIDTH/2 * yval/RESX, &ALPHA_STICK_POINTER);
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "alpha_button_on.lbm"
|
#include "alpha_button_on.lbm"
|
||||||
#include "alpha_button_off.lbm"
|
#include "alpha_button_off.lbm"
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
void drawStatusText(const char * text);
|
void drawStatusText(const char * text);
|
||||||
void drawColumnHeader(const char * const * headers, const char * const * descriptions, uint8_t index);
|
void drawColumnHeader(const char * const * headers, const char * const * descriptions, uint8_t index);
|
||||||
void drawTopbarDatetime();
|
void drawTopbarDatetime();
|
||||||
void drawStick(coord_t x, coord_t y, int16_t xval, int16_t yval);
|
|
||||||
|
|
||||||
#define BUTTON_ON 0x10
|
#define BUTTON_ON 0x10
|
||||||
#define BUTTON_OFF 0x20
|
#define BUTTON_OFF 0x20
|
||||||
|
|
|
@ -41,7 +41,7 @@ uint8_t mixWarning;
|
||||||
uint8_t startupWarningState;
|
uint8_t startupWarningState;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int16_t calibratedStick[NUM_STICKS+NUM_POTS];
|
int16_t calibratedStick[NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS];
|
||||||
int16_t channelOutputs[NUM_CHNOUT] = {0};
|
int16_t channelOutputs[NUM_CHNOUT] = {0};
|
||||||
int16_t ex_chans[NUM_CHNOUT] = {0}; // Outputs (before LIMITS) of the last perMain;
|
int16_t ex_chans[NUM_CHNOUT] = {0}; // Outputs (before LIMITS) of the last perMain;
|
||||||
|
|
||||||
|
@ -424,19 +424,12 @@ void evalInputs(uint8_t mode)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS+NUM_ROTARY_ENCODERS; i++) {
|
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS; i++) {
|
||||||
|
|
||||||
// normalization [0..2048] -> [-1024..1024]
|
// normalization [0..2048] -> [-1024..1024]
|
||||||
uint8_t ch = (i < NUM_STICKS ? CONVERT_MODE(i) : i);
|
uint8_t ch = (i < NUM_STICKS ? CONVERT_MODE(i) : i);
|
||||||
|
|
||||||
#if defined(ROTARY_ENCODERS)
|
|
||||||
int16_t v = ((i < NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS) ? anaIn(i) : getRotaryEncoder(i-(NUM_STICKS+NUM_POTS)));
|
|
||||||
#else
|
|
||||||
int16_t v = anaIn(i);
|
int16_t v = anaIn(i);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(SIMU)
|
#if !defined(SIMU)
|
||||||
if (i < NUM_STICKS+NUM_POTS) {
|
|
||||||
if (IS_POT_MULTIPOS(i)) {
|
if (IS_POT_MULTIPOS(i)) {
|
||||||
v -= RESX;
|
v -= RESX;
|
||||||
}
|
}
|
||||||
|
@ -445,7 +438,6 @@ void evalInputs(uint8_t mode)
|
||||||
v -= calib->mid;
|
v -= calib->mid;
|
||||||
v = v * (int32_t) RESX / (max((int16_t) 100, (v > 0 ? calib->spanPos : calib->spanNeg)));
|
v = v * (int32_t) RESX / (max((int16_t) 100, (v > 0 ? calib->spanPos : calib->spanNeg)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (v < -RESX) v = -RESX;
|
if (v < -RESX) v = -RESX;
|
||||||
|
@ -463,8 +455,6 @@ void evalInputs(uint8_t mode)
|
||||||
|
|
||||||
BeepANACenter mask = (BeepANACenter)1 << ch;
|
BeepANACenter mask = (BeepANACenter)1 << ch;
|
||||||
|
|
||||||
if (i < NUM_STICKS+NUM_POTS) {
|
|
||||||
|
|
||||||
calibratedStick[ch] = v; // for show in expo
|
calibratedStick[ch] = v; // for show in expo
|
||||||
|
|
||||||
// filtering for center beep
|
// filtering for center beep
|
||||||
|
@ -483,13 +473,6 @@ void evalInputs(uint8_t mode)
|
||||||
#else
|
#else
|
||||||
if (tmp <= 1) anaCenter |= (tmp==0 ? mask : (bpanaCenter & mask));
|
if (tmp <= 1) anaCenter |= (tmp==0 ? mask : (bpanaCenter & mask));
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
#if defined(ROTARY_ENCODERS)
|
|
||||||
else if (i >= NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS) {
|
|
||||||
// rotary encoders
|
|
||||||
if (v == 0) anaCenter |= mask;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ch < NUM_STICKS) { // only do this for sticks
|
if (ch < NUM_STICKS) { // only do this for sticks
|
||||||
#if defined(VIRTUALINPUTS)
|
#if defined(VIRTUALINPUTS)
|
||||||
|
@ -519,7 +502,6 @@ void evalInputs(uint8_t mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(VIRTUALINPUTS)
|
#if defined(VIRTUALINPUTS)
|
||||||
calibratedStick[ch] = v;
|
calibratedStick[ch] = v;
|
||||||
#else
|
#else
|
||||||
|
@ -534,6 +516,27 @@ void evalInputs(uint8_t mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(ROTARY_ENCODERS)
|
||||||
|
for (uint8_t i=0; i<NUM_ROTARY_ENCODERS; i++) {
|
||||||
|
if (getRotaryEncoder(i) == 0) {
|
||||||
|
anaCenter |= ((BeepANACenter)1 << (NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS+i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if NUM_MOUSE_ANALOGS > 0
|
||||||
|
for (uint8_t i=0; i<NUM_MOUSE_ANALOGS; i++) {
|
||||||
|
uint8_t ch = NUM_STICKS+NUM_POTS+i;
|
||||||
|
int16_t v = anaIn(MOUSE1+i);
|
||||||
|
CalibData * calib = &g_eeGeneral.calib[ch];
|
||||||
|
v -= calib->mid;
|
||||||
|
v = v * (int32_t) RESX / (max((int16_t) 100, (v > 0 ? calib->spanPos : calib->spanNeg)));
|
||||||
|
if (v < -RESX) v = -RESX;
|
||||||
|
if (v > RESX) v = RESX;
|
||||||
|
calibratedStick[ch] = v;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* EXPOs */
|
/* EXPOs */
|
||||||
applyExpos(anas, mode);
|
applyExpos(anas, mode);
|
||||||
|
|
||||||
|
|
|
@ -521,7 +521,7 @@ int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int16_t sourcesStates[NUM_STICKS+NUM_POTS];
|
static int16_t sourcesStates[NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS];
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS; i++) {
|
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS; i++) {
|
||||||
if (abs(calibratedStick[i] - sourcesStates[i]) > 512) {
|
if (abs(calibratedStick[i] - sourcesStates[i]) > 512) {
|
||||||
|
@ -677,7 +677,7 @@ void incRotaryEncoder(uint8_t idx, int8_t inc)
|
||||||
{
|
{
|
||||||
g_rotenc[idx] += inc;
|
g_rotenc[idx] += inc;
|
||||||
int16_t *value = &(flightModeAddress(getRotaryEncoderFlightPhase(idx))->rotaryEncoders[idx]);
|
int16_t *value = &(flightModeAddress(getRotaryEncoderFlightPhase(idx))->rotaryEncoders[idx]);
|
||||||
*value = limit((int16_t)-1024, (int16_t)(*value + (inc * 8)), (int16_t)+1024);
|
*value = limit((int16_t)-RESX, (int16_t)(*value + (inc * 8)), (int16_t)+RESX);
|
||||||
storageDirty(EE_MODEL);
|
storageDirty(EE_MODEL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1159,7 +1159,7 @@ int16_t applyLimits(uint8_t channel, int32_t value);
|
||||||
|
|
||||||
void evalInputs(uint8_t mode);
|
void evalInputs(uint8_t mode);
|
||||||
uint16_t anaIn(uint8_t chan);
|
uint16_t anaIn(uint8_t chan);
|
||||||
extern int16_t calibratedStick[NUM_STICKS+NUM_POTS];
|
extern int16_t calibratedStick[NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS];
|
||||||
|
|
||||||
#define FLASH_DURATION 20 /*200ms*/
|
#define FLASH_DURATION 20 /*200ms*/
|
||||||
|
|
||||||
|
@ -1495,9 +1495,9 @@ union ReusableBuffer
|
||||||
// 103 bytes
|
// 103 bytes
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
int16_t midVals[NUM_STICKS+NUM_POTS];
|
int16_t midVals[NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS];
|
||||||
int16_t loVals[NUM_STICKS+NUM_POTS];
|
int16_t loVals[NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS];
|
||||||
int16_t hiVals[NUM_STICKS+NUM_POTS];
|
int16_t hiVals[NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS];
|
||||||
uint8_t state;
|
uint8_t state;
|
||||||
#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS)
|
#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS)
|
||||||
struct {
|
struct {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue