Skip to content

Commit 08a591e

Browse files
author
Lisandro
committed
Now its sending the resolution to the display
UC8151D now sets the display resolution
1 parent d53eec3 commit 08a591e

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

src/drivers/Adafruit_UC8151D.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include "Adafruit_EPD.h"
33

44
#define EPD_RAM_BW 0x10
5-
65
#define BUSY_WAIT 500
76

87
/**************************************************************************/
@@ -26,6 +25,9 @@ Adafruit_UC8151D::Adafruit_UC8151D(int width, int height, int16_t SID,
2625
int16_t BUSY)
2726
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY) {
2827

28+
horizontalResolution = width;
29+
verticalResolution = height;
30+
2931
if ((width % 8) != 0) {
3032
width += 8 - (width % 8);
3133
}
@@ -62,6 +64,9 @@ Adafruit_UC8151D::Adafruit_UC8151D(int width, int height, int16_t DC,
6264
int16_t BUSY, SPIClass *spi)
6365
: Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY, spi) {
6466

67+
horizontalResolution = width;
68+
verticalResolution = height;
69+
6570
if ((height % 8) != 0) {
6671
height += 8 - (height % 8);
6772
}
@@ -138,6 +143,7 @@ void Adafruit_UC8151D::powerUp() {
138143
init_code = _epd_init_code;
139144
}
140145
EPD_commandList(init_code);
146+
sendResolution();
141147

142148
if (_epd_lut_code) {
143149
EPD_commandList(_epd_lut_code);
@@ -195,6 +201,22 @@ void Adafruit_UC8151D::setRAMAddress(uint16_t x, uint16_t y) {
195201
(void)y;
196202
}
197203

204+
/**************************************************************************/
205+
/*!
206+
@brief Sends the resolution to the EPD
207+
*/
208+
/**************************************************************************/
209+
void Adafruit_UC8151D::sendResolution() {
210+
const uint8_t uc8151d_resolution_init_code[]{
211+
UC8151D_TRES,
212+
3,
213+
verticalResolution,
214+
(uint8_t)((horizontalResolution & 0xFF00) >> 8),
215+
(uint8_t)(horizontalResolution & 0x00FF),
216+
0xFE};
217+
EPD_commandList(uc8151d_resolution_init_code);
218+
}
219+
198220
/**************************************************************************/
199221
/*!
200222
@brief Transfer the data stored in the buffer(s) to the display

src/drivers/Adafruit_UC8151D.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#define UC8151D_PBC 0x44
2727
#define UC8151D_CDI 0x50
2828
#define UC8151D_LPD 0x51
29-
#define UC8151D_TRES 0x65
29+
#define UC8151D_TRES 0x61
3030
#define UC8151D_GSST 0x70
3131
#define UC8151D_REV 0x70
3232
#define UC8151D_FLG 0x71
@@ -57,7 +57,6 @@ const uint8_t uc8151d_trifull_init_code[] {
5757
UC8151D_PON, 0,
5858
0xFF, 10,
5959
UC8151D_PSR, 2, 0x0F, 0x89,
60-
0x61, 3, 0x80, 0x01, 0x28,
6160
UC8151D_CDI, 1, 0x77,
6261
0xFE};
6362

@@ -69,7 +68,6 @@ const uint8_t uc8151d_partial_init_code[] {
6968
0xFF, 10,
7069
UC8151D_PSR, 1, 0xBF, //LUT from OTP 128x296
7170
UC8151D_PLL, 1, 0x3C, // 3A 100HZ 29 150Hz 39 200HZ 31 171HZ
72-
0x61, 3, 0x80, 0x01, 0x28, //resolution setting
7371
UC8151D_VDCS, 1, 0x12, //vcom_DC setting
7472
UC8151D_CDI, 1, 0x47,
7573
0xFE};
@@ -149,9 +147,12 @@ class Adafruit_UC8151D : public Adafruit_EPD {
149147
void displayPartial(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
150148

151149
protected:
150+
uint8_t verticalResolution;
151+
uint16_t horizontalResolution;
152152
uint8_t writeRAMCommand(uint8_t index);
153153
void setRAMAddress(uint16_t x, uint16_t y);
154154
void busy_wait();
155+
void sendResolution();
155156
};
156157

157158
#endif

0 commit comments

Comments
 (0)