Xinyuan-LilyGO / T-Echo

MIT License
147 stars 22 forks source link

Drawing text on epaper display #7

Closed CharlesMod closed 2 years ago

CharlesMod commented 2 years ago

Hello,

I've been trying for some time to successfully show text on the display, can you provide an example that shows how to do this?

LilyGO commented 2 years ago

Here is a simple display example

CharlesMod commented 2 years ago

Thank you for your quick response!

I have already tried this example, trouble is it only shows bitmap print feature, not text print feature. Can you provide a different example?

CharlesMod commented 2 years ago

FYI tested the following, just makes the code hang when included in the example you provided:

display->setRotation(2);
display->fillScreen(GxEPD_WHITE);
display->setTextColor(GxEPD_BLACK);
display->setFont(&FreeMonoBold12pt7b);
display->setCursor(0, 45);
display->print("Hello World"); //crashes here
display->update();
LilyGO commented 2 years ago

void setup() { Serial.begin(115200); delay(200); boardInit(); delay(200); LilyGo_logo(); // delay(200); display->setRotation(3); display->fillScreen(GxEPD_WHITE); display->setTextColor(GxEPD_BLACK); display->setFont(&FreeMonoBold12pt7b); display->setCursor(0, 45); display->print("Hello World"); //crashes here display->update(); // }

CharlesMod commented 2 years ago

Hm no dice, the //crashes here line when uncommented breaks the sketch, the RGB blinking stops

Here is the full code, does it work on a unit you have there?

/*
  Display lilygo logo example

  This example shows an e-Peper display.The RGB indicator blinks in cycles.

  This example code is in the public domain.
*/

#include "utilities.h"
#include <SPI.h>
#include <Wire.h>

#include <GxEPD.h>
//#include <GxGDEP015OC1/GxGDEP015OC1.h>    // 1.54" b/w
//#include <GxGDEH0154D67/GxGDEH0154D67.h>  // 1.54" b/w
#include <GxDEPG0150BN/GxDEPG0150BN.h>  // 1.54" b/w 

#include GxEPD_BitmapExamples
#include <Fonts/FreeMonoBold12pt7b.h>
#include <GxIO/GxIO_SPI/GxIO_SPI.h>
#include <GxIO/GxIO.h>

void setupDisplay();
void enableBacklight();
void configVDD(void);
void boardInit();
void LilyGo_logo(void);

SPIClass        *dispPort  = nullptr;
SPIClass        *rfPort    = nullptr;
GxIO_Class      *io        = nullptr;
GxEPD_Class     *display   = nullptr;

uint32_t        blinkMillis = 0;
uint8_t rgb = 0;

void setup()
{
  Serial.begin(115200);
  delay(200);
  boardInit();
  delay(200);
  LilyGo_logo();
  delay(200);
  display->setRotation(3);
  display->fillScreen(GxEPD_WHITE);
  display->setTextColor(GxEPD_BLACK);
  display->setFont(&FreeMonoBold12pt7b);
  display->setCursor(0, 45);
  display->print("Hello World"); //crashes here
  display->update();
}

void loop()
{

  if (millis() - blinkMillis > 1000) {

    blinkMillis = millis();
    switch (rgb) {
      case 0:
        digitalWrite(GreenLed_Pin, LOW);
        digitalWrite(RedLed_Pin, HIGH);
        digitalWrite(BlueLed_Pin, HIGH);
        break;
      case 1:
        digitalWrite(GreenLed_Pin, HIGH);
        digitalWrite(RedLed_Pin, LOW);
        digitalWrite(BlueLed_Pin, HIGH);
        break;
      case 2:
        digitalWrite(GreenLed_Pin, HIGH);
        digitalWrite(RedLed_Pin, HIGH);
        digitalWrite(BlueLed_Pin, LOW);
        break;
      default :
        break;
    }
    rgb++;
    rgb %= 3;
  }
}

void LilyGo_logo(void)
{

  display->fillScreen(GxEPD_WHITE);
  display->drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK);
  display->update();
}

void enableBacklight(bool en)
{
  digitalWrite(ePaper_Backlight, en);
}

void setupDisplay()
{
  dispPort = new SPIClass(
    /*SPIPORT*/NRF_SPIM2,
    /*MISO*/ ePaper_Miso,
    /*SCLK*/ePaper_Sclk,
    /*MOSI*/ePaper_Mosi);

  io = new GxIO_Class(
    *dispPort,
    /*CS*/ ePaper_Cs,
    /*DC*/ ePaper_Dc,
    /*RST*/ePaper_Rst);

  display = new GxEPD_Class(
    *io,
    /*RST*/ ePaper_Rst,
    /*BUSY*/ ePaper_Busy);

  dispPort->begin();
  display->init(/*115200*/);
  display->setRotation(2);
  display->fillScreen(GxEPD_WHITE);
  display->setTextColor(GxEPD_BLACK);
  display->setFont(&FreeMonoBold12pt7b);
}

void configVDD(void)
{
  // Configure UICR_REGOUT0 register only if it is set to default value.
  if ((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) ==
      (UICR_REGOUT0_VOUT_DEFAULT << UICR_REGOUT0_VOUT_Pos)) {
    NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen;
    while (NRF_NVMC->READY == NVMC_READY_READY_Busy) {}

    NRF_UICR->REGOUT0 = (NRF_UICR->REGOUT0 & ~((uint32_t)UICR_REGOUT0_VOUT_Msk)) |
                        (UICR_REGOUT0_VOUT_3V3 << UICR_REGOUT0_VOUT_Pos);

    NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren;
    while (NRF_NVMC->READY == NVMC_READY_READY_Busy) {}

    // System reset is needed to update UICR registers.
    NVIC_SystemReset();
  }
}

void boardInit()
{

  uint8_t rlst = 0;

#ifdef HIGH_VOLTAGE
  configVDD();
#endif

  SerialMon.begin(MONITOR_SPEED);
  // delay(5000);
  // while (!SerialMon);
  SerialMon.println("Start\n");

  uint32_t reset_reason;
  sd_power_reset_reason_get(&reset_reason);
  SerialMon.print("sd_power_reset_reason_get:");
  SerialMon.println(reset_reason, HEX);

  pinMode(Power_Enable_Pin, OUTPUT);
  digitalWrite(Power_Enable_Pin, HIGH);

  pinMode(ePaper_Backlight, OUTPUT);
  //enableBacklight(true); //ON backlight
  enableBacklight(false); //OFF  backlight

  pinMode(GreenLed_Pin, OUTPUT);
  pinMode(RedLed_Pin, OUTPUT);
  pinMode(BlueLed_Pin, OUTPUT);

  pinMode(UserButton_Pin, INPUT_PULLUP);
  pinMode(Touch_Pin, INPUT_PULLUP);

  int i = 10;
  while (i--) {
    digitalWrite(GreenLed_Pin, !digitalRead(GreenLed_Pin));
    digitalWrite(RedLed_Pin, !digitalRead(RedLed_Pin));
    digitalWrite(BlueLed_Pin, !digitalRead(BlueLed_Pin));
    delay(300);
  }
  digitalWrite(GreenLed_Pin, HIGH);
  digitalWrite(RedLed_Pin, HIGH);
  digitalWrite(BlueLed_Pin, HIGH);

  setupDisplay();
}
LilyGO commented 2 years ago

I use your code. The normal operation. Are your factory firmware devices running properly?

CharlesMod commented 2 years ago

I received 2 units in my order, one has a barely legible dim screen so I can't use that one, the other appears to work fine. If you send a compiled hex file, I could upload that to my hardware and check for functionality that way and get back to you

LilyGO commented 2 years ago

Refer to this for uploading firmware

CharlesMod commented 2 years ago

I've installed the firmware you linked, the display on one appears to work just fine while the other is still very dim. I'm going to try to clean my installation directory for arduino and try the code I linked above again

CharlesMod commented 2 years ago

Hm no dice, I cleared all of my libraries and reinstalled fresh from the lib folder but the device still says "LilyGo" rather than a blank screen with the words "hello world" shown as expected. I compiled with the Arduino 1.8.13 IDE with the Nordic nRF52840DK (PCA10056)" board definition.

It's worth noting the blue LED is still blinking

https://photos.app.goo.gl/YWjZ4oDC6KqnJfj6A

LilyGO commented 2 years ago

One shows normal.One that's very dark?Are these two e-papers the same batch?

CharlesMod commented 2 years ago

More like very dim than dark yes, they were included in the same shipment.

On Fri, Dec 3, 2021, 6:35 PM LilyGO @.***> wrote:

One shows normal.One that's very dark?Are these two e-papers the same batch?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Xinyuan-LilyGO/LilyGO-T-Echo/issues/7#issuecomment-985941727, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUKGJXFOG245ZRB5SPVUWTUPFV7HANCNFSM5IP4TIUA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

LilyGO commented 2 years ago

Can you see the interface label of e-paper? They are SYX...... ?

CharlesMod commented 2 years ago

Opened up the two units to take a look, both boards are the same revision, 2021-6-28 (V1.0)

The displays are both SYX 2118 according to the screenprinting on the ribbon cable. Other information is the same on both displays as well

HINK-E0154A07-A1 Date:2017-02-28 SYX 2118

On Mon, Dec 6, 2021 at 6:37 PM LilyGO @.***> wrote:

Can you see the interface label of e-paper? They are SYX...... ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Xinyuan-LilyGO/LilyGO-T-Echo/issues/7#issuecomment-987487877, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUKGJX2G55PCOK3IA3CVJTUPVQNPANCNFSM5IP4TIUA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

CharlesMod commented 2 years ago

Can you confirm the display driver library I should be using for this particular screen?

Choices from the example sketches are:

include

//#include <GxGDEP015OC1/GxGDEP015OC1.h> // 1.54" b/w //#include <GxGDEH0154D67/GxGDEH0154D67.h> // 1.54" b/w

include <GxDEPG0150BN/GxDEPG0150BN.h> // 1.54" b/w

On Tue, Dec 7, 2021 at 9:41 AM Charles Dean Modrich @.***> wrote:

Opened up the two units to take a look, both boards are the same revision, 2021-6-28 (V1.0)

The displays are both SYX 2118 according to the screenprinting on the ribbon cable. Other information is the same on both displays as well

HINK-E0154A07-A1 Date:2017-02-28 SYX 2118

On Mon, Dec 6, 2021 at 6:37 PM LilyGO @.***> wrote:

Can you see the interface label of e-paper? They are SYX...... ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Xinyuan-LilyGO/LilyGO-T-Echo/issues/7#issuecomment-987487877, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUKGJX2G55PCOK3IA3CVJTUPVQNPANCNFSM5IP4TIUA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

LilyGO commented 2 years ago

1 You chose the right driver

CharlesMod commented 2 years ago

Hm okay, I still haven't been able to successfully draw text on these screens unfortunately, do you have any other troubleshooting suggestions?

On Thu, Dec 9, 2021, 6:36 PM LilyGO @.***> wrote:

[image: 1] https://user-images.githubusercontent.com/31160602/145502369-3d0d46c6-1961-4c05-a14d-6534341350d6.png You chose the right driver

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Xinyuan-LilyGO/LilyGO-T-Echo/issues/7#issuecomment-990507025, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUKGJRUY47D63QVPFTBKALUQFKRTANCNFSM5IP4TIUA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

mkinney commented 2 years ago

You could drop Meshtastic on the device(s) to see if the screen works. (grab the uf2 file in the firmware.zip file) https://github.com/meshtastic/Meshtastic-device/releases/tag/v1.2.53.19c1f9f

CharlesMod commented 2 years ago

I've done so and the screen definitely works (though one of my units has a screen that's super dim), but the issue is getting fresh code to compile and push text to the screen successfully.

On Fri, Feb 4, 2022 at 1:45 AM mkinney @.***> wrote:

You could drop Meshtastic on the device(s) to see if the screen works. (grab the uf2 file in the firmware.zip file) https://github.com/meshtastic/Meshtastic-device/releases/tag/v1.2.53.19c1f9f

— Reply to this email directly, view it on GitHub https://github.com/Xinyuan-LilyGO/LilyGO-T-Echo/issues/7#issuecomment-1029766763, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUKGJUWELHDO3CL6HNEMUTUZOG33ANCNFSM5IP4TIUA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

piotr-kubica commented 2 years ago

Hi, I'm having the same issue. Seems it has something to do with between GxEPD and AdafruitGfx lib and write() function (used by print()?). It used to work, now it doesn't.

#include <SPI.h>
#include <GxEPD.h>

#include <GxGDE0213B72B/GxGDE0213B72B.h> // 2.13" b/w
#include <GxIO/GxIO_SPI/GxIO_SPI.h>
#include <GxIO/GxIO.h>

#define SPI_MOSI 23
#define SPI_MISO -1
#define SPI_CLK 18
#define ELINK_SS 5
#define ELINK_BUSY 4
#define ELINK_RESET 16
#define ELINK_DC 17

GxIO_Class io(SPI, ELINK_SS, ELINK_DC, ELINK_RESET);
GxEPD_Class display(io, ELINK_RESET, ELINK_BUSY);

#include <Fonts/FreeMonoBold9pt7b.h>

void setup() {
    Serial.begin(115200); 
    Serial.println("\n\n=== hello world ===");

    Serial.print("init_display...");
    SPI.begin(SPI_CLK, SPI_MISO, SPI_MOSI, ELINK_SS);

    display.init();
    Serial.println(" completed");

    delay(3000);
    display.setRotation(3);
    display.setTextWrap(false);
    display.fillScreen(GxEPD_WHITE);
    display.setTextColor(GxEPD_BLACK);

    display.setFont(&FreeMonoBold9pt7b);
    display.setCursor(20, 20);

//// crashes here
//// display.print("text") causes core panic exception !
//    display.print(String("text"));

    // this works ok
    display.fillRect(10, 10, 10, 10, GxEPD_BLACK);

    // this works ok
    display.drawChar(20, 40, 'a', GxEPD_BLACK, GxEPD_WHITE, 1);
    display.drawChar(30, 40, 'b', GxEPD_BLACK, GxEPD_WHITE, 2);
    display.drawChar(40, 40, 'c', GxEPD_BLACK, GxEPD_WHITE, 3);

    //// also crashes here...
//    display.write('d');

    display.update();
}

void loop() {
    // put your main code here, to run repeatedly:
}

The exception (ESP resets and print same exception over and over again)

=== hello world ===
init_display... completed
Guru Meditation Error: Core  1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x400d1844: 6524c2a2 0000ffe7 30004136
Core  1 register dump:
PC      : 0x400d184a  PS      : 0x00060930  A0      : 0x800f06d9  A1      : 0x3ffb2770  
A2      : 0x3ffc0030  A3      : 0x00000074  A4      : 0x00000005  A5      : 0xb33fffff  
A6      : 0x00000001  A7      : 0x00000001  A8      : 0x800d1840  A9      : 0x3ffb2740  
A10     : 0x00000001  A11     : 0x0000000b  A12     : 0x00000001  A13     : 0x00000000  
A14     : 0x00000008  A15     : 0x00000000  SAR     : 0x0000001d  EXCCAUSE: 0x00000000  
EXCVADDR: 0x00000000  LBEG    : 0x40085ce9  LEND    : 0x40085cf9  LCOUNT  : 0xfffffffe  

Backtrace:0x400d1847:0x3ffb27700x400f06d6:0x3ffb2790 0x400f0706:0x3ffb27b0 0x400d11d6:0x3ffb27d0 0x400d4deb:0x3ffb2820 

ELF file SHA256: 0000000000000000

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1100
ho 0 tail 12 room 4
load:0x40078000,len:12308
load:0x40080400,len:3076
entry 0x400805ec

=== hello world ===
init_display... completed
LilyGO commented 2 years ago

Do you use t-Echo? This is NRF52840, not ESP32.

piotr-kubica commented 2 years ago

@LilyGO do you have drivers for LILYGO®TTGO T5 V2.3.1 _ 2.13? Let me know I will try. Maybe it works. Using GxGDE0213B72B or GxDEPG0213BN from https://github.com/Xinyuan-LilyGO/LilyGO-T-Echo/tree/7066ced313bf4ca941c6edbcb20ea3b1aaf0ea95/lib/GxEPD/src worked perfectly before I wonder what has changed.

LilyGO commented 2 years ago

https://github.com/Xinyuan-LilyGO/LilyGo-T5-Epaper-Series

LilyGO commented 2 years ago

I've done so and the screen definitely works (though one of my units has a screen that's super dim), but the issue is getting fresh code to compile and push text to the screen successfully. On Fri, Feb 4, 2022 at 1:45 AM mkinney @.> wrote: You could drop Meshtastic on the device(s) to see if the screen works. (grab the uf2 file in the firmware.zip file) https://github.com/meshtastic/Meshtastic-device/releases/tag/v1.2.53.19c1f9f — Reply to this email directly, view it on GitHub <#7 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUKGJUWELHDO3CL6HNEMUTUZOG33ANCNFSM5IP4TIUA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.Message ID: @.> Updated the GxEPD library. Try to see if the library displays properly