Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelcoeffic committed Sep 28, 2023
1 parent 9504494 commit aa65ddd
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 54 deletions.
54 changes: 28 additions & 26 deletions radio/src/gui/colorlcd/access_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,10 +710,10 @@ void RxOptions::checkEvents()
#define CH_ENABLE_SPORT 4
#define CH_ENABLE_SBUS 5

#define CH_MAP_SBUS_IN (1 << 5) /* 0x20 */
#define CH_MAP_SPORT (1 << 6) /* 0x40 */
#define CH_MAP_SBUS_OUT (1 << 7) /* 0x80 */
#define CH_MAP_FBUS (CH_MAP_SPORT | CH_MAP_SBUS_OUT) /* 0xC0 */
#define CH_MAP_SPORT 0x40
#define CH_MAP_SBUS_OUT 0x80
#define CH_MAP_FBUS 0xC0
#define CH_MAP_SBUS_IN 0xA0

static uint8_t getShiftedChannel(int8_t moduleIdx, int ch)
{
Expand Down Expand Up @@ -749,7 +749,7 @@ class OutputMappingChoice : public Choice
}

public:
OutputMappingChoice(Window* parent, uint32_t capabilities,
OutputMappingChoice(Window* parent, uint32_t capabilities, uint8_t rx_model_id,
uint8_t module, uint8_t channels, uint8_t output_pin) :
Choice(parent, rect_t{}, 0, channels - 1,
std::bind(&OutputMappingChoice::get_output_mapping, this),
Expand All @@ -760,23 +760,7 @@ class OutputMappingChoice : public Choice
channels(channels),
rx_pin(output_pin)
{
if (capabilities & (1 << RECEIVER_CAPABILITY_ENABLE_PWM_CH5_CH6)) {
if (CH_ENABLE_SPORT == output_pin) {
setTextHandler([=] (int val) {
if (val == channels) return std::string(STR_SPORT);
return get_channel_text(val);
});
setMax(channels);
return;
} else if (CH_ENABLE_SBUS == output_pin) {
setTextHandler([=] (int val) {
if (val == channels) return std::string(STR_SBUSOUT);
return get_channel_text(val);
});
setMax(channels);
return;
}
} else if (capabilities & (1 << RECEIVER_CAPABILITY_CONFIGURABLE_PORTS)) {
if (isPXX2ReceiverOptionAvailable(rx_model_id, RECEIVER_OPTION_D_TELE_PORT)) {
setTextHandler([=] (int val) {
switch(val) {
case CH_MAP_SBUS_IN:
Expand Down Expand Up @@ -806,6 +790,24 @@ class OutputMappingChoice : public Choice
setMax(CH_MAP_FBUS);
return;
}

if (capabilities & (1 << RECEIVER_CAPABILITY_ENABLE_PWM_CH5_CH6)) {
if (CH_ENABLE_SPORT == output_pin) {
setTextHandler([=] (int val) {
if (val == channels) return std::string(STR_SPORT);
return get_channel_text(val);
});
setMax(channels);
return;
} else if (CH_ENABLE_SBUS == output_pin) {
setTextHandler([=] (int val) {
if (val == channels) return std::string(STR_SBUSOUT);
return get_channel_text(val);
});
setMax(channels);
return;
}
}

setTextHandler(std::bind(&OutputMappingChoice::get_channel_text, this,
std::placeholders::_1));
Expand All @@ -819,8 +821,8 @@ void RxOptions::update()

auto& hwSettings = getPXX2HardwareAndSettingsBuffer();
auto& rxInfo = hwSettings.modules[moduleIdx].receivers[receiverIdx].information;
// uint8_t receiverModelId = rxInfo.modelID;
uint8_t receiverVariant = rxInfo.variant;
uint8_t rxModelId = rxInfo.modelID;
uint8_t rxVariant = rxInfo.variant;
uint8_t capabilities = rxInfo.capabilities;

FlexGridLayout grid(line_col_dsc, line_row_dsc, 2);
Expand Down Expand Up @@ -858,7 +860,7 @@ void RxOptions::update()
hwSettings.receiverSettings.telemetryDisabled = val;
});

if (isModuleR9MAccess(moduleIdx) && receiverVariant == PXX2_VARIANT_EU &&
if (isModuleR9MAccess(moduleIdx) && rxVariant == PXX2_VARIANT_EU &&
hwSettings.moduleSettings.txPower > 14 /*25mW*/) {
// read only field in this case
tele25mw->disable();
Expand Down Expand Up @@ -933,7 +935,7 @@ void RxOptions::update()
new StaticText(line, rect_t{}, std::string(STR_PIN) + i_str);

uint8_t channels = sentModuleChannels(moduleIdx);
new OutputMappingChoice(line, capabilities, moduleIdx, channels, i);
new OutputMappingChoice(line, capabilities, rxModelId, moduleIdx, channels, i);
}

line = form->newLine(&grid);
Expand Down
54 changes: 27 additions & 27 deletions radio/src/gui/common/stdlcd/model_receiver_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ enum {
#define CH_ENABLE_SPORT 4
#define CH_ENABLE_SBUS 5

#define CH_MAP_SBUS_IN (1 << 5) /* 0x20 */
#define CH_MAP_SPORT (1 << 6) /* 0x40 */
#define CH_MAP_SBUS_OUT (1 << 7) /* 0x80 */
#define CH_MAP_FBUS (CH_MAP_SPORT | CH_MAP_SBUS_OUT) /* 0xC0 */
#define CH_MAP_SPORT 0x40
#define CH_MAP_SBUS_OUT 0x80
#define CH_MAP_FBUS 0xC0
#define CH_MAP_SBUS_IN 0xA0

bool isSPortModeAvailable(int mode)
{
Expand Down Expand Up @@ -237,35 +237,34 @@ void menuModelReceiverOptions(event_t event)
}

if (isPXX2ReceiverOptionAvailable(receiverModelId, RECEIVER_OPTION_D_TELE_PORT)) {
if (mapping == 0b01000000) {
if (mapping == CH_MAP_SPORT) {
lcdDrawText(7 * FW, y, STR_SPORT, attr);
mapping = channelMax + 1;
}
else if (mapping == 0b10000000) {
} else if (mapping == CH_MAP_SBUS_OUT) {
lcdDrawText(7 * FW, y, STR_SBUSOUT, attr);
mapping = channelMax + 2;
}
else if (mapping == 0b11000000) {
} else if (mapping == CH_MAP_FBUS) {
lcdDrawText(7 * FW, y, STR_FBUS, attr);
mapping = channelMax + 3;
}
if (pin == 0) {
selectionMax = channelMax + 4;
if (mapping == 0b10100000) {
if (mapping == CH_MAP_SBUS_IN) {
lcdDrawText(7 * FW, y, STR_SBUSIN, attr);
mapping = selectionMax;
}
}
else if (IS_RECEIVER_CAPABILITY_ENABLED(RECEIVER_CAPABILITY_ENABLE_PWM_CH5_CH6)) {
if (CH_ENABLE_SPORT == pin) {
if (++selectionMax == mapping) {
lcdDrawText(7 * FW, y, STR_SPORT, attr);
}
else {
selectionMax = channelMax + 3;
}
} else if (IS_RECEIVER_CAPABILITY_ENABLED(RECEIVER_CAPABILITY_ENABLE_PWM_CH5_CH6)) {
if (CH_ENABLE_SPORT == pin) {
if (++selectionMax == mapping) {
lcdDrawText(7 * FW, y, STR_SPORT, attr);
}
else if (CH_ENABLE_SBUS == pin) {
if (++selectionMax == mapping) {
lcdDrawText(7 * FW, y, STR_SBUSOUT, attr);
}
} else if (CH_ENABLE_SBUS == pin) {
if (++selectionMax == mapping) {
lcdDrawText(7 * FW, y, STR_SBUSOUT, attr);
}
}
}
Expand All @@ -275,14 +274,15 @@ void menuModelReceiverOptions(event_t event)
mapping = checkIncDec(event, mapping, 0, selectionMax);
if (checkIncDec_Ret) {
if (isPXX2ReceiverOptionAvailable(receiverModelId, RECEIVER_OPTION_D_TELE_PORT)) {
if (mapping == channelMax + 1)
mapping = 0b01000000; // S.Port
else if (mapping == channelMax + 2)
mapping = 0b10000000; // SBUS Out
else if (mapping == channelMax + 3)
mapping = 0b11000000; // FBUS
else if (mapping == channelMax + 4)
mapping = 0b10100000; // SBUS In
if (mapping == channelMax + 1) {
mapping = CH_MAP_SPORT;
} else if (mapping == channelMax + 2) {
mapping = CH_MAP_SBUS_OUT;
} else if (mapping == channelMax + 3) {
mapping = CH_MAP_FBUS;
} else if (mapping == channelMax + 4) {
mapping = CH_MAP_SBUS_IN;
}
}
reusableBuffer.hardwareAndSettings.receiverSettings.outputsMapping[pin] = mapping;
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = RECEIVER_SETTINGS_DIRTY;
Expand Down
1 change: 0 additions & 1 deletion radio/src/pulses/pxx2.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ enum ReceiverCapabilities {
RECEIVER_CAPABILITY_FPORT2,
RECEIVER_CAPABILITY_RACING_MODE,
RECEIVER_CAPABILITY_SBUS24,
RECEIVER_CAPABILITY_CONFIGURABLE_PORTS,
RECEIVER_CAPABILITY_COUNT
};

Expand Down

0 comments on commit aa65ddd

Please sign in to comment.