mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 08:15:17 +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 {
|
||||
NOBACKUP(uint8_t version);
|
||||
NOBACKUP(uint16_t variant);
|
||||
CalibData calib[NUM_STICKS+NUM_POTS];
|
||||
CalibData calib[NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS];
|
||||
NOBACKUP(uint16_t chkSum);
|
||||
N_HORUS_FIELD(int8_t currModel);
|
||||
N_HORUS_FIELD(uint8_t contrast);
|
||||
|
@ -1103,7 +1103,7 @@ static inline void check_struct()
|
|||
CHKSIZE(FrSkyTelemetryData, 7);
|
||||
CHKSIZE(ModelHeader, 27);
|
||||
CHKSIZE(CurveData, 4);
|
||||
CHKSIZE(RadioData, 835);
|
||||
CHKSIZE(RadioData, 847);
|
||||
CHKSIZE(ModelData, 9380);
|
||||
|
||||
#elif defined(PCBSKY9X)
|
||||
|
|
|
@ -22,10 +22,8 @@
|
|||
|
||||
#define XPOT_DELTA 10
|
||||
#define XPOT_DELAY 10 /* cycles */
|
||||
#define POT_BAR_INTERVAL 20
|
||||
#define POT_BAR_BOTTOM 200
|
||||
#define STICKS_WIDTH 90
|
||||
#define STICKS_Y 110
|
||||
#define STICKS_Y 60
|
||||
#define STICK_LEFT_X 25
|
||||
#define STICK_RIGHT_X (LCD_W-STICK_LEFT_X-STICKS_WIDTH)
|
||||
|
||||
|
@ -37,6 +35,17 @@ enum CalibrationState {
|
|||
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()
|
||||
{
|
||||
int16_t calibStickVert = calibratedStick[CONVERT_MODE(1)];
|
||||
|
@ -63,12 +72,17 @@ void drawPots()
|
|||
OPTION_SLIDER_SQUARE_BUTTON);
|
||||
}
|
||||
|
||||
void drawMouse()
|
||||
{
|
||||
drawStick(STICK_LEFT_X, STICKS_Y+100, calibratedStick[11], calibratedStick[12]);
|
||||
}
|
||||
|
||||
bool menuCommonCalib(evt_t event)
|
||||
{
|
||||
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
|
||||
int16_t vt = anaIn(i);
|
||||
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 = 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.hiVals[i] = max(vt, reusableBuffer.calib.hiVals[i]);
|
||||
if (i >= POT1 && i <= POT_LAST) {
|
||||
|
@ -141,10 +155,10 @@ bool menuCommonCalib(evt_t event)
|
|||
// SET MIDPOINT
|
||||
lcdDrawText(50, 3, STR_MENUCALIBRATION, 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.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) {
|
||||
reusableBuffer.calib.xpotsCalib[i].stepsCount = 0;
|
||||
reusableBuffer.calib.xpotsCalib[i].lastCount = 0;
|
||||
|
@ -156,7 +170,7 @@ bool menuCommonCalib(evt_t event)
|
|||
// MOVE STICKS/POTS
|
||||
lcdDrawText(50, 3, STR_MENUCALIBRATION, 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) {
|
||||
g_eeGeneral.calib[i].mid = reusableBuffer.calib.midVals[i];
|
||||
int16_t v = reusableBuffer.calib.midVals[i] - reusableBuffer.calib.loVals[i];
|
||||
|
@ -205,8 +219,10 @@ bool menuCommonCalib(evt_t event)
|
|||
if (horus) {
|
||||
lcd->drawBitmap((LCD_W-horus->getWidth())/2, LCD_H-20-horus->getHeight(), horus);
|
||||
}
|
||||
|
||||
drawSticks();
|
||||
drawPots();
|
||||
drawMouse();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -160,7 +160,10 @@ bool menuStatsAnalogs(evt_t event)
|
|||
lcdDrawNumber(x+140, y, avgJitter[i].get());
|
||||
lcdDrawNumber(x+180, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*250/256, PREC1);
|
||||
#else
|
||||
lcdDrawNumber(x+100, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*25/256);
|
||||
if (i < NUM_STICKS+NUM_POTS)
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -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_off.lbm"
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
void drawStatusText(const char * text);
|
||||
void drawColumnHeader(const char * const * headers, const char * const * descriptions, uint8_t index);
|
||||
void drawTopbarDatetime();
|
||||
void drawStick(coord_t x, coord_t y, int16_t xval, int16_t yval);
|
||||
|
||||
#define BUTTON_ON 0x10
|
||||
#define BUTTON_OFF 0x20
|
||||
|
|
|
@ -41,7 +41,7 @@ uint8_t mixWarning;
|
|||
uint8_t startupWarningState;
|
||||
#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 ex_chans[NUM_CHNOUT] = {0}; // Outputs (before LIMITS) of the last perMain;
|
||||
|
||||
|
@ -424,27 +424,19 @@ void evalInputs(uint8_t mode)
|
|||
}
|
||||
#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]
|
||||
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);
|
||||
#endif
|
||||
|
||||
#if !defined(SIMU)
|
||||
if (i < NUM_STICKS+NUM_POTS) {
|
||||
if (IS_POT_MULTIPOS(i)) {
|
||||
v -= RESX;
|
||||
}
|
||||
else {
|
||||
CalibData * calib = &g_eeGeneral.calib[i];
|
||||
v -= calib->mid;
|
||||
v = v * (int32_t)RESX / (max((int16_t)100, (v>0 ? calib->spanPos : calib->spanNeg)));
|
||||
}
|
||||
if (IS_POT_MULTIPOS(i)) {
|
||||
v -= RESX;
|
||||
}
|
||||
else {
|
||||
CalibData * calib = &g_eeGeneral.calib[i];
|
||||
v -= calib->mid;
|
||||
v = v * (int32_t) RESX / (max((int16_t) 100, (v > 0 ? calib->spanPos : calib->spanNeg)));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -463,35 +455,26 @@ void evalInputs(uint8_t mode)
|
|||
|
||||
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
|
||||
uint8_t tmp = (uint16_t)abs(v) / 16;
|
||||
// filtering for center beep
|
||||
uint8_t tmp = (uint16_t)abs(v) / 16;
|
||||
#if defined(CPUARM)
|
||||
if (mode == e_perout_mode_normal) {
|
||||
if (tmp==0 || (tmp==1 && (bpanaCenter & mask))) {
|
||||
anaCenter |= mask;
|
||||
if ((g_model.beepANACenter & mask) && !(bpanaCenter & mask) && !calibrationState) {
|
||||
if (!IS_POT(i) || IS_POT_AVAILABLE(i)) {
|
||||
AUDIO_POT_MIDDLE(i);
|
||||
}
|
||||
if (mode == e_perout_mode_normal) {
|
||||
if (tmp==0 || (tmp==1 && (bpanaCenter & mask))) {
|
||||
anaCenter |= mask;
|
||||
if ((g_model.beepANACenter & mask) && !(bpanaCenter & mask) && !calibrationState) {
|
||||
if (!IS_POT(i) || IS_POT_AVAILABLE(i)) {
|
||||
AUDIO_POT_MIDDLE(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (tmp <= 1) anaCenter |= (tmp==0 ? mask : (bpanaCenter & mask));
|
||||
#endif
|
||||
}
|
||||
#if defined(ROTARY_ENCODERS)
|
||||
else if (i >= NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS) {
|
||||
// rotary encoders
|
||||
if (v == 0) anaCenter |= mask;
|
||||
}
|
||||
if (tmp <= 1) anaCenter |= (tmp==0 ? mask : (bpanaCenter & mask));
|
||||
#endif
|
||||
|
||||
if (ch < NUM_STICKS) { //only do this for sticks
|
||||
if (ch < NUM_STICKS) { // only do this for sticks
|
||||
#if defined(VIRTUALINPUTS)
|
||||
if (mode & e_perout_mode_nosticks) {
|
||||
v = 0;
|
||||
|
@ -519,21 +502,41 @@ void evalInputs(uint8_t mode)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#if defined(VIRTUALINPUTS)
|
||||
calibratedStick[ch] = v;
|
||||
#else
|
||||
#if defined(HELI)
|
||||
#if defined(HELI)
|
||||
if (d && (ch==ELE_STICK || ch==AIL_STICK)) {
|
||||
v = (int32_t(v) * calc100toRESX(g_model.swashR.value)) / int32_t(d);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
rawAnas[ch] = v;
|
||||
anas[ch] = v; // set values for mixer
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#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 */
|
||||
applyExpos(anas, mode);
|
||||
|
||||
|
|
|
@ -521,7 +521,7 @@ int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS)
|
|||
}
|
||||
#endif
|
||||
|
||||
static int16_t sourcesStates[NUM_STICKS+NUM_POTS];
|
||||
static int16_t sourcesStates[NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS];
|
||||
if (result == 0) {
|
||||
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS; i++) {
|
||||
if (abs(calibratedStick[i] - sourcesStates[i]) > 512) {
|
||||
|
@ -677,7 +677,7 @@ void incRotaryEncoder(uint8_t idx, int8_t inc)
|
|||
{
|
||||
g_rotenc[idx] += inc;
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1159,7 +1159,7 @@ int16_t applyLimits(uint8_t channel, int32_t value);
|
|||
|
||||
void evalInputs(uint8_t mode);
|
||||
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*/
|
||||
|
||||
|
@ -1495,9 +1495,9 @@ union ReusableBuffer
|
|||
// 103 bytes
|
||||
struct
|
||||
{
|
||||
int16_t midVals[NUM_STICKS+NUM_POTS];
|
||||
int16_t loVals[NUM_STICKS+NUM_POTS];
|
||||
int16_t hiVals[NUM_STICKS+NUM_POTS];
|
||||
int16_t midVals[NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS];
|
||||
int16_t loVals[NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS];
|
||||
int16_t hiVals[NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS];
|
||||
uint8_t state;
|
||||
#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS)
|
||||
struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue