add support for 4.2 inch epaper display from WeAct Studio (partial up… (#21717)

* add support for 4.2 inch epaper display from WeAct Studio (partial update)

* make ep_mode=3 decision more clear, reinserted an mistakenly removed comment

---------

Co-authored-by: timehlers <>
This commit is contained in:
timehlers 2024-07-08 17:25:06 +02:00 committed by GitHub
parent 105a08dd20
commit a3048a0b25
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 95 additions and 13 deletions

View File

@ -707,6 +707,11 @@ void UfsCheckSDCardInit(void);
}
#endif
if ((epcoffs_full || epcoffs_part) && !(lutfsize || lutpsize)) {
// no lutfsize or lutpsize, but epcoffs_full or epcoffs_part
ep_mode = 3;
}
#ifdef UDSP_DEBUG
Serial.printf("Device : %s\n", dname);
Serial.printf("xs : %d\n", gxs);
@ -907,7 +912,7 @@ uint16_t index = 0;
SPI_CS_LOW
iob = dsp_cmds[cmd_offset++];
index++;
if (ep_mode == 1 && iob >= EP_RESET) {
if ((ep_mode == 1 || ep_mode == 3) && iob >= EP_RESET) {
// epaper pseudo opcodes
uint8_t args = dsp_cmds[cmd_offset++];
index++;
@ -3429,6 +3434,9 @@ void uDisplay::Init_EPD(int8_t p) {
if (ep_mode == 1) {
ClearFrameMemory(0xFF);
Updateframe_EPD();
} else if (ep_mode == 3) {
ClearFrameMemory(0xFF);
Updateframe_EPD();
} else {
ClearFrame_42();
}
@ -3518,7 +3526,7 @@ void uDisplay::SetLut(const unsigned char* lut) {
}
void uDisplay::Updateframe_EPD(void) {
if (ep_mode == 1) {
if (ep_mode == 1 || ep_mode == 3) {
switch (ep_update_mode) {
case DISPLAY_INIT_PARTIAL:
if (epc_part_cnt) {
@ -3547,15 +3555,33 @@ void uDisplay::DisplayFrame_29(void) {
}
void uDisplay::SetMemoryArea(int x_start, int y_start, int x_end, int y_end) {
spi_command_EPD(SET_RAM_X_ADDRESS_START_END_POSITION);
int x_start1 = (x_start >> 3) & 0xFF;
int x_end1 = (x_end >> 3) & 0xFF;
int y_start1 = y_start & 0xFF;
int y_start2 = (y_start >> 8) & 0xFF;
int y_end1 = y_end & 0xFF;
int y_end2 = (y_end >> 8) & 0xFF;
/* x point must be the multiple of 8 or the last 3 bits will be ignored */
spi_data8_EPD((x_start >> 3) & 0xFF);
spi_data8_EPD((x_end >> 3) & 0xFF);
spi_command_EPD(SET_RAM_Y_ADDRESS_START_END_POSITION);
spi_data8_EPD(y_start & 0xFF);
spi_data8_EPD((y_start >> 8) & 0xFF);
spi_data8_EPD(y_end & 0xFF);
spi_data8_EPD((y_end >> 8) & 0xFF);
if (ep_mode == 3) {
spi_command_EPD(SET_RAM_X_ADDRESS_START_END_POSITION);
spi_data8_EPD(x_start1);
spi_data8_EPD(x_end1);
spi_command_EPD(SET_RAM_Y_ADDRESS_START_END_POSITION);
spi_data8_EPD(y_end1);
spi_data8_EPD(y_end2);
spi_data8_EPD(y_start1);
spi_data8_EPD(y_start2);
} else {
spi_command_EPD(SET_RAM_X_ADDRESS_START_END_POSITION);
spi_data8_EPD(x_start1);
spi_data8_EPD(x_end1);
spi_command_EPD(SET_RAM_Y_ADDRESS_START_END_POSITION);
spi_data8_EPD(y_start1);
spi_data8_EPD(y_start2);
spi_data8_EPD(y_end1);
spi_data8_EPD(y_end2);
}
}
void uDisplay::SetFrameMemory(const unsigned char* image_buffer) {
@ -3569,12 +3595,27 @@ void uDisplay::SetFrameMemory(const unsigned char* image_buffer) {
}
void uDisplay::SetMemoryPointer(int x, int y) {
int x1;
int y1;
int y2;
if (ep_mode == 3) {
x1 = (x >> 3) & 0xFF;
y--;
y1 = y & 0xFF;
y2 = (y >> 8) & 0xFF;
} else {
x1 = (x >> 3) & 0xFF;
y1 = y & 0xFF;
y2 = (y >> 8) & 0xFF;
}
spi_command_EPD(SET_RAM_X_ADDRESS_COUNTER);
/* x point must be the multiple of 8 or the last 3 bits will be ignored */
spi_data8_EPD((x >> 3) & 0xFF);
spi_data8_EPD(x1);
spi_command_EPD(SET_RAM_Y_ADDRESS_COUNTER);
spi_data8_EPD(y & 0xFF);
spi_data8_EPD((y >> 8) & 0xFF);
spi_data8_EPD(y1);
spi_data8_EPD(y2);
}
#if 0

View File

@ -0,0 +1,41 @@
:H,E-PAPER-42-WeAct,400,300,1,SPI,4,*,*,*,*,*,*,*,10
:S,1,1,1,0,10,10
:I
12,0
63,1,80
01,3,2b,01,01
3c,1,01
67,0;
20,0
63,1,80
24,0
66,0
20,0
63,1,80
62,0
:f
64,0
65,0
24,0
66,0
21,2,40,00
22,1,f7
20,0
63,1,80
:p
62,0
22,1,c0
20,0
63,1,80
64,0
65,0
24,0
66,0
21,2,00,00
22,1,fc
20,0
63,1,80
62,0
:T,350,35,10
#