Skip to content

Commit

Permalink
Fixed text display while writing codeplug. (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmatuschek authored Dec 28, 2024
1 parent 95d4932 commit 3c7c673
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
33 changes: 17 additions & 16 deletions lib/opengd77_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ OpenGD77Interface::CommandRequest::initShowCPSScreen() {
this->command = SHOW_CPS_SCREEN;
this->x = 0;
this->y = 0;
this->size = 0;
this->font = 0;
this->alignment = 0;
this->inverted = 0;
memset(this->message, 0, sizeof(this->message));
Expand All @@ -107,24 +107,25 @@ OpenGD77Interface::CommandRequest::initClearScreen() {
this->command = CLEAR_SCREEN;
this->x = 0;
this->y = 0;
this->size = 0;
this->font = 0;
this->alignment = 0;
this->inverted = 0;
memset(this->message, 0, sizeof(this->message));
}

void
OpenGD77Interface::CommandRequest::initDisplay(uint8_t x, uint8_t y,
const char *message, uint8_t iSize,
uint8_t alignment, uint8_t inverted) {
const char *message, unsigned int iSize,
uint8_t font, uint8_t alignment, uint8_t inverted) {
this->type = 'C';
this->command = DISPLAY;
this->x = x;
this->y = y;
this->size = std::min(iSize, uint8_t(16));
this->font = font;
this->alignment = alignment;
this->inverted = inverted;
strncpy(this->message, message, this->size);
memset(this->message, 0, 16);
strncpy(this->message, message, std::min(16u, iSize));
}

void
Expand All @@ -133,7 +134,7 @@ OpenGD77Interface::CommandRequest::initRenderCPS() {
this->command = RENDER_CPS;
this->x = 0;
this->y = 0;
this->size = 0;
this->font = 0;
this->alignment = 0;
this->inverted = 0;
memset(this->message, 0, sizeof(this->message));
Expand All @@ -145,7 +146,7 @@ OpenGD77Interface::CommandRequest::initCloseScreen() {
this->command = CLOSE_CPS_SCREEN;
this->x = 0;
this->y = 0;
this->size = 0;
this->font = 0;
this->alignment = 0;
this->inverted = 0;
memset(this->message, 0, sizeof(this->message));
Expand All @@ -157,7 +158,7 @@ OpenGD77Interface::CommandRequest::initCommand(Option option) {
this->command = COMMAND;
this->option = option;
this->y = 0;
this->size = 0;
this->font = 0;
this->alignment = 0;
this->inverted = 0;
memset(this->message, 0, sizeof(this->message));
Expand Down Expand Up @@ -246,11 +247,11 @@ OpenGD77Interface::write_start(uint32_t bank, uint32_t addr, const ErrorStack &e
if (! sendClearScreen(err))
return false;
//logDebug() << "Send display text ...";
if (! sendDisplay(0, 0, "qDMR", 3, 1, 0, err))
if (! sendDisplay(0, 0, "qDMR", 4, 1, 0, err))
return false;
if (! sendDisplay(0, 16, "Writing", 3, 1, 0, err))
if (! sendDisplay(0, 16, "Writing", 7, 1, 0, err))
return false;
if (! sendDisplay(0, 32, "Codeplug", 3, 1, 0, err))
if (! sendDisplay(0, 32, "Codeplug", 8, 1, 0, err))
return false;
//logDebug() << "Send 'render CPS' ...";
if (! sendRenderCPS(err))
Expand Down Expand Up @@ -341,11 +342,11 @@ OpenGD77Interface::read_start(uint32_t bank, uint32_t addr, const ErrorStack &er
return false;
if (! sendClearScreen(err))
return false;
if (! sendDisplay(0, 0, "qDMR", 3, 1, 0, err))
if (! sendDisplay(0, 0, "qDMR", 4, 1, 0, err))
return false;
if (! sendDisplay(0, 16, "Reading", 3, 1, 0, err))
if (! sendDisplay(0, 16, "Reading", 7, 1, 0, err))
return false;
if (! sendDisplay(0, 32, "Codeplug", 3, 1, 0, err))
if (! sendDisplay(0, 32, "Codeplug", 8, 1, 0, err))
return false;
if (! sendRenderCPS(err))
return false;
Expand Down Expand Up @@ -741,7 +742,7 @@ OpenGD77Interface::sendClearScreen(const ErrorStack &err) {
bool
OpenGD77Interface::sendDisplay(uint8_t x, uint8_t y, const char *message, uint8_t iSize, uint8_t alignment, uint8_t inverted, const ErrorStack &err) {
CommandRequest req;
req.initDisplay(x,y, message, iSize, alignment, inverted);
req.initDisplay(x,y, message, iSize, 3, alignment, inverted);
uint8_t resp;

if (sizeof(CommandRequest) != QSerialPort::write((const char *) &req, sizeof(CommandRequest))) {
Expand Down
7 changes: 4 additions & 3 deletions lib/opengd77_interface.hh
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ protected:
};
/** The y-position on the screen. */
uint8_t y;
/** The size. */
uint8_t size;
/** The font size. */
uint8_t font;
/** The text alignment. */
uint8_t alignment;
/** Is text inverted? */
Expand All @@ -350,7 +350,8 @@ protected:
/** Construct a clear-screen command message. */
void initClearScreen();
/** Construct a "show text on screen" message. */
void initDisplay(uint8_t x, uint8_t y, const char *message, uint8_t iSize, uint8_t alignment, uint8_t inverted);
void initDisplay(uint8_t x, uint8_t y, const char *message, unsigned int iSize,
uint8_t font, uint8_t alignment, uint8_t inverted);
/** Construct a "render CPS" message. */
void initRenderCPS();
/** Construct a "close screen" command message. */
Expand Down

0 comments on commit 3c7c673

Please sign in to comment.