Skip to content

Commit

Permalink
Merge branch 'refactor/oop'
Browse files Browse the repository at this point in the history
  • Loading branch information
martinberlin committed Mar 11, 2021
2 parents 04c2a64 + bcda304 commit b166180
Show file tree
Hide file tree
Showing 23 changed files with 2,846 additions and 94 deletions.
2 changes: 2 additions & 0 deletions components/CalEPD/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Add only the display srcs you are going to use if you want to keep compiled srcs to a minimum:
set(srcs
"models/wave12i48.cpp"
"models/gdew075HD.cpp"
"models/gdew075T7.cpp"
"models/gdew075T8.cpp"
"models/gdew0583t7.cpp"
Expand Down Expand Up @@ -34,6 +35,7 @@ set(srcs

# Parallel epapers supported by Epdiy driver (Component)
"models/parallel/ED047TC1.cpp"
"models/parallel/ED047TC1touch.cpp"

# Pending for more testing:
"models/gdeh0213b73.cpp"
Expand Down
2 changes: 1 addition & 1 deletion components/CalEPD/include/calepd_version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define CALEPD_VERSION "1.0.2"
#define CALEPD_VERSION "1.0.3"
6 changes: 1 addition & 5 deletions components/CalEPD/include/epdParallel.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#ifndef epd_h
#define epd_h

#include <calepd_version.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -39,7 +36,7 @@ class EpdParallel : public virtual Adafruit_GFX
void newline();

// Methods that should be accesible by inheriting this abstract class
protected:
protected:
// This should be inherited from this abstract class so we don't repeat in every model
static inline uint16_t gx_uint16_min(uint16_t a, uint16_t b) {return (a < b ? a : b);};
static inline uint16_t gx_uint16_max(uint16_t a, uint16_t b) {return (a > b ? a : b);};
Expand All @@ -60,4 +57,3 @@ class EpdParallel : public virtual Adafruit_GFX
uint8_t _unicodeEasy(uint8_t c);
// Command & data structs should be implemented by every MODELX display
};
#endif
57 changes: 57 additions & 0 deletions components/CalEPD/include/gdew075HD.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// 7.5 HD 880*528 b/w Controller: ??
#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 "soc/rtc_wdt.h"
#include <gdew_colors.h>

#define GDEW075HD_WIDTH 880
#define GDEW075HD_HEIGHT 528

// EPD comment: Pixel number expressed in bytes; this is neither the buffer size nor the size of the buffer in the controller
// We are not adding page support so here this is our Buffer size
#define GDEW075HD_BUFFER_SIZE (uint32_t(GDEW075HD_WIDTH) * uint32_t(GDEW075HD_HEIGHT) / 8)
// 8 pix of this color in a buffer byte:
#define GDEW075HD_8PIX_BLACK 0x00
#define GDEW075HD_8PIX_WHITE 0xFF

class Gdew075HD : public Epd
{
public:

Gdew075HD(EpdSpi& IO);
uint8_t colors_supported = 1;

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

// EPD tests
void init(bool debug = false);

// Partial update of rectangle from buffer to screen, does not power off
void updateWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool using_rotation);
void fillScreen(uint16_t color);
void update();

private:
EpdSpi& IO;

uint8_t _buffer[GDEW075HD_BUFFER_SIZE];
bool _using_partial_mode = false;
bool _initial = true;

uint16_t _setPartialRamArea(uint16_t x, uint16_t y, uint16_t xe, uint16_t ye);
void _wakeUp();
void _sleep();
void _waitBusy(const char* message);
void _rotate(uint16_t& x, uint16_t& y, uint16_t& w, uint16_t& h);
};
11 changes: 4 additions & 7 deletions components/CalEPD/include/parallel/ED047TC1.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
#define EPD_SDGRAY 25
#define EPD_BLACK 0

// 1 byte of this color in the buffer
// This needs to be refactored since this display uses 4 bit per pixel

class Ed047TC1 : public EpdParallel
{
public:
Expand All @@ -48,13 +45,13 @@ class Ed047TC1 : public EpdParallel

void fillScreen(uint16_t color);
void update(enum DrawMode mode = BLACK_ON_WHITE);

// Partial update of rectangle from buffer to screen, does not power off
// Pending implementation
void updateWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool using_rotation = true);
void updateWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h, enum DrawMode mode = BLACK_ON_WHITE, bool using_rotation = true);

private:
bool color = false;
bool _tempalert = false;
bool _initial = true;
bool _debug_buffer = false;
void _rotate(uint16_t& x, uint16_t& y, uint16_t& w, uint16_t& h);
};
66 changes: 66 additions & 0 deletions components/CalEPD/include/parallel/ED047TC1touch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#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 <epdParallel.h>
#include <Adafruit_GFX.h>
#include <epdspi.h>
#include "epd_driver.h"
#include "L58Touch.h" // Touch interface

#define HAS_16_LEVELS_GRAY 1
#define ED047TC1_WIDTH 960
#define ED047TC1_HEIGHT 540

// COLOR defines (Only 8 but actually this epapers have 16 levels)
#define EPD_WHITE 255
#define EPD_WHITISH 223
#define EPD_SLGRAY 200
#define EPD_LGRAY 150
#define EPD_GRAY 100
#define EPD_DGRAY 50
#define EPD_SDGRAY 25
#define EPD_BLACK 0


class Ed047TC1t : public EpdParallel
{
public:
Ed047TC1t(L58Touch& ts);

uint8_t *framebuffer;
uint8_t colors_supported = 1;

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

void init(bool debug = false);
void clearScreen();
void clearArea(Rect_t area);
void powerOn();
void powerOff();

void fillScreen(uint16_t color);
void update(enum DrawMode mode = BLACK_ON_WHITE);
// Partial update of rectangle from buffer to screen, does not power off
void updateWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h, enum DrawMode mode = BLACK_ON_WHITE, bool using_rotation = true);

// Touch methods
void touchLoop();
void registerTouchHandler(void(*fn)(TPoint point, TEvent e));
void(*_touchHandler)(TPoint point, TEvent e) = nullptr;
void displayRotation(uint8_t rotation); // Rotates both Epd & Touch

private:
L58Touch& Touch;

bool color = false;
bool _initial = true;
bool _debug_buffer = false;
void _rotate(uint16_t& x, uint16_t& y, uint16_t& w, uint16_t& h);
};
Loading

0 comments on commit b166180

Please sign in to comment.