Wismy/frsky new receivers (#7449)

Add internal module OTA
Change virtual keys for X-Lite(S) Lua scripts
This commit is contained in:
WismyYao
2020-03-24 15:15:10 +01:00
committed by GitHub
parent 9e22b1c6c4
commit 629f98a930
31 changed files with 350 additions and 59 deletions
@@ -46,14 +46,18 @@ void onRxOptionsUpdateConfirm(const char * result)
enum {
ITEM_RECEIVER_SETTINGS_PWM_RATE,
ITEM_RECEIVER_SETTINGS_TELEMETRY,
ITEM_RECEIVER_SETTINGS_TELEMETRY_25MW,
ITEM_RECEIVER_SETTINGS_SPORT_FPORT,
ITEM_RECEIVER_SETTINGS_CAPABILITY_NOT_SUPPORTED1,
ITEM_RECEIVER_SETTINGS_CAPABILITY_NOT_SUPPORTED2,
ITEM_RECEIVER_SETTINGS_PINMAP_FIRST
};
#define IS_RECEIVER_CAPABILITY_ENABLED(capability) (reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].receivers[receiverId].information.capabilities & (1 << capability))
#define IF_RECEIVER_CAPABILITY(capability, count) uint8_t(IS_RECEIVER_CAPABILITY_ENABLED(capability) ? count : HIDDEN_ROW)
#define IF_RECEIVER_CAPABILITY(capability, count) uint8_t((reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].receivers[receiverId].information.capabilities & (1 << capability)) ? count : HIDDEN_ROW)
#define CH_ENABLE_SPORT 4
#define CH_ENABLE_SBUS 5
void menuModelReceiverOptions(event_t event)
{
@@ -76,6 +80,7 @@ void menuModelReceiverOptions(event_t event)
SUBMENU_NOTITLE(ITEM_RECEIVER_SETTINGS_PINMAP_FIRST + outputsCount, {
0, // PWM rate
isModuleR9MAccess(g_moduleIdx) && receiverVariant == PXX2_VARIANT_EU && reusableBuffer.hardwareAndSettings.moduleSettings.txPower > 14 /*25mW*/ ? READONLY_ROW : (uint8_t)0, // Telemetry
IF_RECEIVER_CAPABILITY(RECEIVER_CAPABILITY_TELEMETRY_25MW, 0),
IF_RECEIVER_CAPABILITY(RECEIVER_CAPABILITY_FPORT, 0),
uint8_t(reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].receivers[receiverId].information.capabilityNotSupported ? READONLY_ROW : HIDDEN_ROW),
uint8_t(reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].receivers[receiverId].information.capabilityNotSupported ? READONLY_ROW : HIDDEN_ROW),
@@ -139,7 +144,7 @@ void menuModelReceiverOptions(event_t event)
switch (i) {
case ITEM_RECEIVER_SETTINGS_PWM_RATE:
reusableBuffer.hardwareAndSettings.receiverSettings.pwmRate = editCheckBox(reusableBuffer.hardwareAndSettings.receiverSettings.pwmRate, RECEIVER_OPTIONS_2ND_COLUMN, y, isModuleR9MAccess(g_moduleIdx) ? "6.67ms PWM": "9ms PWM", attr, event);
reusableBuffer.hardwareAndSettings.receiverSettings.pwmRate = editCheckBox(reusableBuffer.hardwareAndSettings.receiverSettings.pwmRate, RECEIVER_OPTIONS_2ND_COLUMN, y, isModuleR9MAccess(g_moduleIdx) ? "6.67ms PWM": "7ms PWM", attr, event);
if (attr && checkIncDec_Ret) {
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = RECEIVER_SETTINGS_DIRTY;
}
@@ -152,6 +157,13 @@ void menuModelReceiverOptions(event_t event)
}
break;
case ITEM_RECEIVER_SETTINGS_TELEMETRY_25MW:
reusableBuffer.hardwareAndSettings.receiverSettings.telemetry25mw = editCheckBox(reusableBuffer.hardwareAndSettings.receiverSettings.telemetry25mw, RECEIVER_OPTIONS_2ND_COLUMN, y, "25mw Tele", attr, event);
if (attr && checkIncDec_Ret) {
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = RECEIVER_SETTINGS_DIRTY;
}
break;
case ITEM_RECEIVER_SETTINGS_SPORT_FPORT:
reusableBuffer.hardwareAndSettings.receiverSettings.fport = editCheckBox(reusableBuffer.hardwareAndSettings.receiverSettings.fport, RECEIVER_OPTIONS_2ND_COLUMN, y, "F.Port", attr, event);
if (attr && checkIncDec_Ret) {
@@ -174,27 +186,49 @@ void menuModelReceiverOptions(event_t event)
if (pin < reusableBuffer.hardwareAndSettings.receiverSettings.outputsCount) {
uint8_t & mapping = reusableBuffer.hardwareAndSettings.receiverSettings.outputsMapping[pin];
uint8_t channel = g_model.moduleData[g_moduleIdx].channelsStart + mapping;
int32_t channelValue = channelOutputs[channel];
lcdDrawText(0, y, STR_PIN);
lcdDrawNumber(lcdLastRightPos + 1, y, pin + 1);
putsChn(7 * FW, y, channel + 1, attr);
uint8_t channelMax = sentModuleChannels(g_moduleIdx) - 1;
uint8_t selectionMax = channelMax;
if (IS_RECEIVER_CAPABILITY_ENABLED(RECEIVER_CAPABILITY_ENABLE_PWM_CH5_CH6)) {
if (CH_ENABLE_SPORT == pin || CH_ENABLE_SBUS == pin)
selectionMax += 1;
if (CH_ENABLE_SPORT == pin && selectionMax == channel) {
lcdDrawText(7 * FW, y, "S.PORT", attr);
}
else if (CH_ENABLE_SBUS == pin && selectionMax == channel) {
lcdDrawText(7 * FW, y, "SBUS", attr);
}
else {
putsChn(7 * FW, y, channel + 1, attr);
}
}
else {
putsChn(7 * FW, y, channel + 1, attr);
}
// Channel
if (attr) {
mapping = checkIncDec(event, mapping, 0, sentModuleChannels(g_moduleIdx) - 1);
mapping = checkIncDec(event, mapping, 0, selectionMax);
if (checkIncDec_Ret) {
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = RECEIVER_SETTINGS_DIRTY;
}
}
// Bargraph
#if !defined(PCBX7) // X7 LCD doesn't like too many horizontal lines
lcdDrawRect(RECEIVER_OPTIONS_2ND_COLUMN, y + 2, wbar + 1, 4);
#endif
const uint8_t lenChannel = limit<uint8_t>(1, (abs(channelValue) * wbar / 2 + lim / 2) / lim, wbar / 2);
const coord_t xChannel = (channelValue > 0) ? RECEIVER_OPTIONS_2ND_COLUMN + wbar / 2 : RECEIVER_OPTIONS_2ND_COLUMN + wbar / 2 + 1 - lenChannel;
lcdDrawHorizontalLine(xChannel, y + 3, lenChannel, SOLID, 0);
lcdDrawHorizontalLine(xChannel, y + 4, lenChannel, SOLID, 0);
if (channel <= channelMax) {
int32_t channelValue = channelOutputs[channel];
#if !defined(PCBX7) // X7 LCD doesn't like too many horizontal lines
lcdDrawRect(RECEIVER_OPTIONS_2ND_COLUMN, y + 2, wbar + 1, 4);
#endif
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;
lcdDrawHorizontalLine(xChannel, y + 3, lenChannel, SOLID, 0);
lcdDrawHorizontalLine(xChannel, y + 4, lenChannel, SOLID, 0);
}
}
break;
}