feat: More rotary encoder options for B&W screens (see #2045)

* First build

* Fix X9

* Update api_general.cpp

* Update translations.h

* clean up translations

* fix: B&W option handling, remove magic numbers, cleanup
- Remove references to invertRotary, change to RotEncDir or similar
- Add compatabilty importing to companion, firmware
- Rename Lua API call
- Move magic numbers to enum
- Improve B&W option handling so it doesn't apply changes while in menu

* chore: yaml regen

* fix: Add missing guards for X9D/X9D+

* fix: Wrong enum name in simu

* fix(cpn): Use correct names for UI elements

* fix: Translations

* fix: Allow `rotEncMode` in all yaml due to x9d var
Of the three X9D variants, the X9D+2019 is the only one that
has a rotary encoder as standard. However, as the base config
file is for the X9D, this meant it wasn't reading or writing the
config value. Rather than add a seperate config file for it for
a single variable, simple to just allow it across all targets.

* fix: Companion string, change colorlcd to `Choice`

Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
breadoven
2022-08-04 20:06:17 +10:00
committed by GitHub
co-authored by Peter Feerick
parent 5752cf4061
commit 62692dba6a
53 changed files with 435 additions and 131 deletions
@@ -202,7 +202,7 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
node["noJitterFilter"] = (int)rhs.noJitterFilter;
node["disableRtcWarning"] = (int)rhs.rtcCheckDisable; // TODO: verify
node["keysBacklight"] = (int)rhs.keysBacklight;
node["rotEncDirection"] = (int)rhs.rotEncDirection;
node["rotEncMode"] = (int)rhs.rotEncMode;
node["imperial"] = rhs.imperial;
node["ttsLanguage"] = rhs.ttsLanguage;
node["beepVolume"] = rhs.beepVolume + 2;
@@ -396,7 +396,8 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
node["noJitterFilter"] >> rhs.noJitterFilter; // new, but don't write old
node["disableRtcWarning"] >> rhs.rtcCheckDisable; // TODO: verify
node["keysBacklight"] >> rhs.keysBacklight;
node["rotEncDirection"] >> rhs.rotEncDirection;
node["rotEncDirection"] >> rhs.rotEncMode; // PR2045: read old name and
node["rotEncMode"] >> rhs.rotEncMode; // new, but don't write old
node["imperial"] >> rhs.imperial;
node["ttsLanguage"] >> rhs.ttsLanguage;
node["beepVolume"] >> ioffset_int(rhs.beepVolume, 2);
+1 -1
View File
@@ -238,7 +238,7 @@ class GeneralSettings {
bool noJitterFilter;
bool rtcCheckDisable;
bool keysBacklight;
bool rotEncDirection;
unsigned int rotEncMode;
unsigned int imperial;
char ttsLanguage[TTS_LANGUAGE_LEN + 1];
int beepVolume;
@@ -3035,11 +3035,10 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type
internalField.Append(new BoolField<1>(this, generalData.rtcCheckDisable));
if (IS_JUMPER_T18(board)) {
internalField.Append(new BoolField<1>(this, generalData.keysBacklight));
internalField.Append(new BoolField<1>(this, generalData.rotEncDirection));
internalField.Append(new SpareBitsField<1>(this));
}
else {
internalField.Append(new SpareBitsField<1>(this));
internalField.Append(new BoolField<1>(this, generalData.rotEncDirection));
internalField.Append(new SpareBitsField<2>(this));
}
for (int i=0; i<4; i++) {
@@ -3350,6 +3349,7 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type
if (version >= 220) {
internalField.Append(new SignedField<2>(this, generalData.uartSampleMode, "Uart Sample Mode"));
internalField.Append(new UnsignedField<2>(this, generalData.rotEncMode));
//internalField.Append(new SpareBitsField<6>(this)); // may need padding to end of 8 byte boundary
}
}
+25 -6
View File
@@ -126,11 +126,11 @@ ui(new Ui::GeneralSetup)
}
if (!firmware->getCapability(RotaryEncoderNavigation)) {
ui->invertRotary_CB->hide();
ui->invertRotary_label->hide();
ui->rotEncMode_CB->hide();
ui->rotEncMode_label->hide();
}
else {
ui->invertRotary_CB->setChecked(generalSettings.rotEncDirection);
populateRotEncModeCB();
}
if (!firmware->getCapability(HasPxxCountry)) {
@@ -483,10 +483,29 @@ void GeneralSetupPanel::on_faimode_CB_stateChanged(int)
emit modified();
}
void GeneralSetupPanel::on_invertRotary_CB_stateChanged(int)
void GeneralSetupPanel::populateRotEncModeCB()
{
generalSettings.rotEncDirection = ui->invertRotary_CB->isChecked();
emit modified();
QComboBox * b = ui->rotEncMode_CB;
QString strings[] = { tr("Normal"), tr("Inverted"), tr("Vertical Inverted, Horizontal Normal"), tr("Vertical Inverted, Horizontal Alternate") };
int itemCount = 4;
if (Boards::getCapability(firmware->getBoard(), Board::HasColorLcd)) {
itemCount = 2;
}
b->clear();
for (uint8_t i=0; i < itemCount; i++) {
b->addItem(strings[i], 0);
}
b->setCurrentIndex(generalSettings.rotEncMode);
}
void GeneralSetupPanel::on_rotEncMode_CB_currentIndexChanged(int index)
{
if (!lock) {
generalSettings.rotEncMode = index;
emit modified();
}
}
void GeneralSetupPanel::on_speakerPitchSB_editingFinished()
+2 -1
View File
@@ -49,7 +49,7 @@ class GeneralSetupPanel : public GeneralPanel
void on_countrycode_CB_currentIndexChanged(int index);
void on_units_CB_currentIndexChanged(int index);
void on_faimode_CB_stateChanged(int );
void on_invertRotary_CB_stateChanged(int);
void on_rotEncMode_CB_currentIndexChanged(int index);
void on_speakerPitchSB_editingFinished();
void on_timezoneSB_editingFinished();
void on_adjustRTC_stateChanged(int);
@@ -100,6 +100,7 @@ class GeneralSetupPanel : public GeneralPanel
void populateBacklightCB();
void populateVoiceLangCB();
void populateRotEncCB(int reCount);
void populateRotEncModeCB();
void updateVarioPitchRange();
};
+3 -10
View File
@@ -1146,21 +1146,14 @@ p, li { white-space: pre-wrap; }
<widget class="QComboBox" name="re_CB"/>
</item>
<item row="21" column="0">
<widget class="QLabel" name="invertRotary_label">
<widget class="QLabel" name="rotEncMode_label">
<property name="text">
<string>Invert Rotary</string>
<string>Rotary Encoder Mode</string>
</property>
</widget>
</item>
<item row="21" column="1">
<widget class="QCheckBox" name="invertRotary_CB">
<property name="toolTip">
<string>Invert the direction of the rotary encoder</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="rotEncMode_CB"/>
</item>
</layout>
</item>
+8 -4
View File
@@ -812,7 +812,7 @@ PACK(struct TrainerData {
#if defined(BUZZER)
#define BUZZER_FIELD int8_t buzzerMode:2 // -2=quiet, -1=only alarms, 0=no keys, 1=all (only used on AVR radios without audio hardware)
#else
#define BUZZER_FIELD int8_t spare1:2 SKIP
#define BUZZER_FIELD int8_t spare2:2 SKIP
#endif
PACK(struct RadioData {
@@ -830,7 +830,7 @@ PACK(struct RadioData {
int8_t antennaMode:2 ENUM(AntennaModes);
uint8_t disableRtcWarning:1;
uint8_t keysBacklight:1;
int8_t rotEncDirection:1;
NOBACKUP(uint8_t spare1:1 SKIP);
NOBACKUP(uint8_t internalModule ENUM(ModuleType));
NOBACKUP(TrainerData trainer);
NOBACKUP(uint8_t view); // index of view in main screen
@@ -899,13 +899,17 @@ PACK(struct RadioData {
char ownerRegistrationID[PXX2_LEN_REGISTRATION_ID];
CUST_ATTR(rotEncDirection, r_rotEncDirection, nullptr);
NOBACKUP(uint8_t rotEncMode:2);
NOBACKUP(int8_t uartSampleMode:2); // See UartSampleModes
#if defined(STICK_DEAD_ZONE)
NOBACKUP(uint8_t stickDeadZone:3);
NOBACKUP(uint8_t spare2:3 SKIP);
#else
NOBACKUP(uint8_t spare2:6 SKIP);
NOBACKUP(uint8_t stickDeadZoneSpare:3 SKIP);
#endif
NOBACKUP(uint8_t spare4:1 SKIP);
#if defined(IMU)
NOBACKUP(int8_t imuMax);
+20 -4
View File
@@ -102,7 +102,7 @@ enum {
ITEM_RADIO_SETUP_USB_MODE,
CASE_JACK_DETECT(ITEM_RADIO_SETUP_JACK_MODE)
ITEM_RADIO_SETUP_RX_CHANNEL_ORD,
CASE_ROTARY_ENCODER(ITEM_RADIO_SETUP_ROTARY_INVERSE)
CASE_ROTARY_ENCODER(ITEM_RADIO_SETUP_ROTARY_ENC_MODE)
ITEM_RADIO_SETUP_STICK_MODE_LABELS,
ITEM_RADIO_SETUP_STICK_MODE,
ITEM_RADIO_SETUP_MAX
@@ -137,7 +137,7 @@ void menuRadioSetup(event_t event)
#endif
uint8_t old_editMode = s_editMode;
MENU(STR_RADIO_SETUP, menuTabGeneral, MENU_RADIO_SETUP, HEADER_LINE+ITEM_RADIO_SETUP_MAX, {
HEADER_LINE_COLUMNS CASE_RTCLOCK(2) CASE_RTCLOCK(2) CASE_BATTGRAPH(1)
LABEL(SOUND), CASE_AUDIO(0)
@@ -181,6 +181,9 @@ void menuRadioSetup(event_t event)
if (event == EVT_ENTRY) {
reusableBuffer.generalSettings.stickMode = g_eeGeneral.stickMode;
#if defined(ROTARY_ENCODER_NAVIGATION)
reusableBuffer.generalSettings.rotaryEncoderMode = g_eeGeneral.rotEncMode;
#endif
}
uint8_t sub = menuVerticalPosition - HEADER_LINE;
@@ -661,8 +664,21 @@ void menuRadioSetup(event_t event)
break;
#if defined(ROTARY_ENCODER_NAVIGATION)
case ITEM_RADIO_SETUP_ROTARY_INVERSE:
g_eeGeneral.rotEncDirection = editCheckBox(g_eeGeneral.rotEncDirection, RADIO_SETUP_2ND_COLUMN, y, STR_INVERT_ROTARY, attr, event);
case ITEM_RADIO_SETUP_ROTARY_ENC_MODE:
lcdDrawTextAlignedLeft(y, STR_ROTARY_ENC_MODE);
lcdDrawTextAtIndex(RADIO_SETUP_2ND_COLUMN, y, STR_ROTARY_ENC_OPT,
reusableBuffer.generalSettings.rotaryEncoderMode,
attr);
if (attr && s_editMode > 0) {
CHECK_INCDEC_GENVAR(event,
reusableBuffer.generalSettings.rotaryEncoderMode,
ROTARY_ENCODER_MODE_NORMAL,
ROTARY_ENCODER_MODE_INVERT_VERT_HORZ_ALT);
} else if (reusableBuffer.generalSettings.rotaryEncoderMode !=
g_eeGeneral.rotEncMode) {
g_eeGeneral.rotEncMode =
reusableBuffer.generalSettings.rotaryEncoderMode;
}
break;
#endif
+20 -4
View File
@@ -95,7 +95,7 @@ enum MenuRadioSetupItems {
ITEM_RADIO_SETUP_SWITCHES_DELAY,
ITEM_RADIO_SETUP_USB_MODE,
ITEM_RADIO_SETUP_RX_CHANNEL_ORD,
CASE_ROTARY_ENCODER(ITEM_RADIO_SETUP_ROTARY_INVERSE)
CASE_ROTARY_ENCODER(ITEM_RADIO_SETUP_ROTARY_ENC_MODE)
ITEM_RADIO_SETUP_STICK_MODE_LABELS,
ITEM_RADIO_SETUP_STICK_MODE,
ITEM_RADIO_SETUP_MAX
@@ -124,7 +124,7 @@ void menuRadioSetup(event_t event)
#endif
uint8_t old_editMode = s_editMode;
MENU(STR_RADIO_SETUP, menuTabGeneral, MENU_RADIO_SETUP, ITEM_RADIO_SETUP_MAX, {
2, // date
2, // time
@@ -183,6 +183,9 @@ void menuRadioSetup(event_t event)
if (event == EVT_ENTRY) {
reusableBuffer.generalSettings.stickMode = g_eeGeneral.stickMode;
#if defined(ROTARY_ENCODER_NAVIGATION)
reusableBuffer.generalSettings.rotaryEncoderMode = g_eeGeneral.rotEncMode;
#endif
}
int sub = menuVerticalPosition;
@@ -591,8 +594,21 @@ void menuRadioSetup(event_t event)
break;
#if defined(ROTARY_ENCODER_NAVIGATION)
case ITEM_RADIO_SETUP_ROTARY_INVERSE:
g_eeGeneral.rotEncDirection = editCheckBox(g_eeGeneral.rotEncDirection, RADIO_SETUP_2ND_COLUMN, y, STR_INVERT_ROTARY, attr, event);
case ITEM_RADIO_SETUP_ROTARY_ENC_MODE:
lcdDrawTextAlignedLeft(y, STR_ROTARY_ENC_MODE);
lcdDrawTextAtIndex(RADIO_SETUP_2ND_COLUMN, y, STR_ROTARY_ENC_OPT,
reusableBuffer.generalSettings.rotaryEncoderMode,
attr);
if (attr && s_editMode > 0) {
CHECK_INCDEC_GENVAR(event,
reusableBuffer.generalSettings.rotaryEncoderMode,
ROTARY_ENCODER_MODE_NORMAL,
ROTARY_ENCODER_MODE_INVERT_VERT_HORZ_ALT);
} else if (reusableBuffer.generalSettings.rotaryEncoderMode !=
g_eeGeneral.rotEncMode) {
g_eeGeneral.rotEncMode =
reusableBuffer.generalSettings.rotaryEncoderMode;
}
break;
#endif
+4 -2
View File
@@ -698,8 +698,10 @@ void RadioSetupPage::build(FormWindow * window)
#if defined(ROTARY_ENCODER_NAVIGATION)
line = window->newLine(&grid);
new StaticText(line, rect_t{}, STR_INVERT_ROTARY, 0, COLOR_THEME_PRIMARY1);
new CheckBox(line, rect_t{}, GET_SET_DEFAULT(g_eeGeneral.rotEncDirection));
new StaticText(line, rect_t{}, STR_ROTARY_ENC_MODE, 0, COLOR_THEME_PRIMARY1);
new Choice(line, rect_t{}, STR_ROTARY_ENC_OPT, ROTARY_ENCODER_MODE_NORMAL,
ROTARY_ENCODER_MODE_INVERT_BOTH,
GET_SET_DEFAULT(g_eeGeneral.rotEncMode));
#endif
// RX channel order
+13 -1
View File
@@ -94,7 +94,19 @@ const char * runPopupMenu(event_t event)
drawVerticalScrollbar(MENU_X+MENU_W-1, y+1, MENU_MAX_DISPLAY_LINES * (FH+1), popupMenuOffset, popupMenuItemsCount, display_count);
}
switch (event) {
event_t eventTemp = event;
#if defined(ROTARY_ENCODER_NAVIGATION) && !defined(COLORLCD)
if (g_eeGeneral.rotEncMode >= ROTARY_ENCODER_MODE_INVERT_BOTH) {
if (eventTemp == EVT_ROTARY_LEFT) {
eventTemp = EVT_ROTARY_RIGHT;
} else if (eventTemp == EVT_ROTARY_RIGHT) {
eventTemp = EVT_ROTARY_LEFT;
}
}
#endif
switch (eventTemp) {
#if defined(ROTARY_ENCODER_NAVIGATION)
CASE_EVT_ROTARY_LEFT
#endif
+24 -5
View File
@@ -345,7 +345,16 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t
case EVT_KEY_FIRST(KEY_DOWN):
if (s_editMode>0) break;
do {
#if defined(ROTARY_ENCODER_NAVIGATION)
if (g_eeGeneral.rotEncMode >=
ROTARY_ENCODER_MODE_INVERT_VERT_HORZ_NORM) {
DEC(l_posVert, 0, maxrow);
} else {
INC(l_posVert, 0, maxrow);
}
#else
INC(l_posVert, 0, maxrow);
#endif
} while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert));
#if defined(ROTARY_ENCODER_NAVIGATION)
@@ -368,12 +377,13 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t
if (l_posHorz > 0) {
l_posHorz--;
break;
}
else if (IS_ROTARY_LEFT(event) && s_editMode == 0) {
} else if (IS_ROTARY_LEFT(event) && s_editMode == 0) {
l_posHorz = 0xff;
}
else {
l_posHorz = maxcol;
} else {
l_posHorz =
g_eeGeneral.rotEncMode == ROTARY_ENCODER_MODE_INVERT_VERT_HORZ_ALT
? 0
: maxcol;
break;
}
#else
@@ -388,7 +398,16 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t
if (s_editMode>0) break;
do {
#if defined(ROTARY_ENCODER_NAVIGATION)
if (g_eeGeneral.rotEncMode >=
ROTARY_ENCODER_MODE_INVERT_VERT_HORZ_NORM) {
INC(l_posVert, 0, maxrow);
} else {
DEC(l_posVert, 0, maxrow);
}
#else
DEC(l_posVert, 0, maxrow);
#endif
} while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert));
#if defined(ROTARY_ENCODER_NAVIGATION)
+27 -4
View File
@@ -344,7 +344,16 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, uint8_t
}
do {
#if defined(ROTARY_ENCODER_NAVIGATION)
if (g_eeGeneral.rotEncMode >=
ROTARY_ENCODER_MODE_INVERT_VERT_HORZ_NORM) {
DEC(l_posVert, MENU_FIRST_LINE_EDIT(horTab, horTabMax), rowcount - 1);
} else {
INC(l_posVert, MENU_FIRST_LINE_EDIT(horTab, horTabMax), rowcount - 1);
}
#else
INC(l_posVert, MENU_FIRST_LINE_EDIT(horTab, horTabMax), rowcount-1);
#endif
} while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert));
s_editMode = 0; // if we go down, we must be in this mode
@@ -365,17 +374,31 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, uint8_t
DEC(l_posHorz, 0, maxcol);
break;
}
}
else if (l_posHorz > 0) {
} else if (l_posHorz > 0) {
l_posHorz--;
break;
}
else {
} else {
#if defined(ROTARY_ENCODER_NAVIGATION)
l_posHorz =
g_eeGeneral.rotEncMode == ROTARY_ENCODER_MODE_INVERT_VERT_HORZ_ALT
? 0
: 0xff;
#else
l_posHorz = 0xff;
#endif
}
do {
#if defined(ROTARY_ENCODER_NAVIGATION)
if (g_eeGeneral.rotEncMode >=
ROTARY_ENCODER_MODE_INVERT_VERT_HORZ_NORM) {
INC(l_posVert, MENU_FIRST_LINE_EDIT(horTab, horTabMax), rowcount - 1);
} else {
DEC(l_posVert, MENU_FIRST_LINE_EDIT(horTab, horTabMax), rowcount - 1);
}
#else
DEC(l_posVert, MENU_FIRST_LINE_EDIT(horTab, horTabMax), rowcount-1);
#endif
} while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert));
s_editMode = 0; // if we go up, we must be in this mode
+29 -6
View File
@@ -439,7 +439,16 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t
}
do {
INC(l_posVert, MENU_FIRST_LINE_EDIT(horTab, horTabMax), rowcount-1);
#if defined(ROTARY_ENCODER_NAVIGATION)
if (g_eeGeneral.rotEncMode >=
ROTARY_ENCODER_MODE_INVERT_VERT_HORZ_NORM) {
DEC(l_posVert, MENU_FIRST_LINE_EDIT(horTab, horTabMax), rowcount - 1);
} else {
INC(l_posVert, MENU_FIRST_LINE_EDIT(horTab, horTabMax), rowcount - 1);
}
#else
DEC(l_posVert, MENU_FIRST_LINE_EDIT(horTab, horTabMax), rowcount - 1);
#endif
} while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert));
s_editMode = 0; // if we go down, we must be in this mode
@@ -458,17 +467,31 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t
DEC(l_posHorz, 0, maxcol);
break;
}
}
else if (l_posHorz > 0) {
} else if (l_posHorz > 0) {
l_posHorz--;
break;
}
else {
} else {
#if defined(ROTARY_ENCODER_NAVIGATION)
l_posHorz =
g_eeGeneral.rotEncMode == ROTARY_ENCODER_MODE_INVERT_VERT_HORZ_ALT
? 0
: 0xff;
#else
l_posHorz = 0xff;
#endif
}
do {
DEC(l_posVert, MENU_FIRST_LINE_EDIT(horTab, horTabMax), rowcount-1);
#if defined(ROTARY_ENCODER_NAVIGATION)
if (g_eeGeneral.rotEncMode >=
ROTARY_ENCODER_MODE_INVERT_VERT_HORZ_NORM) {
INC(l_posVert, MENU_FIRST_LINE_EDIT(horTab, horTabMax), rowcount - 1);
} else {
DEC(l_posVert, MENU_FIRST_LINE_EDIT(horTab, horTabMax), rowcount - 1);
}
#else
DEC(l_posVert, MENU_FIRST_LINE_EDIT(horTab, horTabMax), rowcount - 1);
#endif
} while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert));
s_editMode = 0; // if we go up, we must be in this mode
+42 -21
View File
@@ -567,6 +567,26 @@ static int luaGetRotEncSpeed(lua_State * L)
return 1;
}
/*luadoc
@function getRotEncMode()
Return rotary encoder mode
@retval number in list: Normal = 0, Both V and H inverted = 1, V-N = 2, V-A = 3
return 0 on radio without rotary encoder
@status current Introduced in 2.8.0
*/
static int luaGetRotEncMode(lua_State * L)
{
#if defined(ROTARY_ENCODER_NAVIGATION)
lua_pushunsigned(L, g_eeGeneral.rotEncMode);
#else
lua_pushunsigned(L, 0);
#endif
return 1;
}
/*luadoc
@function sportTelemetryPop()
@@ -1020,12 +1040,12 @@ static int luaGetFieldInfo(lua_State * L)
{
bool found;
LuaField field;
if (lua_type(L, 1) == LUA_TNUMBER)
found = luaFindFieldById(luaL_checkinteger(L, 1), field, FIND_FIELD_DESC);
else
found = luaFindFieldByName(luaL_checkstring(L, 1), field, FIND_FIELD_DESC);
if (found) {
lua_newtable(L);
lua_pushtableinteger(L, "id", field.id);
@@ -1594,7 +1614,7 @@ static int luaPopupConfirmation(lua_State * L)
warningText = nullptr;
lua_pushnil(L);
}
return 1;
}
@@ -1996,7 +2016,7 @@ static int luaSerialWrite(lua_State * L)
const char* p = str;
while(wr_len--) _sendCb(_ctx, *p++);
}
return 0;
}
@@ -2055,7 +2075,7 @@ static int luaSerialRead(lua_State * L)
static int shmVar[16] = {0};
/*luadoc
@function setShmVar(id, value)
@function setShmVar(id, value)
@param id: integer between 1 and 16 identifying the shared memory variable.
@@ -2072,10 +2092,10 @@ static int luaSetShmVar(lua_State * L)
{
int id = luaL_checkinteger(L, 1);
int value = luaL_checkinteger(L, 2);
if (1 <= id && id <= 16)
shmVar[id - 1] = value;
return 0;
}
@@ -2096,7 +2116,7 @@ Gets the value of a shared memory variable that can be used for passing data bet
static int luaGetShmVar(lua_State * L)
{
int id = luaL_checkinteger(L, 1);
if (1 <= id && id <= 16)
lua_pushinteger(L, shmVar[id - 1]);
else
@@ -2107,14 +2127,14 @@ static int luaGetShmVar(lua_State * L)
#endif
/*luadoc
@function setStickySwitch(id, value)
@function setStickySwitch(id, value)
@param id: integer identifying the sticky logical switch (zero for LS1 etc.).
@param value: true/false. The new value of the sticky logical switch.
@retval bufferFull: true/false. This function sends a message from Lua to the logical switch processor
via a buffer with eight slots that are read 10 times per second. If the buffer is full, then a true value
@retval bufferFull: true/false. This function sends a message from Lua to the logical switch processor
via a buffer with eight slots that are read 10 times per second. If the buffer is full, then a true value
is returned and no messages was sent (i.e. the switch was not changed).
Sets the value of a sticky logical switch.
@@ -2165,7 +2185,7 @@ static int luaGetLogicalSwitchValue(lua_State * L)
/*luadoc
@function getSwitchIndex(positionName)
@param positionName: string naming a switch position as it is shown on radio menus where you can select a switch. Notice that many names have
@param positionName: string naming a switch position as it is shown on radio menus where you can select a switch. Notice that many names have
special characters in them like arrow up/down etc.
@retval value: integer. The switchIndex, which can be used as input for `getSwitchName(switchIndex)` and `getSwitchValue(switchIndex)`. Also corresponds
@@ -2180,12 +2200,12 @@ static int luaGetSwitchIndex(lua_State * L)
bool negate = false;
bool found = false;
swsrc_t idx;
if (name[0] == '!') {
name++;
negate = true;
}
for (idx = SWSRC_NONE; idx < SWSRC_COUNT; idx++) {
if (isSwitchAvailable(idx, ModelCustomFunctionsContext)) {
char* s = getSwitchPositionName(idx);
@@ -2195,7 +2215,7 @@ static int luaGetSwitchIndex(lua_State * L)
}
}
}
if (found) {
if (negate)
idx = -idx;
@@ -2210,7 +2230,7 @@ static int luaGetSwitchIndex(lua_State * L)
/*luadoc
@function getSwitchName(switchIndex)
@param switchIndex: integer identifying a switch as returned by `getSwitchIndex(positionName)` or fields in the table returned by
@param switchIndex: integer identifying a switch as returned by `getSwitchIndex(positionName)` or fields in the table returned by
`model.getLogicalSwitch(switch)` identifying switches.
@retval value: string naming the switch position as it is shown on radio menus where a switch can be chosen.
@@ -2233,7 +2253,7 @@ static int luaGetSwitchName(lua_State * L)
/*luadoc
@function getSwitchValue(switchIndex)
@param switchIndex: integer identifying a switch as returned by `getSwitchIndex(positionName)` or fields in the table returned by
@param switchIndex: integer identifying a switch as returned by `getSwitchIndex(positionName)` or fields in the table returned by
`model.getLogicalSwitch(switch)` identifying switches.
@retval value: true/false. The value of the switch.
@@ -2267,7 +2287,7 @@ static int luaNextSwitch(lua_State * L)
{
swsrc_t last = luaL_checkinteger(L, 1);
swsrc_t idx = luaL_checkinteger(L, 2);
while (++idx <= last) {
if (isSwitchAvailable(idx, ModelCustomFunctionsContext)) {
char* name = getSwitchPositionName(idx);
@@ -2276,7 +2296,7 @@ static int luaNextSwitch(lua_State * L)
return 2;
}
}
lua_pushnil(L);
return 1;
}
@@ -2285,7 +2305,7 @@ static int luaSwitches(lua_State * L)
{
swsrc_t first;
swsrc_t last;
if (lua_isnumber(L, 1)) {
first = luaL_checkinteger(L, 1) - 1;
if (first < SWSRC_FIRST - 1)
@@ -2385,7 +2405,7 @@ static int luaNextSource(lua_State * L)
{
mixsrc_t last = luaL_checkinteger(L, 1);
mixsrc_t idx = luaL_checkinteger(L, 2);
while (++idx <= last) {
if (isSourceAvailable(idx)) {
char srcName[maxSourceNameLength];
@@ -2433,6 +2453,7 @@ const luaL_Reg opentxLib[] = {
{ "getGeneralSettings", luaGetGeneralSettings },
{ "getGlobalTimer", luaGetGlobalTimer },
{ "getRotEncSpeed", luaGetRotEncSpeed },
{ "getRotEncMode", luaGetRotEncMode },
{ "getValue", luaGetValue },
{ "getRAS", luaGetRAS },
{ "getTxGPS", luaGetTxGPS },
+2 -2
View File
@@ -597,7 +597,7 @@ void resetBacklightTimeout()
uint16_t autoOff = g_eeGeneral.lightAutoOff;
#if defined(COLORLCD)
// prevent the timeout from being 0 seconds on color lcd radios
autoOff = std::max<uint16_t>(1, autoOff);
autoOff = std::max<uint16_t>(1, autoOff);
#endif
lightOffCounter = (autoOff*250) << 1;
}
@@ -1760,7 +1760,7 @@ void opentxInit()
#endif // #if !defined(EEPROM)
initSerialPorts();
currentSpeakerVolume = requiredSpeakerVolume = g_eeGeneral.speakerVolume + VOLUME_LEVEL_DEF;
currentBacklightBright = requiredBacklightBright = g_eeGeneral.backlightBright;
#if !defined(SOFTWARE_VOLUME)
+12
View File
@@ -212,6 +212,15 @@
#define RADIO_TOOLS
#endif
#if defined(ROTARY_ENCODER_NAVIGATION)
enum RotaryEncoderMode {
ROTARY_ENCODER_MODE_NORMAL,
ROTARY_ENCODER_MODE_INVERT_BOTH,
ROTARY_ENCODER_MODE_INVERT_VERT_HORZ_NORM,
ROTARY_ENCODER_MODE_INVERT_VERT_HORZ_ALT
};
#endif
// RESX range is used for internal calculation; The menu says -100.0 to 100.0; internally it is -1024 to 1024 to allow some optimizations
#define RESX_SHIFT 10
#define RESX 1024
@@ -986,6 +995,9 @@ union ReusableBuffer
struct {
uint8_t stickMode;
#if defined(ROTARY_ENCODER_NAVIGATION)
uint8_t rotaryEncoderMode;
#endif
} generalSettings;
struct {
@@ -1807,6 +1807,13 @@ static void r_jitterFilter(void* user, uint8_t* data, uint32_t bitoffs,
yaml_put_bits(data, i, bitoffs, 1);
}
static void r_rotEncDirection(void* user, uint8_t* data, uint32_t bitoffs,
const char* val, uint8_t val_len)
{
uint32_t i = yaml_str2uint(val, val_len);
yaml_put_bits(data, i, bitoffs, 2);
}
static void r_telemetryBaudrate(void* user, uint8_t* data, uint32_t bitoffs,
const char* val, uint8_t val_len)
{
@@ -367,7 +367,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_SIGNED( "rotEncDirection", 1 ),
YAML_PADDING( 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
@@ -437,9 +437,11 @@ static const struct YamlNode struct_RadioData[] = {
YAML_STRING("themeName", 8),
YAML_STRUCT("themeData", 480, struct_OpenTxTheme__PersistentData, NULL),
YAML_STRING("ownerRegistrationID", 8),
YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr),
YAML_UNSIGNED( "rotEncMode", 2 ),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_UNSIGNED( "stickDeadZone", 3 ),
YAML_PADDING( 3 ),
YAML_PADDING( 1 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -338,7 +338,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_SIGNED( "rotEncDirection", 1 ),
YAML_PADDING( 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
@@ -406,8 +406,11 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 8 ),
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr),
YAML_UNSIGNED( "rotEncMode", 2 ),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 6 ),
YAML_PADDING( 3 ),
YAML_PADDING( 1 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -338,7 +338,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_SIGNED( "rotEncDirection", 1 ),
YAML_PADDING( 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
@@ -406,8 +406,11 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 8 ),
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr),
YAML_UNSIGNED( "rotEncMode", 2 ),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 6 ),
YAML_PADDING( 3 ),
YAML_PADDING( 1 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -338,7 +338,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_SIGNED( "rotEncDirection", 1 ),
YAML_PADDING( 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
@@ -406,8 +406,11 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 8 ),
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr),
YAML_UNSIGNED( "rotEncMode", 2 ),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 6 ),
YAML_PADDING( 3 ),
YAML_PADDING( 1 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -346,7 +346,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_SIGNED( "rotEncDirection", 1 ),
YAML_PADDING( 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
@@ -412,8 +412,11 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 96 ),
YAML_PADDING( 144 ),
YAML_STRING("ownerRegistrationID", 8),
YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr),
YAML_UNSIGNED( "rotEncMode", 2 ),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 6 ),
YAML_PADDING( 3 ),
YAML_PADDING( 1 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -338,7 +338,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_SIGNED( "rotEncDirection", 1 ),
YAML_PADDING( 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
@@ -406,8 +406,11 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 8 ),
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr),
YAML_UNSIGNED( "rotEncMode", 2 ),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 6 ),
YAML_PADDING( 3 ),
YAML_PADDING( 1 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -338,7 +338,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_SIGNED( "rotEncDirection", 1 ),
YAML_PADDING( 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
@@ -406,8 +406,11 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 8 ),
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr),
YAML_UNSIGNED( "rotEncMode", 2 ),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 6 ),
YAML_PADDING( 3 ),
YAML_PADDING( 1 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -390,7 +390,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_SIGNED( "rotEncDirection", 1 ),
YAML_PADDING( 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
@@ -460,8 +460,11 @@ static const struct YamlNode struct_RadioData[] = {
YAML_STRING("themeName", 8),
YAML_STRUCT("themeData", 480, struct_OpenTxTheme__PersistentData, NULL),
YAML_STRING("ownerRegistrationID", 8),
YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr),
YAML_UNSIGNED( "rotEncMode", 2 ),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 6 ),
YAML_PADDING( 3 ),
YAML_PADDING( 1 ),
YAML_SIGNED( "imuMax", 8 ),
YAML_SIGNED( "imuOffset", 8 ),
YAML_END
@@ -388,7 +388,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_SIGNED( "rotEncDirection", 1 ),
YAML_PADDING( 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
@@ -458,8 +458,11 @@ static const struct YamlNode struct_RadioData[] = {
YAML_STRING("themeName", 8),
YAML_STRUCT("themeData", 480, struct_OpenTxTheme__PersistentData, NULL),
YAML_STRING("ownerRegistrationID", 8),
YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr),
YAML_UNSIGNED( "rotEncMode", 2 ),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 6 ),
YAML_PADDING( 3 ),
YAML_PADDING( 1 ),
YAML_SIGNED( "imuMax", 8 ),
YAML_SIGNED( "imuOffset", 8 ),
YAML_END
@@ -338,7 +338,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_SIGNED( "rotEncDirection", 1 ),
YAML_PADDING( 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
@@ -406,8 +406,11 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 8 ),
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr),
YAML_UNSIGNED( "rotEncMode", 2 ),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 6 ),
YAML_PADDING( 3 ),
YAML_PADDING( 1 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -345,7 +345,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_SIGNED( "rotEncDirection", 1 ),
YAML_PADDING( 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
@@ -413,8 +413,11 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 8 ),
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr),
YAML_UNSIGNED( "rotEncMode", 2 ),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 6 ),
YAML_PADDING( 3 ),
YAML_PADDING( 1 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -384,7 +384,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_SIGNED( "rotEncDirection", 1 ),
YAML_PADDING( 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
@@ -452,8 +452,11 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 8 ),
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr),
YAML_UNSIGNED( "rotEncMode", 2 ),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 6 ),
YAML_PADDING( 3 ),
YAML_PADDING( 1 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -325,7 +325,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_SIGNED( "rotEncDirection", 1 ),
YAML_PADDING( 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
@@ -391,8 +391,11 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 120 ),
YAML_PADDING( 120 ),
YAML_STRING("ownerRegistrationID", 8),
YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr),
YAML_UNSIGNED( "rotEncMode", 2 ),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 6 ),
YAML_PADDING( 3 ),
YAML_PADDING( 1 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -333,7 +333,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_SIGNED( "rotEncDirection", 1 ),
YAML_PADDING( 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
@@ -401,8 +401,11 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 8 ),
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr),
YAML_UNSIGNED( "rotEncMode", 2 ),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 6 ),
YAML_PADDING( 3 ),
YAML_PADDING( 1 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -330,7 +330,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_SIGNED( "rotEncDirection", 1 ),
YAML_PADDING( 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
@@ -398,8 +398,11 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 8 ),
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr),
YAML_UNSIGNED( "rotEncMode", 2 ),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 6 ),
YAML_PADDING( 3 ),
YAML_PADDING( 1 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -332,7 +332,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_SIGNED( "rotEncDirection", 1 ),
YAML_PADDING( 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
@@ -400,8 +400,11 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 8 ),
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr),
YAML_UNSIGNED( "rotEncMode", 2 ),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 6 ),
YAML_PADDING( 3 ),
YAML_PADDING( 1 ),
YAML_SIGNED( "imuMax", 8 ),
YAML_SIGNED( "imuOffset", 8 ),
YAML_END
@@ -338,7 +338,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_SIGNED( "rotEncDirection", 1 ),
YAML_PADDING( 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
@@ -406,8 +406,11 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 8 ),
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_CUSTOM("rotEncDirection",r_rotEncDirection,nullptr),
YAML_UNSIGNED( "rotEncMode", 2 ),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 6 ),
YAML_PADDING( 3 ),
YAML_PADDING( 1 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -82,8 +82,10 @@ void rotaryEncoderInit()
#define INC_ROT 1
#define INC_ROT_2 2
#else
#define INC_ROT (g_eeGeneral.rotEncDirection ? -1 : 1);
#define INC_ROT_2 (g_eeGeneral.rotEncDirection ? -2 : 2);
#define INC_ROT \
(g_eeGeneral.rotEncMode == ROTARY_ENCODER_MODE_INVERT_BOTH ? -1 : 1);
#define INC_ROT_2 \
(g_eeGeneral.rotEncMode == ROTARY_ENCODER_MODE_INVERT_BOTH ? -2 : 2);
#endif
void rotaryEncoderCheck()
+2 -2
View File
@@ -276,8 +276,8 @@ void OpenTxSimulator::setInputValue(int type, uint8_t index, int16_t value)
void OpenTxSimulator::rotaryEncoderEvent(int steps)
{
#if defined(ROTARY_ENCODER_NAVIGATION)
(g_eeGeneral.rotEncDirection ? steps *= -1 : steps);
(g_eeGeneral.rotEncMode >= ROTARY_ENCODER_MODE_INVERT_BOTH ? steps *= -1
: steps);
ROTARY_ENCODER_NAVIGATION_VALUE += steps * ROTARY_ENCODER_GRANULARITY;
#else
// TODO : this should probably be handled in the GUI
+2 -1
View File
@@ -53,6 +53,7 @@ ISTR(VTELEMSCREENTYPE);
ISTR(VKEYS);
ISTR(VSWITCHES);
ISTR(VSRCRAW);
ISTR(ROTARY_ENC_OPT);
ISTR(VTMRMODES);
ISTR(VPERSISTENT);
ISTR(VUNITSSYSTEM);
@@ -477,7 +478,7 @@ const char STR_OWN[] = TR_OWN;
const char STR_DATE[] = TR_DATE;
const char STR_CHANNELS_MONITOR[] = TR_CHANNELS_MONITOR;
const char STR_ROTARY_ENCODER[] = TR_ROTARY_ENCODER;
const char STR_INVERT_ROTARY[] = TR_INVERT_ROTARY;
const char STR_ROTARY_ENC_MODE[] = TR_ROTARY_ENC_MODE;
const char STR_MIXERS_MONITOR[] = TR_MIXERS_MONITOR;
const char STR_PATH_TOO_LONG[] = TR_PATH_TOO_LONG;
const char STR_VIEW_TEXT[] = TR_VIEW_TEXT;
+3 -1
View File
@@ -138,6 +138,8 @@ extern const char* STR_VKEYS[];
extern const char* STR_VSWITCHES[];
extern const char* STR_VSRCRAW[];
extern const char* STR_ROTARY_ENC_OPT[];
#if defined(TRANSLATIONS_CZ)
extern const char* STR_INPUTNAMES[];
#endif
@@ -727,7 +729,7 @@ extern const char STR_GLOBAL_VAR[];
extern const char STR_OWN[];
extern const char STR_DATE[];
extern const char STR_ROTARY_ENCODER[];
extern const char STR_INVERT_ROTARY[];
extern const char STR_ROTARY_ENC_MODE[];
extern const char STR_CHANNELS_MONITOR[];
extern const char STR_MIXERS_MONITOR[];
extern const char STR_PATH_TOO_LONG[];
+7 -1
View File
@@ -219,6 +219,12 @@
#define TR_ON_ONE_SWITCHES "ON","One"
#if defined(COLORLCD)
#define TR_ROTARY_ENC_OPT "Normal","Inverted"
#else
#define TR_ROTARY_ENC_OPT "Normal","Inverted","V-I H-N","V-I H-A"
#endif
#if defined(IMU)
#define TR_IMU_VSRCRAW "TltX","TltY",
#else
@@ -748,7 +754,7 @@
#define TR_DATE "日期"
#define TR_MONTHS { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
#define TR_ROTARY_ENCODER "滚轮"
#define TR_INVERT_ROTARY "滚轮反向"
#define TR_ROTARY_ENC_MODE TR("RotEnc Mode","Rotary Encoder Mode")
#define TR_CHANNELS_MONITOR "通道查看器"
#define TR_MIXERS_MONITOR "混控查看器"
#define TR_PATH_TOO_LONG "路径太长"
+7 -1
View File
@@ -236,6 +236,12 @@
#define TR_ON_ONE_SWITCHES "ZAP","One"
#if defined(COLORLCD)
#define TR_ROTARY_ENC_OPT "Normal","Inverted"
#else
#define TR_ROTARY_ENC_OPT "Normal","Inverted","V-I H-N","V-I H-A"
#endif
#if defined(IMU)
#define TR_IMU_VSRCRAW "TltX","TltY",
#else
@@ -763,7 +769,7 @@
#define TR_DATE "Datum"
#define TR_MONTHS { "Led", "Úno", "Bře", "Dub", "Kvě", "Čvn", "Čvc", "Srp", "Zář", "Říj", "Lis", "Pro" }
#define TR_ROTARY_ENCODER "R.Enko"
#define TR_INVERT_ROTARY "Invertovat kolečko"
#define TR_ROTARY_ENC_MODE TR("RotEnc Mode","Rotary Encoder Mode")
#define TR_CHANNELS_MONITOR "MONITOR KANÁLU"
#define TR_MIXERS_MONITOR "MONITOR MIXU"
#define TR_PATH_TOO_LONG "Cesta je moc dlouhá"
+1 -1
View File
@@ -748,7 +748,7 @@
#define TR_DATE "Dato"
#define TR_MONTHS { "Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec" }
#define TR_ROTARY_ENCODER "R.E."
#define TR_INVERT_ROTARY "Invert Rotary"
#define TR_ROTARY_ENC_MODE TR("RotEnc Mode","Rotary Encoder Mode")
#define TR_CHANNELS_MONITOR "KANAL MONITOR"
#define TR_MIXERS_MONITOR "MIX MONITOR"
#define TR_PATH_TOO_LONG "Sti for lang"
+7 -1
View File
@@ -221,6 +221,12 @@
#define TR_ON_ONE_SWITCHES "ON","One"
#if defined(COLORLCD)
#define TR_ROTARY_ENC_OPT "Normal","Inverted"
#else
#define TR_ROTARY_ENC_OPT "Normal","Inverted","V-I H-N","V-I H-A"
#endif
#if defined(IMU)
#define TR_IMU_VSRCRAW "TltX","TltY",
#else
@@ -746,7 +752,7 @@
#define TR_DATE "Datum:"
#define TR_MONTHS { "Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez" }
#define TR_ROTARY_ENCODER "Drehgeber"
#define TR_INVERT_ROTARY "Invert Rotary"
#define TR_ROTARY_ENC_MODE TR("RotEnc Mode","Rotary Encoder Mode")
#define TR_CHANNELS_MONITOR "Kanal-Monitor==>"
#define TR_MIXERS_MONITOR "==>Mischer Monitor"
#define TR_PATH_TOO_LONG "Pfad zu Lang"
+7 -1
View File
@@ -219,6 +219,12 @@
#define TR_ON_ONE_SWITCHES "ON","One"
#if defined(COLORLCD)
#define TR_ROTARY_ENC_OPT "Normal","Inverted"
#else
#define TR_ROTARY_ENC_OPT "Normal","Inverted","V-I H-N","V-I H-A"
#endif
#if defined(IMU)
#define TR_IMU_VSRCRAW "TltX","TltY",
#else
@@ -748,7 +754,7 @@
#define TR_DATE "Date"
#define TR_MONTHS { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
#define TR_ROTARY_ENCODER "R.E."
#define TR_INVERT_ROTARY "Invert Rotary"
#define TR_ROTARY_ENC_MODE TR("RotEnc Mode","Rotary Encoder Mode")
#define TR_CHANNELS_MONITOR "CHANNELS MONITOR"
#define TR_MIXERS_MONITOR "MIXERS MONITOR"
#define TR_PATH_TOO_LONG "Path too long"
+7 -1
View File
@@ -218,6 +218,12 @@
#define TR_ON_ONE_SWITCHES "ON","One"
#if defined(COLORLCD)
#define TR_ROTARY_ENC_OPT "Normal","Inverted"
#else
#define TR_ROTARY_ENC_OPT "Normal","Inverted","V-I H-N","V-I H-A"
#endif
#if defined(IMU)
#define TR_IMU_VSRCRAW "TltX","TltY",
#else
@@ -747,7 +753,7 @@
#define TR_DATE "Fecha"
#define TR_MONTHS { "Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic" }
#define TR_ROTARY_ENCODER "R.E."
#define TR_INVERT_ROTARY "Invert Rotary"
#define TR_ROTARY_ENC_MODE TR("RotEnc Mode","Rotary Encoder Mode")
#define TR_CHANNELS_MONITOR "MONITOR CANALES"
#define TR_MIXERS_MONITOR "MONITOR MEZCLAS"
#define TR_PATH_TOO_LONG "Path muy largo"
+8
View File
@@ -233,8 +233,15 @@
#define TR_ROTARY_ENCODERS
#define TR_ROTENC_SWITCHES
#define TR_ON_ONE_SWITCHES "ON","One"
#if defined(COLORLCD)
#define TR_ROTARY_ENC_OPT "Normal","Inverted"
#else
#define TR_ROTARY_ENC_OPT "Normal","Inverted","V-I H-N","V-I H-A"
#endif
#if defined(IMU)
#define TR_IMU_VSRCRAW "TltX","TltY",
#else
@@ -748,6 +755,7 @@
#define TR_DATE "Päivämäärä"
#define TR_MONTHS { "tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mar", "jou" }
#define TR_ROTARY_ENCODER "R.E."
#define TR_ROTARY_ENC_MODE TR("RotEnc Mode","Rotary Encoder Mode")
#define TR_CHANNELS_MONITOR "CHANNELS MONITOR"
#define TR_MIXERS_MONITOR "MIXERS MONITOR"
#define TR_PATH_TOO_LONG "Polku liian pitkä"
+7 -1
View File
@@ -239,6 +239,12 @@
#define TR_ON_ONE_SWITCHES "ON","Un"
#if defined(COLORLCD)
#define TR_ROTARY_ENC_OPT "Normal","Inverted"
#else
#define TR_ROTARY_ENC_OPT "Normal","Inverted","V-I H-N","V-I H-A"
#endif
#if defined(IMU)
#define TR_IMU_VSRCRAW "TltX","TltY",
#else
@@ -766,7 +772,7 @@
#define TR_DATE "Date"
#define TR_MONTHS { "Jan", "Fév", "Mar", "Avr", "Mai", "Jun", "Jul", "Aou", "Sep", "Oct", "Nov", "Dec" }
#define TR_ROTARY_ENCODER "Enc.Rot."
#define TR_INVERT_ROTARY "Invert Rotary"
#define TR_ROTARY_ENC_MODE TR("RotEnc Mode","Rotary Encoder Mode")
#define TR_CHANNELS_MONITOR "MONITEUR CANAUX"
#define TR_MIXERS_MONITOR "MONITEUR MIXAGES "
#define TR_PATH_TOO_LONG "Chemin trop long"
+7 -1
View File
@@ -223,6 +223,12 @@
#define TR_ON_ONE_SWITCHES "ON","One"
#if defined(COLORLCD)
#define TR_ROTARY_ENC_OPT "Normal","Inverted"
#else
#define TR_ROTARY_ENC_OPT "Normal","Inverted","V-I H-N","V-I H-A"
#endif
#if defined(IMU)
#define TR_IMU_VSRCRAW "TltX","TltY",
#else
@@ -746,7 +752,7 @@
#define TR_DATE "Data"
#define TR_MONTHS { "Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic" }
#define TR_ROTARY_ENCODER "R.E."
#define TR_INVERT_ROTARY "Inverti Rotary"
#define TR_ROTARY_ENC_MODE TR("RotEnc Mode","Rotary Encoder Mode")
#define TR_CHANNELS_MONITOR "MONITOR CANALI"
#define TR_MIXERS_MONITOR "MONITOR MIXER"
#define TR_PATH_TOO_LONG "Path troppo lungo"
+7 -1
View File
@@ -222,6 +222,12 @@
#define TR_ON_ONE_SWITCHES "ON","One"
#if defined(COLORLCD)
#define TR_ROTARY_ENC_OPT "Normal","Inverted"
#else
#define TR_ROTARY_ENC_OPT "Normal","Inverted","V-I H-N","V-I H-A"
#endif
#if defined(IMU)
#define TR_IMU_VSRCRAW "TltX","TltY",
#else
@@ -754,7 +760,7 @@
#define TR_DATE "Datum:"
#define TR_MONTHS { "Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec" }
#define TR_ROTARY_ENCODER "Draaischakelaar"
#define TR_INVERT_ROTARY "Invert Rotary"
#define TR_ROTARY_ENC_MODE TR("RotEnc Mode","Rotary Encoder Mode")
#define TR_CHANNELS_MONITOR "Kanaal-Monitor==>"
#define TR_MIXERS_MONITOR "==>MIXERS MONitor"
#define TR_PATH_TOO_LONG "Pad te Lang"
+8 -2
View File
@@ -216,7 +216,13 @@
#define TR_ROTARY_ENCODERS
#define TR_ROTENC_SWITCHES
#define TR_ON_ONE_SWITCHES "ON","One"
#define TR_ON_ONE_SWITCHES "ON","One"
#if defined(COLORLCD)
#define TR_ROTARY_ENC_OPT "Normal","Inverted"
#else
#define TR_ROTARY_ENC_OPT "Normal","Inverted","V-I H-N","V-I H-A"
#endif
#if defined(IMU)
#define TR_IMU_VSRCRAW "TltX","TltY",
@@ -742,7 +748,7 @@
#define TR_DATE "Data"
#define TR_MONTHS { "Jan", "Fev", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
#define TR_ROTARY_ENCODER "R.E."
#define TR_INVERT_ROTARY "Invert Rotary"
#define TR_ROTARY_ENC_MODE TR("RotEnc Mode","Rotary Encoder Mode")
#define TR_CHANNELS_MONITOR "MONITOR KANAŁÓW"
#define TR_MIXERS_MONITOR "MONITOR MIKSER"
#define TR_PATH_TOO_LONG "Ścieżka za długa"
+7 -1
View File
@@ -215,6 +215,12 @@
#define TR_ON_ONE_SWITCHES "ON","One"
#if defined(COLORLCD)
#define TR_ROTARY_ENC_OPT "Normal","Inverted"
#else
#define TR_ROTARY_ENC_OPT "Normal","Inverted","V-I H-N","V-I H-A"
#endif
#if defined(IMU)
#define TR_IMU_VSRCRAW "TltX","TltY",
#else
@@ -747,7 +753,7 @@
#define TR_DATE "Data"
#define TR_MONTHS { "Jan", "Fev", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
#define TR_ROTARY_ENCODER "R.E."
#define TR_INVERT_ROTARY "Invert Rotary"
#define TR_ROTARY_ENC_MODE TR("RotEnc Mode","Rotary Encoder Mode")
#define TR_CHANNELS_MONITOR "CHANNELS MONITOR"
#define TR_MIXERS_MONITOR "MIXERS MONITOR"
#define TR_PATH_TOO_LONG "Path too long"
+8 -2
View File
@@ -70,7 +70,7 @@
#else
#define TR_RETA123 "R","H","G","S","1","2","3"
#endif
#define TR_VCURVEFUNC "---","x>0","x<0","|x|","f>0","f<0","|f|"
#define TR_VMLTPX "Addera","Förstärk","Ersätt"
#define TR_VMLTPX2 "+=","*=",":="
@@ -234,11 +234,16 @@
#endif
#define TR_ROTARY_ENCODERS
#define TR_INVERT_ROTARY "Invertera rullhjul"
#define TR_ROTENC_SWITCHES
#define TR_ON_ONE_SWITCHES "PÅ","Ett"
#if defined(COLORLCD)
#define TR_ROTARY_ENC_OPT "Normal","Inverted"
#else
#define TR_ROTARY_ENC_OPT "Normal","Inverted","V-I H-N","V-I H-A"
#endif
#if defined(IMU)
#define TR_IMU_VSRCRAW "TltX","TltY",
#else
@@ -776,6 +781,7 @@
#define TR_DATE "Datum"
#define TR_MONTHS { "Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec" }
#define TR_ROTARY_ENCODER "R.H."
#define TR_ROTARY_ENC_MODE TR("RotEnc Mode","Rotary Encoder Mode")
#define TR_CHANNELS_MONITOR "Kanalöversikt"
#define TR_MIXERS_MONITOR "MIXERSKÄRM"
#define TR_PATH_TOO_LONG "För lång sökväg"
+7 -1
View File
@@ -219,6 +219,12 @@
#define TR_ON_ONE_SWITCHES "ON","One"
#if defined(COLORLCD)
#define TR_ROTARY_ENC_OPT "Normal","Inverted"
#else
#define TR_ROTARY_ENC_OPT "Normal","Inverted","V-I H-N","V-I H-A"
#endif
#if defined(IMU)
#define TR_IMU_VSRCRAW "TltX","TltY",
#else
@@ -748,7 +754,7 @@
#define TR_DATE "日期"
#define TR_MONTHS { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec " }
#define TR_ROTARY_ENCODER "滾輪"
#define TR_INVERT_ROTARY "滾輪反向"
#define TR_ROTARY_ENC_MODE TR("RotEnc Mode","Rotary Encoder Mode")
#define TR_CHANNELS_MONITOR "通道查看器"
#define TR_MIXERS_MONITOR "混控查看器"
#define TR_PATH_TOO_LONG "路徑太長"