Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions companion/src/firmwares/boardjson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ bool BoardJson::loadDefinition()
if (m_board == Board::BOARD_UNKNOWN)
return true;

if (!loadFile(m_board, m_hwdefn, m_inputs, m_switches, m_keys, m_trims, m_display, m_cfs, m_hardware))
if (!loadFile(m_board, m_hwdefn, m_inputs, m_switches, m_keys, m_trims, m_display, m_cfs, m_hardware, m_hasKeyLockCombo))
return false;

afterLoadFixups(m_board, m_inputs, m_switches, m_keys, m_trims);
Expand Down Expand Up @@ -1015,7 +1015,7 @@ bool BoardJson::loadDefinition()
// static
bool BoardJson::loadFile(Board::Type board, QString hwdefn, InputsTable * inputs, SwitchesTable * switches,
KeysTable * keys, TrimsTable * trims, DisplayDefn & display, CustomSwitchesDefn & cfs,
HardwareDefn & hardware)
HardwareDefn & hardware, bool & hasKeyLockCombo)
{
if (board == Board::BOARD_UNKNOWN) {
return false;
Expand Down Expand Up @@ -1202,6 +1202,9 @@ bool BoardJson::loadFile(Board::Type board, QString hwdefn, InputsTable * inputs
}
}

hasKeyLockCombo = obj.value("key_lock_combo").isArray() &&
obj.value("key_lock_combo").toArray().size() == 2;

if (obj.value("trims").isArray()) {
const QJsonArray &trms = obj.value("trims").toArray();

Expand Down
4 changes: 3 additions & 1 deletion companion/src/firmwares/boardjson.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class BoardJson

const Board::KeyInfo getKeyInfo(int index) const;
const int getKeyIndex(const QString key) const;
bool hasKeyLockCombo() const { return m_hasKeyLockCombo; }

const int getSwitchIndex(const QString val, Board::LookupValueType lvt) const;
const int getCFSIndexForSwitch(int sw) const;
Expand Down Expand Up @@ -201,6 +202,7 @@ class BoardJson
DisplayDefn m_display;
CustomSwitchesDefn m_cfs;
HardwareDefn m_hardware;
bool m_hasKeyLockCombo = false;

struct InputCounts {
unsigned int flexGyroAxes;
Expand All @@ -226,7 +228,7 @@ class BoardJson

static bool loadFile(Board::Type board, QString hwdefn, InputsTable * inputs, SwitchesTable * switches,
KeysTable * keys, TrimsTable * trims, DisplayDefn & lcd, CustomSwitchesDefn & cfs,
HardwareDefn & hardware);
HardwareDefn & hardware, bool & hasKeyLockCombo);
static void afterLoadFixups(Board::Type board, InputsTable * inputs, SwitchesTable * switches,
KeysTable * keys, TrimsTable * trims);

Expand Down
2 changes: 2 additions & 0 deletions companion/src/firmwares/edgetx/yaml_generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
}

node["oneLogPerDay"] = (int)rhs.oneLogPerDay;
node["keyLockEnabled"] = (int)rhs.keyLockEnabled;

return node;
}
Expand Down Expand Up @@ -775,6 +776,7 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
}

node["oneLogPerDay"] >> rhs.oneLogPerDay;
node["keyLockEnabled"] >> rhs.keyLockEnabled;

// override critical settings after import
// TODO: for consistency move up call stack to use existing eeprom and profile conversions
Expand Down
1 change: 1 addition & 0 deletions companion/src/firmwares/generalsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ class GeneralSettings {
unsigned int qmFavorites[MAX_QMFAVOURITES];
char* qmFavoritesTools[MAX_QMFAVOURITES];
bool oneLogPerDay;
bool keyLockEnabled;

void switchConfigClear();

Expand Down
20 changes: 20 additions & 0 deletions companion/src/generaledit/generalsetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "autocombobox.h"
#include "namevalidator.h"
#include "helpers.h"
#include "boardjson.h"

constexpr char FIM_HATSMODE[] {"Hats Mode"};
constexpr char FIM_STICKMODE[] {"Stick Mode"};
Expand Down Expand Up @@ -474,6 +475,17 @@ void GeneralSetupPanel::setValues()
ui->startSoundCB->setChecked(!generalSettings.dontPlayHello);
ui->modelQuickSelect_CB->setChecked(generalSettings.modelQuickSelect);
ui->chkOneLogPerDay->setChecked(generalSettings.oneLogPerDay);
{
BoardJson* bj = Boards::getBoardJson(board);
bool hasCombo = bj && bj->hasKeyLockCombo();
ui->chkKeyLockEnabled->setChecked(hasCombo && generalSettings.keyLockEnabled);
ui->chkKeyLockEnabled->setEnabled(hasCombo);
ui->label_keyLockEnabled->setEnabled(hasCombo);
if (!hasCombo) {
ui->chkKeyLockEnabled->setToolTip(tr("Not available on this radio (no key combo defined)"));
ui->label_keyLockEnabled->setToolTip(tr("Not available on this radio (no key combo defined)"));
}
}

if (Boards::getCapability(board, Board::HasColorLcd)) {
ui->modelSelectLayout_CB->setCurrentIndex(generalSettings.modelSelectLayout);
Expand Down Expand Up @@ -951,3 +963,11 @@ void GeneralSetupPanel::on_chkOneLogPerDay_stateChanged(int)
emit modified();
}
}

void GeneralSetupPanel::on_chkKeyLockEnabled_stateChanged(int)
{
if (!lock) {
generalSettings.keyLockEnabled = ui->chkKeyLockEnabled->isChecked();
emit modified();
}
}
1 change: 1 addition & 0 deletions companion/src/generaledit/generalsetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class GeneralSetupPanel : public GeneralPanel

void on_pwrOffIfInactiveSB_editingFinished();
void on_chkOneLogPerDay_stateChanged(int);
void on_chkKeyLockEnabled_stateChanged(int);

private:
Ui::GeneralSetup *ui;
Expand Down
14 changes: 14 additions & 0 deletions companion/src/generaledit/generalsetup.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,20 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="30" column="0">
<widget class="QLabel" name="label_keyLockEnabled">
<property name="text">
<string>Key lock</string>
</property>
</widget>
</item>
<item row="30" column="1">
<widget class="QCheckBox" name="chkKeyLockEnabled">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
Expand Down
6 changes: 6 additions & 0 deletions radio/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ add_definitions(

set(HW_DESC_JSON ${FLAVOUR}.json)

AddHWGenTarget(${HW_DESC_JSON} hal_keys_lock hal_keys_lock.h)
add_custom_target(hal_keys_lock_hdr DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/hal_keys_lock.h)
if(TARGET board)
add_dependencies(board hal_keys_lock_hdr)
endif()

include(hal/CMakeLists.txt)

add_subdirectory(bitmaps)
Expand Down
3 changes: 2 additions & 1 deletion radio/src/boards/generic_stm32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ set(BOARD_LIB_SRC
)

add_library(minimal_board_lib OBJECT EXCLUDE_FROM_ALL ${MINIMAL_BOARD_LIB_SRC})
add_dependencies(minimal_board_lib hal_keys_lock_hdr)

add_library(board_lib OBJECT EXCLUDE_FROM_ALL ${BOARD_LIB_SRC})
add_dependencies(board_lib minimal_board_lib)
add_dependencies(board_lib minimal_board_lib hal_keys_lock_hdr)

if(DEBUG)
target_compile_definitions(board_lib PRIVATE DEBUG)
Expand Down
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/boxer.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,5 +329,9 @@
"surface": 0,
"cpu": "STM32F407xG",
"cpu_type": "STM32F4"
}
},
"key_lock_combo": [
"KEY_SYS",
"KEY_MODEL"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/bumblebee.json
Original file line number Diff line number Diff line change
Expand Up @@ -398,5 +398,9 @@
"surface": 0,
"cpu": "STM32F407xG",
"cpu_type": "STM32F4"
}
},
"key_lock_combo": [
"KEY_MENU",
"KEY_ENTER"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/commando8.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,5 +278,9 @@
"surface": 0,
"cpu": "STM32F407xE",
"cpu_type": "STM32F4"
}
},
"key_lock_combo": [
"KEY_SYS",
"KEY_MODEL"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/f16.json
Original file line number Diff line number Diff line change
Expand Up @@ -437,5 +437,9 @@
"surface": 0,
"cpu": "STM32F429xI",
"cpu_type": "STM32F4"
}
},
"key_lock_combo": [
"KEY_SYS",
"KEY_MODEL"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/gx12.json
Original file line number Diff line number Diff line change
Expand Up @@ -439,5 +439,9 @@
"surface": 0,
"cpu": "STM32F407xG",
"cpu_type": "STM32F4"
}
},
"key_lock_combo": [
"KEY_SYS",
"KEY_MODEL"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/lr3pro.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,9 @@
"surface": 0,
"cpu": "STM32F205xE",
"cpu_type": "STM32F2"
}
},
"key_lock_combo": [
"KEY_ENTER",
"KEY_RIGHT"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/mt12.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,5 +307,9 @@
"surface": 1,
"cpu": "STM32F407xG",
"cpu_type": "STM32F4"
}
},
"key_lock_combo": [
"KEY_SYS",
"KEY_MODEL"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/pocket.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,9 @@
"surface": 0,
"cpu": "STM32F407xE",
"cpu_type": "STM32F4"
}
},
"key_lock_combo": [
"KEY_SYS",
"KEY_MODEL"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/t12.json
Original file line number Diff line number Diff line change
Expand Up @@ -334,5 +334,9 @@
"surface": 0,
"cpu": "STM32F205xE",
"cpu_type": "STM32F2"
}
},
"key_lock_combo": [
"KEY_ENTER",
"KEY_RIGHT"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/t12max.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,9 @@
"surface": 0,
"cpu": "STM32F407xG",
"cpu_type": "STM32F4"
}
},
"key_lock_combo": [
"KEY_PAGEDN",
"KEY_ENTER"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/t14.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,9 @@
"surface": 0,
"cpu": "STM32F407xG",
"cpu_type": "STM32F4"
}
},
"key_lock_combo": [
"KEY_MENU",
"KEY_ENTER"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/t15.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,5 +372,9 @@
"surface": 0,
"cpu": "STM32F429xI",
"cpu_type": "STM32F4"
}
},
"key_lock_combo": [
"KEY_SYS",
"KEY_TELE"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/t15pro.json
Original file line number Diff line number Diff line change
Expand Up @@ -376,5 +376,9 @@
"surface": 0,
"cpu": "STM32H750xB",
"cpu_type": "STM32H7"
}
},
"key_lock_combo": [
"KEY_PAGEDN",
"KEY_ENTER"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/t16.json
Original file line number Diff line number Diff line change
Expand Up @@ -451,5 +451,9 @@
"surface": 0,
"cpu": "STM32F429xI",
"cpu_type": "STM32F4"
}
},
"key_lock_combo": [
"KEY_SYS",
"KEY_MODEL"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/t18.json
Original file line number Diff line number Diff line change
Expand Up @@ -453,5 +453,9 @@
"surface": 0,
"cpu": "STM32F429xI",
"cpu_type": "STM32F4"
}
},
"key_lock_combo": [
"KEY_SYS",
"KEY_MODEL"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/t20.json
Original file line number Diff line number Diff line change
Expand Up @@ -531,5 +531,9 @@
"surface": 0,
"cpu": "STM32F407xE",
"cpu_type": "STM32F4"
}
},
"key_lock_combo": [
"KEY_MENU",
"KEY_ENTER"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/t20v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -531,5 +531,9 @@
"surface": 0,
"cpu": "STM32F407xG",
"cpu_type": "STM32F4"
}
},
"key_lock_combo": [
"KEY_MENU",
"KEY_ENTER"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/t8.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,5 +274,9 @@
"surface": 0,
"cpu": "STM32F205xE",
"cpu_type": "STM32F2"
}
},
"key_lock_combo": [
"KEY_SYS",
"KEY_MODEL"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/tlite.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,9 @@
"surface": 0,
"cpu": "STM32F205xE",
"cpu_type": "STM32F2"
}
},
"key_lock_combo": [
"KEY_ENTER",
"KEY_RIGHT"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/tpro.json
Original file line number Diff line number Diff line change
Expand Up @@ -364,5 +364,9 @@
"surface": 0,
"cpu": "STM32F205xE",
"cpu_type": "STM32F2"
}
},
"key_lock_combo": [
"KEY_MENU",
"KEY_ENTER"
]
}
6 changes: 5 additions & 1 deletion radio/src/boards/hw_defs/tpros.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,9 @@
"surface": 0,
"cpu": "STM32F407xG",
"cpu_type": "STM32F4"
}
},
"key_lock_combo": [
"KEY_MENU",
"KEY_ENTER"
]
}
Loading