Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor SRXL telemetry Textgen and CMS displayport. #122

Merged
merged 1 commit into from
Jun 27, 2024
Merged
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
8 changes: 4 additions & 4 deletions src/main/io/displayport_srxl.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ static int srxlWriteString(displayPort_t *displayPort, uint8_t col, uint8_t row,
static int srxlClearScreen(displayPort_t *displayPort, displayClearOption_e options)
{
UNUSED(options);
for (int row = 0; row < SPEKTRUM_SRXL_TEXTGEN_BUFFER_ROWS; row++) {
for (int col= 0; col < SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS; col++) {
for (int row = 0; row < SPEKTRUM_SRXL_TEXTGEN_ROWS; row++) {
for (int col= 0; col < SPEKTRUM_SRXL_TEXTGEN_COLS; col++) {
srxlWriteChar(displayPort, col, row, DISPLAYPORT_ATTR_NONE, ' ');
}
}
Expand Down Expand Up @@ -147,8 +147,8 @@ static displayPort_t *displayPortSrxlInit()
{
srxlDisplayPort.device = NULL;
displayInit(&srxlDisplayPort, &srxlVTable, DISPLAYPORT_DEVICE_TYPE_SRXL);
srxlDisplayPort.rows = SPEKTRUM_SRXL_TEXTGEN_BUFFER_ROWS;
srxlDisplayPort.cols = SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS;
srxlDisplayPort.rows = SPEKTRUM_SRXL_TEXTGEN_ROWS;
srxlDisplayPort.cols = SPEKTRUM_SRXL_TEXTGEN_COLS;

return &srxlDisplayPort;
}
Expand Down
21 changes: 7 additions & 14 deletions src/main/telemetry/srxl.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,6 @@ bool srxlFrameFlightPackCurrent(sbuf_t *dst, timeUs_t currentTimeUs)
// Betaflight CMS using Spektrum Tx telemetry TEXT_GEN sensor as display.

#define SPEKTRUM_SRXL_DEVICE_TEXTGEN (0x0C) // Text Generator
#define SPEKTRUM_SRXL_DEVICE_TEXTGEN_ROWS (9) // Text Generator ROWS
#define SPEKTRUM_SRXL_DEVICE_TEXTGEN_COLS (13) // Text Generator COLS

/*
typedef struct
Expand All @@ -473,19 +471,14 @@ typedef struct
} STRU_SPEKTRUM_SRXL_TEXTGEN;
*/

#if ( SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS > SPEKTRUM_SRXL_DEVICE_TEXTGEN_COLS )
static char srxlTextBuff[SPEKTRUM_SRXL_TEXTGEN_BUFFER_ROWS][SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS];
static bool lineSent[SPEKTRUM_SRXL_TEXTGEN_BUFFER_ROWS];
#else
static char srxlTextBuff[SPEKTRUM_SRXL_DEVICE_TEXTGEN_ROWS][SPEKTRUM_SRXL_DEVICE_TEXTGEN_COLS];
static bool lineSent[SPEKTRUM_SRXL_DEVICE_TEXTGEN_ROWS];
#endif
static char srxlTextBuff[SPEKTRUM_SRXL_TEXTGEN_ROWS][SPEKTRUM_SRXL_TEXTGEN_COLS];
static bool lineSent[SPEKTRUM_SRXL_TEXTGEN_ROWS];

//**************************************************************************
// API Running in external client task context. E.g. in the CMS task
int spektrumTmTextGenPutChar(uint8_t col, uint8_t row, char c)
{
if (row < SPEKTRUM_SRXL_TEXTGEN_BUFFER_ROWS && col < SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS) {
if (row < SPEKTRUM_SRXL_TEXTGEN_ROWS && col < SPEKTRUM_SRXL_TEXTGEN_COLS) {
// Only update and force a tm transmision if something has actually changed.
if (srxlTextBuff[row][col] != c) {
srxlTextBuff[row][col] = c;
Expand All @@ -508,18 +501,18 @@ bool srxlFrameText(sbuf_t *dst, timeUs_t currentTimeUs)

// Skip already sent lines...
while (lineSent[lineNo] &&
lineCount < SPEKTRUM_SRXL_DEVICE_TEXTGEN_ROWS) {
lineNo = (lineNo + 1) % SPEKTRUM_SRXL_DEVICE_TEXTGEN_ROWS;
lineCount < SPEKTRUM_SRXL_TEXTGEN_ROWS) {
lineNo = (lineNo + 1) % SPEKTRUM_SRXL_TEXTGEN_ROWS;
lineCount++;
}

sbufWriteU8(dst, SPEKTRUM_SRXL_DEVICE_TEXTGEN);
sbufWriteU8(dst, SRXL_FRAMETYPE_SID);
sbufWriteU8(dst, lineNo);
sbufWriteData(dst, srxlTextBuff[lineNo], SPEKTRUM_SRXL_DEVICE_TEXTGEN_COLS);
sbufWriteData(dst, srxlTextBuff[lineNo], SPEKTRUM_SRXL_TEXTGEN_COLS);

lineSent[lineNo] = true;
lineNo = (lineNo + 1) % SPEKTRUM_SRXL_DEVICE_TEXTGEN_ROWS;
lineNo = (lineNo + 1) % SPEKTRUM_SRXL_TEXTGEN_ROWS;

return true;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/telemetry/srxl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ void initSrxlTelemetry(void);
bool checkSrxlTelemetryState(void);
void handleSrxlTelemetry(timeUs_t currentTimeUs);

#define SPEKTRUM_SRXL_TEXTGEN_BUFFER_ROWS 9
#define SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS 12 // Airware 1.20
//#define SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS 13 // Airware 1.21
#define SPEKTRUM_SRXL_TEXTGEN_ROWS 9
//#define SPEKTRUM_SRXL_TEXTGEN_COLS 12 // Airware 1.20
#define SPEKTRUM_SRXL_TEXTGEN_COLS 13 // Airware 1.21
#define SPEKTRUM_SRXL_TEXTGEN_CLEAR_SCREEN 255

int spektrumTmTextGenPutChar(uint8_t col, uint8_t row, char c);