Skip to content

Commit

Permalink
Add epd_powerdown for lilygo (#179)
Browse files Browse the repository at this point in the history
* added epd_powerdown

On lilygo disable display power but not touch screen.
  The epd power flag was re-purposed as power enable
   however it also disables the touch.
  this workaround may still leave power on to epd
  and as such may cause other problems such as grey screen.
  please also use poweroff when you sleep the system
  wake on touch will still work just not the I2C interface.

* lilygo epd_powerdown note in readme

Sorry it's not the prettiest thing.

* Documentation change

Deoxygenised the comments on the function so it will be explained in the readthedocs.io

* Clarify readme

* Finish readme  for lily go

* Clean up

* Oops
  • Loading branch information
Yardie- committed May 10, 2022
1 parent fd8a290 commit 3ffb83c
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,25 @@ The following list is compiled from past experiences and GitHub issues:
* **The existing image fades / darkens when updating a partial screen region.** Make sure the VCOM voltage is [calibrated](https://epdiy.readthedocs.io/en/latest/getting_started.html#calibrate-vcom) for your specific display.
* **The second third of the image is replaced with the last third.** This seems to be a timing issue we could not yet quite figure out the reason for. For a workarround or suggestions please [join the discussion](https://github.com/vroland/epdiy/issues/15).
* **The ESP does not boot correctly when external periperals are connected.** Make sure not to pull GPIO12 high during boot, as it is a strapping pin internal voltage selection (https://github.com/vroland/epdiy/issues/17).


LilyGo Boards
---------------
There are several differences with these boards.
One particular one is the way the LilyGo handles power to the display the official lilygo code has two states.
This is now handled in epdiy in a different way to the lilygo code.
**epd_poweroff()** completely turns the power off to the display and the other peripherals of the lilygo.
The new function **epd_powerdown()** keeps the peripherals on (this allows the touch functions to continue to work).
**epd_poweroff() should allways be called before sleeping the system**
You can still use touch to wake the screen with the following.
In Arduino it works like this.
`epd_poweroff();`

`epd_deinit();`

`esp_sleep_enable_ext1_wakeup(GPIO_SEL_13, ESP_EXT1_WAKEUP_ANY_HIGH);`

`esp_deep_sleep_start();`

More on E-Paper Displays
------------------------

Expand Down Expand Up @@ -115,4 +133,3 @@ The board and schematic are licensed under a <a rel="license" href="https://crea

Firmware and remaining examples are licensed under the terms of the GNU Lesser GPL version 3.
Utilities are licensed under the terms of the MIT license.

22 changes: 22 additions & 0 deletions src/epd_driver/config_reg_v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,28 @@ static void cfg_poweron(epd_config_register_t *cfg) {
// END POWERON
}

#if defined(CONFIG_EPD_BOARD_REVISION_LILYGO_T5_47)
static void cfg_powerdown(epd_config_register_t *cfg) {
// This was re-purposed as power enable however it also disables the touch.
// this workaround may still leave power on to epd and as such may cause other
// problems such as grey screen.
cfg->pos_power_enable = false;
push_cfg(cfg);
busy_delay(10 * 240);

cfg->neg_power_enable = false;
cfg->pos_power_enable = false;
push_cfg(cfg);
busy_delay(100 * 240);

cfg->ep_stv = false;
cfg->ep_output_enable = false;
cfg->ep_mode = false;
cfg->power_disable = true;
push_cfg(cfg);
}
#endif

static void cfg_poweroff(epd_config_register_t *cfg) {
// POWEROFF
cfg->pos_power_enable = false;
Expand Down
7 changes: 7 additions & 0 deletions src/epd_driver/display_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ void epd_poweron() {
cfg_poweron(&config_reg);
}

#if defined(CONFIG_EPD_BOARD_REVISION_LILYGO_T5_47)
void epd_powerdown() {
cfg_powerdown(&config_reg);
i2s_gpio_detach();
}
#endif

void epd_poweroff() {
cfg_poweroff(&config_reg);
i2s_gpio_detach();
Expand Down
24 changes: 24 additions & 0 deletions src/epd_driver/include/epd_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,30 @@ void epd_deinit();
/** Enable display power supply. */
void epd_poweron();

#if defined(CONFIG_EPD_BOARD_REVISION_LILYGO_T5_47)
/** This is a Lilygo47 specific function
This is a work around a hardware issue with the Lilygo47 epd_poweroff() turns off the epaper completely
however the hardware of the Lilygo47 is different than the official boards. Which means that on the Lilygo47 this
disables power to the touchscreen.
This is a workaround to allow to disable display power but not the touch screen.
On the Lilygo the epd power flag was re-purposed as power enable
for everything. This is a hardware thing.
\warning This workaround may still leave power on to epd and as such may cause other problems such as grey screen.
Please also use epd_poweroff() and epd_deinit() when you sleep the system wake on touch will still work.
Arduino specific code:
\code{.c}
epd_poweroff();
epd_deinit();
esp_sleep_enable_ext1_wakeup(GPIO_SEL_13, ESP_EXT1_WAKEUP_ANY_HIGH);
esp_deep_sleep_start();
\endcode
*/
void epd_powerdown();
#endif

/** Disable display power supply. */
void epd_poweroff();

Expand Down

0 comments on commit 3ffb83c

Please sign in to comment.