Skip to content

Commit

Permalink
[EPD] BARO screen adjustment for 2:1 aspect ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed Jul 29, 2024
1 parent bac6de3 commit fa8183a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 9 deletions.
8 changes: 4 additions & 4 deletions software/firmware/source/SoftRF/src/driver/EPD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,13 +628,13 @@ void EPD_fini(int reason, bool screen_saver)
display->setFont(&FreeMonoBold12pt7b);
display->getTextBounds(msg, 0, 0, &tbx, &tby, &tbw, &tbh);
x = (display_width - tbw) / 2;
y = tbh + tbh / 2;
y = tbh + tbh / 2 + dy;
display->setCursor(x, y);
display->print(msg);

#if defined(EPD_ASPECT_RATIO_1C1)
x = (display_width - 128) / 2;
y = (display_height - 128) / 2 - tbh / 2;
y = (display_height - 128) / 2 - tbh / 2 + dy;
display->drawBitmap(x, y, sleep_icon_128x128, 128, 128, GxEPD_BLACK);
#endif /* EPD_ASPECT_RATIO_1C1 */

Expand All @@ -643,11 +643,11 @@ void EPD_fini(int reason, bool screen_saver)

#if defined(EPD_ASPECT_RATIO_1C1)
x = 5;
y += 128 + 17;
y += 128 + 17 + dy;
#endif /* EPD_ASPECT_RATIO_1C1 */
#if defined(EPD_ASPECT_RATIO_2C1)
x = 30;
y = (3 * display_height) / 4;
y = (3 * display_height) / 4 + dy;
#endif /* EPD_ASPECT_RATIO_2C1 */
display->setCursor(x, y);
display->print(EPD_SoftRF_text4);
Expand Down
6 changes: 5 additions & 1 deletion software/firmware/source/SoftRF/src/platform/ESP32.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ extern Adafruit_NeoPixel strip;
SOC_GPIO_PIN_HELTRK_LED : \
hw_info.model == SOFTRF_MODEL_ECO ?\
SOC_GPIO_PIN_T3C6_LED : \
hw_info.model == SOFTRF_MODEL_INK ?\
SOC_GPIO_PIN_T3S3_LED : \
hw_info.model != SOFTRF_MODEL_PRIME_MK2 ?\
SOC_UNUSED_PIN : \
(hw_info.revision == 2 ? \
Expand All @@ -176,7 +178,9 @@ extern Adafruit_NeoPixel strip;
SOC_GPIO_PIN_HELTRK_GNSS_PPS : \
(hw_info.model == SOFTRF_MODEL_ECO ? \
SOC_GPIO_PIN_T3C6_GNSS_PPS : \
SOC_UNUSED_PIN))))
(hw_info.model == SOFTRF_MODEL_INK ? \
SOC_GPIO_PIN_T3S3_GNSS_PPS : \
SOC_UNUSED_PIN)))))

#define SOC_GPIO_PIN_BUZZER (hw_info.model == SOFTRF_MODEL_PRIME_MK2 ? \
SOC_UNUSED_PIN : \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
#define SOC_GPIO_PIN_TULTIMA_SCK _PINNUM(0, 3) // P0.03
#define SOC_GPIO_PIN_TULTIMA_SS _PINNUM(0, 23) // P0.23

/* SX1262 or SX1276 */
/* LR1121, SX1262, SX1276 or SX1280 */
#define SOC_GPIO_PIN_TULTIMA_RST _PINNUM(0, 25) // P0.25
#define SOC_GPIO_PIN_TULTIMA_DIO1 _PINNUM(0, 15) // P0.15
#define SOC_GPIO_PIN_TULTIMA_BUSY _PINNUM(0, 17) // P0.17
#define SOC_GPIO_PIN_TULTIMA_EN _PINNUM(0, 13) // P0.13

/* I2C */
#define SOC_GPIO_PIN_TULTIMA_SDA _PINNUM(1, 1) // P1.01
Expand Down Expand Up @@ -47,6 +48,9 @@
#define SOC_GPIO_PIN_SFL_TULTIMA_HOLD _PINNUM(1, 15) // P1.15
#define SOC_GPIO_PIN_SFL_TULTIMA_WP _PINNUM(0, 31) // P0.31

/* RTC */
#define SOC_GPIO_PIN_RTC_TULTIMA_INT _PINNUM(1, 2) // P1.02

/* I2S */
#define SOC_GPIO_PIN_I2S_TULTIMA_LRCK _PINNUM(1, 0) // P1.00
#define SOC_GPIO_PIN_I2S_TULTIMA_BCK _PINNUM(0, 24) // P0.24
Expand All @@ -56,4 +60,12 @@
/* IMU */
#define SOC_GPIO_PIN_IMU_TULTIMA_SS _PINNUM(0, 28) // P0.28
#define SOC_GPIO_PIN_IMU_TULTIMA_INT _PINNUM(0, 30) // P0.30
#define SOC_GPIO_PIN_IMU_TULTIMA_HB _PINNUM(1, 12) // P1.12 /* TBD */
#define SOC_GPIO_PIN_IMU_TULTIMA_RST SOC_UNUSED_PIN

/* FT6336U */
#define SOC_GPIO_PIN_TOUCH_TULTIMA_RST _PINNUM(0, 8) // P0.08
#define SOC_GPIO_PIN_TOUCH_TULTIMA_INT _PINNUM(0, 6) // P0.06

/* DRV2605 */
#define SOC_GPIO_PIN_MOTOR_TULTIMA_EN _PINNUM(1, 9) // P1.09
32 changes: 29 additions & 3 deletions software/firmware/source/SoftRF/src/ui/Baro_EPD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ static float alt_scale = 1.0;

void EPD_baro_setup()
{
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 (hw_info.baro != BARO_MODULE_NONE) {
EPD_pages_mask |= (1 << VIEW_MODE_BARO);
}
Expand All @@ -48,9 +62,9 @@ void EPD_baro_setup()
strcpy(navbox1.title + strlen(Altitude_text),
ui->units == UNITS_METRIC ? "M" : "FT");
navbox1.x = 0;
navbox1.y = 0;
navbox1.width = display->width();
navbox1.height = display->height() / 3;
navbox1.y = 0 + dy;
navbox1.width = display_width;
navbox1.height = display_height / 3;
navbox1.value = Baro_altitude() * alt_scale;
// navbox1.prev_value = navbox1.value;
navbox1.timestamp = millis();
Expand Down Expand Up @@ -118,6 +132,7 @@ static void EPD_Draw_NavBoxes()

display->setFont(&FreeMonoBold18pt7b);

#if defined(EPD_ASPECT_RATIO_1C1)
display->setCursor(navbox1.x + navbox1.width / 3 + 15, navbox1.y + 52);
display->print(navbox1.value);

Expand All @@ -126,6 +141,17 @@ static void EPD_Draw_NavBoxes()

display->setCursor(navbox3.x + navbox3.width / 3 + 15, navbox3.y + 52);
display->print(navbox3.value);
#endif /* EPD_ASPECT_RATIO_1C1 */
#if defined(EPD_ASPECT_RATIO_2C1)
display->setCursor(navbox1.x + navbox1.width / 2 + 17, navbox1.y + 32);
display->print(navbox1.value);

display->setCursor(navbox2.x + navbox2.width / 2 + 17, navbox2.y + 32);
display->print(navbox2.value);

display->setCursor(navbox3.x + navbox3.width / 2 + 59, navbox3.y + 32);
display->print(navbox3.value);
#endif /* EPD_ASPECT_RATIO_2C1 */

#if defined(USE_EPD_TASK)
/* a signal to background EPD update task */
Expand Down
2 changes: 2 additions & 0 deletions software/firmware/source/SoftRF/src/ui/Status_EPD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ void EPD_status_setup()
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 */

memcpy(navbox1.title, NAVBOX1_TITLE, strlen(NAVBOX1_TITLE));
navbox1.x = 0;
Expand Down

0 comments on commit fa8183a

Please sign in to comment.