Skip to content

Commit

Permalink
[EPD] TEXT screen adjustment for 2:1 aspect ratio [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed Jul 26, 2024
1 parent 42240af commit 3ace05d
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 6 deletions.
27 changes: 21 additions & 6 deletions software/firmware/source/SoftRF/src/driver/EPD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,25 +748,40 @@ void EPD_Message(const char *msg1, const char *msg2)

display->fillScreen(GxEPD_WHITE);

uint16_t display_width = display->width();
uint16_t display_height = display->height();
int16_t dy = 0;

#if defined(EPD_ASPECT_RATIO_2C1)

if (display->epd2.panel == GxEPD2::DEPG0213BN) {
if (display_width == 128) display_width = 122;
if (display_height == 128) {
display_height = 122;
if (display->getRotation() == ROTATE_90 ) { dy = 6; }
}
}
#endif /* EPD_ASPECT_RATIO_2C1 */

if (msg2 == NULL) {

display->getTextBounds(msg1, 0, 0, &tbx, &tby, &tbw, &tbh);
x = (display->width() - tbw) / 2;
y = (display->height() + tbh) / 2;
x = (display_width - tbw) / 2;
y = (display_height + tbh) / 2 + dy;
display->setCursor(x, y);
display->print(msg1);

} else {

display->getTextBounds(msg1, 0, 0, &tbx, &tby, &tbw, &tbh);
x = (display->width() - tbw) / 2;
y = display->height() / 2 - tbh;
x = (display_width - tbw) / 2;
y = display_height / 2 - tbh + dy;
display->setCursor(x, y);
display->print(msg1);

display->getTextBounds(msg2, 0, 0, &tbx, &tby, &tbw, &tbh);
x = (display->width() - tbw) / 2;
y = display->height() / 2 + tbh;
x = (display_width - tbw) / 2;
y = display_height / 2 + tbh + dy;
display->setCursor(x, y);
display->print(msg2);
}
Expand Down
52 changes: 52 additions & 0 deletions software/firmware/source/SoftRF/src/ui/Text_EPD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ static void EPD_Draw_Text()
display->setFont(&FreeMonoBold12pt7b);

{
#if defined(EPD_ASPECT_RATIO_1C1)
uint16_t x = 20;
#endif /* EPD_ASPECT_RATIO_1C1 */
#if defined(EPD_ASPECT_RATIO_2C1)
uint16_t x = 50;
#endif /* EPD_ASPECT_RATIO_2C1 */
uint16_t y = 0;

int16_t tbx, tby;
Expand All @@ -168,11 +173,25 @@ static void EPD_Draw_Text()
snprintf(info_line, sizeof(info_line), "Traffic %d/%d", EPD_current, j);
display->getTextBounds(info_line, 0, 0, &tbx, &tby, &tbw, &tbh);
y += tbh;

#if defined(EPD_ASPECT_RATIO_2C1)
if (display->epd2.panel == GxEPD2::DEPG0213BN) {
if (display->height() == 128) {
if (display->getRotation() == ROTATE_270 ) { y -= 6; }
}
}
#endif /* EPD_ASPECT_RATIO_2C1 */

display->setCursor(x, y);
display->print(info_line);
// Serial.println(info_line);

#if defined(EPD_ASPECT_RATIO_1C1)
y += TEXT_VIEW_LINE_SPACING;
#endif /* EPD_ASPECT_RATIO_1C1 */
#if defined(EPD_ASPECT_RATIO_2C1)
y += 5;
#endif /* EPD_ASPECT_RATIO_2C1 */

if (oclock == 0) {
strcpy(info_line, " ahead");
Expand All @@ -185,7 +204,12 @@ static void EPD_Draw_Text()
display->print(info_line);
// Serial.println(info_line);

#if defined(EPD_ASPECT_RATIO_1C1)
y += TEXT_VIEW_LINE_SPACING;
#endif /* EPD_ASPECT_RATIO_1C1 */
#if defined(EPD_ASPECT_RATIO_2C1)
y += 5;
#endif /* EPD_ASPECT_RATIO_2C1 */

snprintf(info_line, sizeof(info_line), "%4.1f %s out", disp_dist, u_dist);
display->getTextBounds(info_line, 0, 0, &tbx, &tby, &tbw, &tbh);
Expand All @@ -194,7 +218,12 @@ static void EPD_Draw_Text()
display->print(info_line);
// Serial.println(info_line);

#if defined(EPD_ASPECT_RATIO_1C1)
y += TEXT_VIEW_LINE_SPACING;
#endif /* EPD_ASPECT_RATIO_1C1 */
#if defined(EPD_ASPECT_RATIO_2C1)
y += 5;
#endif /* EPD_ASPECT_RATIO_2C1 */

snprintf(info_line, sizeof(info_line), "%4d %s ", disp_alt, u_alt);

Expand All @@ -212,8 +241,14 @@ static void EPD_Draw_Text()
display->print(info_line);
// Serial.println(info_line);

#if defined(EPD_ASPECT_RATIO_1C1)
y += TEXT_VIEW_LINE_SPACING;
#endif /* EPD_ASPECT_RATIO_1C1 */
#if defined(EPD_ASPECT_RATIO_2C1)
y += 5;
#endif /* EPD_ASPECT_RATIO_2C1 */

#if defined(EPD_ASPECT_RATIO_1C1)
snprintf(info_line, sizeof(info_line), "CoG %3d deg",
(int) traffic_by_dist[EPD_current - 1].fop->course);
display->getTextBounds(info_line, 0, 0, &tbx, &tby, &tbw, &tbh);
Expand All @@ -230,8 +265,25 @@ static void EPD_Draw_Text()
display->setCursor(x, y);
display->print(info_line);
// Serial.println(info_line);
#endif /* EPD_ASPECT_RATIO_1C1 */
#if defined(EPD_ASPECT_RATIO_2C1)
char tmp_buf[20];

snprintf(tmp_buf, sizeof(tmp_buf), "CoG %3d GS %3d %s",
(int) traffic_by_dist[EPD_current - 1].fop->course,
disp_spd, u_spd);
display->getTextBounds(tmp_buf, 0, 0, &tbx, &tby, &tbw, &tbh);
y += tbh;
display->setCursor(0, y);
display->print(tmp_buf);
#endif /* EPD_ASPECT_RATIO_2C1 */

#if defined(EPD_ASPECT_RATIO_1C1)
y += TEXT_VIEW_LINE_SPACING;
#endif /* EPD_ASPECT_RATIO_1C1 */
#if defined(EPD_ASPECT_RATIO_2C1)
y += 5;
#endif /* EPD_ASPECT_RATIO_2C1 */

display->getTextBounds(id_text, 0, 0, &tbx, &tby, &tbw, &tbh);
y += tbh;
Expand Down

0 comments on commit 3ace05d

Please sign in to comment.