add EPD test

This commit is contained in:
Shuanglei Tao
2024-12-07 22:45:29 +08:00
parent 17d78460af
commit 4987a4de7f
5 changed files with 245 additions and 4 deletions

View File

@@ -228,8 +228,7 @@ void EPD_4IN2_Clear(void)
UWORD Width, Height;
Width = (EPD_4IN2_WIDTH % 8 == 0)? (EPD_4IN2_WIDTH / 8 ): (EPD_4IN2_WIDTH / 8 + 1);
Height = EPD_4IN2_HEIGHT;
EPD_4IN2_SendCommand(0x92);
EPD_4IN2_SetLut();
EPD_4IN2_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
@@ -256,8 +255,14 @@ void EPD_4IN2_Display(UBYTE *Image)
UWORD Width, Height;
Width = (EPD_4IN2_WIDTH % 8 == 0)? (EPD_4IN2_WIDTH / 8 ): (EPD_4IN2_WIDTH / 8 + 1);
Height = EPD_4IN2_HEIGHT;
EPD_4IN2_SendCommand(0x92);
EPD_4IN2_SetLut();
EPD_4IN2_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_4IN2_SendData(0x00);
}
}
EPD_4IN2_SendCommand(0x13);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {

160
EPD/EPD_Test.c Normal file
View File

@@ -0,0 +1,160 @@
#include "EPD_Test.h"
#include "EPD_4in2.h"
const unsigned char EPD_4IN2_4Gray_lut_vcom[] =
{
0x00 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
0x60 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
0x00 ,0x14 ,0x00 ,0x00 ,0x00 ,0x01,
0x00 ,0x13 ,0x0A ,0x01 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00
};
const unsigned char EPD_4IN2_4Gray_lut_ww[] ={
0x40 ,0x0A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 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
};
static void EPD_4IN2_4Gray_lut(void)
{
unsigned int count;
EPD_4IN2_SendCommand(0x20); //vcom
for(count=0;count<42;count++)
{EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_vcom[count]);}
EPD_4IN2_SendCommand(0x21); //red not use
for(count=0;count<42;count++)
{EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_ww[count]);}
EPD_4IN2_SendCommand(0x22); //bw r
for(count=0;count<42;count++)
{EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_bw[count]);}
EPD_4IN2_SendCommand(0x23); //wb w
for(count=0;count<42;count++)
{EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_wb[count]);}
EPD_4IN2_SendCommand(0x24); //bb b
for(count=0;count<42;count++)
{EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_bb[count]);}
EPD_4IN2_SendCommand(0x25); //vcom
for(count=0;count<42;count++)
{EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_ww[count]);}
}
static void drawNormal(void)
{
UWORD Width, Height;
Width = (EPD_4IN2_WIDTH % 8 == 0)? (EPD_4IN2_WIDTH / 8 ): (EPD_4IN2_WIDTH / 8 + 1);
Height = EPD_4IN2_HEIGHT;
EPD_4IN2_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_4IN2_SendData(0xFF);
}
}
EPD_4IN2_SendCommand(0x13);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_4IN2_SendData(((j + 1)*2 > Height) ? 0x00 : 0xFF);
}
}
EPD_4IN2_TurnOnDisplay();
}
static void draw4Gray(void)
{
UWORD Width, Height;
Width = (EPD_4IN2_WIDTH % 8 == 0)? (EPD_4IN2_WIDTH / 8 ): (EPD_4IN2_WIDTH / 8 + 1);
Height = EPD_4IN2_HEIGHT;
EPD_4IN2_SendCommand(0x10);
for (UWORD i = 0; i < Width * Height; i++) {
UWORD idx = (i % 50) / 12;
if (idx > 3) idx = 3;
if (idx == 0 || idx == 1) {
EPD_4IN2_SendData(0x00);
} else if (idx == 2 || idx == 3) {
EPD_4IN2_SendData(0xFF);
}
}
EPD_4IN2_SendCommand(0x13);
for (UWORD i = 0; i < Width * Height; i++) {
UWORD idx = (i % 50) / 12;
if (idx > 3) idx = 3;
if (idx == 0 || idx == 2) {
EPD_4IN2_SendData(0x00);
} else if (idx == 1 || idx == 3) {
EPD_4IN2_SendData(0xFF);
}
}
EPD_4IN2_4Gray_lut();
EPD_4IN2_TurnOnDisplay();
}
void EPD_4in2_test(void)
{
DEV_Module_Init();
EPD_4IN2_Init();
EPD_4IN2_Clear();
DEV_Delay_ms(500);
drawNormal();
DEV_Delay_ms(3000);
EPD_4IN2_Clear();
DEV_Delay_ms(500);
draw4Gray();
DEV_Delay_ms(500);
EPD_4IN2_Sleep();
DEV_Delay_ms(500);
DEV_Module_Exit();
}

3
EPD/EPD_Test.h Normal file
View File

@@ -0,0 +1,3 @@
#include "DEV_Config.h"
void EPD_4in2_test(void);

View File

@@ -408,6 +408,62 @@
<Group>
<GroupName>EPD</GroupName>
<Files>
<File>
<FileName>EPD_Test.c</FileName>
<FileType>1</FileType>
<FilePath>..\EPD\EPD_Test.c</FilePath>
<FileOption>
<CommonProperty>
<UseCPPCompiler>2</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>0</IncludeInBuild>
<AlwaysBuild>2</AlwaysBuild>
<GenerateAssemblyFile>2</GenerateAssemblyFile>
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
<Cads>
<interw>2</interw>
<Optim>0</Optim>
<oTime>2</oTime>
<SplitLS>2</SplitLS>
<OneElfS>2</OneElfS>
<Strict>2</Strict>
<EnumInt>2</EnumInt>
<PlainCh>2</PlainCh>
<Ropi>2</Ropi>
<Rwpi>2</Rwpi>
<wLevel>0</wLevel>
<uThumb>2</uThumb>
<uSurpInc>2</uSurpInc>
<uC99>2</uC99>
<uGnu>2</uGnu>
<useXO>2</useXO>
<v6Lang>0</v6Lang>
<v6LangP>0</v6LangP>
<vShortEn>2</vShortEn>
<vShortWch>2</vShortWch>
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
</File>
<File>
<FileName>DEV_Config.c</FileName>
<FileType>1</FileType>
@@ -955,6 +1011,11 @@
<Group>
<GroupName>EPD</GroupName>
<Files>
<File>
<FileName>EPD_Test.c</FileName>
<FileType>1</FileType>
<FilePath>..\EPD\EPD_Test.c</FilePath>
</File>
<File>
<FileName>DEV_Config.c</FileName>
<FileType>1</FileType>
@@ -1502,6 +1563,11 @@
<Group>
<GroupName>EPD</GroupName>
<Files>
<File>
<FileName>EPD_Test.c</FileName>
<FileType>1</FileType>
<FilePath>..\EPD\EPD_Test.c</FilePath>
</File>
<File>
<FileName>DEV_Config.c</FileName>
<FileType>1</FileType>

7
main.c
View File

@@ -27,6 +27,9 @@
#include "app_error.h"
#include "app_timer.h"
#include "EPD_ble.h"
#ifdef DEBUG
#include "EPD_Test.h"
#endif
#define IS_SRVC_CHANGED_CHARACT_PRESENT 1 /**< Include or not the service_changed characteristic. if not enabled, the server's database cannot be changed for the lifetime of the device*/
@@ -386,6 +389,10 @@ int main(void)
NRF_LOG_PRINTF("done.\n");
#ifdef DEBUG
EPD_4in2_test();
#endif
for (;;)
{
power_manage();