Data structs ready ...
This commit is contained in:
@@ -86,15 +86,13 @@ inline bool isExtraModule(uint8_t)
|
||||
#if defined(TARANIS_INTERNAL_PPM)
|
||||
inline bool isModulePPM(uint8_t idx)
|
||||
{
|
||||
return idx == TRAINER_MODULE ||
|
||||
(idx == INTERNAL_MODULE && g_model.moduleData[INTERNAL_MODULE].type == MODULE_TYPE_PPM) ||
|
||||
return (idx == INTERNAL_MODULE && g_model.moduleData[INTERNAL_MODULE].type == MODULE_TYPE_PPM) ||
|
||||
(idx == EXTERNAL_MODULE && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM);
|
||||
}
|
||||
#else
|
||||
inline bool isModulePPM(uint8_t idx)
|
||||
{
|
||||
return idx == TRAINER_MODULE ||
|
||||
isExtraModule(idx) ||
|
||||
return isExtraModule(idx) ||
|
||||
(idx == EXTERNAL_MODULE && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM);
|
||||
}
|
||||
#endif
|
||||
@@ -194,27 +192,12 @@ inline int8_t maxModuleChannels_M8(uint8_t idx)
|
||||
{
|
||||
if (isExtraModule(idx))
|
||||
return MAX_EXTRA_MODULE_CHANNELS_M8;
|
||||
else if (idx == TRAINER_MODULE)
|
||||
return MAX_TRAINER_CHANNELS_M8;
|
||||
else if (isModuleXJT(idx))
|
||||
return maxChannelsXJT[1 + g_model.moduleData[idx].rfProtocol];
|
||||
else
|
||||
return maxChannelsModules[g_model.moduleData[idx].type];
|
||||
}
|
||||
|
||||
inline int8_t maxModuleChannels(uint8_t idx)
|
||||
{
|
||||
return 8 + maxModuleChannels_M8(idx);
|
||||
}
|
||||
|
||||
inline int8_t minModuleChannels(uint8_t idx)
|
||||
{
|
||||
if (isModuleCrossfire(idx))
|
||||
return 16;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int8_t defaultModuleChannels_M8(uint8_t idx)
|
||||
{
|
||||
if (isModulePPM(idx))
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "opentx.h"
|
||||
|
||||
template<class T>
|
||||
void setupPulsesPPM(uint8_t port, PpmPulsesData<T> * ppmPulsesData)
|
||||
void setupPulsesPPM(PpmPulsesData<T> * ppmPulsesData, uint8_t channelsStart, int8_t channelsCount, int8_t frameLength)
|
||||
{
|
||||
int16_t PPM_range = g_model.extendedLimits ? (512*LIMIT_EXT_PERCENT/100) * 2 : 512 * 2; // range of 0.7 .. 1.7msec
|
||||
|
||||
@@ -29,8 +29,8 @@ void setupPulsesPPM(uint8_t port, PpmPulsesData<T> * ppmPulsesData)
|
||||
// each pulse is 0.7..1.7ms long with a 0.3ms stop tail
|
||||
// The pulse ISR is 2mhz that's why everything is multiplied by 2
|
||||
|
||||
uint32_t firstCh = g_model.moduleData[port].channelsStart;
|
||||
uint32_t lastCh = min<unsigned int>(MAX_OUTPUT_CHANNELS, firstCh + 8 + g_model.moduleData[port].channelsCount);
|
||||
uint8_t firstCh = channelsStart;
|
||||
uint8_t lastCh = min<uint8_t>(MAX_OUTPUT_CHANNELS, firstCh + 8 + channelsCount);
|
||||
|
||||
#if defined(STM32)
|
||||
ppmPulsesData->ptr = ppmPulsesData->pulses;
|
||||
@@ -40,7 +40,7 @@ void setupPulsesPPM(uint8_t port, PpmPulsesData<T> * ppmPulsesData)
|
||||
#endif
|
||||
|
||||
int32_t rest = 22500u * 2;
|
||||
rest += (int32_t(g_model.moduleData[port].ppm.frameLength)) * 1000;
|
||||
rest += int32_t(frameLength) * 1000;
|
||||
for (uint32_t i=firstCh; i<lastCh; i++) {
|
||||
int16_t v = limit((int16_t)-PPM_range, channelOutputs[i], (int16_t)PPM_range) + 2*PPM_CH_CENTER(i);
|
||||
rest -= v;
|
||||
@@ -61,10 +61,10 @@ void setupPulsesPPM(uint8_t port, PpmPulsesData<T> * ppmPulsesData)
|
||||
|
||||
void setupPulsesPPMModule(uint8_t port)
|
||||
{
|
||||
setupPulsesPPM<pulse_duration_t>(port, &modulePulsesData[port].ppm);
|
||||
setupPulsesPPM<pulse_duration_t>(&modulePulsesData[port].ppm, g_model.moduleData[port].channelsStart, g_model.moduleData[port].channelsCount, g_model.moduleData[port].ppm.frameLength);
|
||||
}
|
||||
|
||||
void setupPulsesPPMTrainer()
|
||||
{
|
||||
setupPulsesPPM<trainer_pulse_duration_t>(TRAINER_MODULE, &trainerPulsesData.ppm);
|
||||
setupPulsesPPM<trainer_pulse_duration_t>(&trainerPulsesData.ppm, g_model.trainerData.channelsStart, g_model.trainerData.channelsCount, g_model.trainerData.frameLength);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,13 @@ class Pxx2Pulses: public PxxPulses<Pxx2Transport> {
|
||||
Pxx2Transport::addByteWithoutCrc(0x00);
|
||||
|
||||
// TYPE_C + TYPE_ID
|
||||
Pxx2Transport::addByte(0x26); // This one is CRC-ed on purpose
|
||||
// TODO optimization ? Pxx2Transport::addByte(0x26); // This one is CRC-ed on purpose
|
||||
}
|
||||
|
||||
void addFrameType(uint8_t type_c, uint8_t type_id)
|
||||
{
|
||||
Pxx2Transport::addByte(type_c);
|
||||
Pxx2Transport::addByte(type_id);
|
||||
}
|
||||
|
||||
void addCrc()
|
||||
|
||||
Reference in New Issue
Block a user