Giter Club home page Giter Club logo

heltec-eink-modules's Introduction

Heltec E-Ink Modules

Third-party Arduino Library for Heltec E-Ink Module displays, and Wireless Paper boards
Run-time drawing, using Adafruit-GFX.

Read the API

Get started with "Wireless Paper" boards

Supported Platforms

Platform Tested
ATmega328P Arduino Uno R3, Arduino Nano
ATmega2560 Arduino Mega 2560
ESP32 Devkit V1, Heltec Wireless Paper
ESP8266 NodeMcu v3, LOLIN D1 Mini
SAMD21G18A Protoneer Nano ARM

Supported Displays - Identify your model

Pay attention to the model name: you will need it to use the library.

1.54 Inch

Model Name Flex Connector Label Front Image Rear Image Colors Screen Protector Resolution (px) Fastmode (partial refresh)
DEPG0154BNS800 FPC-7525 Front Rear Black, White Red Tab 152 x 152 Yes
DEPG0150BNS810 FPC-8101 Front Rear Black, White Red Tab 200 x 200 Yes
GDEP015OC1 1 HINK-E0154A05-A2 Front Rear Black, White Blue Tab 200 x 200 Yes

1 Closest match. No official information available.

2.13 Inch

Model Name Flex Connector Label Front Image Rear Image Colors Screen Protector Resolution (px) Fastmode (partial refresh)
DEPG0213RWS800 2 FPC-7528B Front Rear Black, White, Red Red Tab 250 x 122 No
QYEG0213RWS800 2 FPC-7528 Front Rear Black, White, Red Red Tab 250 x 122 No

2 Currently, these two displays use the same driver. This is not guaranteed in the future.

2.9 Inch

Model Name Flex Connector Label Front Image Rear Image Colors Screen Protector Resolution (px) Fastmode (partial refresh)
DEPG0290BNS800 FPC-7519 rev.b Front Rear Black, White Red Tab 296 x 128 Yes
DEPG0290BNS75A  FPC-750 Front Rear Black, White Red Tab 296 x 128 Yes
GDE029A1 SYX-1553 Front Rear Black, White Blue Tab 296 x 128 Yes

Wireless Paper

Model Name Flex Connector Label Front Image Rear Image 3 Colors Screen Protector Resolution (px) Fastmode (partial refresh)
LCMEN2R13EFC1 Hidden, printed on back-side
(HINK-E0213A162-FPC-A0)
Front Rear
Rear, with sticker
Black, White Green Tab 250 x 122 Yes
DEPG0213BNS800 FPC-7528B Front Rear Black, White Red Tab 250 x 122 Yes

3 Version-marking sticker is present on some LCMEN2R13EFC1 boards.

Wiring

Warning: in some cases, connecting directly to the display will cause damage!
See your boards's wiring page for specific information:

Drawing

Compatibility or Convenience?

1. Compatibility

The DRAW() operation allows for RAM saving tricks (paging). Required for older boards, configurable for new boards.
More info about paging here.

#include "heltec-eink-modules.h"

// Use the correct class for your display; set pins for D/C, CS, BUSY
DEPG0150BNS810 display(2, 4, 5);

void setup() {

    // Any config is set first
    display.setBackgroundColor(BLACK);

    // Drawing action goes inside DRAW()
    DRAW (display) {
        display.fillCircle(50, 100, 20, WHITE);
        display.fillCircle(50, 100, 10, BLACK);
    }

}

void loop() {}

2. Convenience

If you're using a fancy new device, you can choose to avoid the DRAW() pattern:

#include "heltec-eink-modules.h"

// Use the correct class for your display; set pins for D/C, CS, BUSY
DEPG0150BNS810 display(2, 4, 5);

void setup() {
    
    display.setBackgroundColor(BLACK);

    // Start working on a new drawing (with a BLACK background)
    display.clearMemory();

    // Draw the same circles from the other example
    display.fillCircle(50, 100, 20, WHITE);
    display.fillCircle(50, 100, 10, BLACK);
    
    // Whenever you're ready, display your masterpiece
    display.update();

}

void loop() {}

Shapes and Text

Drawing operations come from the Adafruit GFX library You'll find a full list of supported commands in the API. Check out the examples folder to see them in action. Alternatively, the official adafruit-gfx tutorial is a good place to start.

Fonts

The library comes with a selection of custom fonts. You can create more with truetype2gfx.
See the Fonts example.

Images

As decided by the Adafruit library, the ancient "XBitmap" is the format of choice for pre-rendered graphics. Luckily, GIMP maintains good support for it. If you need a hint on how to use it, I have thrown together a tutorial on preparing XBitmap images.

SD card

It is possible to load and save .bmp images, using a cheap SD card SPI adapter. Read more

Configuration

Model Name

The Model Name of your display is used to select the correct driver. Find your model name.

Pins

// Make sure to use the correct class for your display model
DEPG0150BNS810 display(dc, cs, busy);   

Pass the pin numbers to which the D/C, CS, and BUSY pins from the display are connected.

If you're using ESP32, you are free to set custom SDI, and CLK pins if you wish.
If you're using SAMD21G18A, you are able to make some changes to SDI and CLK assignment. See wiring.

DEPG0150BNS810 display(dc, cs, busy, sdi, clk);

If you're using a "Wireless Paper" board, you don't need to pass pins; they are already set.

Saving RAM

On older boards, this library makes use of paging.This technique allows drawing with less RAM, with the cost of decreased speed.
On newer boards, this technique is not required, and is disabled by default (regardless of your code style)

If you wish to tweak this speed vs. RAM trade-off, or enable the technique on a newer board, you can usually specificy a custom "page_height" in the display constructor. This specifies how many lines of the display should be calculated at once.

DEPG0150BNS810 display(dc, cs, busy, page_height);

Saving Flash

On older boards in particular, the library can occupy a large portion of the "flash memory". If you need to reduce this, you can manually edit the optimization.h file, to disable unused features.

Note: for ATmega328, some of the more-obscure features are disabled by default.

Saving Power

Many E-ink manufacturers provide a deep-sleep mode. With Heltec display modules, this mode is often not usable.

For "Display Modules":

Consider using a PNP transistor, or other switching device, to disconnect your display when needed. The library can handle this for you. Configure your custom switch hardware with useCustomPowerSwitch(), then call customPowerOff() and customPowerOn() as required.

See your board's wiring page for a suggested schematic.

For "Wireless Paper":

A low power state is available for the whole board (18μA while sleeping). See Wireless Paper

Fast Mode (Partial Refresh)

E-Ink displays generally take several seconds to refresh. Some displays have an alternative mode, where the image updates much faster. This is known officially as a "Partial Refresh". For the sake of simplicity, this library instead uses the term "Fast Mode".

The trade-off is that images drawn in fast mode are of a lower quality. The process may also be particularly difficult on the hardware. Use sparingly.

Not all displays support fast mode.

Call fastmodeOn() to enable.
Call fastmodeOff() to return to normal.

Troubleshooting

  • Double-check your wiring
    On breadboard, or header pins, it is easy to be one row out.
    Make sure to use a level-shifter, if needed.

  • Double-check your constructor

    // Make sure to use the correct class for your display model,
    // and the correct pins to match your wiring
    
    DEPG0150BNS810 display(dc, cs, busy);   
  • Take a look at the examples, and the API
    Some commands might not work the way you would expect. If unsure, double check.

  • Disconnect and Reconnect
    If the display has been used incorrectly, it can get "stuck".
    Remove all power from the display and Arduino for 5 seconds.

Installation

Arduino: Library can be installed to Arduino IDE with Sketch -> Include Library -> Add .Zip Library.., or through the built-in Library Manager.

Platform.io: Available through the built-in library registry, or alternatively, can be installed by extracting the Zip file to the lib folder of your project.

Acknowledgements

heltec-eink-modules's People

Contributors

todd-herbert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

heltec-eink-modules's Issues

Driver code for Wireless Paper LCMEN2R13EFC1 module eink display.

Hi, thanks for your work. I have found the wireless paper module LCMEN2R13EFC1 eink display driver command, actually it's for the HINK-E0213A162-FPC-A0 eink display.
The sample code is use the epd2in13bc-demo.ino file in this address: https://www.waveshare.net/w/upload/d/d5/E-Paper_ESP8266_Driver_Board_Code.7z And need to do some small hack. Just delete the 0x61 Reg cmd and data, which is set the RESOLUTION_SETTING. If add this register config, the eink display will not respond to the code, which is confusing...

And the total init func is like this:

/******************************************************************************
function :	Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_2IN13BC_Init(void)
{
    EPD_2IN13BC_Reset();

    EPD_2IN13BC_SendCommand(0x06); // BOOSTER_SOFT_START
    EPD_2IN13BC_SendData(0x17);
    EPD_2IN13BC_SendData(0x17);
    EPD_2IN13BC_SendData(0x17);
	
    EPD_2IN13BC_SendCommand(0x04); // POWER_ON
    EPD_2IN13BC_ReadBusy();
	
    EPD_2IN13BC_SendCommand(0x00); // PANEL_SETTING
    EPD_2IN13BC_SendData(0x8F);  // origin code
    // EPD_2IN13BC_SendData(0x0F);
    // EPD_2IN13BC_SendData(0x09);
	
    EPD_2IN13BC_SendCommand(0x50); // VCOM_AND_DATA_INTERVAL_SETTING
    EPD_2IN13BC_SendData(0xF0);  // origin code is 0xF0
    // EPD_2IN13BC_SendCommand(0x61); // RESOLUTION_SETTING
    // EPD_2IN13BC_SendData(EPD_2IN13BC_WIDTH); // width: 104
    // EPD_2IN13BC_SendData(EPD_2IN13BC_HEIGHT >> 8); // height: 212
    // EPD_2IN13BC_SendData(EPD_2IN13BC_HEIGHT & 0xFF);
}

Other functions don't need to modify, and works out of box.

ESP8266/ESP32 Support

ESP32 Boards: Xiao ESP32C3, Lolin S2 Mini,
ESP8266 Boards: Adafruit Huzzah 8266, Wemos D1 Mini Pro

Issue: Compiling failure for ESP32/8266 platforms, all boards.

Software:
Arduino SDK 2.1.1
CLI 0.32.3
ESP32 Core: 2.0.10
ESP8266 Core: 3.1.2
heltec-eink-modules: 2.4.1

Steps taken: removed & re-installed esp32/esp8266 cores & library. Tried several boards with same error.

Error:

`/Users/kritch/Documents/Arduino/libraries/heltec-eink-modules/src/Displays/DEPG0150BNS810/paging.cpp: In member function 'bool DEPG0150BNS810::calculating()':
/Users/kritch/Documents/Arduino/libraries/heltec-eink-modules/src/Displays/DEPG0150BNS810/paging.cpp:139:72: error: no matching function for call to 'min(int, uint8_t&)'
         page_bottom = min(page_top + pagefile_height - 1, winrot_bottom);
                                                                        ^
In file included from /Users/kritch/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/esp-2021r2-patch5-8.4.0/riscv32-esp-elf/include/c++/8.4.0/algorithm:62,
                 from /Users/kritch/Library/Arduino15/packages/esp32/hardware/esp32/2.0.9/cores/esp32/Arduino.h:172,
                 from /Users/kritch/Documents/Arduino/libraries/heltec-eink-modules/src/Displays/DEPG0150BNS810/DEPG0150BNS810.h:1,
                 from /Users/kritch/Documents/Arduino/libraries/heltec-eink-modules/src/Displays/DEPG0150BNS810/paging.cpp:1:
/Users/kritch/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/esp-2021r2-patch5-8.4.0/riscv32-esp-elf/include/c++/8.4.0/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)'
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/Users/kritch/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/esp-2021r2-patch5-8.4.0/riscv32-esp-elf/include/c++/8.4.0/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
/Users/kritch/Documents/Arduino/libraries/heltec-eink-modules/src/Displays/DEPG0150BNS810/paging.cpp:139:72: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
         page_bottom = min(page_top + pagefile_height - 1, winrot_bottom);`

SPI pins not configurable for ESP32

did not see where to configure CLK or SDI.

This is a good note, thank you.
With Arduino UNO, the SPI pins are fixed. Because of this, there has so far been no option for user to specify CLK and SDI pins.
I will look into adding this as a configuration option for ESP32.

Originally posted by @todd-herbert in #4 (comment)

HELTEC 2.90" V2 - Multiple incompatible versions circulating

It has come to my attention that "not all displays are created equal". A new batch of 2.90" Black and White displays appears to have a different panel which is not currently supported by this library. This will be investigated in the near future.

ESP8266: can't get Black to show.

ESP8266: D1 mini
display: DEPG0213RWS800

I can't get the colors to function like expected. Black and Red both give me a red color.

I've recorded a refresh where it looks like the circles are drawn at different stages.
At the beginning of the refresh, it draws a black rectangle around the display, so i don't think my screen is broken. but: I don't have a Arduino to verify this.

e-ink_refresh.mp4

Code:

#include "heltec-eink-modules.h"
#define PIN_BUSY    5
#define PIN_CS      4
#define PIN_DC      2
DEPG0213RWS800 display( PIN_DC, PIN_CS, PIN_BUSY );      // 2.13" V2 - BWR - Red Tab
void setup() {
  DRAW (display) {
    display.fillCircle(75,50,50,BLACK);
    display.fillCircle(75,200,50,RED);
  }
}
void loop() {}

EDIT: I've rewritten the issue. Now only black is broken. The display.overwrite() call doesn't seem to be supported with v3.0.0.

"Fast Mode" and clearing

I have a Heltec 1.54" V2 (BW) that seems to work properly with the fonts example if DEPG0150BNS810 is defined on an Arduino Mega 2560. But for some reason fastmodeOn seems to have the exact opposite effect. Meaning for a proper full clear I have to do:

  DRAW(display) {
    display.fastmodeOn();
    display.clear();
  }
  delay(1000);

Then the display clears the entire contents without ghosting.

  1. Is this a display (driver) quirk or nuance of this library's clear()?

So the resulting minimal working code looks like this:

void setup() {
  display.setRotation(PINS_RIGHT);
  display.setFont(&FreeSerifBold12pt7b);
  display.setDefaultColor(WHITE);
  display.setTextColor(BLACK);

  DRAW(display) {
    display.fastmodeOn();
    display.clear();
  }
  delay(2000);
}

void loop() {
  DRAW(display) {
    display.fastmodeOn();
    display.clear();
  }
  delay(2000);

  DRAW(display) {
    display.fastmodeOff();
    display.setCursor(5, 25);
    display.print(millis());
  }
  delay(5000);
}

If I merge the two DRAWs in the loop text starts overlapping (seems to do a partial update only). If I don't do fastmodeOn() in the first DRAW there's always slight ghosting. If I don't do fastmodeOff() in the second block, it displays the previous value and then (with ghosting) the new value on a previously fully cleared display.

What I'm getting at is that I'd expect this to work (draw the new text once in a while without ghosting), but it doesn't:

void setup() {
  display.setRotation(PINS_RIGHT);
  display.setFont(&FreeSerifBold12pt7b);
  display.setDefaultColor(WHITE);
  display.setTextColor(BLACK);

  display.fastmodeOff();
  display.clear();
  delay(2000);
}

void loop() {
  DRAW(display) {
    display.clear();
    display.setCursor(5, 25);
    display.print(millis());
  }
  delay(5000);
}

What wrong assumptions am I making about the display or the library?

Heltec 1.54" V2 display incompatible/wrong resolution

I'm trying to use this library for my 1.54" V2 display, but when running the examples it all looks from. After playing around for a bit, I found that my display has a resolution of 152x152 and not 200x200, as stated here: https://heltec.org/project/154-e-ink/.

After I changed the resolution in the code, the display seems to work with the "fast_mode" example, but only some of it. All other examples still produce "scan line" looking things, and some display updates still produce garbage. I also got some weird lines on the right side of the display.

Right now, I'm a bit confused as why the resolution in the code is set to 200x200, when the specs say 152x152. Even the AliExpress listing I bought my display from claims it to be 200x200.

This library (https://github.com/HelTecAutomation/e-ink) does work with my display, however it is very poorly documented, and I would much rather use this library instead.

// EDIT
Seems like Heltec added support for this new screen here.

Partial refresh inbetween deep sleeps

First of all, thank you so much for this project! It turned e-waste into something usable..

I have a specific problem that I tried in various ways to approach but none seem to work. I'm trying to code a clock with an esp32 that updates the time on the e-paper display after every minute and then goes to deep sleep for the rest of the time. The idea is to do a full update every full hour and the rest of the time should be partial (or fast-)updates.

The GxEPD2 library allows to skip the initial refresh of the display when initializing. I can't find anything similar here. I basically tried the "fast_mode" example but added a deep sleep command like this:

void setup() {
    display.setTextSize(2);
    display.fastmodeOn();

    display.setCursor(0, f.bottom() - 30);
    display.println("Fastmode:");
    display.println("On");
    display.update();

    display.setTextColor(WHITE);
    display.setWindow( f.left(), f.top(), f.width(), f.height() - 35 ); // Don't overwrite the bottom 35px

    for (int demo = 0; demo <= 5; demo++) { // Count up to 5
      display.drawXBitmap(ICON_L, ICON_T, hourglasses[demo % 3], hourglass_1_width, hourglass_1_height, BLACK);
      display.fillRect(0, 0, 30, 30, BLACK);
      display.setCursor(10, 10);
      display.print(demo);
      display.update();
    }
    display.fastmodeOff();

    esp_sleep_enable_timer_wakeup(2*1000000ULL);
    esp_deep_sleep_start();
}

Compiling

Hello,

When I try to compile the e-ink module (Wireless Paper with LCMEN2R13EFC1 display), I always get the compile error message :

/Users/B/Documents/Arduino/libraries/heltec-eink-modules/src/Platforms/WirelessPaper/power_controls.cpp: In function 'void Platform::prepareToSleep()':
/Users/B/Documents/Arduino/libraries/heltec-eink-modules/src/Platforms/WirelessPaper/power_controls.cpp:81:9: error: 'gpio_hold_en' was not declared in this scope; did you mean 'gpio_mode_t'?
81 | gpio_hold_en((gpio_num_t) PIN_LORA_NSS); // "stay where you're told"
| ^~~~~~~~~~~~
| gpio_mode_t

Is there a way to solve this ?

Refreshing the display in fast mode.

Totally new to the epaper display world.
I am running an instrumentation display, ESP32 and DEPG0290BNS75A.
The full display area is updated in fast mode every 10 seconds.

Would this snippet be enough to refresh the display? refreshNeeded is set to several minutes, maybe 10.

if (millis() - lastRefresh > refreshNeeded)
{
   display.fastmodeOff();
   display.update();
   display.fastmodeOn();
   lastRefresh = millis();
}

When I test this it still looks good after a day, no visible ghosting.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.