mirror of
https://github.com/opentx/opentx.git
synced 2025-07-17 13:25:20 +03:00
parent
1845df0df5
commit
1c70646cf1
4 changed files with 62 additions and 28 deletions
|
@ -1905,6 +1905,16 @@ void menuModelFailsafe(event_t event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum MenuModelReceiverOptions {
|
||||||
|
ITEM_RECEIVER_TELEMETRY,
|
||||||
|
ITEM_RECEIVER_PWM_RATE,
|
||||||
|
ITEM_RECEIVER_PINMAP
|
||||||
|
};
|
||||||
|
|
||||||
|
#define RECEIVER_OPTIONS_2ND_COLUMN 80
|
||||||
|
#define IF_TELEM_DISPLAYED(x) (g_model.moduleData[g_moduleIdx].pxx.receiver_telem_off ? (uint8_t)(x) : HIDDEN_ROW) //Todo need capabilities
|
||||||
|
#define IF_PWM_RATE_DISPLAYED(x) (g_model.moduleData[g_moduleIdx].pxx.receiver_telem_off ? (uint8_t)(x) : HIDDEN_ROW) //Todo need capabilities
|
||||||
|
|
||||||
void menuModelReceiverOptions(event_t event)
|
void menuModelReceiverOptions(event_t event)
|
||||||
{
|
{
|
||||||
if (menuEvent) {
|
if (menuEvent) {
|
||||||
|
@ -1914,7 +1924,10 @@ void menuModelReceiverOptions(event_t event)
|
||||||
|
|
||||||
const int lim = (g_model.extendedLimits ? (512 * LIMIT_EXT_PERCENT / 100) : 512) * 2;
|
const int lim = (g_model.extendedLimits ? (512 * LIMIT_EXT_PERCENT / 100) : 512) * 2;
|
||||||
uint8_t wbar = LCD_W / 2 - 20;
|
uint8_t wbar = LCD_W / 2 - 20;
|
||||||
SIMPLE_SUBMENU_NOTITLE(sentModuleChannels(g_moduleIdx));
|
|
||||||
|
SUBMENU_NOTITLE(sentModuleChannels(g_moduleIdx) + ITEM_RECEIVER_PINMAP, {IF_TELEM_DISPLAYED(0), IF_PWM_RATE_DISPLAYED(0)});
|
||||||
|
int8_t sub = menuVerticalPosition;
|
||||||
|
|
||||||
|
|
||||||
lcdDrawTextAlignedLeft(0, STR_RECEIVER_OPTIONS);
|
lcdDrawTextAlignedLeft(0, STR_RECEIVER_OPTIONS);
|
||||||
drawReceiverName(FW * 13, 0, reusableBuffer.receiverSetup.receiverId);
|
drawReceiverName(FW * 13, 0, reusableBuffer.receiverSetup.receiverId);
|
||||||
|
@ -1926,44 +1939,58 @@ void menuModelReceiverOptions(event_t event)
|
||||||
moduleSettings[reusableBuffer.receiverSetup.moduleIdx].mode = MODULE_MODE_RECEIVER_SETTINGS;
|
moduleSettings[reusableBuffer.receiverSetup.moduleIdx].mode = MODULE_MODE_RECEIVER_SETTINGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(SIMU)
|
||||||
|
reusableBuffer.receiverSetup.state = 0xFF;
|
||||||
|
#endif
|
||||||
if (reusableBuffer.receiverSetup.state != 0) {
|
if (reusableBuffer.receiverSetup.state != 0) {
|
||||||
for (uint8_t i = 0; i < NUM_BODY_LINES; i++) {
|
for (uint8_t k=0; k<LCD_LINES-1; k++) {
|
||||||
coord_t y = MENU_HEADER_HEIGHT + 1 + i * FH;
|
coord_t y = MENU_HEADER_HEIGHT + 1 + k*FH;
|
||||||
uint8_t pin = menuVerticalOffset + i;
|
uint8_t i = k + menuVerticalOffset;
|
||||||
|
LcdFlags attr = (sub==i ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0);
|
||||||
|
uint8_t pin = i - ITEM_RECEIVER_PINMAP;
|
||||||
uint8_t channel = reusableBuffer.receiverSetup.channelMapping[pin];
|
uint8_t channel = reusableBuffer.receiverSetup.channelMapping[pin];
|
||||||
int32_t channelValue = channelOutputs[channel];
|
int32_t channelValue = channelOutputs[channel];
|
||||||
|
|
||||||
// Pin
|
switch (i) {
|
||||||
lcdDrawText(0, y, "Pin");
|
case ITEM_RECEIVER_TELEMETRY:
|
||||||
lcdDrawNumber(lcdLastRightPos + 1, y, pin + 1);
|
reusableBuffer.receiverSetup.telemetryEnabled = editCheckBox(reusableBuffer.receiverSetup.telemetryEnabled , RECEIVER_OPTIONS_2ND_COLUMN, y, "Telemetry", attr, event);
|
||||||
|
break;
|
||||||
|
case ITEM_RECEIVER_PWM_RATE:
|
||||||
|
reusableBuffer.receiverSetup.pwmRate = editCheckBox(reusableBuffer.receiverSetup.pwmRate , RECEIVER_OPTIONS_2ND_COLUMN, y, "9ms PWM", attr, event);
|
||||||
|
break;
|
||||||
|
|
||||||
// Channel
|
default:
|
||||||
LcdFlags flags = 0;
|
|
||||||
if (menuVerticalPosition == pin) {
|
// Pin
|
||||||
flags |= INVERS;
|
lcdDrawText(0, y, "Pin");
|
||||||
if (s_editMode > 0) {
|
lcdDrawNumber(lcdLastRightPos + 1, y, pin + 1);
|
||||||
flags |= BLINK;
|
|
||||||
channel = checkIncDec(event, channel, 0, sentModuleChannels(g_moduleIdx));
|
// Channel
|
||||||
if (checkIncDec_Ret) {
|
if (menuVerticalPosition == pin) {
|
||||||
reusableBuffer.receiverSetup.channelMapping[pin] = channel;
|
if (s_editMode > 0) {
|
||||||
reusableBuffer.receiverSetup.state = 0x40;
|
channel = checkIncDec(event, channel, 0, sentModuleChannels(g_moduleIdx));
|
||||||
moduleSettings[reusableBuffer.receiverSetup.moduleIdx].mode = MODULE_MODE_RECEIVER_SETTINGS;
|
if (checkIncDec_Ret) {
|
||||||
|
reusableBuffer.receiverSetup.channelMapping[pin] = channel;
|
||||||
|
reusableBuffer.receiverSetup.state = 0x40;
|
||||||
|
moduleSettings[reusableBuffer.receiverSetup.moduleIdx].mode = MODULE_MODE_RECEIVER_SETTINGS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
putsChn(7 * FW, y, channel + 1, attr);
|
||||||
putsChn(7 * FW, y, channel + 1, flags);
|
|
||||||
|
|
||||||
// Bargraph
|
// Bargraph
|
||||||
#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(LCD_W - 3 - wbar, y + 1, wbar + 1, 4);
|
lcdDrawRect(LCD_W - 3 - wbar, y + 1, wbar + 1, 4);
|
||||||
#endif
|
#endif
|
||||||
const uint8_t lenChannel = limit<uint8_t>(1, (abs(channelValue) * wbar / 2 + lim / 2) / lim, wbar / 2);
|
const uint8_t lenChannel = limit<uint8_t>(1, (abs(channelValue) * wbar / 2 + lim / 2) / lim, wbar / 2);
|
||||||
const coord_t xChannel = (channelValue > 0) ? LCD_W - 3 - wbar / 2 : LCD_W - 2 - wbar / 2 - lenChannel;
|
const coord_t xChannel = (channelValue > 0) ? LCD_W - 3 - wbar / 2 : LCD_W - 2 - wbar / 2 - lenChannel;
|
||||||
lcdDrawHorizontalLine(xChannel, y + 2, lenChannel, SOLID, 0);
|
lcdDrawHorizontalLine(xChannel, y + 2, lenChannel, SOLID, 0);
|
||||||
lcdDrawHorizontalLine(xChannel, y + 3, lenChannel, SOLID, 0);
|
lcdDrawHorizontalLine(xChannel, y + 3, lenChannel, SOLID, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lcdDrawText(4*FW, 4*FH, "Waiting for RX...");
|
lcdDrawText(4 * FW, 4 * FH, "Waiting for RX...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1147,6 +1147,8 @@ union ReusableBuffer
|
||||||
uint8_t moduleIdx;
|
uint8_t moduleIdx;
|
||||||
uint8_t receiverId;
|
uint8_t receiverId;
|
||||||
uint8_t channelMapping[24];
|
uint8_t channelMapping[24];
|
||||||
|
uint8_t telemetryEnabled;
|
||||||
|
uint8_t pwmRate;
|
||||||
} receiverSetup;
|
} receiverSetup;
|
||||||
|
|
||||||
// 103 bytes
|
// 103 bytes
|
||||||
|
|
|
@ -154,7 +154,10 @@ void Pxx2Pulses::setupReceiverSettingsFrame(uint8_t module)
|
||||||
else {
|
else {
|
||||||
addFrameType(PXX2_TYPE_C_MODULE, PXX2_TYPE_ID_RX_SETTINGS);
|
addFrameType(PXX2_TYPE_C_MODULE, PXX2_TYPE_ID_RX_SETTINGS);
|
||||||
Pxx2Transport::addByte(reusableBuffer.receiverSetup.state + reusableBuffer.receiverSetup.receiverId);
|
Pxx2Transport::addByte(reusableBuffer.receiverSetup.state + reusableBuffer.receiverSetup.receiverId);
|
||||||
Pxx2Transport::addByte(0x0);
|
uint8_t flag1 = 0;
|
||||||
|
if(reusableBuffer.receiverSetup.pwmRate)
|
||||||
|
flag1 ^= 0x30;
|
||||||
|
Pxx2Transport::addByte(flag1);
|
||||||
for (int i = 0; i < 24; i++) {
|
for (int i = 0; i < 24; i++) {
|
||||||
Pxx2Transport::addByte(reusableBuffer.receiverSetup.channelMapping[i]);
|
Pxx2Transport::addByte(reusableBuffer.receiverSetup.channelMapping[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,8 @@ void processReceiverSettingsFrame(uint8_t module, uint8_t * frame)
|
||||||
reusableBuffer.receiverSetup.channelMapping[pin] = frame[5 + pin];
|
reusableBuffer.receiverSetup.channelMapping[pin] = frame[5 + pin];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reusableBuffer.receiverSetup.pwmRate = frame[4] & 0x30;
|
||||||
|
|
||||||
reusableBuffer.receiverSetup.state = 0xFF;
|
reusableBuffer.receiverSetup.state = 0xFF;
|
||||||
moduleSettings[module].mode = MODULE_MODE_NORMAL;
|
moduleSettings[module].mode = MODULE_MODE_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue