Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions radio/src/gui/gui_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -973,12 +973,13 @@ bool isExternalModuleAvailable(int moduleType)
return false;
#endif

#if !defined(HARDWARE_EXTERNAL_MODULE_SIZE_STD)
#if !defined(HARDWARE_EXTERNAL_MODULE_SIZE_STD) // Ignore Standard Size modules
if (moduleType == MODULE_TYPE_R9M_PXX1 ||
moduleType == MODULE_TYPE_R9M_PXX2 ||
moduleType == MODULE_TYPE_XJT_PXX1 ||
moduleType == MODULE_TYPE_DSM2 ||
moduleType == MODULE_TYPE_LEMON_DSMP )
moduleType == MODULE_TYPE_DSM2 // ||
//moduleType == MODULE_TYPE_LEMON_DSMP /* Lemon DSMP now has small/lite size too */
)
return false;
#endif

Expand Down Expand Up @@ -1015,6 +1016,10 @@ bool isExternalModuleAvailable(int moduleType)
return false;
#endif

#if !defined(DSMP)
if (moduleType == MODULE_TYPE_DSMP) return false;
#endif

#if !defined(SBUS)
if (moduleType == MODULE_TYPE_SBUS)
return false;
Expand Down
71 changes: 50 additions & 21 deletions radio/src/pulses/dsmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "edgetx.h"
#include "telemetry/spektrum.h"

#define DSMP_SEND_X_PLUS 0
#define DSMP_SEND_X_PLUS 1

#define DSMP_BITRATE 115200

Expand Down Expand Up @@ -63,6 +63,8 @@ static uint8_t AETR_TAER_MAP[] = {2, 0, 1};

static DSMPModuleStatus dsmpStatus = DSMPModuleStatus();



// Power cycle of the DSMP module
// The DSMP module code has the channel data initialized to 0 and initial number of bits as 10b (ch resolution 1024)
// The Setup message pass the last BIND configuration to the Module via the setup package (for example, 2048 it was bound to DSMX).
Expand Down Expand Up @@ -356,11 +358,19 @@ static void processDSMPBindPacket(uint8_t module, uint8_t* packet)

static void processDSMPManufacturerData(uint8_t module, uint8_t* packet)
{
// Format M,M,M,M, V, V where M is 4 byte manufacturer data, and V is 2 byte
// Format M,M,M,M, V, V, yy,yy, mm, dd, rel
// where M is 4 byte manufacturer data, and V is 2 byte

dsmpStatus.version[0] = packet[4]; // Major
dsmpStatus.version[1] = packet[5]; // Minor
dsmpStatus.fm_year = (packet[6] << 8) | packet[7]; // FM Year
dsmpStatus.fm_mm = packet[8]; // FM Month
dsmpStatus.fm_dd = packet[9]; // FM Day
dsmpStatus.fm_rev = packet[10]; // FM Rev

TRACE("LemonDSMP: Ver [%d.%d]", dsmpStatus.version[0], dsmpStatus.version[1]);
TRACE("LemonDSMP: FW [%d-%d-%d.%d]",
dsmpStatus.fm_year, dsmpStatus.fm_mm, dsmpStatus.fm_dd, dsmpStatus.fm_rev);

if (dsmpStatus.version[0] > 1 && mixerSchedulerGetPeriod(module) != SCHEDULER_PERIOD_V2) {
// V2 suppors 11ms
Expand Down Expand Up @@ -448,8 +458,9 @@ static void dsmpProcessData(void* ctx, uint8_t data, uint8_t* buffer,
}

if (rxBufferCount < TELEMETRY_RX_PACKET_SIZE) {

#if 0
TRACE("[DSMP] Data 0x%02X, len = %d", data, rxBufferCount);
#endif
buffer[rxBufferCount++] = data; // Keep building message
} else {
TRACE("[DSMP] array size %d error", rxBufferCount);
Expand All @@ -465,23 +476,48 @@ static void dsmpProcessData(void* ctx, uint8_t data, uint8_t* buffer,

void DSMPModuleStatus::getStatusString(char* statusText) const
{
if (!isValid()) {
strcpy(statusText, STR_MODULE_NO_TELEMETRY);
return;
}
if (!isValid()) {
strcpy(statusText, STR_MODULE_NO_TELEMETRY);
return;
}

const auto& md = g_model.moduleData[EXTERNAL_MODULE];
auto channels = md.getChannelsCount();
const auto& md = g_model.moduleData[EXTERNAL_MODULE];
auto channels = md.getChannelsCount();

char* tmp = statusText;

char* tmp = statusText;
*tmp = 0;

// Version
*tmp = 0;
tmp = strAppend(tmp, "v", 1);
const char* mode;

// Protocol Used
mode = (flags & DSMP_FLAGS_DSMX) ? "X" : "2"; // DSMX or DSM2
tmp = strAppend(tmp, mode, strlen(mode));
mode =
(flags & DSMP_FLAGS_11mS) ? "_2F" : "_1F"; // 1 or 2 Frames (11ms/22ms)
tmp = strAppend(tmp, mode, strlen(mode));

// Version
tmp = strAppend(tmp, " v", 2);
if (dsmpStatus.fm_year > 0) {
// Firmware Build Date (Compact, ex:251012.1)
tmp = strAppendUnsigned(tmp, dsmpStatus.fm_year % 100);
tmp = strAppendUnsigned(tmp, dsmpStatus.fm_mm / 10);
tmp = strAppendUnsigned(tmp, dsmpStatus.fm_mm % 10);
tmp = strAppendUnsigned(tmp, dsmpStatus.fm_dd / 10);
tmp = strAppendUnsigned(tmp, dsmpStatus.fm_dd % 10);
tmp = strAppend(tmp, ".", 1);
tmp = strAppendUnsigned(tmp, dsmpStatus.fm_rev);
} else {
// Simple version format
tmp = strAppendUnsigned(tmp, dsmpStatus.version[0]);
tmp = strAppend(tmp, ".", 1);
tmp = strAppendUnsigned(tmp, dsmpStatus.version[1]);
}

#if 0
// Already displayin the TAER checkbox, so probably not needed
// Channel Order
char b[] = "? ";
if (ch_order != 0xFF) { // Same encoding as MultiModule
uint8_t temp = ch_order;
Expand All @@ -496,14 +532,7 @@ void DSMPModuleStatus::getStatusString(char* statusText) const

tmp = strAppend(tmp, " ", 1);
tmp = strAppend(tmp, b, strlen(b));

const char* mode;

mode = (flags & DSMP_FLAGS_DSMX) ? " X" : " 2"; // DSMX or DSM2
tmp = strAppend(tmp, mode, strlen(mode));

mode = (flags & DSMP_FLAGS_11mS) ? "_2F" : "_1F"; // 1 or 2 Frames (11ms/22ms)
tmp = strAppend(tmp, mode, strlen(mode));
#endif

#if 0
// Good for Debugging, but not much for regular users
Expand Down
4 changes: 4 additions & 0 deletions radio/src/pulses/dsmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ struct DSMPModuleStatus {
tmr10ms_t lastUpdate;
uint8_t ch_order = 0xFF;
uint8_t flags = 0;
uint16_t fm_year = 0;
uint8_t fm_mm = 0;
uint8_t fm_dd = 0;
uint8_t fm_rev = 0;

inline bool isValid() const { return (bool)(get_tmr10ms() - lastUpdate < 500);}
void getStatusString(char *statusText) const;
Expand Down
2 changes: 1 addition & 1 deletion radio/src/pulses/modules_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int8_t maxModuleChannels_M8(uint8_t moduleIdx)
} else if (isModuleMultimoduleDSM2(moduleIdx)) {
return 4; // 12 channels
} else if (isModuleDSMP(moduleIdx)) {
return 4; // 12 channels
return 8; // 16 channels supported for V2
} else {
return maxChannelsModules_M8[g_model.moduleData[moduleIdx].type];
}
Expand Down
4 changes: 3 additions & 1 deletion radio/src/pulses/modules_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,9 @@ inline int8_t minModuleChannels(uint8_t idx)
inline int8_t defaultModuleChannels_M8(uint8_t idx)
{
if (isModulePPM(idx))
return 0; // 8 channels
return 0; // 8 channels
else if (isModuleDSMP(idx))
return 4; // 12 channels
else
return maxModuleChannels_M8(idx);
}
Expand Down
Loading