Fixes #2902
This commit is contained in:
@@ -173,7 +173,7 @@ void putPcmHead(unsigned int port)
|
|||||||
|
|
||||||
void setupPulsesPXX(unsigned int port)
|
void setupPulsesPXX(unsigned int port)
|
||||||
{
|
{
|
||||||
uint16_t chan=0, chan_low=0;
|
uint16_t pulseValue=0, pulseValueLow=0;
|
||||||
|
|
||||||
modulePulsesData[port].pxx.ptr = modulePulsesData[port].pxx.pulses;
|
modulePulsesData[port].pxx.ptr = modulePulsesData[port].pxx.pulses;
|
||||||
modulePulsesData[port].pxx.pcmValue = 0 ;
|
modulePulsesData[port].pxx.pcmValue = 0 ;
|
||||||
@@ -224,56 +224,56 @@ void setupPulsesPXX(unsigned int port)
|
|||||||
for (int i=0; i<8; i++) {
|
for (int i=0; i<8; i++) {
|
||||||
if (flag1 & PXX_SEND_FAILSAFE) {
|
if (flag1 & PXX_SEND_FAILSAFE) {
|
||||||
if (g_model.moduleData[port].failsafeMode == FAILSAFE_HOLD) {
|
if (g_model.moduleData[port].failsafeMode == FAILSAFE_HOLD) {
|
||||||
chan = (i < sendUpperChannels ? 4095 : 2047);
|
pulseValue = (i < sendUpperChannels ? 4095 : 2047);
|
||||||
}
|
}
|
||||||
else if (g_model.moduleData[port].failsafeMode == FAILSAFE_NOPULSES) {
|
else if (g_model.moduleData[port].failsafeMode == FAILSAFE_NOPULSES) {
|
||||||
chan = (i < sendUpperChannels ? 2048 : 0);
|
pulseValue = (i < sendUpperChannels ? 2048 : 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (i < sendUpperChannels) {
|
if (i < sendUpperChannels) {
|
||||||
int16_t failsafeValue = g_model.moduleData[port].failsafeChannels[8+i];
|
int16_t failsafeValue = g_model.moduleData[port].failsafeChannels[8+i];
|
||||||
if (failsafeValue == FAILSAFE_CHANNEL_HOLD)
|
if (failsafeValue == FAILSAFE_CHANNEL_HOLD)
|
||||||
chan = 4095;
|
pulseValue = 4095;
|
||||||
else if (failsafeValue == FAILSAFE_CHANNEL_NOPULSE)
|
else if (failsafeValue == FAILSAFE_CHANNEL_NOPULSE)
|
||||||
chan = 2048;
|
pulseValue = 2048;
|
||||||
else
|
else
|
||||||
chan = limit(2049, PPM_CH_CENTER(8+g_model.moduleData[port].channelsStart+i) - PPM_CENTER + (failsafeValue * 512 / 682) + 3072, 4094);
|
pulseValue = limit(2049, PPM_CH_CENTER(8+g_model.moduleData[port].channelsStart+i) - PPM_CENTER + (failsafeValue * 512 / 682) + 3072, 4094);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int16_t failsafeValue = g_model.moduleData[port].failsafeChannels[i];
|
int16_t failsafeValue = g_model.moduleData[port].failsafeChannels[i];
|
||||||
if (failsafeValue == FAILSAFE_CHANNEL_HOLD)
|
if (failsafeValue == FAILSAFE_CHANNEL_HOLD)
|
||||||
chan = 2047;
|
pulseValue = 2047;
|
||||||
else if (failsafeValue == FAILSAFE_CHANNEL_NOPULSE)
|
else if (failsafeValue == FAILSAFE_CHANNEL_NOPULSE)
|
||||||
chan = 0;
|
pulseValue = 0;
|
||||||
else
|
else
|
||||||
chan = limit(1, PPM_CH_CENTER(g_model.moduleData[port].channelsStart+i) - PPM_CENTER + (failsafeValue * 512 / 682) + 1024, 2046);
|
pulseValue = limit(1, PPM_CH_CENTER(g_model.moduleData[port].channelsStart+i) - PPM_CENTER + (failsafeValue * 512 / 682) + 1024, 2046);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (i < sendUpperChannels)
|
if (i < sendUpperChannels)
|
||||||
chan = limit(2049, PPM_CH_CENTER(8+g_model.moduleData[port].channelsStart+i) - PPM_CENTER + (channelOutputs[8+g_model.moduleData[port].channelsStart+i] * 512 / 682) + 3072, 4094);
|
pulseValue = limit(2049, PPM_CH_CENTER(8+g_model.moduleData[port].channelsStart+i) - PPM_CENTER + (channelOutputs[8+g_model.moduleData[port].channelsStart+i] * 512 / 682) + 3072, 4094);
|
||||||
else if (i < NUM_CHANNELS(port))
|
else if (i < NUM_CHANNELS(port))
|
||||||
chan = limit(1, PPM_CH_CENTER(g_model.moduleData[port].channelsStart+i) - PPM_CENTER + (channelOutputs[g_model.moduleData[port].channelsStart+i] * 512 / 682) + 1024, 2046);
|
pulseValue = limit(1, PPM_CH_CENTER(g_model.moduleData[port].channelsStart+i) - PPM_CENTER + (channelOutputs[g_model.moduleData[port].channelsStart+i] * 512 / 682) + 1024, 2046);
|
||||||
else
|
else
|
||||||
chan = 1024;
|
pulseValue = 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i & 1) {
|
if (i & 1) {
|
||||||
putPcmByte(chan_low, port); // Low byte of channel
|
putPcmByte(pulseValueLow, port); // Low byte of channel
|
||||||
putPcmByte(((chan_low >> 8) & 0x0F) | (chan << 4), port); // 4 bits each from 2 channels
|
putPcmByte(((pulseValueLow >> 8) & 0x0F) | (pulseValue << 4), port); // 4 bits each from 2 channels
|
||||||
putPcmByte(chan >> 4, port); // High byte of channel
|
putPcmByte(pulseValue >> 4, port); // High byte of channel
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
chan_low = chan;
|
pulseValueLow = pulseValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CRC16 */
|
/* CRC16 */
|
||||||
putPcmByte(0, port);
|
putPcmByte(0, port);
|
||||||
chan = modulePulsesData[port].pxx.pcmCrc;
|
pulseValue = modulePulsesData[port].pxx.pcmCrc;
|
||||||
putPcmByte(chan>>8, port);
|
putPcmByte(pulseValue>>8, port);
|
||||||
putPcmByte(chan, port);
|
putPcmByte(pulseValue, port);
|
||||||
|
|
||||||
/* Sync */
|
/* Sync */
|
||||||
putPcmHead(port);
|
putPcmHead(port);
|
||||||
|
|||||||
Reference in New Issue
Block a user