Skip to content

Commit

Permalink
1.1 Add gdem029E97 gdeq037T31
Browse files Browse the repository at this point in the history
  • Loading branch information
martinberlin committed Mar 11, 2023
1 parent 09376f1 commit 4b0c193
Show file tree
Hide file tree
Showing 8 changed files with 827 additions and 9 deletions.
15 changes: 12 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ set(srcs
"models/goodisplay/gdey0154d67.cpp"
"models/goodisplay/gdey029T94.cpp"
"models/goodisplay/gdey027T91.cpp"
"models/goodisplay/gdeq037T31.cpp"
# With touch integrated
"models/goodisplay/touch/gdey027T91T.cpp"
# Other mixed brands mostly GOODISPLAY based or using their epapers
"models/wave12i48.cpp"
#"models/wave12i48.cpp"
"models/gdew075HD.cpp"
"models/gdew075T7.cpp"
"models/gdew075T7Grays.cpp"
"models/gdew075T8.cpp"
"models/gdew0583t7.cpp"
"models/gdew042t2.cpp"
"models/gdew042t2Grays.cpp"
"models/gdem029E97.cpp"
"models/gdew027w3.cpp"
"models/wave12i48.cpp"
# Touch model, please also enable FT6X36-IDF in the REQUIRE section
Expand All @@ -36,7 +38,7 @@ set(srcs
"models/color/gdeh042Z96.cpp"
"models/color/gdeh042Z21.cpp"
"models/color/gdeq042Z21.cpp"
"models/color/wave12i48BR.cpp"
#"models/color/wave12i48BR.cpp"

# 7 colors ACEP
"models/color/gdey073d46.cpp"
Expand Down Expand Up @@ -66,9 +68,16 @@ set(srcs
"epd.cpp"
"epd7color.cpp"
"epdspi.cpp"
"epd4spi.cpp"
#"epd4spi.cpp"
)

idf_build_get_property(target IDF_TARGET)
message(STATUS "→ Building example for ${target}")

if (${target} EQUAL "esp32")
list(APPENDS srcs "epd4spi.cpp")
endif()

# If the project does not use a touch display component FT6X36-IDF can be removed or #commented
idf_component_register(SRCS ${srcs}
REQUIRES "Adafruit-GFX"
Expand Down
37 changes: 37 additions & 0 deletions epd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,40 @@ void Epd::printerf(const char *format, ...) {
void Epd::newline() {
write(10);
}

void Epd::draw_centered_text(const GFXfont *font, int16_t x, int16_t y, uint16_t w, uint16_t h, const char* format, ...) {
// Handle printf arguments
va_list args;
va_start(args, format);
char max_buffer[1024];
int size = vsnprintf(max_buffer, sizeof max_buffer, format, args);
va_end(args);
string text = "";
if (size < sizeof(max_buffer)) {
text = string(max_buffer);

} else {
ESP_LOGE("draw_centered_text", "max_buffer out of range. Increase max_buffer!");
}
// Draw external boundary where text needs to be centered in the middle
setFont(font);
int16_t text_x = 0;
int16_t text_y = 0;
uint16_t text_w = 0;
uint16_t text_h = 0;

getTextBounds(text.c_str(), x, y, &text_x, &text_y, &text_w, &text_h);
//display.drawRect(text_x, text_y, text_w, text_h, EPD_BLACK); // text boundaries

if (text_w > w) {
printf("W: Text width out of bounds");
}
if (text_h > h) {
printf("W: Text height out of bounds");
}
// Calculate the middle position
text_x += (w-text_w)/2;
uint ty = (h/2)+y+(text_h/2);
setCursor(text_x, ty);
print(text);
}
2 changes: 1 addition & 1 deletion include/calepd_version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define CALEPD_VERSION "1.0.9"
#define CALEPD_VERSION "1.1"
7 changes: 2 additions & 5 deletions include/epd.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@ class Epd : public virtual Adafruit_GFX
virtual void init(bool debug = false) = 0;
virtual void update() = 0;

// Partial methods are going to be implemented by each model clases
//virtual void updateWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool using_rotation = true);
// partial update of rectangle at (xs,ys) from buffer to screen at (xd,yd), does not power off
//virtual void updateToWindow(uint16_t xs, uint16_t ys, uint16_t xd, uint16_t yd, uint16_t w, uint16_t h, bool using_rotation = true);

// This are common methods every MODELX will inherit
// hook to Adafruit_GFX::write
size_t write(uint8_t);
Expand All @@ -124,6 +119,8 @@ class Epd : public virtual Adafruit_GFX
void println(const std::string& text);
void printerf(const char *format, ...);
void newline();
void draw_centered_text(const GFXfont *font, int16_t x, int16_t y, uint16_t w, uint16_t h, const char* format, ...);

// Methods that should be accesible by inheriting this abstract class
protected:
// This should be inherited from this abstract class so we don't repeat in every model
Expand Down
70 changes: 70 additions & 0 deletions include/gdem029E97.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// GOODISPLAY product https://www.good-display.com/product/-2.9-inch-partial-refresh-e-paper-display-temperature-sensing,-GDEM029E97-302.html
// Controller: SSD1675A
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "esp_system.h"
#include <stdint.h>
#include <math.h>
#include "sdkconfig.h"
#include "esp_log.h"
#include <string>
#include <epd.h>
#include <Adafruit_GFX.h>
#include <epdspi.h>
#include <gdew_4grays.h>
#include <esp_timer.h>

// All comments below are from J-M Zingg (Ref. EPD)
// The physical number of pixels (for controller parameter) not using this here so will probably fly away
#define GDEM029E97_X_PIXELS 128
#define GDEM029E97_Y_PIXELS 296

// The logical width and height of the display
#define GDEM029E97_WIDTH 128
#define GDEM029E97_HEIGHT 296

#define GDEM029E97_BUFFER_SIZE (uint32_t(GDEM029E97_WIDTH) * uint32_t(GDEM029E97_HEIGHT) / 8)

class Gdem029E97 : public Epd
{
public:
Gdem029E97(EpdSpi& IO);
// Counts only Ink color so BWR will have 2
const uint8_t colors_supported = 1;
const uint8_t partial_supported = 1;
uint8_t spi_optimized = true;

void drawPixel(int16_t x, int16_t y, uint16_t color); // Override GFX own drawPixel method

// EPD tests
void init(bool debug = false);
void setMonoMode(bool mode);
void fillScreen(uint16_t color);
void update();
void eraseDisplay(bool using_partial_update = false);

// Partial update test status please check repository Wiki
void updateWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool using_rotation = true);

private:
EpdSpi& IO;
int partials = 0;
uint8_t _mono_buffer[GDEM029E97_BUFFER_SIZE];
uint8_t _buffer1[GDEM029E97_BUFFER_SIZE];
uint8_t _buffer2[GDEM029E97_BUFFER_SIZE];
uint8_t vcom=0x26;
bool debug_enabled = false;

void _wakeUp();
void _wakeUpPartial();
void _sleep();

void _waitBusy(const char* message);
void _rotate(uint16_t& x, uint16_t& y, uint16_t& w, uint16_t& h);
// Ram data entry mode methods
void _setRamDataEntryMode(uint8_t em);
void _SetRamArea(uint8_t Xstart, uint8_t Xend, uint8_t Ystart, uint8_t Ystart1, uint8_t Yend, uint8_t Yend1);
void _SetRamPointer(uint8_t addrX, uint8_t addrY, uint8_t addrY1);
};
70 changes: 70 additions & 0 deletions include/goodisplay/gdeq037T31.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// GOODISPLAY product page still not online
// Controller: UC8253
// GDEQ037T31_416x240
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "esp_system.h"
#include <stdint.h>
#include <math.h>
#include "sdkconfig.h"
#include "esp_log.h"
#include <string>
#include <epd.h>
#include <Adafruit_GFX.h>
#include <epdspi.h>
#include <gdew_4grays.h>
#include <esp_timer.h>

// Display dimensions
#define GDEQ037T31_WIDTH 240
#define GDEQ037T31_HEIGHT 416

#define GDEQ037T31_BUFFER_SIZE (uint32_t(GDEQ037T31_WIDTH) * uint32_t(GDEQ037T31_HEIGHT) / 8)

// 1 byte of this color in the buffer
#define GDEQ037T31_8PIX_BLACK 0xFF
#define GDEQ037T31_8PIX_WHITE 0x00

class Gdeq037T31 : public Epd
{
public:
Gdeq037T31(EpdSpi& IO);
bool fast_mode = false;

// Counts only Ink color so BWR will have 2
const uint8_t colors_supported = 1;
const uint8_t partial_supported = 1;
uint16_t total_updates = 0;
bool spi_optimized = true;

void drawPixel(int16_t x, int16_t y, uint16_t color); // Override GFX own drawPixel method

// EPD tests
void init(bool debug = false);
void initFullUpdate();
void initPartialUpdate();
void setMonoMode(bool mode); // No idea if supports 4 grays
void fillScreen(uint16_t color);
void update();

// Partial update test status please check repository Wiki
void updateWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool using_rotation = true);

private:
EpdSpi& IO;
bool _mono_mode = false;
bool _partial_mode = false;
bool debug_enabled = false;
uint8_t _mono_buffer[GDEQ037T31_BUFFER_SIZE];
uint8_t _old_buffer[GDEQ037T31_BUFFER_SIZE];


void _wakeUp();
void _sleep();

void _waitBusy(const char* message);
void _rotate(uint16_t& x, uint16_t& y, uint16_t& w, uint16_t& h);
uint16_t _setPartialRamArea(uint16_t x, uint16_t y, uint16_t xe, uint16_t ye);
};
Loading

0 comments on commit 4b0c193

Please sign in to comment.