mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 17:25:13 +03:00
GET RX SETTINGS now has a variable length. Still KO here
This commit is contained in:
parent
bfe5900017
commit
420b7c3ccc
5 changed files with 21 additions and 48 deletions
|
@ -1928,14 +1928,13 @@ void menuModelReceiverOptions(event_t event)
|
||||||
SUBMENU_NOTITLE(ITEM_RECEIVER_PINMAP_FIRST + sentModuleChannels(g_moduleIdx), {IF_TELEM_DISPLAYED(0), IF_PWM_RATE_DISPLAYED(0)});
|
SUBMENU_NOTITLE(ITEM_RECEIVER_PINMAP_FIRST + sentModuleChannels(g_moduleIdx), {IF_TELEM_DISPLAYED(0), IF_PWM_RATE_DISPLAYED(0)});
|
||||||
int8_t sub = menuVerticalPosition;
|
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);
|
||||||
lcdInvertLine(0);
|
lcdInvertLine(0);
|
||||||
|
|
||||||
if (event == EVT_ENTRY || (reusableBuffer.receiverSetup.state == RECEIVER_OK && get_tmr10ms() >= reusableBuffer.receiverSetup.updateTime)) {
|
if (event == EVT_ENTRY || (reusableBuffer.receiverSetup.state == RECEIVER_OK && get_tmr10ms() >= reusableBuffer.receiverSetup.updateTime)) {
|
||||||
reusableBuffer.receiverSetup.updateTime = get_tmr10ms() + 500/*5s*/;
|
reusableBuffer.receiverSetup.updateTime = get_tmr10ms() + 500/*5s*/;
|
||||||
moduleSettings[reusableBuffer.receiverSetup.moduleIdx].mode = MODULE_MODE_RECEIVER_GET_SETTINGS;
|
moduleSettings[reusableBuffer.receiverSetup.moduleIdx].mode = MODULE_MODE_RECEIVER_SETTINGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
|
@ -2005,8 +2004,7 @@ void menuModelReceiverOptions(event_t event)
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
reusableBuffer.receiverSetup.timeout = 0;
|
reusableBuffer.receiverSetup.timeout = 0;
|
||||||
moduleSettings[reusableBuffer.receiverSetup.moduleIdx].mode = MODULE_MODE_RECEIVER_SET_SETTINGS;
|
moduleSettings[reusableBuffer.receiverSetup.moduleIdx].mode = MODULE_MODE_RECEIVER_SETTINGS;
|
||||||
TRACE("Change detected");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -74,8 +74,7 @@ enum ModuleSettingsMode
|
||||||
MODULE_MODE_NORMAL,
|
MODULE_MODE_NORMAL,
|
||||||
MODULE_MODE_SPECTRUM_ANALYSER,
|
MODULE_MODE_SPECTRUM_ANALYSER,
|
||||||
MODULE_MODE_GET_HARDWARE_INFO,
|
MODULE_MODE_GET_HARDWARE_INFO,
|
||||||
MODULE_MODE_RECEIVER_SET_SETTINGS,
|
MODULE_MODE_RECEIVER_SETTINGS,
|
||||||
MODULE_MODE_RECEIVER_GET_SETTINGS,
|
|
||||||
MODULE_MODE_BEEP_FIRST,
|
MODULE_MODE_BEEP_FIRST,
|
||||||
MODULE_MODE_REGISTER = MODULE_MODE_BEEP_FIRST,
|
MODULE_MODE_REGISTER = MODULE_MODE_BEEP_FIRST,
|
||||||
MODULE_MODE_BIND,
|
MODULE_MODE_BIND,
|
||||||
|
|
|
@ -145,34 +145,17 @@ void Pxx2Pulses::setupRegisterFrame(uint8_t module)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pxx2Pulses::setupReceiverSetSettingsFrame(uint8_t module)
|
void Pxx2Pulses::setupReceiverSettingsFrame(uint8_t module)
|
||||||
{
|
{
|
||||||
TRACE("Sending SET frame");
|
|
||||||
addFrameType(PXX2_TYPE_C_MODULE, PXX2_TYPE_ID_RX_SETTINGS);
|
|
||||||
Pxx2Transport::addByte(0x40 + reusableBuffer.receiverSetup.receiverId);
|
|
||||||
uint8_t flag1 = 0;
|
|
||||||
if (reusableBuffer.receiverSetup.pwmRate)
|
|
||||||
flag1 |= PXX2_RECV_OPTION_MASK_FASTPWM;
|
|
||||||
if (reusableBuffer.receiverSetup.telemetryEnabled)
|
|
||||||
flag1 |= PXX2_RECV_OPTION_MASK_TELEMETRY;
|
|
||||||
Pxx2Transport::addByte(flag1);
|
|
||||||
for (int i = 0; i < 24; i++) {
|
|
||||||
Pxx2Transport::addByte(reusableBuffer.receiverSetup.channelMapping[i]);
|
|
||||||
}
|
|
||||||
reusableBuffer.receiverSetup.timeout = get_tmr10ms() + 20/*200ms*/;
|
|
||||||
reusableBuffer.receiverSetup.state = RECEIVER_WAITING_RESPONSE; // module will be confirming changes
|
|
||||||
moduleSettings[module].mode = MODULE_MODE_NORMAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Pxx2Pulses::setupReceiverGetSettingsFrame(uint8_t module)
|
|
||||||
{
|
|
||||||
TRACE("Sending GET frame");
|
|
||||||
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(0x00);
|
uint8_t flag1 = 0;
|
||||||
for (int i = 0; i < 24; i++) {
|
if (reusableBuffer.receiverSetup.pwmRate)
|
||||||
Pxx2Transport::addByte(0x00);
|
flag1 |= PXX2_RX_SETTINGS_FLAG1_FASTPWM;
|
||||||
|
Pxx2Transport::addByte(flag1);
|
||||||
|
uint8_t channelsCount = sentModuleChannels(module);
|
||||||
|
for (int i = 0; i < channelsCount; i++) {
|
||||||
|
Pxx2Transport::addByte(reusableBuffer.receiverSetup.channelMapping[i]);
|
||||||
}
|
}
|
||||||
reusableBuffer.receiverSetup.timeout = get_tmr10ms() + 20/*200ms*/;
|
reusableBuffer.receiverSetup.timeout = get_tmr10ms() + 20/*200ms*/;
|
||||||
reusableBuffer.receiverSetup.state = RECEIVER_WAITING_RESPONSE;
|
reusableBuffer.receiverSetup.state = RECEIVER_WAITING_RESPONSE;
|
||||||
|
@ -253,11 +236,8 @@ void Pxx2Pulses::setupFrame(uint8_t module)
|
||||||
case MODULE_MODE_GET_HARDWARE_INFO:
|
case MODULE_MODE_GET_HARDWARE_INFO:
|
||||||
setupHardwareInfoFrame(module);
|
setupHardwareInfoFrame(module);
|
||||||
break;
|
break;
|
||||||
case MODULE_MODE_RECEIVER_GET_SETTINGS:
|
case MODULE_MODE_RECEIVER_SETTINGS:
|
||||||
setupReceiverGetSettingsFrame(module);
|
setupReceiverSettingsFrame(module);
|
||||||
break;
|
|
||||||
case MODULE_MODE_RECEIVER_SET_SETTINGS:
|
|
||||||
setupReceiverSetSettingsFrame(module);
|
|
||||||
break;
|
break;
|
||||||
case MODULE_MODE_REGISTER:
|
case MODULE_MODE_REGISTER:
|
||||||
setupRegisterFrame(module);
|
setupRegisterFrame(module);
|
||||||
|
|
|
@ -43,11 +43,9 @@
|
||||||
#define PXX2_CHANNELS_FLAG0_FAILSAFE (1 << 6)
|
#define PXX2_CHANNELS_FLAG0_FAILSAFE (1 << 6)
|
||||||
#define PXX2_CHANNELS_FLAG0_RANGECHECK (1 << 7)
|
#define PXX2_CHANNELS_FLAG0_RANGECHECK (1 << 7)
|
||||||
|
|
||||||
#define PXX2_RECV_OPTION_MASK_FASTPWM 0x10
|
#define PXX2_RX_SETTINGS_FLAG1_FASTPWM (1 << 4)
|
||||||
#define PXX2_RECV_OPTION_MASK_TELEMETRY 0x00 // Todo : update when defined
|
#define PXX2_RECV_OPTION_MASK_TELEMETRY 0x00 // TODO : update when defined
|
||||||
|
|
||||||
const uint8_t DEFAULT_CHANNEL_MAPPING[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
|
|
||||||
const uint8_t CH9TO16_CHANNEL_MAPPING[] = {0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67};
|
|
||||||
|
|
||||||
enum PXX2RegisterSteps {
|
enum PXX2RegisterSteps {
|
||||||
REGISTER_START,
|
REGISTER_START,
|
||||||
|
@ -120,9 +118,7 @@ class Pxx2Pulses: public PxxPulses<Pxx2Transport> {
|
||||||
|
|
||||||
void setupShareMode(uint8_t module);
|
void setupShareMode(uint8_t module);
|
||||||
|
|
||||||
void setupReceiverSetSettingsFrame(uint8_t module);
|
void setupReceiverSettingsFrame(uint8_t module);
|
||||||
|
|
||||||
void setupReceiverGetSettingsFrame(uint8_t module);
|
|
||||||
|
|
||||||
void setupChannelsFrame(uint8_t module);
|
void setupChannelsFrame(uint8_t module);
|
||||||
|
|
||||||
|
|
|
@ -62,14 +62,14 @@ void processGetHardwareInfoFrame(uint8_t module, uint8_t * frame)
|
||||||
|
|
||||||
void processReceiverSettingsFrame(uint8_t module, uint8_t * frame)
|
void processReceiverSettingsFrame(uint8_t module, uint8_t * frame)
|
||||||
{
|
{
|
||||||
TRACE("Got Option frame");
|
uint8_t channelsCount = sentModuleChannels(module);
|
||||||
for (uint8_t pin = 0; pin < 24; pin++) {
|
for (uint8_t pin = 0; pin < channelsCount; pin++) {
|
||||||
reusableBuffer.receiverSetup.channelMapping[pin] = frame[5 + pin];
|
reusableBuffer.receiverSetup.channelMapping[pin] = frame[5 + pin];
|
||||||
}
|
}
|
||||||
if(frame[4] & PXX2_RECV_OPTION_MASK_FASTPWM)
|
if (frame[4] & PXX2_RX_SETTINGS_FLAG1_FASTPWM)
|
||||||
reusableBuffer.receiverSetup.pwmRate = 1;
|
reusableBuffer.receiverSetup.pwmRate = 1;
|
||||||
if(frame[4] & PXX2_RECV_OPTION_MASK_TELEMETRY)
|
// if (frame[4] & PXX2_RECV_OPTION_MASK_TELEMETRY)
|
||||||
reusableBuffer.receiverSetup.telemetryEnabled = 1;
|
// reusableBuffer.receiverSetup.telemetryEnabled = 1;
|
||||||
reusableBuffer.receiverSetup.state = RECEIVER_OK;
|
reusableBuffer.receiverSetup.state = RECEIVER_OK;
|
||||||
reusableBuffer.receiverSetup.timeout = 0;
|
reusableBuffer.receiverSetup.timeout = 0;
|
||||||
moduleSettings[module].mode = MODULE_MODE_NORMAL;
|
moduleSettings[module].mode = MODULE_MODE_NORMAL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue