Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ajjjjjjjj committed Dec 8, 2024
2 parents 5627957 + f7e573f commit b434750
Show file tree
Hide file tree
Showing 19 changed files with 132 additions and 209 deletions.
9 changes: 0 additions & 9 deletions radio/src/datastructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -435,15 +435,6 @@ PACK(struct ModuleData {
uint8_t lowPowerMode : 1;
int8_t optionValue;
} multi);
NOBACKUP(struct {
uint8_t power : 2; // 0=10 mW, 1=100 mW, 2=500 mW, 3=1W
uint8_t spare1 : 2;
uint8_t receiver_telem_off : 1; // false = receiver telem enabled
uint8_t receiver_channel_9_16 : 1; // false = pwm out 1-8, true 9-16
uint8_t external_antenna : 1; // false = internal antenna, true = external antenna
uint8_t fast : 1; // TODO: to be used later by external module (fast means serial @ high speed)
uint8_t spare2;
} pxx);
NOBACKUP(struct {
uint8_t spare1 : 6;
uint8_t noninverted : 1;
Expand Down
4 changes: 4 additions & 0 deletions radio/src/gui/128x64/model_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ void editTimerCountdown(int timerIdx, coord_t y, LcdFlags attr, event_t event)
}
}

#if defined(PCBTARANIS)
void onBindMenu(const char * result)
{
uint8_t moduleIdx = CURRENT_MODULE_EDITED(menuVerticalPosition);
Expand All @@ -243,6 +244,7 @@ void onBindMenu(const char * result)

moduleState[moduleIdx].mode = MODULE_MODE_BIND;
}
#endif


void menuModelSetup(event_t event)
Expand Down Expand Up @@ -360,9 +362,11 @@ void menuModelSetup(event_t event)

TITLE(STR_MENUSETUP);

#if defined(PXX)
if (event == EVT_ENTRY) {
reusableBuffer.modelsetup.r9mPower = g_model.moduleData[EXTERNAL_MODULE].pxx.power;
}
#endif

uint8_t sub = menuVerticalPosition - HEADER_LINE;
int8_t editMode = s_editMode;
Expand Down
2 changes: 1 addition & 1 deletion radio/src/mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ getvalue_t getValue(mixsrc_t i)
}
#endif

#if defined(PCBGRUVIN9X) || defined(PCBMEGA2560) || defined(ROTARY_ENCODERS)
#if defined(ROTARY_ENCODERS)
else if (i <= MIXSRC_LAST_ROTARY_ENCODER) {
return getRotaryEncoder(i-MIXSRC_REa);
}
Expand Down
2 changes: 1 addition & 1 deletion radio/src/opentx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1734,7 +1734,7 @@ void opentxInit()
globalData.unexpectedShutdown = 1;
}

#if defined(SDCARD) && !defined(PCBMEGA2560)
#if defined(SDCARD)
// SDCARD related stuff, only done if not unexpectedShutdown
if (!globalData.unexpectedShutdown) {
sdInit();
Expand Down
10 changes: 5 additions & 5 deletions radio/src/pulses/crossfire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,24 @@ uint8_t createCrossfireChannelsFrame(uint8_t* frame, int16_t * pulses) {
}

void setupPulsesCrossfire() {
uint8_t* pulses = modulePulsesData[EXTERNAL_MODULE].crossfire.pulses;
uint8_t* pulses = extmodulePulsesData.crossfire.pulses;

if (outputTelemetryBufferSize > 0) {
memcpy(pulses, outputTelemetryBuffer, outputTelemetryBufferSize);
modulePulsesData[EXTERNAL_MODULE].crossfire.length = outputTelemetryBufferSize;
extmodulePulsesData.crossfire.length = outputTelemetryBufferSize;
outputTelemetryBufferSize = 0;
outputTelemetryBufferTrigger = 0;
} else {
if (moduleState[EXTERNAL_MODULE].counter == CRSF_FRAME_MODELID) {
modulePulsesData[EXTERNAL_MODULE].crossfire.length = createCrossfireModelIDFrame(pulses);
extmodulePulsesData.crossfire.length = createCrossfireModelIDFrame(pulses);
moduleState[EXTERNAL_MODULE].counter = CRSF_FRAME_MODELID_SENT;
} else if (moduleState[EXTERNAL_MODULE].counter == CRSF_FRAME_MODELID_SENT && crossfireModuleStatus.queryCompleted == false) {
modulePulsesData[EXTERNAL_MODULE].crossfire.length = createCrossfirePingFrame(pulses);
extmodulePulsesData.crossfire.length = createCrossfirePingFrame(pulses);
// } else if (moduleState[EXTERNAL_MODULE].mode == MODULE_MODE_BIND) {
// p_buf += createCrossfireBindFrame(p_buf);
// moduleState[module].mode = MODULE_MODE_NORMAL;
} else {
modulePulsesData[EXTERNAL_MODULE].crossfire.length = createCrossfireChannelsFrame(
extmodulePulsesData.crossfire.length = createCrossfireChannelsFrame(
pulses,
&channelOutputs[g_model.moduleData[EXTERNAL_MODULE].channelsStart]);
}
Expand Down
34 changes: 17 additions & 17 deletions radio/src/pulses/dsm2_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
#if defined(PPM_PIN_SERIAL)
void putDsm2SerialBit(uint8_t bit)
{
modulePulsesData[EXTERNAL_MODULE].dsm2.serialByte >>= 1;
extmodulePulsesData.dsm2.serialByte >>= 1;
if (bit & 1) {
modulePulsesData[EXTERNAL_MODULE].dsm2.serialByte |= 0x80;
extmodulePulsesData.dsm2.serialByte |= 0x80;
}
if (++modulePulsesData[EXTERNAL_MODULE].dsm2.serialBitCount >= 8) {
*modulePulsesData[EXTERNAL_MODULE].dsm2.ptr++ = modulePulsesData[EXTERNAL_MODULE].dsm2.serialByte;
modulePulsesData[EXTERNAL_MODULE].dsm2.serialBitCount = 0;
if (++extmodulePulsesData.dsm2.serialBitCount >= 8) {
*extmodulePulsesData.dsm2.ptr++ = extmodulePulsesData.dsm2.serialByte;
extmodulePulsesData.dsm2.serialBitCount = 0;
}
}

Expand All @@ -65,14 +65,14 @@ void putDsm2Flush()
#else
void _send_1(uint8_t v)
{
if (modulePulsesData[EXTERNAL_MODULE].dsm2.index & 1)
if (extmodulePulsesData.dsm2.index & 1)
v += 2;
else
v -= 2;

*modulePulsesData[EXTERNAL_MODULE].dsm2.ptr++ = v - 1;
modulePulsesData[EXTERNAL_MODULE].dsm2.index += 1;
modulePulsesData[EXTERNAL_MODULE].dsm2.rest -= v;
*extmodulePulsesData.dsm2.ptr++ = v - 1;
extmodulePulsesData.dsm2.index += 1;
extmodulePulsesData.dsm2.rest -= v;
}

void sendByteDsm2(uint8_t b) // max 10 changes 0 10 10 10 10 1
Expand All @@ -96,10 +96,10 @@ void sendByteDsm2(uint8_t b) // max 10 changes 0 10 10 10 10 1

void putDsm2Flush()
{
if (modulePulsesData[EXTERNAL_MODULE].dsm2.index & 1)
*modulePulsesData[EXTERNAL_MODULE].dsm2.ptr++ = modulePulsesData[EXTERNAL_MODULE].dsm2.rest;
if (extmodulePulsesData.dsm2.index & 1)
*extmodulePulsesData.dsm2.ptr++ = extmodulePulsesData.dsm2.rest;
else
*(modulePulsesData[EXTERNAL_MODULE].dsm2.ptr - 1) = modulePulsesData[EXTERNAL_MODULE].dsm2.rest;
*(extmodulePulsesData.dsm2.ptr - 1) = extmodulePulsesData.dsm2.rest;
}
#endif

Expand All @@ -111,14 +111,14 @@ void setupPulsesDSM2(uint8_t port)
uint8_t dsmDat[14];

#if defined(PPM_PIN_SERIAL)
modulePulsesData[EXTERNAL_MODULE].dsm2.serialByte = 0 ;
modulePulsesData[EXTERNAL_MODULE].dsm2.serialBitCount = 0 ;
extmodulePulsesData.dsm2.serialByte = 0 ;
extmodulePulsesData.dsm2.serialBitCount = 0 ;
#else
modulePulsesData[EXTERNAL_MODULE].dsm2.index = 0;
modulePulsesData[EXTERNAL_MODULE].dsm2.rest = DSM2_PERIOD * 2000;
extmodulePulsesData.dsm2.index = 0;
extmodulePulsesData.dsm2.rest = DSM2_PERIOD * 2000;
#endif

modulePulsesData[EXTERNAL_MODULE].dsm2.ptr = modulePulsesData[EXTERNAL_MODULE].dsm2.pulses;
extmodulePulsesData.dsm2.ptr = extmodulePulsesData.dsm2.pulses;

switch (moduleState[port].protocol) {
case PROTO_DSM2_LP45:
Expand Down
10 changes: 5 additions & 5 deletions radio/src/pulses/multi_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ void setupPulsesMultimodule(uint8_t port)
static int counter = 0;

#if defined(PPM_PIN_SERIAL)
modulePulsesData[EXTERNAL_MODULE].dsm2.serialByte = 0 ;
modulePulsesData[EXTERNAL_MODULE].dsm2.serialBitCount = 0 ;
extmodulePulsesData.dsm2.serialByte = 0 ;
extmodulePulsesData.dsm2.serialBitCount = 0 ;
#else
modulePulsesData[EXTERNAL_MODULE].dsm2.rest = multiSyncStatus.getAdjustedRefreshRate();
modulePulsesData[EXTERNAL_MODULE].dsm2.index = 0;
extmodulePulsesData.dsm2.rest = multiSyncStatus.getAdjustedRefreshRate();
extmodulePulsesData.dsm2.index = 0;
#endif

modulePulsesData[EXTERNAL_MODULE].dsm2.ptr = modulePulsesData[EXTERNAL_MODULE].dsm2.pulses;
extmodulePulsesData.dsm2.ptr = extmodulePulsesData.dsm2.pulses;

// Every 1000 cycles (=9s) send a config packet that configures the multimodule (inversion, telemetry type)
counter++;
Expand Down
23 changes: 15 additions & 8 deletions radio/src/pulses/ppm_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
// range of 0.7 .. 1.7msec
int16_t PPM_range = g_model.extendedLimits ? (512*LIMIT_EXT_PERCENT/100) * 2 : 512 * 2;
Expand All @@ -30,8 +30,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;
Expand All @@ -41,7 +41,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;
Expand All @@ -62,12 +62,19 @@ void setupPulsesPPM(uint8_t port, PpmPulsesData<T> * ppmPulsesData)
//TRACE("ppmPulsesData: %p",(void*)&ppmPulsesData);
}

void setupPulsesPPMModule(uint8_t port)
void setupPulsesPPMTrainer()
{
setupPulsesPPM<pulse_duration_t>(port, &modulePulsesData[port].ppm);
setupPulsesPPM<trainer_pulse_duration_t>(&trainerPulsesData.ppm, g_model.moduleData[TRAINER_MODULE].channelsStart, g_model.moduleData[TRAINER_MODULE].channelsCount, g_model.moduleData[TRAINER_MODULE].ppm.frameLength);
}

void setupPulsesPPMTrainer()
#if defined(TARANIS_INTERNAL_PPM)
void setupPulsesPPMInternalModule()
{
setupPulsesPPM<trainer_pulse_duration_t>(TRAINER_MODULE, &trainerPulsesData.ppm);
setupPulsesPPM(&intmodulePulsesData.ppm, g_model.moduleData[INTERNAL_MODULE].channelsStart, g_model.moduleData[INTERNAL_MODULE].channelsCount, g_model.moduleData[INTERNAL_MODULE].ppm.frameLength);
}
#endif

void setupPulsesPPMExternalModule()
{
setupPulsesPPM(&extmodulePulsesData.ppm, g_model.moduleData[EXTERNAL_MODULE].channelsStart, g_model.moduleData[EXTERNAL_MODULE].channelsCount, g_model.moduleData[EXTERNAL_MODULE].ppm.frameLength);
}
Loading

0 comments on commit b434750

Please sign in to comment.