Skip to content

Commit

Permalink
[EPD] boot splash and status screens adjustment for 2:1 aspect ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed Jul 19, 2024
1 parent 3f9e0cf commit 2a76b88
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 32 deletions.
47 changes: 41 additions & 6 deletions software/firmware/source/SoftRF/src/driver/EPD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,32 @@ bool EPD_setup(bool splash_screen)

display->init( /* 38400 */ );

display->setRotation((3 + ui->rotate) & 0x3); /* 270 deg. is default angle */
display->setRotation((ROTATE_270 + ui->rotate) & 0x3); /* 270 deg. is default angle */

display->setTextColor(GxEPD_BLACK);
display->setTextWrap(false);

display->setFont(&FreeMonoBold24pt7b);
display->getTextBounds(EPD_SoftRF_text1, 0, 0, &tbx1, &tby1, &tbw1, &tbh1);
display->getTextBounds(EPD_SoftRF_text3, 0, 0, &tbx3, &tby3, &tbw3, &tbh3);

display->setFullWindow();

display->fillScreen(GxEPD_WHITE);

#if defined(EPD_ASPECT_RATIO_1C1) || defined(EPD_ASPECT_RATIO_2C1)
#if defined(EPD_ASPECT_RATIO_1C1)
display->setFont(&FreeMonoBold24pt7b);
#elif defined(EPD_ASPECT_RATIO_2C1)
display->setFont(&FreeMonoBold18pt7b);
#endif
display->getTextBounds(EPD_SoftRF_text1, 0, 0, &tbx1, &tby1, &tbw1, &tbh1);
display->getTextBounds(EPD_SoftRF_text3, 0, 0, &tbx3, &tby3, &tbw3, &tbh3);

if (hw_info.model == SOFTRF_MODEL_BADGE ||
hw_info.model == SOFTRF_MODEL_INK) {

x = (display->width() - tbw1) / 2;
y = (display->height() + tbh1) / 2 - tbh3;
#if defined(EPD_ASPECT_RATIO_2C1)
y -= 10;
#endif /* EPD_ASPECT_RATIO_2C1 */
display->setCursor(x, y);
display->print(EPD_SoftRF_text1);

Expand All @@ -106,13 +115,23 @@ bool EPD_setup(bool splash_screen)

x = (display->width() - tbw2) / 2;
y = (display->height() + tbh2) / 2;
#if defined(EPD_ASPECT_RATIO_2C1)
y -= 10;
#endif /* EPD_ASPECT_RATIO_2C1 */
display->setCursor(x, y);
display->print(EPD_SoftRF_text2);

#if defined(EPD_ASPECT_RATIO_1C1)
display->setFont(&FreeMonoBold24pt7b);
#elif defined(EPD_ASPECT_RATIO_2C1)
display->setFont(&FreeMonoBold18pt7b);
#endif

x = (display->width() - tbw3) / 2;
y = (display->height() + tbh3) / 2 + tbh3;
#if defined(EPD_ASPECT_RATIO_2C1)
y -= 10;
#endif /* EPD_ASPECT_RATIO_2C1 */
display->setCursor(x, y);
display->print(EPD_SoftRF_text3);

Expand All @@ -125,6 +144,13 @@ bool EPD_setup(bool splash_screen)
display->getTextBounds(buf, 0, 0, &tbx4, &tby4, &tbw4, &tbh4);
x = (display->width() - tbw4) / 2;
y = display->height() - tbh4;
#if defined(EPD_ASPECT_RATIO_2C1)
if (display->epd2.panel == GxEPD2::DEPG0213BN &&
display->height() == 128 &&
display->getRotation() == ROTATE_270) {
y -= 6;
}
#endif /* EPD_ASPECT_RATIO_2C1 */
display->setCursor(x, y);
display->print(buf);

Expand All @@ -134,6 +160,7 @@ bool EPD_setup(bool splash_screen)
display->setCursor(x, y);
display->print(EPD_SoftRF_text1);
}
#endif /* EPD_ASPECT_RATIO_1C1 || EPD_ASPECT_RATIO_2C1 */

// first update should be full refresh
display->display(false);
Expand Down Expand Up @@ -190,6 +217,7 @@ void EPD_info1()
{
switch (hw_info.display)
{
#if defined(EPD_ASPECT_RATIO_1C1)
case DISPLAY_EPD_1_54:
case DISPLAY_EPD_2_7:
int16_t tbx, tby;
Expand Down Expand Up @@ -280,6 +308,7 @@ void EPD_info1()
#endif

break;
#endif /* EPD_ASPECT_RATIO_1C1 */

case DISPLAY_NONE:
default:
Expand All @@ -293,6 +322,7 @@ void EPD_info2(int acfts, char *reg, char *mam, char *cn)

switch (hw_info.display)
{
#if defined(EPD_ASPECT_RATIO_1C1)
case DISPLAY_EPD_1_54:
case DISPLAY_EPD_2_7:
int16_t tbx, tby;
Expand Down Expand Up @@ -412,6 +442,7 @@ void EPD_info2(int acfts, char *reg, char *mam, char *cn)

delay(3000);
break;
#endif /* EPD_ASPECT_RATIO_1C1 */

case DISPLAY_NONE:
default:
Expand All @@ -424,6 +455,7 @@ void EPD_loop()
switch (hw_info.display)
{
case DISPLAY_EPD_1_54:
case DISPLAY_EPD_2_13:

if (EPD_vmode_updated) {
#if defined(USE_EPD_TASK)
Expand Down Expand Up @@ -502,6 +534,7 @@ void EPD_fini(int reason, bool screen_saver)

switch (hw_info.display)
{
#if defined(EPD_ASPECT_RATIO_1C1)
case DISPLAY_EPD_1_54:
#if defined(USE_EPD_TASK)
while (EPD_update_in_progress != EPD_UPDATE_NONE) delay(100);
Expand Down Expand Up @@ -600,6 +633,7 @@ void EPD_fini(int reason, bool screen_saver)

// SoC->Display_unlock();
break;
#endif /* EPD_ASPECT_RATIO_1C1 */

case DISPLAY_NONE:
default:
Expand All @@ -609,7 +643,8 @@ void EPD_fini(int reason, bool screen_saver)

void EPD_Mode()
{
if (hw_info.display == DISPLAY_EPD_1_54) {
if (hw_info.display == DISPLAY_EPD_1_54 ||
hw_info.display == DISPLAY_EPD_2_13) {
for (int i=0; i < VIEW_MODES_COUNT; i++) {
int next_view_mode = (EPD_view_mode + i) % VIEW_MODES_COUNT;
if ((next_view_mode != EPD_view_mode) &&
Expand Down
2 changes: 2 additions & 0 deletions software/firmware/source/SoftRF/src/driver/EPD.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@
#define EPD_HIBERNATE display->hibernate()
//#define EPD_HIBERNATE display->powerOff()

#ifndef EPD_POWEROFF
//#define EPD_POWEROFF {}
#define EPD_POWEROFF display->powerOff()
#endif /* EPD_POWEROFF */

enum
{
Expand Down
10 changes: 5 additions & 5 deletions software/firmware/source/SoftRF/src/platform/ESP32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ unsigned long TaskInfoTime;

const char *Hardware_Rev[] = {
[0] = "2024-02-28",
[1] = "TBD",
[2] = "TBD",
[1] = "N/A",
[2] = "N/A",
[3] = "Unknown"
};

Expand Down Expand Up @@ -3514,7 +3514,7 @@ static byte ESP32_Display_setup()

TaskInfoTime = millis();
#endif /* USE_EPD_TASK */
rval = DISPLAY_EPD_1_54;
rval = DISPLAY_EPD_2_13;
}
#endif /* USE_EPAPER */
} else {
Expand All @@ -3523,7 +3523,7 @@ static byte ESP32_Display_setup()
tft = new TFT_eSPI(LV_HOR_RES, LV_VER_RES);
tft->init();
#if defined(CONFIG_IDF_TARGET_ESP32S3)
uint8_t r = ui->rotate;
uint8_t r = (ROTATE_90 + ui->rotate) & 0x3; /* 90 deg. is default angle */
#else
#if LV_HOR_RES != 135 && LV_HOR_RES != 80
uint8_t r = 0;
Expand Down Expand Up @@ -4483,7 +4483,7 @@ void handleMainEvent(AceButton* button, uint8_t eventType,
}
#endif /* USE_OLED */
#if defined(USE_EPAPER)
if (button == &button_1 && hw_info.display == DISPLAY_EPD_1_54) {
if (button == &button_1 && hw_info.display == DISPLAY_EPD_2_13) {
EPD_Mode();
}
#endif /* USE_EPAPER */
Expand Down
2 changes: 2 additions & 0 deletions software/firmware/source/SoftRF/src/platform/ESP32.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,9 @@ extern const USB_Device_List_t supported_USB_devices[];
#define ENABLE_REMOTE_ID
//#define EXCLUDE_VOICE_MESSAGE
//#define USE_EPAPER
//#define EPD_ASPECT_RATIO_2C1
//#define USE_EPD_TASK
//#define EPD_POWEROFF {}
#endif /* S3 */

#if defined(CONFIG_IDF_TARGET_ESP32S2)
Expand Down
1 change: 1 addition & 0 deletions software/firmware/source/SoftRF/src/platform/nRF52.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ struct rst_info {
//#define EXCLUDE_OLED_BARO_PAGE
//#define EXCLUDE_OLED_049
#define USE_EPAPER // + kb
#define EPD_ASPECT_RATIO_1C1
#define USE_EPD_TASK
#define USE_TIME_SLOTS

Expand Down
78 changes: 57 additions & 21 deletions software/firmware/source/SoftRF/src/ui/Status_EPD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,24 @@ static navbox_t navbox6;

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

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; }
}
}

memcpy(navbox1.title, NAVBOX1_TITLE, strlen(NAVBOX1_TITLE));
navbox1.x = 0;
navbox1.y = 0;
navbox1.width = display->width() / 2;
navbox1.height = display->height() / 3;
navbox1.value = 0;
navbox1.y = 0 + dy;
navbox1.width = display_width / 2;
navbox1.height = display_height / 3;
navbox1.value = 0;
// navbox1.prev_value = navbox1.value;
navbox1.timestamp = millis();

Expand All @@ -61,7 +73,7 @@ void EPD_status_setup()
navbox2.y = navbox1.y;
navbox2.width = navbox1.width;
navbox2.height = navbox1.height;
navbox2.value = 0;
navbox2.value = 0;
// navbox2.prev_value = navbox2.value;
navbox2.timestamp = millis();

Expand All @@ -70,16 +82,21 @@ void EPD_status_setup()
navbox3.y = navbox1.y + navbox1.height;
navbox3.width = navbox1.width;
navbox3.height = navbox1.height;
navbox3.value = ThisAircraft.addr;
navbox3.value = ThisAircraft.addr;
// navbox3.prev_value = navbox3.value;
navbox3.timestamp = millis();

#if defined(EPD_ASPECT_RATIO_1C1)
memcpy(navbox4.title, NAVBOX4_TITLE, strlen(NAVBOX4_TITLE));
#endif /* EPD_ASPECT_RATIO_1C1 */
#if defined(EPD_ASPECT_RATIO_2C1)
memcpy(navbox4.title, NAVBOX4_TITLE, strlen(NAVBOX4_TITLE) - 4);
#endif /* EPD_ASPECT_RATIO_2C1 */
navbox4.x = navbox3.width;
navbox4.y = navbox3.y;
navbox4.width = navbox3.width;
navbox4.height = navbox3.height;
navbox4.value = settings->rf_protocol;
navbox4.value = settings->rf_protocol;
// navbox4.prev_value = navbox4.value;
navbox4.timestamp = millis();

Expand All @@ -88,7 +105,7 @@ void EPD_status_setup()
navbox5.y = navbox3.y + navbox3.height;
navbox5.width = navbox3.width;
navbox5.height = navbox3.height;
navbox5.value = rx_packets_counter % 1000;
navbox5.value = rx_packets_counter % 1000;
// navbox5.prev_value = navbox5.value;
navbox5.timestamp = millis();

Expand All @@ -97,7 +114,7 @@ void EPD_status_setup()
navbox6.y = navbox5.y;
navbox6.width = navbox5.width;
navbox6.height = navbox5.height;
navbox6.value = tx_packets_counter % 1000;
navbox6.value = tx_packets_counter % 1000;
// navbox6.prev_value = navbox6.value;
navbox6.timestamp = millis();
}
Expand All @@ -116,11 +133,6 @@ static void EPD_Draw_NavBoxes()
#else
{
#endif
uint16_t top_navboxes_x = navbox1.x;
uint16_t top_navboxes_y = navbox1.y;
uint16_t top_navboxes_w = navbox1.width + navbox2.width;
uint16_t top_navboxes_h = maxof2(navbox1.height, navbox2.height);

display->fillScreen(GxEPD_WHITE);

display->drawRoundRect( navbox1.x + 1, navbox1.y + 1,
Expand All @@ -143,10 +155,20 @@ static void EPD_Draw_NavBoxes()

display->setFont(&FreeMonoBold18pt7b);

#if defined(EPD_ASPECT_RATIO_1C1)
display->setCursor(navbox1.x + 25, navbox1.y + 52);
#endif /* EPD_ASPECT_RATIO_1C1 */
#if defined(EPD_ASPECT_RATIO_2C1)
display->setCursor(navbox1.x + 75, navbox1.y + 32);
#endif /* EPD_ASPECT_RATIO_2C1 */
display->print(navbox1.value);

#if defined(EPD_ASPECT_RATIO_1C1)
display->setCursor(navbox2.x + 15, navbox2.y + 52);
#endif /* EPD_ASPECT_RATIO_1C1 */
#if defined(EPD_ASPECT_RATIO_2C1)
display->setCursor(navbox2.x + 55, navbox2.y + 32);
#endif /* EPD_ASPECT_RATIO_2C1 */
display->print((float) navbox2.value / 10, 1);

uint16_t middle_navboxes_x = navbox3.x;
Expand All @@ -173,22 +195,26 @@ static void EPD_Draw_NavBoxes()

display->setFont(&FreeSerifBold12pt7b);

display->setCursor(navbox3.x + 5, navbox3.y + 50);

snprintf(buf, sizeof(buf), "%06X", navbox3.value);

#if defined(EPD_ASPECT_RATIO_1C1)
display->setCursor(navbox3.x + 5, navbox3.y + 50);
#endif /* EPD_ASPECT_RATIO_1C1 */
#if defined(EPD_ASPECT_RATIO_2C1)
display->setCursor(navbox3.x + 28, navbox3.y + 30);
#endif /* EPD_ASPECT_RATIO_2C1 */
display->print(buf);

display->setFont(&FreeMonoBold18pt7b);

#if defined(EPD_ASPECT_RATIO_1C1)
display->setCursor(navbox4.x + 15, navbox4.y + 50);
#endif /* EPD_ASPECT_RATIO_1C1 */
#if defined(EPD_ASPECT_RATIO_2C1)
display->setCursor(navbox4.x + 55, navbox4.y + 30);
#endif /* EPD_ASPECT_RATIO_2C1 */
display->print(Protocol_ID[navbox4.value]);

uint16_t bottom_navboxes_x = navbox5.x;
uint16_t bottom_navboxes_y = navbox5.y;
uint16_t bottom_navboxes_w = navbox5.width + navbox4.width;
uint16_t bottom_navboxes_h = maxof2(navbox5.height, navbox6.height);

display->drawRoundRect( navbox5.x + 1, navbox5.y + 1,
navbox5.width - 2, navbox5.height - 2,
4, GxEPD_BLACK);
Expand All @@ -208,10 +234,20 @@ static void EPD_Draw_NavBoxes()

display->setFont(&FreeMonoBold18pt7b);

#if defined(EPD_ASPECT_RATIO_1C1)
display->setCursor(navbox5.x + 25, navbox5.y + 50);
#endif /* EPD_ASPECT_RATIO_1C1 */
#if defined(EPD_ASPECT_RATIO_2C1)
display->setCursor(navbox5.x + 55, navbox5.y + 30);
#endif /* EPD_ASPECT_RATIO_2C1 */
display->print(navbox5.value);

#if defined(EPD_ASPECT_RATIO_1C1)
display->setCursor(navbox6.x + 25, navbox6.y + 50);
#endif /* EPD_ASPECT_RATIO_1C1 */
#if defined(EPD_ASPECT_RATIO_2C1)
display->setCursor(navbox6.x + 55, navbox6.y + 30);
#endif /* EPD_ASPECT_RATIO_2C1 */
if (settings->mode == SOFTRF_MODE_RECEIVER ||
settings->rf_protocol == RF_PROTOCOL_ADSB_UAT ||
settings->txpower == RF_TX_POWER_OFF) {
Expand Down

0 comments on commit 2a76b88

Please sign in to comment.