Paperd.Ink Library 0.0.5
Library for interacting with Paperd.Ink devices.
Loading...
Searching...
No Matches
GxEPD2_1248.h
Go to the documentation of this file.
1// Display Library for SPI e-paper panels from Dalian Good Display and boards from Waveshare.
2// Requires HW SPI and Adafruit_GFX. Caution: the e-paper panels require 3.3V supply AND data lines!
3//
4// based on Demo Example from Good Display:
5// Panel: GDEW1248T3 : http://www.e-paper-display.com/products_detail/productId=414.html
6// Controller: IL0326 : http://www.e-paper-display.com/download_detail/downloadsId=768.html
7//
8// Author: Jean-Marc Zingg
9//
10// Version: see library.properties
11//
12// Library: https://github.com/ZinggJM/GxEPD2
13
14#ifndef _GxEPD2_1248_H_
15#define _GxEPD2_1248_H_
16
17#include "../GxEPD2_EPD.h"
18
19class GxEPD2_1248 : public GxEPD2_EPD
20{
21 public:
22 // attributes
23 static const uint16_t WIDTH = 1304;
24 static const uint16_t HEIGHT = 984;
26 static const bool hasColor = false;
27 static const bool hasPartialUpdate = true;
28 static const bool hasFastPartialUpdate = true; // set this false to force full refresh always
29 static const uint16_t power_on_time = 200; // ms, e.g. 131001us
30 static const uint16_t power_off_time = 50; // ms, e.g. 41001us
31 static const uint16_t full_refresh_time = 4600; // ms, e.g. 4579001us
32 static const uint16_t partial_refresh_time = 1600; // ms, e.g. 1525001us
33 // constructors
34#if defined(ESP32)
35 // general constructor for use with all parameters on ESP32, e.g. for Waveshare ESP32 driver board mounted on connection board
36 GxEPD2_1248(int16_t sck, int16_t miso, int16_t mosi,
37 int16_t cs_m1, int16_t cs_s1, int16_t cs_m2, int16_t cs_s2,
38 int16_t dc1, int16_t dc2, int16_t rst1, int16_t rst2,
39 int16_t busy_m1, int16_t busy_s1, int16_t busy_m2, int16_t busy_s2);
40#endif
41 // general constructor for use with standard SPI pins, default SCK, MISO and MOSI
42 GxEPD2_1248(int16_t cs_m1, int16_t cs_s1, int16_t cs_m2, int16_t cs_s2,
43 int16_t dc1, int16_t dc2, int16_t rst1, int16_t rst2,
44 int16_t busy_m1, int16_t busy_s1, int16_t busy_m2, int16_t busy_s2);
45 // constructor with minimal parameter set, standard SPI, dc1 and dc2, rst1 and rst2 to one pin, one busy used (can be -1)
46 GxEPD2_1248(int16_t cs_m1, int16_t cs_s1, int16_t cs_m2, int16_t cs_s2, int16_t dc, int16_t rst, int16_t busy);
47 // methods (virtual)
48 void init(uint32_t serial_diag_bitrate = 0); // serial_diag_bitrate = 0 : disabled
49 void init(uint32_t serial_diag_bitrate, bool initial, uint16_t reset_duration = 20, bool pulldown_rst_mode = false);
50 // Support for Bitmaps (Sprites) to Controller Buffer and to Screen
51 void clearScreen(uint8_t value = 0xFF); // init controller memory and screen (default white)
52 void writeScreenBuffer(uint8_t value = 0xFF); // init controller memory (default white)
53 void writeScreenBufferAgain(uint8_t value = 0xFF); // init previous buffer controller memory (default white)
54 // write to controller memory, without screen refresh; x and w should be multiple of 8
55 void writeImage(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
56 void writeImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
57 int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
58 void writeImage(const uint8_t* black, const uint8_t* color, int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
59 void writeImagePart(const uint8_t* black, const uint8_t* color, int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
60 int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
61 // for differential update: set current and previous buffers equal (for fast partial update to work correctly)
62 void writeImageAgain(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
63 void writeImagePartAgain(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
64 int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
65 // write sprite of native data to controller memory, without screen refresh; x and w should be multiple of 8
66 void writeNative(const uint8_t* data1, const uint8_t* data2, int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
67 // write to controller memory, with screen refresh; x and w should be multiple of 8
68 void drawImage(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
69 void drawImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
70 int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
71 void drawImage(const uint8_t* black, const uint8_t* color, int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
72 void drawImagePart(const uint8_t* black, const uint8_t* color, int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
73 int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
74 // write sprite of native data to controller memory, with screen refresh; x and w should be multiple of 8
75 void drawNative(const uint8_t* data1, const uint8_t* data2, int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
76 void refresh(bool partial_update_mode = false); // screen refresh from controller memory to full screen
77 void refresh(int16_t x, int16_t y, int16_t w, int16_t h); // screen refresh from controller memory, partial screen
78 void powerOff(); // turns off generation of panel driving voltages, avoids screen fading over time
79 void hibernate(); // turns powerOff() and sets controller to deep sleep for minimum power use, ONLY if wakeable by RST (rst >= 0)
80 private:
81 void _reset();
82 void _initSPI();
83 void _setPartialRamArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
84 void _PowerOn();
85 void _PowerOff();
86 void _InitDisplay();
87 void _Init_Full();
88 void _Init_Part();
89 void _Update_Full();
90 void _Update_Part();
91 void _writeCommandMaster(uint8_t c);
92 void _writeDataMaster(uint8_t d);
93 void _writeCommandAll(uint8_t c);
94 void _writeDataAll(uint8_t d);
95 void _writeDataPGM_All(const uint8_t* data, uint16_t n, int16_t fill_with_zeroes = 0);
96 void _waitWhileAnyBusy(const char* comment = 0, uint16_t busy_time = 5000);
97 void _getMasterTemperature();
98 private:
99 friend class GDEW1248T3_OTP;
100 void _readController(uint8_t cmd, uint8_t* data, uint16_t n, int8_t cs = -1, int8_t dc = -1);
101 private:
102 int16_t _sck, _miso, _mosi, _dc1, _dc2, _rst1, _rst2;
103 int16_t _cs_m1, _cs_s1, _cs_m2, _cs_s2;
104 int16_t _busy_m1, _busy_s1, _busy_m2, _busy_s2;
105 int8_t _temperature;
106 static const unsigned char lut_20_LUTC_partial[];
107 static const unsigned char lut_21_LUTWW_partial[];
108 static const unsigned char lut_22_LUTKW_partial[];
109 static const unsigned char lut_23_LUTWK_partial[];
110 static const unsigned char lut_24_LUTKK_partial[];
111 static const unsigned char lut_25_LUTBD_partial[];
112 private:
113 class ScreenPart
114 {
115 public:
116 ScreenPart(uint16_t width, uint16_t height, bool rev_scan, int16_t cs, int16_t dc);
117 void writeScreenBuffer(uint8_t command, uint8_t value = 0xFF); // init controller memory current (default white)
118 void writeImagePart(uint8_t command, const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
119 int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
120 void writeCommand(uint8_t c);
121 void writeData(uint8_t d);
122 private:
123 void _setPartialRamArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
124 void _startTransfer();
125 void _transfer(uint8_t value);
126 void _endTransfer();
127 public:
128 const uint16_t WIDTH, HEIGHT;
129 private:
130 bool _rev_scan;
131 int16_t _cs, _dc;
132 const SPISettings _spi_settings;
133 };
134 ScreenPart M1, S1, M2, S2;
135};
136
137#endif
void init(uint32_t serial_diag_bitrate=0)
void writeImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap, int16_t x, int16_t y, int16_t w, int16_t h, bool invert=false, bool mirror_y=false, bool pgm=false)
void refresh(bool partial_update_mode=false)
static const uint16_t partial_refresh_time
Definition GxEPD2_1248.h:32
static const bool hasFastPartialUpdate
Definition GxEPD2_1248.h:28
friend class GDEW1248T3_OTP
Definition GxEPD2_1248.h:99
static const bool hasPartialUpdate
Definition GxEPD2_1248.h:27
static const uint16_t full_refresh_time
Definition GxEPD2_1248.h:31
void writeNative(const uint8_t *data1, const uint8_t *data2, int16_t x, int16_t y, int16_t w, int16_t h, bool invert=false, bool mirror_y=false, bool pgm=false)
static const uint16_t power_off_time
Definition GxEPD2_1248.h:30
void drawImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap, int16_t x, int16_t y, int16_t w, int16_t h, bool invert=false, bool mirror_y=false, bool pgm=false)
static const uint16_t power_on_time
Definition GxEPD2_1248.h:29
void writeImageAgain(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert=false, bool mirror_y=false, bool pgm=false)
GxEPD2_1248(int16_t cs_m1, int16_t cs_s1, int16_t cs_m2, int16_t cs_s2, int16_t dc1, int16_t dc2, int16_t rst1, int16_t rst2, int16_t busy_m1, int16_t busy_s1, int16_t busy_m2, int16_t busy_s2)
static const bool hasColor
Definition GxEPD2_1248.h:26
void writeScreenBufferAgain(uint8_t value=0xFF)
void clearScreen(uint8_t value=0xFF)
static const uint16_t HEIGHT
Definition GxEPD2_1248.h:24
void writeImage(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert=false, bool mirror_y=false, bool pgm=false)
void writeScreenBuffer(uint8_t value=0xFF)
void drawImage(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert=false, bool mirror_y=false, bool pgm=false)
static const uint16_t WIDTH
Definition GxEPD2_1248.h:23
void drawNative(const uint8_t *data1, const uint8_t *data2, int16_t x, int16_t y, int16_t w, int16_t h, bool invert=false, bool mirror_y=false, bool pgm=false)
void writeImagePartAgain(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap, int16_t x, int16_t y, int16_t w, int16_t h, bool invert=false, bool mirror_y=false, bool pgm=false)
static const GxEPD2::Panel panel
Definition GxEPD2_1248.h:25
Panel
Definition GxEPD2.h:37
@ GDEW1248T3
Definition GxEPD2.h:74