mirror of
https://github.com/opentx/opentx.git
synced 2025-07-24 00:35:18 +03:00
Stick mode now in one global variable, it should work in Horus emerge… (#3455)
* Stick mode now in one global variable, it should work in Horus emergency mode * Improvements (suggested by Bertrand)
This commit is contained in:
parent
d2f654e32d
commit
baacc0fe29
7 changed files with 88 additions and 81 deletions
|
@ -141,6 +141,10 @@ void menuGeneralSetup(uint8_t event)
|
||||||
|
|
||||||
MENU(STR_MENURADIOSETUP, menuTabGeneral, e_Setup, ITEM_SETUP_MAX+1, {0, CASE_RTCLOCK(2) CASE_RTCLOCK(2) CASE_BATTGRAPH(1) LABEL(SOUND), CASE_AUDIO(0) CASE_BUZZER(0) CASE_VOICE(0) CASE_CPUARM(0) CASE_CPUARM(0) CASE_CPUARM(0) 0, CASE_AUDIO(0) CASE_VARIO_CPUARM(LABEL(VARIO)) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0) 0, LABEL(ALARMS), 0, CASE_CAPACITY(0) CASE_PCBSKY9X(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, CASE_CPUARM(0) CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, CASE_SPLASH_PARAM(0) CASE_GPS(0) CASE_GPS(0) CASE_PXX(0) CASE_CPUARM(0) CASE_CPUARM(0) IF_FAI_CHOICE(0) CASE_MAVLINK(0) CASE_CPUARM(0) 0, COL_TX_MODE, 1/*to force edit mode*/});
|
MENU(STR_MENURADIOSETUP, menuTabGeneral, e_Setup, ITEM_SETUP_MAX+1, {0, CASE_RTCLOCK(2) CASE_RTCLOCK(2) CASE_BATTGRAPH(1) LABEL(SOUND), CASE_AUDIO(0) CASE_BUZZER(0) CASE_VOICE(0) CASE_CPUARM(0) CASE_CPUARM(0) CASE_CPUARM(0) 0, CASE_AUDIO(0) CASE_VARIO_CPUARM(LABEL(VARIO)) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0) 0, LABEL(ALARMS), 0, CASE_CAPACITY(0) CASE_PCBSKY9X(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, CASE_CPUARM(0) CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, CASE_SPLASH_PARAM(0) CASE_GPS(0) CASE_GPS(0) CASE_PXX(0) CASE_CPUARM(0) CASE_CPUARM(0) IF_FAI_CHOICE(0) CASE_MAVLINK(0) CASE_CPUARM(0) 0, COL_TX_MODE, 1/*to force edit mode*/});
|
||||||
|
|
||||||
|
if (event == EVT_ENTRY) {
|
||||||
|
reusableBuffer.generalSettings.stickMode = g_eeGeneral.stickMode;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t sub = menuVerticalPosition - 1;
|
uint8_t sub = menuVerticalPosition - 1;
|
||||||
|
|
||||||
for (uint8_t i=0; i<LCD_LINES-1; i++) {
|
for (uint8_t i=0; i<LCD_LINES-1; i++) {
|
||||||
|
@ -557,16 +561,16 @@ void menuGeneralSetup(uint8_t event)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITEM_SETUP_STICK_MODE:
|
case ITEM_SETUP_STICK_MODE:
|
||||||
lcdDrawChar(2*FW, y, '1'+g_eeGeneral.stickMode, attr);
|
lcdDrawChar(2*FW, y, '1'+reusableBuffer.generalSettings.stickMode, attr);
|
||||||
for (uint8_t i=0; i<4; i++) {
|
for (uint8_t i=0; i<4; i++) {
|
||||||
putsMixerSource((6+4*i)*FW, y, MIXSRC_Rud + pgm_read_byte(modn12x3 + 4*g_eeGeneral.stickMode + i), 0);
|
putsMixerSource((6+4*i)*FW, y, MIXSRC_Rud + pgm_read_byte(modn12x3 + 4*reusableBuffer.generalSettings.stickMode + i), 0);
|
||||||
}
|
}
|
||||||
if (attr && s_editMode>0) {
|
if (attr && s_editMode>0) {
|
||||||
CHECK_INCDEC_GENVAR(event, g_eeGeneral.stickMode, 0, 3);
|
CHECK_INCDEC_GENVAR(event, reusableBuffer.generalSettings.stickMode, 0, 3);
|
||||||
}
|
}
|
||||||
else if (stickMode != g_eeGeneral.stickMode) {
|
else if (reusableBuffer.generalSettings.stickMode != g_eeGeneral.stickMode) {
|
||||||
pausePulses();
|
pausePulses();
|
||||||
stickMode = g_eeGeneral.stickMode;
|
g_eeGeneral.stickMode = reusableBuffer.generalSettings.stickMode;
|
||||||
checkTHR();
|
checkTHR();
|
||||||
resumePulses();
|
resumePulses();
|
||||||
clearKeyEvents();
|
clearKeyEvents();
|
||||||
|
|
|
@ -117,6 +117,10 @@ bool menuGeneralSetup(evt_t event)
|
||||||
LABEL(BACKLIGHT), 0, 0, 0, 0, 0,
|
LABEL(BACKLIGHT), 0, 0, 0, 0, 0,
|
||||||
CASE_GPS(LABEL(GPS)) CASE_GPS(0) CASE_GPS(0) CASE_PXX(0) 0, 0, 0, 0, 0, 0, 1/*to force edit mode*/ });
|
CASE_GPS(LABEL(GPS)) CASE_GPS(0) CASE_GPS(0) CASE_PXX(0) 0, 0, 0, 0, 0, 0, 1/*to force edit mode*/ });
|
||||||
|
|
||||||
|
if (event == EVT_ENTRY) {
|
||||||
|
reusableBuffer.generalSettings.stickMode = g_eeGeneral.stickMode;
|
||||||
|
}
|
||||||
|
|
||||||
int sub = menuVerticalPosition;
|
int sub = menuVerticalPosition;
|
||||||
|
|
||||||
for (int i=0; i<NUM_BODY_LINES; i++) {
|
for (int i=0; i<NUM_BODY_LINES; i++) {
|
||||||
|
@ -496,17 +500,17 @@ bool menuGeneralSetup(evt_t event)
|
||||||
{
|
{
|
||||||
lcdDrawText(MENUS_MARGIN_LEFT, y, NO_INDENT(STR_MODE));
|
lcdDrawText(MENUS_MARGIN_LEFT, y, NO_INDENT(STR_MODE));
|
||||||
char s[2] = " ";
|
char s[2] = " ";
|
||||||
s[0] = '1'+g_eeGeneral.stickMode;
|
s[0] = '1'+reusableBuffer.generalSettings.stickMode;
|
||||||
lcdDrawText(RADIO_SETUP_2ND_COLUMN, y, s, attr);
|
lcdDrawText(RADIO_SETUP_2ND_COLUMN, y, s, attr);
|
||||||
for (uint8_t i=0; i<4; i++) {
|
for (uint8_t i=0; i<4; i++) {
|
||||||
putsMixerSource(RADIO_SETUP_2ND_COLUMN + 40 + 50*i, y, MIXSRC_Rud + pgm_read_byte(modn12x3 + 4*g_eeGeneral.stickMode + i));
|
putsMixerSource(RADIO_SETUP_2ND_COLUMN + 40 + 50*i, y, MIXSRC_Rud + pgm_read_byte(modn12x3 + 4*reusableBuffer.generalSettings.stickMode + i));
|
||||||
}
|
}
|
||||||
if (attr && s_editMode>0) {
|
if (attr && s_editMode>0) {
|
||||||
CHECK_INCDEC_GENVAR(event, g_eeGeneral.stickMode, 0, 3);
|
CHECK_INCDEC_GENVAR(event, reusableBuffer.generalSettings.stickMode, 0, 3);
|
||||||
}
|
}
|
||||||
else if (stickMode != g_eeGeneral.stickMode) {
|
else if (reusableBuffer.generalSettings.stickMode != g_eeGeneral.stickMode) {
|
||||||
pausePulses();
|
pausePulses();
|
||||||
stickMode = g_eeGeneral.stickMode;
|
g_eeGeneral.stickMode = reusableBuffer.generalSettings.stickMode;
|
||||||
checkTHR();
|
checkTHR();
|
||||||
resumePulses();
|
resumePulses();
|
||||||
clearKeyEvents();
|
clearKeyEvents();
|
||||||
|
|
|
@ -116,6 +116,10 @@ void menuGeneralSetup(uint8_t event)
|
||||||
|
|
||||||
MENU(STR_MENURADIOSETUP, menuTabGeneral, e_Setup, ITEM_SETUP_MAX, { 2, 2, 1, LABEL(SOUND), 0, 0, 0, 0, 0, 0, 0, CASE_VARIO(LABEL(VARIO)) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0) 0, LABEL(ALARMS), 0, 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, 0, CASE_REVPLUS(0) CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, CASE_SPLASH_PARAM(0) CASE_GPS(LABEL(GPS)) CASE_GPS(0) CASE_GPS(0) CASE_GPS(0) CASE_PXX(0) 0, 0, IF_FAI_CHOICE(0) CASE_MAVLINK(0) 0, 0, LABEL(TX_MODE), 0, 1/*to force edit mode*/ });
|
MENU(STR_MENURADIOSETUP, menuTabGeneral, e_Setup, ITEM_SETUP_MAX, { 2, 2, 1, LABEL(SOUND), 0, 0, 0, 0, 0, 0, 0, CASE_VARIO(LABEL(VARIO)) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0) 0, LABEL(ALARMS), 0, 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, 0, CASE_REVPLUS(0) CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, CASE_SPLASH_PARAM(0) CASE_GPS(LABEL(GPS)) CASE_GPS(0) CASE_GPS(0) CASE_GPS(0) CASE_PXX(0) 0, 0, IF_FAI_CHOICE(0) CASE_MAVLINK(0) 0, 0, LABEL(TX_MODE), 0, 1/*to force edit mode*/ });
|
||||||
|
|
||||||
|
if (event == EVT_ENTRY) {
|
||||||
|
reusableBuffer.generalSettings.stickMode = g_eeGeneral.stickMode;
|
||||||
|
}
|
||||||
|
|
||||||
int sub = menuVerticalPosition;
|
int sub = menuVerticalPosition;
|
||||||
|
|
||||||
for (unsigned int i=0; i<NUM_BODY_LINES; i++) {
|
for (unsigned int i=0; i<NUM_BODY_LINES; i++) {
|
||||||
|
@ -466,16 +470,16 @@ void menuGeneralSetup(uint8_t event)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITEM_SETUP_STICK_MODE:
|
case ITEM_SETUP_STICK_MODE:
|
||||||
lcdDrawChar(2*FW, y, '1'+g_eeGeneral.stickMode, attr);
|
lcdDrawChar(2*FW, y, '1'+reusableBuffer.generalSettings.stickMode, attr);
|
||||||
for (uint8_t i=0; i<4; i++) {
|
for (uint8_t i=0; i<4; i++) {
|
||||||
putsStickName((6+4*i)*FW, y, pgm_read_byte(modn12x3 + 4*g_eeGeneral.stickMode + i), 0);
|
putsStickName((6+4*i)*FW, y, pgm_read_byte(modn12x3 + 4*reusableBuffer.generalSettings.stickMode + i), 0);
|
||||||
}
|
}
|
||||||
if (attr && s_editMode>0) {
|
if (attr && s_editMode>0) {
|
||||||
CHECK_INCDEC_GENVAR(event, g_eeGeneral.stickMode, 0, 3);
|
CHECK_INCDEC_GENVAR(event, reusableBuffer.generalSettings.stickMode, 0, 3);
|
||||||
}
|
}
|
||||||
else if (stickMode != g_eeGeneral.stickMode) {
|
else if (reusableBuffer.generalSettings.stickMode != g_eeGeneral.stickMode) {
|
||||||
pausePulses();
|
pausePulses();
|
||||||
stickMode = g_eeGeneral.stickMode;
|
g_eeGeneral.stickMode = reusableBuffer.generalSettings.stickMode;
|
||||||
checkTHR();
|
checkTHR();
|
||||||
resumePulses();
|
resumePulses();
|
||||||
clearKeyEvents();
|
clearKeyEvents();
|
||||||
|
|
|
@ -67,8 +67,6 @@ audioQueue audio;
|
||||||
|
|
||||||
uint8_t heartbeat;
|
uint8_t heartbeat;
|
||||||
|
|
||||||
uint8_t stickMode;
|
|
||||||
|
|
||||||
#if defined(OVERRIDE_CHANNEL_FUNCTION)
|
#if defined(OVERRIDE_CHANNEL_FUNCTION)
|
||||||
safetych_t safetyCh[NUM_CHNOUT];
|
safetych_t safetyCh[NUM_CHNOUT];
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -539,15 +539,13 @@ typedef struct {
|
||||||
extern const pm_uint8_t bchout_ar[];
|
extern const pm_uint8_t bchout_ar[];
|
||||||
extern const pm_uint8_t modn12x3[];
|
extern const pm_uint8_t modn12x3[];
|
||||||
|
|
||||||
extern uint8_t stickMode;
|
|
||||||
|
|
||||||
//convert from mode 1 to mode stickMode
|
//convert from mode 1 to mode stickMode
|
||||||
//NOTICE! => 0..3 -> 0..3
|
//NOTICE! => 0..3 -> 0..3
|
||||||
#define RUD_STICK 0
|
#define RUD_STICK 0
|
||||||
#define ELE_STICK 1
|
#define ELE_STICK 1
|
||||||
#define THR_STICK 2
|
#define THR_STICK 2
|
||||||
#define AIL_STICK 3
|
#define AIL_STICK 3
|
||||||
#define CONVERT_MODE(x) (((x)<=AIL_STICK) ? pgm_read_byte(modn12x3 + 4*stickMode + (x)) : (x) )
|
#define CONVERT_MODE(x) (((x)<=AIL_STICK) ? pgm_read_byte(modn12x3 + 4*g_eeGeneral.stickMode + (x)) : (x) )
|
||||||
|
|
||||||
extern uint8_t channel_order(uint8_t x);
|
extern uint8_t channel_order(uint8_t x);
|
||||||
|
|
||||||
|
@ -1486,57 +1484,60 @@ extern void opentxInit();
|
||||||
#define SD_SCREEN_FILE_LENGTH (64)
|
#define SD_SCREEN_FILE_LENGTH (64)
|
||||||
union ReusableBuffer
|
union ReusableBuffer
|
||||||
{
|
{
|
||||||
// 275 bytes
|
// 275 bytes
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
char listnames[NUM_BODY_LINES][LEN_MODEL_NAME];
|
char listnames[NUM_BODY_LINES][LEN_MODEL_NAME];
|
||||||
#if !defined(CPUARM)
|
#if !defined(CPUARM)
|
||||||
uint16_t eepromfree;
|
uint16_t eepromfree;
|
||||||
#endif
|
#endif
|
||||||
#if defined(SDCARD)
|
#if defined(SDCARD)
|
||||||
char menu_bss[POPUP_MENU_MAX_LINES][MENU_LINE_LENGTH];
|
char menu_bss[POPUP_MENU_MAX_LINES][MENU_LINE_LENGTH];
|
||||||
char mainname[45]; // because reused for SD backup / restore, max backup filename 44 chars: "/MODELS/MODEL0134353-2014-06-19-04-51-27.bin"
|
char mainname[45]; // because reused for SD backup / restore, max backup filename 44 chars: "/MODELS/MODEL0134353-2014-06-19-04-51-27.bin"
|
||||||
#else
|
#else
|
||||||
char mainname[LEN_MODEL_NAME];
|
char mainname[LEN_MODEL_NAME];
|
||||||
#endif
|
#endif
|
||||||
|
} modelsel;
|
||||||
|
|
||||||
} modelsel;
|
// 103 bytes
|
||||||
|
struct
|
||||||
// 103 bytes
|
{
|
||||||
struct
|
int16_t midVals[NUM_STICKS+NUM_POTS];
|
||||||
{
|
int16_t loVals[NUM_STICKS+NUM_POTS];
|
||||||
int16_t midVals[NUM_STICKS+NUM_POTS];
|
int16_t hiVals[NUM_STICKS+NUM_POTS];
|
||||||
int16_t loVals[NUM_STICKS+NUM_POTS];
|
uint8_t state;
|
||||||
int16_t hiVals[NUM_STICKS+NUM_POTS];
|
|
||||||
uint8_t state;
|
|
||||||
#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS)
|
#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS)
|
||||||
struct {
|
struct {
|
||||||
uint8_t stepsCount;
|
uint8_t stepsCount;
|
||||||
int16_t steps[XPOTS_MULTIPOS_COUNT];
|
int16_t steps[XPOTS_MULTIPOS_COUNT];
|
||||||
uint8_t lastCount;
|
uint8_t lastCount;
|
||||||
int16_t lastPosition;
|
int16_t lastPosition;
|
||||||
} xpotsCalib[NUM_XPOTS];
|
} xpotsCalib[NUM_XPOTS];
|
||||||
#endif
|
#endif
|
||||||
} calib;
|
} calib;
|
||||||
|
|
||||||
#if defined(SDCARD)
|
#if defined(SDCARD)
|
||||||
// 274 bytes
|
// 274 bytes
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
char lines[NUM_BODY_LINES][SD_SCREEN_FILE_LENGTH+1+1]; // the last char is used to store the flags (directory) of the line
|
char lines[NUM_BODY_LINES][SD_SCREEN_FILE_LENGTH+1+1]; // the last char is used to store the flags (directory) of the line
|
||||||
uint32_t available;
|
uint32_t available;
|
||||||
uint16_t offset;
|
uint16_t offset;
|
||||||
uint16_t count;
|
uint16_t count;
|
||||||
char originalName[SD_SCREEN_FILE_LENGTH+1];
|
char originalName[SD_SCREEN_FILE_LENGTH+1];
|
||||||
} sdmanager;
|
} sdmanager;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
char id[27];
|
char id[27];
|
||||||
} version;
|
} version;
|
||||||
#endif
|
#endif
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint8_t stickMode;
|
||||||
|
} generalSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern union ReusableBuffer reusableBuffer;
|
extern union ReusableBuffer reusableBuffer;
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) OpenTX
|
* Copyright (C) OpenTX
|
||||||
*
|
*
|
||||||
* Based on code named
|
* Based on code named
|
||||||
* th9x - http://code.google.com/p/th9x
|
* th9x - http://code.google.com/p/th9x
|
||||||
* er9x - http://code.google.com/p/er9x
|
* er9x - http://code.google.com/p/er9x
|
||||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||||
*
|
*
|
||||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
* published by the Free Software Foundation.
|
* published by the Free Software Foundation.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -97,8 +97,6 @@ void storageReadAll()
|
||||||
eeLoadModelHeaders();
|
eeLoadModelHeaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
stickMode = g_eeGeneral.stickMode;
|
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
for (uint8_t i=0; languagePacks[i]!=NULL; i++) {
|
for (uint8_t i=0; languagePacks[i]!=NULL; i++) {
|
||||||
if (!strncmp(g_eeGeneral.ttsLanguage, languagePacks[i]->id, 2)) {
|
if (!strncmp(g_eeGeneral.ttsLanguage, languagePacks[i]->id, 2)) {
|
||||||
|
|
|
@ -177,8 +177,6 @@ void storageReadAll()
|
||||||
storageEraseAll(true);
|
storageEraseAll(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
stickMode = g_eeGeneral.stickMode;
|
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
for (uint8_t i=0; languagePacks[i]!=NULL; i++) {
|
for (uint8_t i=0; languagePacks[i]!=NULL; i++) {
|
||||||
if (!strncmp(g_eeGeneral.ttsLanguage, languagePacks[i]->id, 2)) {
|
if (!strncmp(g_eeGeneral.ttsLanguage, languagePacks[i]->id, 2)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue