1.54" e-ink display - Partial Update

Hi,

I have an arduino Nano with a Heltec (similar to Waveshare) 1.54" e-ink display. Im trying to figure out a way to have numerous lines of text, then partially update 1 line to something else without disturbing the other lines.

a a
b b
c --> C
d d

Partial update code:

//     :   1.54inch e-paper display demo

#include <SPI.h>
#include <EPD1in54.h>
#include <EPDPaint.h>
#include "imagedata.h"

#define COLORED     0
#define UNCOLORED   1

/**
  * Due to RAM not enough in Arduino UNO, a frame buffer is not allowed.
  * In this case, a smaller image buffer is allocated and you have to
  * update a partial display several times.
  * 1 byte = 8 pixels, therefore you have to set 8*N pixels at a time.
  */
unsigned char image[1024];
EPDPaint paint(image, 0, 0);    // width should be the multiple of 8
EPD1in54 epd; // default reset: 8, dc: 9, cs: 10, busy: 7

unsigned long timeStartMs;
unsigned long timeNowS;
unsigned long timeShowedS = 1000;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);

  if (epd.init(lutFullUpdate) != 0) {
    Serial.print("e-Paper init failed");
    return;
  }

  /**
   *  there are 2 memory areas embedded in the e-paper display
   *  and once the display is refreshed, the memory area will be auto-toggled,
   *  i.e. the next action of SetFrameMemory will set the other memory area
   *  therefore you have to clear the frame memory twice.
   */
  epd.clearFrameMemory(0xFF);   // bit set = white, bit reset = black
  epd.displayFrame();
  epd.clearFrameMemory(0xFF);   // bit set = white, bit reset = black
  epd.displayFrame();

  if (epd.init(lutPartialUpdate) != 0) {
    Serial.print("e-Paper init failed");
    return;
  }


   
  epd.setFrameMemory(IMAGE_DATA);
  epd.displayFrame();
  epd.setFrameMemory(IMAGE_DATA);
  epd.displayFrame();

 

  timeStartMs = millis();
}

void loop() {
  // put your main code here, to run repeatedly:
  timeNowS = (millis() - timeStartMs) / 1000;
  if (timeNowS != timeShowedS) {
    timeShowedS = timeNowS;
    updateTime(timeShowedS);
  }
  delay(20);
}

void updateTime(unsigned long seconds) {
  char time_string[] = {'0', '0', ':', '0', '0', '\0'};
  time_string[0] = seconds / 60 / 10 + '0';
  time_string[1] = seconds / 60 % 10 + '0';
  time_string[3] = seconds % 60 / 10 + '0';
  time_string[4] = seconds % 60 % 10 + '0';

  paint.setWidth(40);
  paint.setHeight(96);
  paint.setRotate(ROTATE_270);

  paint.clear(UNCOLORED);
  paint.drawStringAt(0, 4, time_string, &Font24, COLORED);
  epd.setFrameMemory(paint.getImage(), 88, 88, paint.getWidth(), paint.getHeight());
  epd.displayFrame();
}

This code uses a picture file, displays it then in the gap partially updates the screen with a timer.

The next code is the same, but displaying a line of text, then hoping to display the same timer underneath it and have it partially updating. Problem is each time the timer updates so does the entire screen. I am not sure why...

//     :   1.54inch e-paper display demo

#include <SPI.h>
#include <EPD1in54.h>
#include <EPDPaint.h>
#include "imagedata.h"

#define COLORED     0
#define UNCOLORED   1

/**
  * Due to RAM not enough in Arduino UNO, a frame buffer is not allowed.
  * In this case, a smaller image buffer is allocated and you have to
  * update a partial display several times.
  * 1 byte = 8 pixels, therefore you have to set 8*N pixels at a time.
  */
unsigned char image[1024];
EPDPaint paint(image, 0, 0);    // width should be the multiple of 8
EPD1in54 epd; // default reset: 8, dc: 9, cs: 10, busy: 7

unsigned long timeStartMs;
unsigned long timeNowS;
unsigned long timeShowedS = 1000;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);

  if (epd.init(lutFullUpdate) != 0) {
    Serial.print("e-Paper init failed");
    return;
  }

  epd.clearFrameMemory(0xFF);   // bit set = white, bit reset = black
  epd.displayFrame();
  epd.clearFrameMemory(0xFF);   // bit set = white, bit reset = black
  epd.displayFrame();

  paint.setRotate(ROTATE_0);
  paint.setWidth(200);
  paint.setHeight(24);

  paint.clear(UNCOLORED);
  paint.drawStringAt(30, 4, "TESTING", &Font16, COLORED);
  epd.setFrameMemory(paint.getImage(), 0, 10, paint.getWidth(), paint.getHeight());

  epd.displayFrame();

  delay(2000);  //Partial update next


  timeStartMs = millis();
}

void loop() {
  // put your main code here, to run repeatedly:
  timeNowS = (millis() - timeStartMs) / 1000;
  if (timeNowS != timeShowedS) {
    timeShowedS = timeNowS;
    updateTime(timeShowedS);
  }
  delay(20);
}

void updateTime(unsigned long seconds) {
  char time_string[] = {'0', '0', ':', '0', '0', '\0'};
  time_string[0] = seconds / 60 / 10 + '0';
  time_string[1] = seconds / 60 % 10 + '0';
  time_string[3] = seconds % 60 / 10 + '0';
  time_string[4] = seconds % 60 % 10 + '0';

  paint.setWidth(200);
  paint.setHeight(32);
  paint.setRotate(ROTATE_0);

  paint.clear(UNCOLORED);
  paint.drawStringAt(0, 4, time_string, &Font24, COLORED);
  epd.setFrameMemory(paint.getImage(), 40, 80, paint.getWidth(), paint.getHeight());
  epd.displayFrame();
}

Any help would be greatly received, yes I am aware of the dangers of running 5v pins to the display but seems ok so far.

Many thanks. J.

imagedata.cpp (26.2 KB)

imagedata.h (1.24 KB)

Using this library...

Hi,

I have an Arduino Nano 33 IOT and Heltec 1.54" e-ink display and would love to know how to get it to work!?

Connections are..

GND to GND
VCC to 3.3v
D/C to 9
C/S to 10
CLK to 13
SDL to 11
BUSY to 7

No reset?

I am using your library link also

Regards

James