以下代码请自己参考,没有技术支持。
以上代码为微雪官方代码,解压后用keil打开,芯片使用STM32F103C8T6。默认已经配置好了,编译后下载程序即可。
void EPD_2IN13_V2_Init(uint8_t Mode, uint16_t width, uint16_t height)
{
uint8_t count;
EPD_Reset();
// width = 104;
// height = 212;
if (Mode == EPD_2IN13_V2_FULL)
{
EPD_2IN13_V2_ReadBusy();
EPD_SendCommand(0x12); // soft reset
EPD_2IN13_V2_ReadBusy();
EPD_SendCommand(0x18); // set built in temperature sensor
EPD_SendData(0x80);
EPD_SendCommand(0x1A); // set built in temperature sensor
EPD_SendData(0x07); //
EPD_SendData(0xF0); //
EPD_SendCommand(0x74); //set analog block control
EPD_SendData(0x54);
EPD_SendCommand(0x7E); //set digital block control
EPD_SendData(0x3B);
EPD_SendCommand(0x01); //Driver output control
EPD_SendData((height-1)&0xFF); //0xF9-->(249+1)=250
EPD_SendData(((height-1)&0xFF00)>>8);
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x11); //data entry mode
EPD_SendData(0x01);
EPD_SendCommand(0x44); //set Ram-X address start/end position
EPD_SendData(0x00);
EPD_SendData((width+7)/8-1); //0x0C-->(15+1)*8=128
EPD_SendCommand(0x45); //set Ram-Y address start/end position
EPD_SendData((height-1)&0xFF); //0xF9-->(249+1)=250
EPD_SendData(((height-1)&0xFF00)>>8);
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x3C); //BorderWavefrom
EPD_SendData(0x01);
EPD_SendCommand(0x2C); //VCOM Voltage
EPD_SendData(0x50); //
EPD_SendCommand(0x03);
EPD_SendData(EPD_2IN13_V2_lut_full_update[70]);
EPD_SendCommand(0x04); //
EPD_SendData(EPD_2IN13_V2_lut_full_update[71]);
EPD_SendData(EPD_2IN13_V2_lut_full_update[72]);
EPD_SendData(EPD_2IN13_V2_lut_full_update[73]);
EPD_SendCommand(0x3A); //Dummy Line
EPD_SendData(EPD_2IN13_V2_lut_full_update[74]);
EPD_SendCommand(0x3B); //Gate time
EPD_SendData(EPD_2IN13_V2_lut_full_update[75]);
EPD_SendCommand(0x32);
for (count = 0; count < 70; count++)
{
EPD_SendData(EPD_2IN13_V2_lut_full_update[count]);
}
EPD_2IN13_V2_ReadBusy();
EPD_SendCommand(0x4E); // set RAM x address count to 0;
EPD_SendData(0x00);
EPD_SendCommand(0x4F); // set RAM y address count to 0X127;
EPD_SendData((height-1)&0xFF); //0xF9-->(249+1)=250
EPD_SendData(((height-1)&0xFF00)>>8);
EPD_SendData(height-1);
EPD_SendData(0x00);
}
else if (Mode == EPD_2IN13_V2_PART)
{
EPD_SendCommand(0x18); // set built in temperature sensor
EPD_SendData(0x80);
EPD_SendCommand(0x1A); // set built in temperature sensor
EPD_SendData(0x07); //
EPD_SendData(0xF0); //
EPD_SendCommand(0x2C); //VCOM Voltage
EPD_SendData(0x28);
EPD_2IN13_V2_ReadBusy();
EPD_SendCommand(0x32);
for (count = 0; count < 70; count++)
{
EPD_SendData(EPD_2IN13_V2_lut_partial_update[count]);
}
EPD_SendCommand(0x37);
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendData(0x40);
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x22);
EPD_SendData(0xC0);
EPD_SendCommand(0x20);
EPD_2IN13_V2_ReadBusy();
}
else
{
Debug("error, the Mode is EPD_2IN13_FULL or EPD_2IN13_PART");
}
}
void EPD_2IN13_V2_Display(uint8_t *Image, uint16_t width, uint16_t height)
{
uint16_t Width, Height;
//Width = (width % 8 == 0) ? (width / 8) : (width / 8 + 1);
Width = (width+7)/8;
Height = height;
EPD_SendCommand(0x24);
for (uint16_t j = 0; j < Height; j++)
{
for (uint16_t i = 0; i < Width; i++)
{
EPD_SendData(Image[i + j * Width]);
}
}
EPD_2IN13_V2_TurnOnDisplay();
}
void EPD_2IN13_V2_TurnOnDisplay(void)
{
EPD_SendCommand(0x22);
EPD_SendData(0xC4);
EPD_SendCommand(0x20);
// EPD_2IN13_V2_ReadBusy();
}
void EPD_2IN13_V2_ReadBusy(void)
{
Debug("e-Paper busy\r\n");
while (EPD_BUSY !=0)
{
//LOW: idle, HIGH: busy
wdg_reload(WATCHDOG_DEFAULT_PERIOD);
}
Debug("e-Paper busy release\r\n");
}