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:
@@ -218,6 +218,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);
|
||||
@@ -261,6 +262,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
|
||||
@@ -288,6 +304,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;
|
||||
@@ -303,8 +325,13 @@ void epd_enter_deepsleepmode(uint8_t mode)
|
||||
|
||||
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();
|
||||
@@ -326,15 +353,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
|
||||
@@ -344,10 +376,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
|
||||
@@ -355,6 +391,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;
|
||||
@@ -364,8 +413,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;
|
||||
@@ -386,6 +437,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;
|
||||
@@ -414,6 +476,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();
|
||||
}
|
||||
|
||||
@@ -465,6 +533,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();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,12 @@ extern "C"
|
||||
|
||||
#include "ch32v10x.h"
|
||||
|
||||
//#define EPD_42
|
||||
//#define EPD_29
|
||||
//#define EPD_213
|
||||
//#define EPD_154
|
||||
|
||||
#if (!defined EPD_29) && (!defined EPD_213) && (!defined EPD_154)
|
||||
#if (!defined EPD_29) && (!defined EPD_213) && (!defined EPD_154) && (!defined EPD_42)
|
||||
#error EPD Type Undefine
|
||||
#endif
|
||||
|
||||
@@ -31,6 +32,10 @@ extern "C"
|
||||
#define EPD_H 200
|
||||
#endif
|
||||
|
||||
#ifdef EPD_42
|
||||
#define EPD_W 400
|
||||
#define EPD_H 300
|
||||
#endif
|
||||
|
||||
#define EPD_OK 0
|
||||
#define EPD_ERROR 1
|
||||
@@ -76,6 +81,7 @@ extern "C"
|
||||
void epd_init_internalTempSensor(void);
|
||||
void epd_update(void);
|
||||
void epd_update_partial(void);
|
||||
void epd_address_set(uint16_t x_start,uint16_t y_start,uint16_t x_end,uint16_t y_end);
|
||||
void epd_setpos(uint16_t x, uint16_t y);
|
||||
void epd_display(uint8_t *Image1, uint8_t *Image2);
|
||||
void epd_displayBW(uint8_t *Image);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "bmp.h"
|
||||
|
||||
// define for White Black Red Epaper Module
|
||||
#define EPD_BWR
|
||||
//#define EPD_BWR
|
||||
|
||||
uint8_t image_bw[EPD_W_BUFF_SIZE * EPD_H];
|
||||
#ifdef EPD_BWR
|
||||
@@ -56,16 +56,25 @@ int main(void)
|
||||
epd_init();
|
||||
|
||||
#ifdef EPD_BWR
|
||||
#ifdef EPD_42
|
||||
epd_paint_newimage(image_bw, EPD_W, EPD_H, EPD_ROTATE_270, EPD_COLOR_WHITE);
|
||||
epd_paint_newimage(image_red, EPD_W, EPD_H, EPD_ROTATE_270, EPD_COLOR_WHITE);
|
||||
#else
|
||||
epd_paint_newimage(image_bw, EPD_W, EPD_H, EPD_ROTATE_180, EPD_COLOR_WHITE);
|
||||
|
||||
epd_paint_newimage(image_red, EPD_W, EPD_H, EPD_ROTATE_180, EPD_COLOR_WHITE);
|
||||
#endif
|
||||
|
||||
epd_paint_selectimage(image_bw);
|
||||
epd_paint_clear(EPD_COLOR_WHITE);
|
||||
|
||||
epd_paint_selectimage(image_red);
|
||||
epd_paint_clear(EPD_COLOR_WHITE);
|
||||
|
||||
#ifdef EPD_42
|
||||
epd_paint_showPicture((EPD_W - 250) / 2, (EPD_H - 122) / 2, 250, 122, gImage_4, EPD_COLOR_WHITE);
|
||||
#else
|
||||
epd_paint_showPicture((EPD_H - 250) / 2, (EPD_W - 122) / 2, 250, 122, gImage_4, EPD_COLOR_WHITE);
|
||||
#endif
|
||||
|
||||
epd_display(image_bw, image_red);
|
||||
epd_enter_deepsleepmode(EPD_DEEPSLEEP_MODE1);
|
||||
@@ -83,6 +92,10 @@ int main(void)
|
||||
#ifdef EPD_29
|
||||
epd_paint_showString(10, 0, (uint8_t *)&"2.9 Epaper Module", EPD_FONT_SIZE24x12, EPD_COLOR_BLACK);
|
||||
epd_paint_showString(10, 50, (uint8_t *)&"with 296 x 128 resolution", EPD_FONT_SIZE16x8, EPD_COLOR_BLACK);
|
||||
#endif
|
||||
#ifdef EPD_42
|
||||
epd_paint_showString(10, 0, (uint8_t *)&"4.2 Inch Epaper Module", EPD_FONT_SIZE24x12, EPD_COLOR_BLACK);
|
||||
epd_paint_showString(10, 50, (uint8_t *)&"with 400 x 300 resolution", EPD_FONT_SIZE16x8, EPD_COLOR_BLACK);
|
||||
#endif
|
||||
epd_paint_showString(10, 29, (uint8_t *)&"Designed By WeAct Studio", EPD_FONT_SIZE16x8, EPD_COLOR_BLACK);
|
||||
|
||||
@@ -99,8 +112,13 @@ int main(void)
|
||||
#endif
|
||||
|
||||
epd_display(image_bw, image_red);
|
||||
|
||||
#else
|
||||
#ifdef EPD_42
|
||||
epd_paint_newimage(image_bw, EPD_W, EPD_H, EPD_ROTATE_270, EPD_COLOR_WHITE);
|
||||
#else
|
||||
epd_paint_newimage(image_bw, EPD_W, EPD_H, EPD_ROTATE_180, EPD_COLOR_WHITE);
|
||||
#endif
|
||||
|
||||
epd_paint_selectimage(image_bw);
|
||||
|
||||
@@ -109,8 +127,12 @@ int main(void)
|
||||
epd_paint_showPicture((EPD_H - 200) / 2,(EPD_W - 64) / 2,200,64,gImage_5,EPD_COLOR_WHITE);
|
||||
#else
|
||||
epd_paint_clear(EPD_COLOR_WHITE);
|
||||
#ifdef EPD_42
|
||||
epd_paint_showPicture((EPD_W - 250) / 2, (EPD_H - 122) / 2, 250, 122, gImage_4, EPD_COLOR_WHITE);
|
||||
#else
|
||||
epd_paint_showPicture((EPD_H - 250) / 2, (EPD_W - 122) / 2, 250, 122, gImage_4, EPD_COLOR_WHITE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
epd_displayBW(image_bw);
|
||||
epd_enter_deepsleepmode(EPD_DEEPSLEEP_MODE1);
|
||||
@@ -138,11 +160,15 @@ epd_paint_showString(10, 29, (uint8_t *)&"Designed By WeAct Studio", EPD_FONT_SI
|
||||
epd_paint_showString(10, 50, (uint8_t *)&"with 296 x 128 resolution", EPD_FONT_SIZE16x8, EPD_COLOR_BLACK);
|
||||
epd_paint_showString(10, 29, (uint8_t *)&"Designed By WeAct Studio", EPD_FONT_SIZE16x8, EPD_COLOR_BLACK);
|
||||
#endif
|
||||
|
||||
#ifdef EPD_42
|
||||
epd_paint_showString(10, 0, (uint8_t *)&"4.2 Inch Epaper Module", EPD_FONT_SIZE24x12, EPD_COLOR_BLACK);
|
||||
epd_paint_showString(10, 50, (uint8_t *)&"with 400 x 300 resolution", EPD_FONT_SIZE16x8, EPD_COLOR_BLACK);
|
||||
epd_paint_showString(10, 29, (uint8_t *)&"Designed By WeAct Studio", EPD_FONT_SIZE16x8, EPD_COLOR_BLACK);
|
||||
#endif
|
||||
#if 1
|
||||
epd_paint_showString(10,100,(uint8_t *)&"CH32V103C8T6 Example",EPD_FONT_SIZE16x8,EPD_COLOR_BLACK);
|
||||
#else
|
||||
epd_paint_drawRectangle(10, 103, EPD_H - 10, 116, EPD_COLOR_BLACK, 1);
|
||||
epd_paint_drawRectangle(10, EPD_W-20, EPD_H - 10, EPD_W-6, EPD_COLOR_BLACK, 1);
|
||||
#endif
|
||||
|
||||
sprintf((char *)&text, ">> Partial Mode");
|
||||
|
||||
Reference in New Issue
Block a user