mirror of
https://github.com/WeActStudio/WeActStudio.EpaperModule.git
synced 2026-08-16 13:13:45 +02:00
add 4.2 inch epaper module examples
This commit is contained in:
@@ -208,6 +208,7 @@ uint8_t epd_init(void)
|
||||
if (epd_wait_busy())
|
||||
return 1;
|
||||
|
||||
#if defined(EPD_29) || defined(EPD_213) || defined(EPD_154)
|
||||
epd_write_reg(0x01); // Driver output control
|
||||
#if defined(EPD_29) || defined(EPD_213)
|
||||
epd_write_data(0x27);
|
||||
@@ -251,6 +252,21 @@ uint8_t epd_init(void)
|
||||
epd_write_reg(0x21); // Display update control
|
||||
epd_write_data(0x00);
|
||||
epd_write_data(0x80);
|
||||
#endif
|
||||
|
||||
#elif defined(EPD_42)
|
||||
epd_write_reg(0x21); // Display Update Controll
|
||||
epd_write_data(0x40);
|
||||
epd_write_data(0x00);
|
||||
epd_write_reg(0x01); // Set MUX as 300
|
||||
epd_write_data(0x2B);
|
||||
epd_write_data(0x01);
|
||||
epd_write_data(0x00);
|
||||
epd_write_reg(0x3C); //BorderWavefrom
|
||||
epd_write_data(0x01);
|
||||
epd_write_reg(0x11); // data entry mode
|
||||
epd_write_data(0x03); // X-mode
|
||||
epd_address_set(0,0,EPD_W-1,EPD_H-1);
|
||||
#endif
|
||||
|
||||
epd_write_reg(0x18); // Read built-in temperature sensor
|
||||
@@ -278,6 +294,12 @@ uint8_t epd_init_partial(void)
|
||||
}
|
||||
_epd_write_data_over();
|
||||
epd_cs_set();
|
||||
#elif defined(EPD_42)
|
||||
epd_write_reg(0x3C); //BorderWavefrom
|
||||
epd_write_data(0x80);
|
||||
epd_write_reg(0x21); // Display Update Controll
|
||||
epd_write_data(0x00); // RED normal
|
||||
epd_write_data(0x00); // single chip application
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
@@ -293,8 +315,13 @@ epd_power_off();
|
||||
|
||||
uint8_t epd_power_on(void)
|
||||
{
|
||||
#if defined EPD_42
|
||||
epd_write_reg(0x22); // Display Update Control
|
||||
epd_write_data(0xe0);
|
||||
#else
|
||||
epd_write_reg(0x22); // Display Update Control
|
||||
epd_write_data(0xf8);
|
||||
#endif
|
||||
epd_write_reg(0x20); // Activate Display Update Sequence
|
||||
|
||||
return epd_wait_busy();
|
||||
@@ -316,15 +343,20 @@ void epd_init_internalTempSensor(void)
|
||||
|
||||
epd_write_reg(0x1A);
|
||||
epd_write_data(0x7F);
|
||||
epd_write_data(0xF0);
|
||||
// epd_write_data(0xF0);
|
||||
}
|
||||
|
||||
void epd_update(void)
|
||||
{
|
||||
|
||||
#ifdef EPD_154
|
||||
epd_write_reg(0x22); // Display Update Control
|
||||
#ifdef EPD_154
|
||||
epd_write_data(0xF4);
|
||||
#elif defined EPD_42
|
||||
epd_write_reg(0x22); // Display Update Control
|
||||
epd_write_data(0xF7);
|
||||
#else
|
||||
epd_write_reg(0x22); // Display Update Control
|
||||
epd_write_data(0xF7);
|
||||
#endif
|
||||
epd_write_reg(0x20); // Activate Display Update Sequence
|
||||
@@ -334,10 +366,14 @@ void epd_update(void)
|
||||
|
||||
void epd_update_partial(void)
|
||||
{
|
||||
#ifdef EPD_154
|
||||
epd_write_reg(0x22); // Display Update Control
|
||||
#ifdef EPD_154
|
||||
epd_write_data(0xFC);
|
||||
#elif defined EPD_42
|
||||
epd_write_reg(0x22); // Display Update Control
|
||||
epd_write_data(0xFF);
|
||||
#else
|
||||
epd_write_reg(0x22); // Display Update Control
|
||||
epd_write_data(0xCC);
|
||||
#endif
|
||||
epd_write_reg(0x20); // Activate Display Update Sequence
|
||||
@@ -345,6 +381,19 @@ void epd_update_partial(void)
|
||||
epd_wait_busy();
|
||||
}
|
||||
|
||||
void epd_address_set(uint16_t x_start,uint16_t y_start,uint16_t x_end,uint16_t y_end)
|
||||
{
|
||||
epd_write_reg(0x44); // SET_RAM_X_ADDRESS_START_END_POSITION
|
||||
epd_write_data((x_start>>3) & 0xFF);
|
||||
epd_write_data((x_end>>3) & 0xFF);
|
||||
|
||||
epd_write_reg(0x45); // SET_RAM_Y_ADDRESS_START_END_POSITION
|
||||
epd_write_data(y_start & 0xFF);
|
||||
epd_write_data((y_start >> 8) & 0xFF);
|
||||
epd_write_data(y_end & 0xFF);
|
||||
epd_write_data((y_end >> 8) & 0xFF);
|
||||
}
|
||||
|
||||
void epd_setpos(uint16_t x, uint16_t y)
|
||||
{
|
||||
uint8_t _x;
|
||||
@@ -354,8 +403,10 @@ void epd_setpos(uint16_t x, uint16_t y)
|
||||
|
||||
#ifdef EPD_154
|
||||
_y = 199 - y;
|
||||
#else
|
||||
#elif defined(EPD_29) || defined(EPD_213)
|
||||
_y = 295 - y;
|
||||
#elif defined(EPD_42)
|
||||
_y = y;
|
||||
#endif
|
||||
|
||||
epd_write_reg(0x4E); // set RAM x address count to 0;
|
||||
@@ -376,6 +427,17 @@ void epd_writedata(uint8_t *Image1, uint32_t length)
|
||||
epd_cs_set();
|
||||
}
|
||||
|
||||
void epd_writedata2(uint8_t data, uint32_t length)
|
||||
{
|
||||
epd_cs_reset();
|
||||
for (uint32_t j = 0; j < length; j++)
|
||||
{
|
||||
_epd_write_data(data);
|
||||
}
|
||||
_epd_write_data_over();
|
||||
epd_cs_set();
|
||||
}
|
||||
|
||||
void epd_display(uint8_t *Image1, uint8_t *Image2)
|
||||
{
|
||||
uint32_t Width, Height, i, j;
|
||||
@@ -404,6 +466,12 @@ void epd_display(uint8_t *Image1, uint8_t *Image2)
|
||||
_epd_write_data_over();
|
||||
epd_cs_set();
|
||||
|
||||
#if defined EPD_42
|
||||
epd_write_reg(0x21); // Display Update Controll
|
||||
epd_write_data(0x00); // RED normal
|
||||
epd_write_data(0x00); // single chip application
|
||||
#endif
|
||||
|
||||
epd_update();
|
||||
}
|
||||
|
||||
@@ -455,6 +523,11 @@ void epd_displayRED(uint8_t *Image)
|
||||
epd_write_reg(0x26);
|
||||
epd_writedata(Image, Width * Height);
|
||||
|
||||
#if defined EPD_42
|
||||
epd_write_reg(0x21); // Display Update Controll
|
||||
epd_write_data(0x00); // RED normal
|
||||
epd_write_data(0x00); // single chip application
|
||||
#endif
|
||||
epd_update();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user