enter racing mode by spec function

This commit is contained in:
WismyYao
2021-01-30 13:39:09 +08:00
parent a933903e6b
commit 744bcab0b9
22 changed files with 61 additions and 23 deletions
+3 -2
View File
@@ -526,10 +526,11 @@ void setCustomFailsafe(uint8_t moduleIndex)
g_model.failsafeChannels[ch] = channelOutputs[ch];
}
}
storageDirty(EE_MODEL);
}
}
int32_t getChannelValue(uint8_t channel) {
int32_t getChannelValue(uint8_t channel)
{
return channelOutputs[channel] + 2*PPM_CH_CENTER(channel) - 2*PPM_CENTER;
}
+2 -1
View File
@@ -142,7 +142,8 @@ PACK(struct ModuleState {
uint8_t protocol:4;
uint8_t mode:4;
uint8_t paused:1;
uint8_t spare:7;
uint8_t racingMode:1;
uint8_t spare:6;
uint16_t counter;
union
{
+1 -1
View File
@@ -29,7 +29,7 @@
#define PXX2_LOWSPEED_BAUDRATE 230400
#define PXX2_HIGHSPEED_BAUDRATE 450000
#define PXX2_PERIOD 4 // 4ms
#define PXX2_PERIOD 50 // 4ms
#define PXX2_TOOLS_PERIOD 1 // 1ms
#define PXX2_FRAME_MAXLENGTH 64
+9 -3
View File
@@ -47,14 +47,20 @@ void Pxx2Pulses::addFlag1(uint8_t module)
else {
subType = g_model.moduleData[module].subType;
}
Pxx2Transport::addByte(subType << 4);
uint8_t flag1 = subType << 4u;
if (isFunctionActive(FUNCTION_RACING_MODE)) {
flag1 |= PXX2_CHANNELS_FLAG1_RACING_MODE;
}
Pxx2Transport::addByte(flag1);
}
void Pxx2Pulses::addPulsesValues(uint16_t low, uint16_t high)
{
Pxx2Transport::addByte(low); // Low byte of channel
Pxx2Transport::addByte(((low >> 8) & 0x0F) | (high << 4)); // 4 bits each from 2 channels
Pxx2Transport::addByte(high >> 4); // High byte of channel
Pxx2Transport::addByte(((low >> 8u) & 0x0Fu) | (high << 4u)); // 4 bits each from 2 channels
Pxx2Transport::addByte(high >> 4u); // High byte of channel
}
void Pxx2Pulses::addChannels(uint8_t module)
+2
View File
@@ -46,6 +46,7 @@
#define PXX2_CHANNELS_FLAG0_FAILSAFE (1 << 6)
#define PXX2_CHANNELS_FLAG0_RANGECHECK (1 << 7)
#define PXX2_CHANNELS_FLAG1_RACING_MODE (1 << 3)
#define PXX2_RX_SETTINGS_FLAG0_WRITE (1 << 6)
@@ -268,6 +269,7 @@ enum ReceiverCapabilities {
RECEIVER_CAPABILITY_TELEMETRY_25MW,
RECEIVER_CAPABILITY_ENABLE_PWM_CH5_CH6,
RECEIVER_CAPABILITY_FPORT2,
RECEIVER_CAPABILITY_RACING_MODE,
RECEIVER_CAPABILITY_COUNT
};