Skip to content

Commit a646cea

Browse files
elecpowerphilmoz
authored andcommitted
Sources add inverted and exclude gyro
1 parent 0106b15 commit a646cea

28 files changed

+81
-25
lines changed

companion/src/datamodels/compounditemmodels.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,11 @@ BacklightSourceItemModel::BacklightSourceItemModel(const GeneralSettings * const
678678
setId(IMID_BacklightSource);
679679
setUpdateMask(IMUE_SystemRefresh);
680680

681+
// Descending source direction: inverted (!) sources
682+
addItems(SOURCE_TYPE_SWITCH, -board->getCapability(Board::Switches));
683+
addItems(SOURCE_TYPE_INPUT, -board->getCapability(Board::Inputs), -board->getCapability(Board::Sticks));
684+
685+
// Ascending source direction (including zero)
681686
addItems(SOURCE_TYPE_NONE, 1);
682687
addItems(SOURCE_TYPE_INPUT, board->getCapability(Board::Inputs), board->getCapability(Board::Sticks));
683688
addItems(SOURCE_TYPE_SWITCH, board->getCapability(Board::Switches));
@@ -686,14 +691,17 @@ BacklightSourceItemModel::BacklightSourceItemModel(const GeneralSettings * const
686691
void BacklightSourceItemModel::setDynamicItemData(QStandardItem * item, const RawSource & src) const
687692
{
688693
item->setText(src.toString(modelData, generalSettings, boardType));
689-
item->setData(src.isAvailable(modelData, generalSettings, boardType), IMDR_Available);
694+
item->setData(src.isAvailable(modelData, generalSettings, boardType, RawSource::AVAILABLE_BACKLIGHTSRC), IMDR_Available);
690695
}
691696

692697
void BacklightSourceItemModel::addItems(const RawSourceType & type, int count, const int start)
693698
{
694699
const int idxAdj = (type == SOURCE_TYPE_NONE ? -1 : 0);
695700

696-
for (int i = 1 + start; i <= count; ++i) {
701+
int first = start + count < 0 ? start + count : start + 1;
702+
int last = start + count < 0 ? start : start + count + 1;
703+
704+
for (int i = first; i < last; ++i) {
697705
const RawSource src = RawSource(type, i + idxAdj);
698706
QStandardItem * modelItem = new QStandardItem();
699707
modelItem->setData(src.toValue(), IMDR_Id);

companion/src/firmwares/boardjson.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,11 @@ bool BoardJson::isInputFlex(const InputDefn & defn)
752752
return defn.type == Board::AIT_FLEX;
753753
}
754754

755+
const bool BoardJson::isInputFlexGyroAxis(int index) const
756+
{
757+
return (index >=0 && index < (int)m_inputs->size()) ? isInputFlexGyroAxis(m_inputs->at(index)) : false;
758+
}
759+
755760
// static
756761
bool BoardJson::isInputFlexGyroAxis(const InputDefn & defn)
757762
{
@@ -761,6 +766,11 @@ bool BoardJson::isInputFlexGyroAxis(const InputDefn & defn)
761766
val[0] == 'T' && val[1] == 'I' && val[2] == 'L' && val[3] == 'T' && val[4] == '_' && (val[5] == 'X' || val[5] == 'Y'));
762767
}
763768

769+
const bool BoardJson::isInputFlexJoystickAxis(int index) const
770+
{
771+
return (index >=0 && index < (int)m_inputs->size()) ? isInputFlexJoystickAxis(m_inputs->at(index)) : false;
772+
}
773+
764774
// static
765775
bool BoardJson::isInputFlexJoystickAxis(const InputDefn & defn)
766776
{

companion/src/firmwares/boardjson.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ class BoardJson
130130
const bool isInputCalibrated(int index) const;
131131
const bool isInputConfigurable(int index) const;
132132
const bool isInputIgnored(int index) const;
133+
const bool isInputFlexGyroAxis(int index) const;
134+
const bool isInputFlexJoystickAxis(int index) const;
133135
const bool isInputFlexPot(int index) const;
134136
const bool isInputFlexSwitch(int index) const;
135137
const bool isInputStick(int index) const;

companion/src/firmwares/boards.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,11 @@ bool Boards::isInputConfigurable(int index, Board::Type board)
11591159
return getBoardJson(board)->isInputConfigurable(index);
11601160
}
11611161

1162+
bool Boards::isInputGyroAxis(int index, Board::Type board)
1163+
{
1164+
return getBoardJson(board)->isInputFlexGyroAxis(index);
1165+
}
1166+
11621167
bool Boards::isInputIgnored(int index, Board::Type board)
11631168
{
11641169
return getBoardJson(board)->isInputIgnored(index);

companion/src/firmwares/boards.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ class Boards
454454
static bool isInputAvailable(int index, Board::Type board = Board::BOARD_UNKNOWN);
455455
static bool isInputCalibrated(int index, Board::Type board = Board::BOARD_UNKNOWN);
456456
static bool isInputConfigurable(int index, Board::Type board = Board::BOARD_UNKNOWN);
457+
static bool isInputGyroAxis(int index, Board::Type board = Board::BOARD_UNKNOWN);
457458
static bool isInputIgnored(int index, Board::Type board = Board::BOARD_UNKNOWN);
458459
static bool isInputPot(int index, Board::Type board = Board::BOARD_UNKNOWN);
459460
static bool isInputStick(int index, Board::Type board = Board::BOARD_UNKNOWN);

companion/src/firmwares/rawsource.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,10 @@ bool RawSource::isStick(Board::Type board) const
280280
return false;
281281
}
282282

283-
bool RawSource::isAvailable(const ModelData * const model, const GeneralSettings * const gs, Board::Type board) const
283+
bool RawSource::isAvailable(const ModelData * const model,
284+
const GeneralSettings * const gs,
285+
Board::Type board,
286+
const int flags) const
284287
{
285288
if (type == SOURCE_TYPE_NONE && index == 0)
286289
return true;
@@ -392,6 +395,10 @@ bool RawSource::isAvailable(const ModelData * const model, const GeneralSettings
392395
gs->serialPort[GeneralSettings::SP_AUX2] == GeneralSettings::AUX_SERIAL_SPACEMOUSE))))
393396
return false;
394397

398+
if (type == SOURCE_TYPE_INPUT && (flags & AVAILABLE_BACKLIGHTSRC) &&
399+
Boards::isInputGyroAxis(abs(index) - 1, board))
400+
return false;
401+
395402
return true;
396403
}
397404

companion/src/firmwares/rawsource.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,12 @@ class RawSource {
248248
AllSourceGroups = InputSourceGroups | GVarsGroup | TelemGroup | ScriptsGroup
249249
};
250250

251+
// flags to refine isAvailable
252+
enum AvailableFlags {
253+
AVAILABLE_ALL,
254+
AVAILABLE_BACKLIGHTSRC = 0x001
255+
};
256+
251257
RawSource() { clear(); }
252258

253259
explicit RawSource(int value):
@@ -272,7 +278,10 @@ class RawSource {
272278
RawSourceRange getRange(const ModelData * model, const GeneralSettings & settings, unsigned int flags=0) const;
273279
bool isStick(Board::Type board = Board::BOARD_UNKNOWN) const;
274280
bool isTimeBased(Board::Type board = Board::BOARD_UNKNOWN) const;
275-
bool isAvailable(const ModelData * const model = nullptr, const GeneralSettings * const gs = nullptr, Board::Type board = Board::BOARD_UNKNOWN) const;
281+
bool isAvailable(const ModelData * const model = nullptr,
282+
const GeneralSettings * const gs = nullptr,
283+
Board::Type board = Board::BOARD_UNKNOWN,
284+
const int flags = 0) const;
276285
bool isSet() const { return type != SOURCE_TYPE_NONE || index != 0; }
277286
void clear() { type = SOURCE_TYPE_NONE; index = 0; }
278287
static StringTagMappingTable getSpecialTypesLookupTable();

radio/src/datastructs_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ PACK(struct RadioData {
11181118

11191119
#if defined(COLORLCD)
11201120
NOBACKUP(uint8_t spare:3 SKIP);
1121-
#elif LCD_W == 123
1121+
#elif LCD_W == 128
11221122
uint8_t invertLCD:1; // Invert B&W LCD display
11231123
#else
11241124
NOBACKUP(uint8_t spare:1 SKIP);

radio/src/storage/yaml/yaml_datastructs_128x64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ static const struct YamlNode struct_RadioData[] = {
367367
YAML_UNSIGNED( "rotEncMode", 3 ),
368368
YAML_SIGNED( "uartSampleMode", 2 ),
369369
YAML_PADDING( 3 ),
370+
YAML_SIGNED_CUST( "backlightSrc", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
370371
YAML_UNSIGNED( "radioGFDisabled", 1 ),
371372
YAML_UNSIGNED( "radioTrainerDisabled", 1 ),
372373
YAML_UNSIGNED( "modelHeliDisabled", 1 ),
@@ -381,7 +382,6 @@ static const struct YamlNode struct_RadioData[] = {
381382
YAML_UNSIGNED( "disablePwrOnOffHaptic", 1 ),
382383
YAML_UNSIGNED( "modelQuickSelect", 1 ),
383384
YAML_UNSIGNED( "invertLCD", 1 ),
384-
YAML_PADDING( 2 ),
385385
YAML_UNSIGNED( "pwrOffIfInactive", 8 ),
386386
YAML_END
387387
};

radio/src/storage/yaml/yaml_datastructs_f16.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ static const struct YamlNode struct_RadioData[] = {
388388
YAML_SIGNED( "imuMax", 8 ),
389389
YAML_SIGNED( "imuOffset", 8 ),
390390
YAML_STRING("selectedTheme", 26),
391+
YAML_SIGNED_CUST( "backlightSrc", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
391392
YAML_UNSIGNED( "labelSingleSelect", 1 ),
392393
YAML_UNSIGNED( "labelMultiMode", 1 ),
393394
YAML_UNSIGNED( "favMultiMode", 1 ),
@@ -406,7 +407,7 @@ static const struct YamlNode struct_RadioData[] = {
406407
YAML_UNSIGNED( "disableTrainerPoweroffAlarm", 1 ),
407408
YAML_UNSIGNED( "disablePwrOnOffHaptic", 1 ),
408409
YAML_UNSIGNED( "modelQuickSelect", 1 ),
409-
YAML_PADDING( 5 ),
410+
YAML_PADDING( 3 ),
410411
YAML_UNSIGNED( "pwrOffIfInactive", 8 ),
411412
YAML_END
412413
};

0 commit comments

Comments
 (0)