mirror of
https://github.com/opentx/opentx.git
synced 2025-07-13 19:40:20 +03:00
On recent receivers it is possible to assign a different function to all pins
This commit is contained in:
parent
211b59c3c7
commit
6ea6ea19e4
4 changed files with 99 additions and 29 deletions
|
@ -215,44 +215,79 @@ bool menuModelReceiverOptions(event_t event)
|
||||||
{
|
{
|
||||||
uint8_t pin = i - ITEM_RECEIVER_SETTINGS_PINMAP_FIRST;
|
uint8_t pin = i - ITEM_RECEIVER_SETTINGS_PINMAP_FIRST;
|
||||||
if (pin < reusableBuffer.hardwareAndSettings.receiverSettings.outputsCount) {
|
if (pin < reusableBuffer.hardwareAndSettings.receiverSettings.outputsCount) {
|
||||||
uint8_t & mapping = reusableBuffer.hardwareAndSettings.receiverSettings.outputsMapping[pin];
|
uint8_t mapping = reusableBuffer.hardwareAndSettings.receiverSettings.outputsMapping[pin];
|
||||||
uint8_t channel = g_model.moduleData[g_moduleIdx].channelsStart + mapping;
|
|
||||||
int32_t channelValue = channelOutputs[channel];
|
|
||||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PIN);
|
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PIN);
|
||||||
lcdDrawNumber(lcdNextPos + 1, y, pin + 1);
|
lcdDrawNumber(lcdNextPos + 1, y, pin + 1);
|
||||||
|
|
||||||
uint8_t channelMax = sentModuleChannels(g_moduleIdx) - 1;
|
uint8_t channelMax = sentModuleChannels(g_moduleIdx) - 1;
|
||||||
uint8_t selectionMax = channelMax;
|
uint8_t selectionMax = channelMax;
|
||||||
|
|
||||||
if (IS_RECEIVER_CAPABILITY_ENABLED(RECEIVER_CAPABILITY_ENABLE_PWM_CH5_CH6)) {
|
if (mapping <= channelMax) {
|
||||||
if (CH_ENABLE_SPORT == pin || CH_ENABLE_SBUS == pin) {
|
uint8_t channel = g_model.moduleData[g_moduleIdx].channelsStart + mapping;
|
||||||
selectionMax += 1;
|
putsChn(100, y, channel + 1, attr);
|
||||||
}
|
}
|
||||||
if (CH_ENABLE_SPORT == pin && selectionMax == channel) {
|
|
||||||
lcdDrawText(100, y, "S.PORT", attr);
|
if (isPXX2ReceiverOptionAvailable(receiverModelId, RECEIVER_OPTION_D_TELE_PORT)) {
|
||||||
|
if (mapping == 0b01000000) {
|
||||||
|
lcdDrawText(100, y, "S.Port", attr);
|
||||||
|
mapping = channelMax + 1;
|
||||||
}
|
}
|
||||||
else if (CH_ENABLE_SBUS == pin && selectionMax == channel) {
|
else if (mapping == 0b10000000) {
|
||||||
|
lcdDrawText(100, y, "SBUS Out", attr);
|
||||||
|
mapping = channelMax + 2;
|
||||||
|
}
|
||||||
|
else if (mapping == 0b11000000) {
|
||||||
|
lcdDrawText(100, y, "FBUS", attr);
|
||||||
|
mapping = channelMax + 3;
|
||||||
|
}
|
||||||
|
if (pin == 0) {
|
||||||
|
selectionMax = channelMax + 4;
|
||||||
|
if (mapping == 0b10100000) {
|
||||||
|
lcdDrawText(100, y, "SBUS In", attr);
|
||||||
|
mapping = selectionMax;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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(100, y, "S.Port", attr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (CH_ENABLE_SBUS == pin) {
|
||||||
|
if (++selectionMax == mapping) {
|
||||||
lcdDrawText(100, y, "SBUS", attr);
|
lcdDrawText(100, y, "SBUS", attr);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
putsChn(100, y, channel + 1, attr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
putsChn(100, y, channel + 1, attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Channel
|
// Channel
|
||||||
if (attr) {
|
if (attr) {
|
||||||
mapping = checkIncDec(event, mapping, 0, selectionMax);
|
mapping = checkIncDec(event, mapping, 0, selectionMax);
|
||||||
if (checkIncDec_Ret) {
|
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
|
||||||
|
}
|
||||||
|
reusableBuffer.hardwareAndSettings.receiverSettings.outputsMapping[pin] = mapping;
|
||||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = RECEIVER_SETTINGS_DIRTY;
|
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = RECEIVER_SETTINGS_DIRTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bargraph
|
// Bargraph
|
||||||
if (channel <= channelMax) {
|
if (mapping <= channelMax) {
|
||||||
lcdDrawRect(RECEIVER_OPTIONS_2ND_COLUMN, y + 4, wbar + 1, 10);
|
lcdDrawRect(RECEIVER_OPTIONS_2ND_COLUMN, y + 4, wbar + 1, 10);
|
||||||
|
uint8_t channel = g_model.moduleData[g_moduleIdx].channelsStart + mapping;
|
||||||
|
int32_t channelValue = channelOutputs[channel];
|
||||||
auto lenChannel = limit<uint8_t>(1, (abs(channelValue) * wbar / 2 + lim / 2) / lim, wbar / 2);
|
auto lenChannel = limit<uint8_t>(1, (abs(channelValue) * wbar / 2 + lim / 2) / lim, wbar / 2);
|
||||||
auto xChannel = (channelValue > 0) ? RECEIVER_OPTIONS_2ND_COLUMN + wbar / 2 : RECEIVER_OPTIONS_2ND_COLUMN + wbar / 2 + 1 - lenChannel;
|
auto xChannel = (channelValue > 0) ? RECEIVER_OPTIONS_2ND_COLUMN + wbar / 2 : RECEIVER_OPTIONS_2ND_COLUMN + wbar / 2 + 1 - lenChannel;
|
||||||
lcdDrawSolidFilledRect(xChannel, y + 5, lenChannel, 8, TEXT_INVERTED_BGCOLOR);
|
lcdDrawSolidFilledRect(xChannel, y + 5, lenChannel, 8, TEXT_INVERTED_BGCOLOR);
|
||||||
|
|
|
@ -209,42 +209,77 @@ void menuModelReceiverOptions(event_t event)
|
||||||
{
|
{
|
||||||
uint8_t pin = i - ITEM_RECEIVER_SETTINGS_PINMAP_FIRST;
|
uint8_t pin = i - ITEM_RECEIVER_SETTINGS_PINMAP_FIRST;
|
||||||
if (pin < reusableBuffer.hardwareAndSettings.receiverSettings.outputsCount) {
|
if (pin < reusableBuffer.hardwareAndSettings.receiverSettings.outputsCount) {
|
||||||
uint8_t & mapping = reusableBuffer.hardwareAndSettings.receiverSettings.outputsMapping[pin];
|
uint8_t mapping = reusableBuffer.hardwareAndSettings.receiverSettings.outputsMapping[pin];
|
||||||
uint8_t channel = g_model.moduleData[g_moduleIdx].channelsStart + mapping;
|
|
||||||
lcdDrawText(0, y, STR_PIN);
|
lcdDrawText(0, y, STR_PIN);
|
||||||
lcdDrawNumber(lcdLastRightPos + 1, y, pin + 1);
|
lcdDrawNumber(lcdLastRightPos + 1, y, pin + 1);
|
||||||
|
|
||||||
uint8_t channelMax = sentModuleChannels(g_moduleIdx) - 1;
|
uint8_t channelMax = sentModuleChannels(g_moduleIdx) - 1;
|
||||||
uint8_t selectionMax = channelMax;
|
uint8_t selectionMax = channelMax;
|
||||||
|
|
||||||
if (IS_RECEIVER_CAPABILITY_ENABLED(RECEIVER_CAPABILITY_ENABLE_PWM_CH5_CH6)) {
|
if (mapping <= channelMax) {
|
||||||
if (CH_ENABLE_SPORT == pin || CH_ENABLE_SBUS == pin)
|
uint8_t channel = g_model.moduleData[g_moduleIdx].channelsStart + mapping;
|
||||||
selectionMax += 1;
|
putsChn(7 * FW, y, channel + 1, attr);
|
||||||
|
|
||||||
if (CH_ENABLE_SPORT == pin && selectionMax == channel) {
|
|
||||||
lcdDrawText(7 * FW, y, "S.PORT", attr);
|
|
||||||
}
|
}
|
||||||
else if (CH_ENABLE_SBUS == pin && selectionMax == channel) {
|
|
||||||
|
if (isPXX2ReceiverOptionAvailable(receiverModelId, RECEIVER_OPTION_D_TELE_PORT)) {
|
||||||
|
if (mapping == 0b01000000) {
|
||||||
|
lcdDrawText(7 * FW, y, "S.Port", attr);
|
||||||
|
mapping = channelMax + 1;
|
||||||
|
}
|
||||||
|
else if (mapping == 0b10000000) {
|
||||||
|
lcdDrawText(7 * FW, y, "SBUS Out", attr);
|
||||||
|
mapping = channelMax + 2;
|
||||||
|
}
|
||||||
|
else if (mapping == 0b11000000) {
|
||||||
|
lcdDrawText(7 * FW, y, "FBUS", attr);
|
||||||
|
mapping = channelMax + 3;
|
||||||
|
}
|
||||||
|
if (pin == 0) {
|
||||||
|
selectionMax = channelMax + 4;
|
||||||
|
if (mapping == 0b10100000) {
|
||||||
|
lcdDrawText(7 * FW, y, "SBUS In", attr);
|
||||||
|
mapping = selectionMax;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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, "S.Port", attr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (CH_ENABLE_SBUS == pin) {
|
||||||
|
if (++selectionMax == mapping) {
|
||||||
lcdDrawText(7 * FW, y, "SBUS", attr);
|
lcdDrawText(7 * FW, y, "SBUS", attr);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
putsChn(7 * FW, y, channel + 1, attr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
putsChn(7 * FW, y, channel + 1, attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Channel
|
// Channel
|
||||||
if (attr) {
|
if (attr) {
|
||||||
mapping = checkIncDec(event, mapping, 0, selectionMax);
|
mapping = checkIncDec(event, mapping, 0, selectionMax);
|
||||||
if (checkIncDec_Ret) {
|
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
|
||||||
|
}
|
||||||
|
reusableBuffer.hardwareAndSettings.receiverSettings.outputsMapping[pin] = mapping;
|
||||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = RECEIVER_SETTINGS_DIRTY;
|
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = RECEIVER_SETTINGS_DIRTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bargraph
|
// Bargraph
|
||||||
if (channel <= channelMax) {
|
if (mapping <= channelMax) {
|
||||||
|
uint8_t channel = g_model.moduleData[g_moduleIdx].channelsStart + mapping;
|
||||||
int32_t channelValue = channelOutputs[channel];
|
int32_t channelValue = channelOutputs[channel];
|
||||||
#if !defined(PCBX7) // X7 LCD doesn't like too many horizontal lines
|
#if !defined(PCBX7) // X7 LCD doesn't like too many horizontal lines
|
||||||
lcdDrawRect(RECEIVER_OPTIONS_2ND_COLUMN, y + 2, wbar + 1, 4);
|
lcdDrawRect(RECEIVER_OPTIONS_2ND_COLUMN, y + 2, wbar + 1, 4);
|
||||||
|
|
|
@ -112,9 +112,9 @@ class ReceiverSettings {
|
||||||
uint8_t fport;
|
uint8_t fport;
|
||||||
uint8_t enablePwmCh5Ch6;
|
uint8_t enablePwmCh5Ch6;
|
||||||
uint8_t fport2;
|
uint8_t fport2;
|
||||||
uint8_t sbus24;
|
|
||||||
uint8_t outputsCount;
|
uint8_t outputsCount;
|
||||||
uint8_t outputsMapping[24];
|
uint8_t outputsMapping[24];
|
||||||
|
uint8_t sbus24;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BindInformation {
|
class BindInformation {
|
||||||
|
|
|
@ -240,7 +240,7 @@ void Pxx2Pulses::setupReceiverSettingsFrame(uint8_t module)
|
||||||
Pxx2Transport::addByte(flag1);
|
Pxx2Transport::addByte(flag1);
|
||||||
uint8_t outputsCount = min<uint8_t>(24, reusableBuffer.hardwareAndSettings.receiverSettings.outputsCount);
|
uint8_t outputsCount = min<uint8_t>(24, reusableBuffer.hardwareAndSettings.receiverSettings.outputsCount);
|
||||||
for (int i = 0; i < outputsCount; i++) {
|
for (int i = 0; i < outputsCount; i++) {
|
||||||
Pxx2Transport::addByte(min<uint8_t>(23, reusableBuffer.hardwareAndSettings.receiverSettings.outputsMapping[i]));
|
Pxx2Transport::addByte(reusableBuffer.hardwareAndSettings.receiverSettings.outputsMapping[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reusableBuffer.hardwareAndSettings.receiverSettings.timeout = get_tmr10ms() + 200/*next try in 2s*/;
|
reusableBuffer.hardwareAndSettings.receiverSettings.timeout = get_tmr10ms() + 200/*next try in 2s*/;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue