Merge with latest 2.3
This commit is contained in:
@@ -372,6 +372,11 @@ inline int8_t defaultModuleChannels_M8(uint8_t idx)
|
||||
return maxModuleChannels_M8(idx);
|
||||
}
|
||||
|
||||
inline uint8_t sentModulePXXChannels(uint8_t idx)
|
||||
{
|
||||
return 8 + g_model.moduleData[idx].channelsCount;
|
||||
}
|
||||
|
||||
inline int8_t sentModuleChannels(uint8_t idx)
|
||||
{
|
||||
if (isModuleCrossfire(idx))
|
||||
@@ -381,7 +386,7 @@ inline int8_t sentModuleChannels(uint8_t idx)
|
||||
else if (isModuleSBUS(idx))
|
||||
return 16;
|
||||
else
|
||||
return 8 + g_model.moduleData[idx].channelsCount;
|
||||
return sentModulePXXChannels(idx);
|
||||
}
|
||||
|
||||
inline bool isDefaultModelRegistrationID()
|
||||
|
||||
+21
-16
@@ -219,21 +219,21 @@ void enablePulsesExternalModule(uint8_t protocol)
|
||||
}
|
||||
}
|
||||
|
||||
void setupPulsesExternalModule(uint8_t protocol)
|
||||
bool setupPulsesExternalModule(uint8_t protocol)
|
||||
{
|
||||
switch (protocol) {
|
||||
#if defined(PXX1)
|
||||
case PROTOCOL_CHANNELS_PXX1_PULSES:
|
||||
extmodulePulsesData.pxx.setupFrame(EXTERNAL_MODULE);
|
||||
scheduleNextMixerCalculation(EXTERNAL_MODULE, PXX_PULSES_PERIOD);
|
||||
break;
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#if defined(PXX1) && defined(HARDWARE_EXTERNAL_MODULE_SIZE_SML)
|
||||
case PROTOCOL_CHANNELS_PXX1_SERIAL:
|
||||
extmodulePulsesData.pxx_uart.setupFrame(EXTERNAL_MODULE);
|
||||
scheduleNextMixerCalculation(EXTERNAL_MODULE, EXTMODULE_PXX1_SERIAL_PERIOD);
|
||||
break;
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#if defined(PXX2)
|
||||
@@ -241,14 +241,14 @@ void setupPulsesExternalModule(uint8_t protocol)
|
||||
case PROTOCOL_CHANNELS_PXX2_LOWSPEED:
|
||||
extmodulePulsesData.pxx2.setupFrame(EXTERNAL_MODULE);
|
||||
scheduleNextMixerCalculation(EXTERNAL_MODULE, PXX2_PERIOD);
|
||||
break;
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#if defined(SBUS)
|
||||
case PROTOCOL_CHANNELS_SBUS:
|
||||
setupPulsesSbus();
|
||||
scheduleNextMixerCalculation(EXTERNAL_MODULE, SBUS_PERIOD);
|
||||
break;
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#if defined(DSM2)
|
||||
@@ -257,32 +257,33 @@ void setupPulsesExternalModule(uint8_t protocol)
|
||||
case PROTOCOL_CHANNELS_DSM2_DSMX:
|
||||
setupPulsesDSM2();
|
||||
scheduleNextMixerCalculation(EXTERNAL_MODULE, DSM2_PERIOD);
|
||||
break;
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#if defined(CROSSFIRE)
|
||||
case PROTOCOL_CHANNELS_CROSSFIRE:
|
||||
setupPulsesCrossfire();
|
||||
scheduleNextMixerCalculation(EXTERNAL_MODULE, CROSSFIRE_PERIOD);
|
||||
break;
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#if defined(MULTIMODULE)
|
||||
case PROTOCOL_CHANNELS_MULTIMODULE:
|
||||
setupPulsesMultiExternalModule();
|
||||
scheduleNextMixerCalculation(EXTERNAL_MODULE, MULTIMODULE_PERIOD);
|
||||
break;
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#if defined(PPM)
|
||||
case PROTOCOL_CHANNELS_PPM:
|
||||
setupPulsesPPMExternalModule();
|
||||
scheduleNextMixerCalculation(EXTERNAL_MODULE, PPM_PERIOD(EXTERNAL_MODULE));
|
||||
break;
|
||||
return true;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
scheduleNextMixerCalculation(EXTERNAL_MODULE, 50/*ms*/);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,7 +339,9 @@ bool setupPulsesInternalModule(uint8_t protocol)
|
||||
#if defined(PXX1) && defined(INTMODULE_USART)
|
||||
case PROTOCOL_CHANNELS_PXX1_SERIAL:
|
||||
intmodulePulsesData.pxx_uart.setupFrame(INTERNAL_MODULE);
|
||||
#if !defined(INTMODULE_HEARTBEAT)
|
||||
#if defined(INTMODULE_HEARTBEAT)
|
||||
scheduleNextMixerCalculation(INTERNAL_MODULE, INTMODULE_PXX1_SERIAL_PERIOD + 1 /* backup */);
|
||||
#else
|
||||
scheduleNextMixerCalculation(INTERNAL_MODULE, INTMODULE_PXX1_SERIAL_PERIOD);
|
||||
#endif
|
||||
return true;
|
||||
@@ -351,11 +354,13 @@ bool setupPulsesInternalModule(uint8_t protocol)
|
||||
if (moduleState[INTERNAL_MODULE].mode == MODULE_MODE_SPECTRUM_ANALYSER || moduleState[INTERNAL_MODULE].mode == MODULE_MODE_POWER_METER) {
|
||||
scheduleNextMixerCalculation(INTERNAL_MODULE, PXX2_TOOLS_PERIOD);
|
||||
}
|
||||
#if !defined(INTMODULE_HEARTBEAT)
|
||||
else {
|
||||
#if defined(INTMODULE_HEARTBEAT)
|
||||
scheduleNextMixerCalculation(INTERNAL_MODULE, PXX2_PERIOD + 1 /* backup */);
|
||||
#else
|
||||
scheduleNextMixerCalculation(INTERNAL_MODULE, PXX2_PERIOD);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
@@ -375,7 +380,8 @@ bool setupPulsesInternalModule(uint8_t protocol)
|
||||
#endif
|
||||
|
||||
default:
|
||||
return true;
|
||||
scheduleNextMixerCalculation(INTERNAL_MODULE, 50/*ms*/);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,8 +416,7 @@ bool setupPulsesExternalModule()
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
setupPulsesExternalModule(protocol);
|
||||
return true;
|
||||
return setupPulsesExternalModule(protocol);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -69,17 +69,17 @@ void Pxx1Pulses<PxxTransport>::addExtraFlags(uint8_t module)
|
||||
}
|
||||
|
||||
template <class PxxTransport>
|
||||
void Pxx1Pulses<PxxTransport>::addChannels(uint8_t port, uint8_t sendFailsafe, uint8_t sendUpperChannels)
|
||||
void Pxx1Pulses<PxxTransport>::addChannels(uint8_t moduleIdx, uint8_t sendFailsafe, uint8_t sendUpperChannels)
|
||||
{
|
||||
uint16_t pulseValue = 0;
|
||||
uint16_t pulseValueLow = 0;
|
||||
|
||||
for (int8_t i=0; i<8; i++) {
|
||||
for (uint8_t i = 0; i < 8; i++) {
|
||||
if (sendFailsafe) {
|
||||
if (g_model.moduleData[port].failsafeMode == FAILSAFE_HOLD) {
|
||||
if (g_model.moduleData[moduleIdx].failsafeMode == FAILSAFE_HOLD) {
|
||||
pulseValue = (i < sendUpperChannels ? 4095 : 2047);
|
||||
}
|
||||
else if (g_model.moduleData[port].failsafeMode == FAILSAFE_NOPULSES) {
|
||||
else if (g_model.moduleData[moduleIdx].failsafeMode == FAILSAFE_NOPULSES) {
|
||||
pulseValue = (i < sendUpperChannels ? 2048 : 0);
|
||||
}
|
||||
else {
|
||||
@@ -92,7 +92,7 @@ void Pxx1Pulses<PxxTransport>::addChannels(uint8_t port, uint8_t sendFailsafe, u
|
||||
pulseValue = 2048;
|
||||
}
|
||||
else {
|
||||
failsafeValue += 2*PPM_CH_CENTER(8+g_model.moduleData[port].channelsStart+i) - 2*PPM_CENTER;
|
||||
failsafeValue += 2*PPM_CH_CENTER(8+g_model.moduleData[moduleIdx].channelsStart+i) - 2*PPM_CENTER;
|
||||
pulseValue = limit(2049, (failsafeValue * 512 / 682) + 3072, 4094);
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ void Pxx1Pulses<PxxTransport>::addChannels(uint8_t port, uint8_t sendFailsafe, u
|
||||
pulseValue = 0;
|
||||
}
|
||||
else {
|
||||
failsafeValue += 2*PPM_CH_CENTER(g_model.moduleData[port].channelsStart+i) - 2*PPM_CENTER;
|
||||
failsafeValue += 2*PPM_CH_CENTER(g_model.moduleData[moduleIdx].channelsStart+i) - 2*PPM_CENTER;
|
||||
pulseValue = limit(1, (failsafeValue * 512 / 682) + 1024, 2046);
|
||||
}
|
||||
}
|
||||
@@ -113,12 +113,12 @@ void Pxx1Pulses<PxxTransport>::addChannels(uint8_t port, uint8_t sendFailsafe, u
|
||||
}
|
||||
else {
|
||||
if (i < sendUpperChannels) {
|
||||
int channel = 8 + g_model.moduleData[port].channelsStart + i;
|
||||
int channel = 8 + g_model.moduleData[moduleIdx].channelsStart + i;
|
||||
int value = channelOutputs[channel] + 2*PPM_CH_CENTER(channel) - 2*PPM_CENTER;
|
||||
pulseValue = limit(2049, (value * 512 / 682) + 3072, 4094);
|
||||
}
|
||||
else if (i < sentModuleChannels(port)) {
|
||||
int channel = g_model.moduleData[port].channelsStart + i;
|
||||
else if (i < sentModulePXXChannels(moduleIdx)) {
|
||||
int channel = g_model.moduleData[moduleIdx].channelsStart + i;
|
||||
int value = channelOutputs[channel] + 2*PPM_CH_CENTER(channel) - 2*PPM_CENTER;
|
||||
pulseValue = limit(1, (value * 512 / 682) + 1024, 2046);
|
||||
}
|
||||
@@ -186,7 +186,7 @@ void Pxx1Pulses<PxxTransport>::setupFrame(uint8_t module)
|
||||
moduleState[module].counter = 1000;
|
||||
}
|
||||
add8ChannelsFrame(module, 0, sendFailsafe);
|
||||
if (sentModuleChannels(module) > 8) {
|
||||
if (sentModulePXXChannels(module) > 8) {
|
||||
add8ChannelsFrame(module, 8, sendFailsafe);
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -25,8 +25,12 @@
|
||||
#include "crc.h"
|
||||
|
||||
struct HeartbeatCapture {
|
||||
#if !defined(INTMODULE_USART)
|
||||
uint32_t timestamp;
|
||||
#endif
|
||||
#if defined(DEBUG_LATENCY)
|
||||
uint32_t count;
|
||||
#endif
|
||||
uint8_t valid;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user