71 lines
2.1 KiB
C++
71 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include <SPI.h>
|
|
#include <Wire.h>
|
|
|
|
#define ENABLE_GxEPD2_GFX 0
|
|
|
|
#include <GxEPD2_BW.h>
|
|
#include <GxEPD2_3C.h>
|
|
#include <GxEPD2_4C.h>
|
|
#include <GxEPD2_7C.h>
|
|
#include <Fonts/FreeSans9pt7b.h>
|
|
#include <Fonts/FreeSansBold12pt7b.h>
|
|
#include <Fonts/FreeSans18pt7b.h>
|
|
|
|
#include <epd/GxEPD2_150_BN.h> // 1.54" b/w
|
|
#include <epd/GxEPD2_213_B74.h> // 2.13" b/w
|
|
#include <CRC32.h>
|
|
|
|
#include "DisplayDriver.h"
|
|
|
|
//GxEPD2_BW<GxEPD2_150_BN, 200> display(GxEPD2_150_BN(DISP_CS, DISP_DC, DISP_RST, DISP_BUSY)); // DEPG0150BN 200x200, SSD1681, TTGO T5 V2.4.1
|
|
|
|
|
|
class GxEPDDisplay : public DisplayDriver {
|
|
|
|
#if defined(EINK_DISPLAY_MODEL)
|
|
GxEPD2_BW<EINK_DISPLAY_MODEL, EINK_DISPLAY_MODEL::HEIGHT> display;
|
|
const float scale_x = EINK_SCALE_X;
|
|
const float scale_y = EINK_SCALE_Y;
|
|
const float offset_x = EINK_X_OFFSET;
|
|
const float offset_y = EINK_Y_OFFSET;
|
|
#else
|
|
GxEPD2_BW<GxEPD2_150_BN, 200> display;
|
|
const float scale_x = 1.5625f;
|
|
const float scale_y = 1.5625f;
|
|
const float offset_x = 0;
|
|
const float offset_y = 10;
|
|
#endif
|
|
bool _init = false;
|
|
bool _isOn = false;
|
|
uint16_t _curr_color;
|
|
CRC32 display_crc;
|
|
int last_display_crc_value = 0;
|
|
|
|
public:
|
|
// there is a margin in y...
|
|
#if defined(EINK_DISPLAY_MODEL)
|
|
GxEPDDisplay() : DisplayDriver(128, 128), display(EINK_DISPLAY_MODEL(PIN_DISPLAY_CS, PIN_DISPLAY_DC, PIN_DISPLAY_RST, PIN_DISPLAY_BUSY)) {}
|
|
#else
|
|
GxEPDDisplay() : DisplayDriver(128, 128), display(GxEPD2_150_BN(DISP_CS, DISP_DC, DISP_RST, DISP_BUSY)) {}
|
|
#endif
|
|
|
|
bool begin();
|
|
|
|
bool isOn() override {return _isOn;};
|
|
void turnOn() override;
|
|
void turnOff() override;
|
|
void clear() override;
|
|
void startFrame(Color bkg = DARK) override;
|
|
void setTextSize(int sz) override;
|
|
void setColor(Color c) override;
|
|
void setCursor(int x, int y) override;
|
|
void print(const char* str) override;
|
|
void fillRect(int x, int y, int w, int h) override;
|
|
void drawRect(int x, int y, int w, int h) override;
|
|
void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override;
|
|
uint16_t getTextWidth(const char* str) override;
|
|
void endFrame() override;
|
|
};
|