mirror of
https://github.com/HalfSweetStudio/EPaperDrive.git
synced 2026-03-29 06:19:48 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19d7b3224f | ||
|
|
c1ae182026 | ||
|
|
4f1d375a1a | ||
|
|
f847b5651c | ||
|
|
1196c4f91a | ||
|
|
a3264912ad | ||
|
|
8797aaa8b3 | ||
|
|
8728602643 | ||
|
|
a2fa1a4778 | ||
|
|
5a874ea7cf |
@@ -2,7 +2,7 @@
|
||||
这是一个简单好用性能强大的Arduino墨水屏驱动库,支持目前市面上较常见的多种墨水屏。
|
||||
|
||||
## 我应该如何使用它?
|
||||
请着重参考[例程](https://github.com/HalfSweetStudio/EPaperDrive/tree/main/examples)与[API手册](docs/API手册.md),如果您遇到了例程不能使用的情况,请提交issue说明详细情况。
|
||||
请着重参考[例程](https://github.com/HalfSweetStudio/EPaperDrive/tree/main/examples)、[API手册](docs/API手册.md)以及[用户手册](docs/用户手册.md),如果您遇到了例程不能使用的情况,请提交issue说明详细情况。
|
||||
|
||||
## 我应该采用什么样的驱动电路?
|
||||
事实上,几乎所有的串口SPI的墨水屏驱动电路以及引脚定义都是相同的,如果您有微雪或者大连佳显等厂商提供的驱动板,您开源直接使用它。如果您是裸屏,那么我建议您采用这款[驱动板](https://oshwhub.com/ludas/mo-shui-ping-qu-dong)。需要注意的是,请您采用4-wire模式来驱动墨水屏,我们暂不支持3-wire模式。
|
||||
|
||||
@@ -17,4 +17,7 @@
|
||||
|
||||
## 如何显示图片?
|
||||
想要在墨水屏上显示一些图片,也许是个不错的主意。令人兴奋的是,我们提供了一系列的API供您完成您绝妙的创意。您可以调用`drawXbm`与`DrawXbm_P`函数来向缓存中绘入您所期望的图片。这两个函数的区别在于`DrawXbm_P`绘制的是您采用PROGMEM类型存储的图像,这会将数据存储在flash而不是RAM,相信您会喜欢上这一点。
|
||||
也许您会有这样的疑问,如何将.jpg等拓展名的图像转换为可识别的数据呢?非常简单,只需要使用任意一款图像取模软件(我喜欢用Image2lcd,虽然它很古老,但是依旧能完美地完成任务),使用单色模式垂直扫描将其转换为一连串的c数组即可。
|
||||
也许您会有这样的疑问,如何将.jpg等拓展名的图像转换为可识别的数据呢?非常简单,只需要使用任意一款图像取模软件(我喜欢用Image2lcd,虽然它很古老,但是依旧能完美地完成任务),使用单色模式垂直扫描将其转换为一连串的c数组即可。
|
||||
|
||||
## 制作自己的字体
|
||||
您可以使用[FontMaker](https://gitee.com/kerndev/FontMaker)软件来生成自己的字库,使用该软件生成垂直扫描、高位在前,标准字库为ASCII或者Unicode的bin文件字库,并调用`SetFont()`函数进行定义文件路径和宽高。
|
||||
@@ -56,6 +56,7 @@ void setup()
|
||||
#endif
|
||||
#endif
|
||||
EPD.SetHardSPI(&SPI);
|
||||
LittleFS.begin();
|
||||
EPD.SetFS(&LittleFS); //设置存放字体的文件系统,传入的为该文件系统的操作指针,可自行修改
|
||||
|
||||
EPD.EPD_Set_Model(HINKE0266A15A0); //设置屏幕类型,具体型号可以参考文档
|
||||
|
||||
BIN
examples/HardSPIHelloWorld/data/font10
Normal file
BIN
examples/HardSPIHelloWorld/data/font10
Normal file
Binary file not shown.
BIN
examples/HardSPIHelloWorld/data/font12
Normal file
BIN
examples/HardSPIHelloWorld/data/font12
Normal file
Binary file not shown.
BIN
examples/HardSPIHelloWorld/data/font32
Normal file
BIN
examples/HardSPIHelloWorld/data/font32
Normal file
Binary file not shown.
BIN
examples/HardSPIHelloWorld/data/font60
Normal file
BIN
examples/HardSPIHelloWorld/data/font60
Normal file
Binary file not shown.
BIN
examples/HardSPIHelloWorld/data/font70
Normal file
BIN
examples/HardSPIHelloWorld/data/font70
Normal file
Binary file not shown.
BIN
examples/HardSPIHelloWorld/data/weathericon
Normal file
BIN
examples/HardSPIHelloWorld/data/weathericon
Normal file
Binary file not shown.
BIN
examples/HardSPIHelloWorld/data/weathericon32
Normal file
BIN
examples/HardSPIHelloWorld/data/weathericon32
Normal file
Binary file not shown.
BIN
examples/HardSPIHelloWorld/data/weathericon50
Normal file
BIN
examples/HardSPIHelloWorld/data/weathericon50
Normal file
Binary file not shown.
BIN
examples/HardSPIHelloWorld/data/weathericon80
Normal file
BIN
examples/HardSPIHelloWorld/data/weathericon80
Normal file
Binary file not shown.
@@ -87,4 +87,4 @@ void setup()
|
||||
void loop()
|
||||
{
|
||||
delay(1); //防止看门狗咬
|
||||
}
|
||||
}
|
||||
BIN
examples/HelloWorld/data/font10
Normal file
BIN
examples/HelloWorld/data/font10
Normal file
Binary file not shown.
BIN
examples/HelloWorld/data/font12
Normal file
BIN
examples/HelloWorld/data/font12
Normal file
Binary file not shown.
BIN
examples/HelloWorld/data/font32
Normal file
BIN
examples/HelloWorld/data/font32
Normal file
Binary file not shown.
BIN
examples/HelloWorld/data/font60
Normal file
BIN
examples/HelloWorld/data/font60
Normal file
Binary file not shown.
BIN
examples/HelloWorld/data/font70
Normal file
BIN
examples/HelloWorld/data/font70
Normal file
Binary file not shown.
BIN
examples/HelloWorld/data/weathericon
Normal file
BIN
examples/HelloWorld/data/weathericon
Normal file
Binary file not shown.
BIN
examples/HelloWorld/data/weathericon32
Normal file
BIN
examples/HelloWorld/data/weathericon32
Normal file
Binary file not shown.
BIN
examples/HelloWorld/data/weathericon50
Normal file
BIN
examples/HelloWorld/data/weathericon50
Normal file
Binary file not shown.
BIN
examples/HelloWorld/data/weathericon80
Normal file
BIN
examples/HelloWorld/data/weathericon80
Normal file
Binary file not shown.
86
examples/ThreeColor/ThreeColor.ino
Normal file
86
examples/ThreeColor/ThreeColor.ino
Normal file
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* @file HelloWorld.ino
|
||||
* @author HalfSweet (Email:HalfSweet@HalfSweet.cn or QQ:2522182733)
|
||||
* @brief 该文件为支持三色的墨水屏显示出三种颜色的例程
|
||||
* @version 0.1
|
||||
* @date 2022-04-20
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <EPaperDrive.h>
|
||||
//包含你需要使用的文件系统,例如:
|
||||
#include <LittleFS.h>
|
||||
|
||||
#define BAUD_SPEED 74880 //串口调试的波特率,可自行修改
|
||||
|
||||
#define CS 15
|
||||
#define RST 2
|
||||
#define DC 0
|
||||
#define BUSY 4
|
||||
#define CLK 14
|
||||
#define DIN 13
|
||||
EPaperDrive EPD(0, CS, RST, DC, BUSY, CLK, DIN); //驱动库的实例化,此处为使用软件SPI
|
||||
|
||||
const uint8_t city_icon[24] = {
|
||||
/* 0X01,0X01,0X0C,0X00,0X0C,0X00, */
|
||||
0X00,
|
||||
0X00,
|
||||
0X1C,
|
||||
0X00,
|
||||
0X77,
|
||||
0X00,
|
||||
0X41,
|
||||
0X80,
|
||||
0X9C,
|
||||
0X60,
|
||||
0XA2,
|
||||
0X30,
|
||||
0XA2,
|
||||
0X30,
|
||||
0X9C,
|
||||
0XC0,
|
||||
0X41,
|
||||
0X80,
|
||||
0X77,
|
||||
0X00,
|
||||
0X1C,
|
||||
0X00,
|
||||
0X00,
|
||||
0X00,
|
||||
};
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(BAUD_SPEED);
|
||||
LittleFS.begin(); //请务必先手动初始化一遍文件系统再将指针传入
|
||||
EPD.SetFS(&LittleFS); //设置存放字体的文件系统,传入的为该文件系统的操作指针,可自行修改
|
||||
|
||||
EPD.EPD_Set_Model(DKE42_3COLOR); //设置屏幕类型,具体型号可以参考文档
|
||||
EPD.EPD_init_Full(); //全刷初始化,使用全刷波形
|
||||
EPD.clearbuffer(); //清空缓存(全白)
|
||||
EPD.fontscale = 2; //字体缩放系数(支持1和2,对图片也有效,用完记得重新改成1)
|
||||
EPD.SetFont(FONT12); //选择字体,具体支持的字体见文档
|
||||
EPD.DrawUTF(0, 0, "Hello World"); //绘制字符串
|
||||
EPD.DrawUTF(26, 0, "我喜欢墨水屏"); //绘制字符串
|
||||
EPD.fontscale = 1; //字体缩放系数改回1
|
||||
EPD.DrawXbm_P(100, 0, 12, 12, (uint8_t *)city_icon); //绘制图片
|
||||
EPD.EPD_Transfer_Full_BW((unsigned char *)EPD.EPDbuffer, 1); //将黑白图像传入缓存
|
||||
EPD.clearbuffer();
|
||||
EPD.fontscale = 2;
|
||||
EPD.DrawUTF(40, 0, "现在是红色");
|
||||
EPD.fontscale = 1;
|
||||
EPD.DrawXbm_P(100, 30, 12, 12, (uint8_t *)city_icon); //绘制图片
|
||||
EPD.EPD_Transfer_Full_RED((unsigned char *)EPD.EPDbuffer,1);
|
||||
Serial.printf("缓存图像绘制完毕,准备全刷 \n");
|
||||
EPD.EPD_Update();
|
||||
EPD.ReadBusy_long();//等待屏幕刷新完成后才继续往下运行
|
||||
EPD.deepsleep(); //让屏幕进入休眠模式
|
||||
Serial.println("全刷完毕");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
delay(1); //防止看门狗咬
|
||||
}
|
||||
0
examples/ThreeColor/data/ThreeColor.ino
Normal file
0
examples/ThreeColor/data/ThreeColor.ino
Normal file
BIN
examples/ThreeColor/data/font10
Normal file
BIN
examples/ThreeColor/data/font10
Normal file
Binary file not shown.
BIN
examples/ThreeColor/data/font12
Normal file
BIN
examples/ThreeColor/data/font12
Normal file
Binary file not shown.
BIN
examples/ThreeColor/data/font32
Normal file
BIN
examples/ThreeColor/data/font32
Normal file
Binary file not shown.
BIN
examples/ThreeColor/data/font60
Normal file
BIN
examples/ThreeColor/data/font60
Normal file
Binary file not shown.
BIN
examples/ThreeColor/data/font70
Normal file
BIN
examples/ThreeColor/data/font70
Normal file
Binary file not shown.
BIN
examples/ThreeColor/data/weathericon32
Normal file
BIN
examples/ThreeColor/data/weathericon32
Normal file
Binary file not shown.
BIN
examples/ThreeColor/data/weathericon50
Normal file
BIN
examples/ThreeColor/data/weathericon50
Normal file
Binary file not shown.
BIN
examples/ThreeColor/data/weathericon80
Normal file
BIN
examples/ThreeColor/data/weathericon80
Normal file
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
#include "EPaperDrive.h"
|
||||
//#include "EPD_drive_gpio.h"
|
||||
// #include "EPD_drive_gpio.h"
|
||||
|
||||
uint8_t UNICODEbuffer[200];
|
||||
String fontname;
|
||||
@@ -18,6 +18,7 @@ EPaperDrive::EPaperDrive(bool SPIMode, uint8_t CS, uint8_t RST, uint8_t DC, uint
|
||||
pinMode(CS, OUTPUT); // io初始化
|
||||
pinMode(DC, OUTPUT);
|
||||
pinMode(RST, OUTPUT);
|
||||
digitalWrite(RST, HIGH);
|
||||
pinMode(BUSY, INPUT);
|
||||
pinMode(CLK, OUTPUT);
|
||||
pinMode(DIN, OUTPUT);
|
||||
@@ -27,6 +28,7 @@ EPaperDrive::EPaperDrive(bool SPIMode, uint8_t CS, uint8_t RST, uint8_t DC, uint
|
||||
pinMode(CS, OUTPUT);
|
||||
pinMode(DC, OUTPUT);
|
||||
pinMode(RST, OUTPUT);
|
||||
digitalWrite(RST, HIGH);
|
||||
pinMode(BUSY, INPUT);
|
||||
}
|
||||
}
|
||||
@@ -40,7 +42,7 @@ void EPaperDrive::driver_delay_xms(unsigned long xms)
|
||||
delay(xms);
|
||||
}
|
||||
|
||||
void EPaperDrive::SetFS(fs::FS* FSType)
|
||||
void EPaperDrive::SetFS(fs::FS *FSType)
|
||||
{
|
||||
UserFS = FSType;
|
||||
}
|
||||
@@ -62,23 +64,23 @@ void EPaperDrive::SPI_Write(uint8_t value)
|
||||
// delayMicroseconds(1);
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
//高位在前发送方式 根据升级器件特性定
|
||||
// 高位在前发送方式 根据升级器件特性定
|
||||
if ((value & 0x80) == 0x80)
|
||||
EPD_DIN_1;
|
||||
else
|
||||
EPD_DIN_0;
|
||||
// delayMicroseconds(1); //等待数据稳定 根据实际时钟调整
|
||||
EPD_CLK_1; //上升沿发送数据
|
||||
EPD_CLK_1; // 上升沿发送数据
|
||||
// delayMicroseconds(1);//CLK高电平保持一段时间 这个可以不需要 根据具体的spi时钟来确定
|
||||
EPD_CLK_0; //把时钟拉低实现为下一次上升沿发送数据做准备
|
||||
value = value << 1; //发送数据的位向前移动一位
|
||||
EPD_CLK_0; // 把时钟拉低实现为下一次上升沿发送数据做准备
|
||||
value = value << 1; // 发送数据的位向前移动一位
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EPaperDrive::SetFont(FONT fontindex)
|
||||
{
|
||||
FontIndex = fontindex;
|
||||
// FontIndex = fontindex;
|
||||
switch (fontindex)
|
||||
{
|
||||
case 0:
|
||||
@@ -148,6 +150,14 @@ void EPaperDrive::SetFont(FONT fontindex)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void EPaperDrive::SetFont(const char *dir, uint16_t hight, uint16_t width)
|
||||
{
|
||||
fontname = String(dir);
|
||||
fontwidth = width;
|
||||
fontheight = hight;
|
||||
}
|
||||
|
||||
void EPaperDrive::DrawCircle(int x, int y, int r, bool fill)
|
||||
{
|
||||
if (fill == 0)
|
||||
@@ -182,8 +192,8 @@ void EPaperDrive::DrawEmptyBox(int x, int y, int w, int h)
|
||||
{
|
||||
DrawXline(y, y + w, x);
|
||||
DrawXline(y, y + w, x + h);
|
||||
DrawYline(x, x + w, y);
|
||||
DrawYline(x, x + w, y + w);
|
||||
DrawYline(x, x + h, y);
|
||||
DrawYline(x, x + h, y + w);
|
||||
}
|
||||
|
||||
void EPaperDrive::DrawChart(int x, int y, int w, int c1, int c2, int c3, int c4, int c5, int c6)
|
||||
@@ -337,7 +347,7 @@ int EPaperDrive::getIcon(int weathercodeindex)
|
||||
return 37;
|
||||
return 17;
|
||||
}
|
||||
void EPaperDrive::DrawWeatherChart(int xmin, int xmax, int ymin, int ymax, int point_n, int show_n, String tmax, String tmin, String code_d, String code_n, String text_d, String text_n, String date, String week) //绘制天气温度变化曲线
|
||||
void EPaperDrive::DrawWeatherChart(int xmin, int xmax, int ymin, int ymax, int point_n, int show_n, String tmax, String tmin, String code_d, String code_n, String text_d, String text_n, String date, String week) // 绘制天气温度变化曲线
|
||||
{
|
||||
if (tmax == ",,,,,")
|
||||
{
|
||||
@@ -353,14 +363,14 @@ void EPaperDrive::DrawWeatherChart(int xmin, int xmax, int ymin, int ymax, int p
|
||||
String code_d_a[point_n], code_n_a[point_n], text_d_a[point_n], text_n_a[point_n], date_a[point_n], week_a[point_n];
|
||||
int tmax_a[point_n], tmin_a[point_n];
|
||||
int min_data = 999, max_data = -999;
|
||||
int tmin_x_cord[point_n], tmax_x_cord[point_n]; //将数值转成屏幕坐标
|
||||
int tmin_x_cord[point_n], tmax_x_cord[point_n]; // 将数值转成屏幕坐标
|
||||
|
||||
String temp_min[point_n];
|
||||
String temp_max[point_n];
|
||||
int j = 0, k = 0, l = 0;
|
||||
//分割tmax和tmin
|
||||
// Serial.println(tmax); Serial.println(tmin);
|
||||
// Serial.println(code_d);
|
||||
// 分割tmax和tmin
|
||||
// Serial.println(tmax); Serial.println(tmin);
|
||||
// Serial.println(code_d);
|
||||
for (int i = 0; i < tmin.length(); i++)
|
||||
{
|
||||
temp_min[j] += tmin[i];
|
||||
@@ -377,14 +387,14 @@ void EPaperDrive::DrawWeatherChart(int xmin, int xmax, int ymin, int ymax, int p
|
||||
k++;
|
||||
}
|
||||
j = 0;
|
||||
//分割code_d
|
||||
// 分割code_d
|
||||
for (int i = 0; i < code_d.length(); i++)
|
||||
{
|
||||
code_d_a[j] += code_d[i];
|
||||
if (code_d.charAt(i) == char(','))
|
||||
j++;
|
||||
}
|
||||
//分割code_n
|
||||
// 分割code_n
|
||||
j = 0;
|
||||
for (int i = 0; i < code_n.length(); i++)
|
||||
{
|
||||
@@ -392,7 +402,7 @@ void EPaperDrive::DrawWeatherChart(int xmin, int xmax, int ymin, int ymax, int p
|
||||
if (code_n.charAt(i) == char(','))
|
||||
j++;
|
||||
}
|
||||
//分割text_d
|
||||
// 分割text_d
|
||||
j = 0;
|
||||
for (int i = 0; i < text_d.length(); i++)
|
||||
{
|
||||
@@ -401,7 +411,7 @@ void EPaperDrive::DrawWeatherChart(int xmin, int xmax, int ymin, int ymax, int p
|
||||
else
|
||||
text_d_a[j] += text_d[i];
|
||||
}
|
||||
//分割text_n
|
||||
// 分割text_n
|
||||
j = 0;
|
||||
for (int i = 0; i < text_n.length(); i++)
|
||||
{
|
||||
@@ -410,7 +420,7 @@ void EPaperDrive::DrawWeatherChart(int xmin, int xmax, int ymin, int ymax, int p
|
||||
else
|
||||
text_n_a[j] += text_n[i];
|
||||
}
|
||||
//分割week_n
|
||||
// 分割week_n
|
||||
j = 0;
|
||||
for (int i = 0; i < week.length(); i++)
|
||||
{
|
||||
@@ -432,7 +442,7 @@ void EPaperDrive::DrawWeatherChart(int xmin, int xmax, int ymin, int ymax, int p
|
||||
tmax_a[i] = temp_max[i].toInt(); // Serial.printf("max:%d\n",tmax_a[i]);
|
||||
tmin_a[i] = temp_min[i].toInt(); // Serial.printf("min:%d\n",tmin_a[i]);
|
||||
}
|
||||
//找出计算最大最小值
|
||||
// 找出计算最大最小值
|
||||
for (int i = 0; i < show_n; i++)
|
||||
{
|
||||
if (tmax_a[i] > max_data)
|
||||
@@ -444,7 +454,7 @@ void EPaperDrive::DrawWeatherChart(int xmin, int xmax, int ymin, int ymax, int p
|
||||
if (tmin_a[i] < min_data)
|
||||
min_data = tmin_a[i];
|
||||
}
|
||||
//转换坐标
|
||||
// 转换坐标
|
||||
if ((max_data - min_data) != 0)
|
||||
{
|
||||
for (int i = 0; i < show_n; i++)
|
||||
@@ -472,7 +482,7 @@ void EPaperDrive::DrawWeatherChart(int xmin, int xmax, int ymin, int ymax, int p
|
||||
|
||||
}
|
||||
*/
|
||||
//画折线
|
||||
// 画折线
|
||||
for (int i = 0; i < show_n - 1; i++)
|
||||
{
|
||||
DrawLine(tmin_x_cord[i], ymin + dy * i, tmin_x_cord[i + 1], ymin + dy * (i + 1));
|
||||
@@ -481,7 +491,7 @@ void EPaperDrive::DrawWeatherChart(int xmin, int xmax, int ymin, int ymax, int p
|
||||
// DrawLine(tmin_x_cord[i]-1,ymin+dy*i,tmin_x_cord[i+1]-1,ymin+dy*(i+1));
|
||||
// DrawLine(tmax_x_cord[i]-1,ymin+dy*i,tmax_x_cord[i+1]-1,ymin+dy*(i+1));
|
||||
}
|
||||
//画圆圈,添加标注
|
||||
// 画圆圈,添加标注
|
||||
for (int i = 0; i < show_n; i++)
|
||||
{
|
||||
DrawCircle(tmin_x_cord[i], ymin + dy * i, 3, 1);
|
||||
@@ -661,6 +671,7 @@ void EPaperDrive::DrawUnicodeChar(int16_t x, int16_t y, uint8_t width, uint8_t h
|
||||
else
|
||||
sizeofsinglechar = (height / 8 + 1) * width;
|
||||
offset = (code[0] * 0x100 + code[1]) * sizeofsinglechar;
|
||||
Serial.printf("offset:%d", offset);
|
||||
// Serial.println("code[1]");
|
||||
// Serial.println(code[1]);
|
||||
// Serial.println("sizeofsinglechar");
|
||||
@@ -677,15 +688,16 @@ void EPaperDrive::DrawUnicodeChar(int16_t x, int16_t y, uint8_t width, uint8_t h
|
||||
}*/
|
||||
// Serial.println("offset");
|
||||
// Serial.println(offset);
|
||||
if (offset < 0xff * sizeofsinglechar && FontIndex < 10)
|
||||
{
|
||||
drawXbm(x, y, width, height, (uint8_t *)zi);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawXbm(x, y, width, height, (uint8_t *)zi);
|
||||
}
|
||||
|
||||
/* if (offset < 0xff * sizeofsinglechar && FontIndex < 10)
|
||||
{
|
||||
drawXbm(x, y, width, height, (uint8_t *)zi);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawXbm(x, y, width, height, (uint8_t *)zi);
|
||||
} */
|
||||
// 上面这坨代码我也不知道是干啥的,看着好像没用就注释了
|
||||
drawXbm(x, y, width, height, (uint8_t *)zi); // 上面注释里面需要的东西
|
||||
// SPIFFS.end();
|
||||
}
|
||||
|
||||
@@ -864,7 +876,7 @@ void EPaperDrive::DrawXbm_p_gray(int16_t xMove, int16_t yMove, int16_t width, in
|
||||
}
|
||||
void EPaperDrive::DrawXbm_spiff_gray(int16_t xMove, int16_t yMove, int16_t width, int16_t height, uint8_t level)
|
||||
{
|
||||
// File f = UserFS->open("/pic.xbm", "r");
|
||||
// File f = UserFS->open("/pic.xbm", "r");
|
||||
File f = UserFS->open("/pic.xbm", "r");
|
||||
|
||||
int16_t heightInXbm = (height + 1) / 2;
|
||||
@@ -1862,7 +1874,7 @@ void EPaperDrive::EPD_Init(void)
|
||||
{
|
||||
// Serial.printf("开始全刷初始化 \n");
|
||||
driver_delay_xms(10);
|
||||
ReadBusy(); //读busy信号
|
||||
ReadBusy(); // 读busy信号
|
||||
|
||||
EPD_WriteCMD(0x12); // 软件复位 soft reset
|
||||
ReadBusy();
|
||||
@@ -2086,13 +2098,13 @@ void EPaperDrive::EPD_init_Full(void)
|
||||
// Serial.printf("即将写入全刷波形 \n");
|
||||
EPD_Write((uint8_t *)LUTDefault_full_GDEY042Z98, sizeof(LUTDefault_full_GDEY042Z98));
|
||||
|
||||
EPD_WriteCMD(0x3F);
|
||||
EPD_WriteData(*(LUTDefault_full_GDEY042Z98 + 227 + 1));
|
||||
// EPD_WriteCMD(0x3F);
|
||||
// EPD_WriteData(*(LUTDefault_full_GDEY042Z98 + 227 + 1));
|
||||
|
||||
EPD_WriteCMD(0x03); //门电压 gate voltage
|
||||
EPD_WriteCMD(0x03); // 门电压 gate voltage
|
||||
EPD_WriteData(*(LUTDefault_full_GDEY042Z98 + 228 + 1));
|
||||
|
||||
EPD_WriteCMD(0x04); //源电压 source voltage
|
||||
EPD_WriteCMD(0x04); // 源电压 source voltage
|
||||
EPD_WriteData(*(LUTDefault_full_GDEY042Z98 + 229 + 1));
|
||||
EPD_WriteData(*(LUTDefault_full_GDEY042Z98 + 230 + 1));
|
||||
EPD_WriteData(*(LUTDefault_full_GDEY042Z98 + 231 + 1));
|
||||
@@ -2238,10 +2250,10 @@ void EPaperDrive::EPD_init_Part(void)
|
||||
EPD_WriteCMD(0x3F);
|
||||
EPD_WriteData(*(LUTDefault_part_GDEY042Z98 + 227 + 1));
|
||||
|
||||
EPD_WriteCMD(0x03); //门电压 gate voltage
|
||||
EPD_WriteCMD(0x03); // 门电压 gate voltage
|
||||
EPD_WriteData(*(LUTDefault_part_GDEY042Z98 + 228 + 1));
|
||||
|
||||
EPD_WriteCMD(0x04); //源电压 source voltage
|
||||
EPD_WriteCMD(0x04); // 源电压 source voltage
|
||||
EPD_WriteData(*(LUTDefault_part_GDEY042Z98 + 229 + 1));
|
||||
EPD_WriteData(*(LUTDefault_part_GDEY042Z98 + 230 + 1));
|
||||
EPD_WriteData(*(LUTDefault_part_GDEY042Z98 + 231 + 1));
|
||||
@@ -2440,7 +2452,7 @@ void EPaperDrive::EPD_Dis_Full(uint8_t *DisBuffer, uint8_t Label)
|
||||
else if (EPD_Type == GDEY042Z98 || EPD_Type == HINKE0266A15A0)
|
||||
{
|
||||
EPD_SetRamPointer(xStart / 8, yEnd % 256, yEnd / 256);
|
||||
EPD_WriteDispRam_Old(xDot / 8, yDot, (uint8_t *)DisBuffer, 0, 1); //我也不知道啥情况,但是如果你不对这个寄存器写两遍一样的数据局刷无效
|
||||
EPD_WriteDispRam_Old(xDot / 8, yDot, (uint8_t *)DisBuffer, 0, 1); // 我也不知道啥情况,但是如果你不对这个寄存器写两遍一样的数据局刷无效
|
||||
// EPD_WriteDispRam_Old(xDot / 8, yDot, (uint8_t *)DisBuffer, 0, 1);
|
||||
}
|
||||
else
|
||||
@@ -2452,6 +2464,10 @@ void EPaperDrive::EPD_Dis_Full(uint8_t *DisBuffer, uint8_t Label)
|
||||
|
||||
else if (EPD_Type == WF29 || EPD_Type == WF58 || EPD_Type == WF29BZ03 || EPD_Type == C154 || EPD_Type == WF42 || EPD_Type == WFT0290CZ10)
|
||||
{
|
||||
if (EPD_Type == WFT0290CZ10)
|
||||
{
|
||||
EPD_WriteDispRam_Old(xDot / 8, yDot, (uint8_t *)DisBuffer, 0, 0xff);
|
||||
}
|
||||
if (Label == 2)
|
||||
{
|
||||
EPD_WriteDispRam(xDot / 8, yDot, (uint8_t *)DisBuffer, 0, 0xff); // white
|
||||
@@ -2495,12 +2511,38 @@ void EPaperDrive::EPD_Dis_Part(int xStart, int xEnd, int yStart, int yEnd, uint8
|
||||
yEnd = yDot - temp1 - 2;
|
||||
yStart = yDot - temp2 - 3;
|
||||
}
|
||||
|
||||
switch (EPD_Type)
|
||||
{
|
||||
case WX29:
|
||||
case WFT0290CZ10:
|
||||
case DKE29_3COLOR:
|
||||
case WF29:
|
||||
if (xStart % 8 != 0)
|
||||
{
|
||||
xStart -= (xStart % 8);
|
||||
}
|
||||
if (xEnd % 8 != 0)
|
||||
{
|
||||
xEnd += (8 - xEnd % 8);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (yStart % 8 != 0)
|
||||
{
|
||||
yStart -= (yStart % 8);
|
||||
}
|
||||
if (yEnd % 8 != 0)
|
||||
{
|
||||
yEnd += (8 - yEnd % 8);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
unsigned int Xsize = xEnd - xStart;
|
||||
unsigned int Ysize = yEnd - yStart + 1;
|
||||
if (Xsize % 8 != 0)
|
||||
{
|
||||
Xsize = Xsize + (8 - Xsize % 8);
|
||||
}
|
||||
|
||||
Xsize = Xsize / 8;
|
||||
unsigned int offset = yStart * xDot / 8 + xStart / 8;
|
||||
if (EPD_Type == WX29 || EPD_Type == OPM42 || EPD_Type == DKE42_3COLOR || EPD_Type == DKE29_3COLOR || EPD_Type == GDEY042Z98 || EPD_Type == HINKE0266A15A0)
|
||||
@@ -2537,6 +2579,15 @@ void EPaperDrive::EPD_Dis_Part(int xStart, int xEnd, int yStart, int yEnd, uint8
|
||||
EPD_SetRamPointer(xStart / 8, yEnd % 256, yEnd / 256);
|
||||
EPD_WriteDispRam_Old(Xsize, Ysize, (uint8_t *)DisBuffer, offset, 1);
|
||||
}
|
||||
else if (EPD_Type == OPM42 || EPD_Type == DKE42_3COLOR)
|
||||
{
|
||||
EPD_WriteDispRam(Xsize, Ysize, (uint8_t *)DisBuffer, offset, 1);
|
||||
}
|
||||
else if (EPD_Type == WX29)
|
||||
{
|
||||
EPD_SetRamPointer(xStart / 8, yEnd % 256, yEnd / 256);
|
||||
EPD_WriteDispRam(Xsize, Ysize, (uint8_t *)DisBuffer, offset, 1);
|
||||
}
|
||||
|
||||
// EPD_WriteDispRam_Old(Xsize, Ysize,(uint8_t *)DisBuffer,offset,1);
|
||||
}
|
||||
|
||||
@@ -209,6 +209,15 @@ public:
|
||||
*/
|
||||
void SetFont(FONT fontindex);
|
||||
|
||||
/**
|
||||
* @brief 设置字体,使用自定义的路径以及尺寸
|
||||
*
|
||||
* @param dir 字体文件的路径
|
||||
* @param hight 字体高度
|
||||
* @param width 字体宽度
|
||||
*/
|
||||
void SetFont(const char *dir, uint16_t hight, uint16_t width);
|
||||
|
||||
/**
|
||||
* @brief 在图像缓存中画字符串
|
||||
*
|
||||
@@ -463,6 +472,11 @@ public:
|
||||
*/
|
||||
void EPD_Write(uint8_t *value, uint8_t datalen);
|
||||
|
||||
void EPD_WriteDispRam_Old(unsigned int XSize, unsigned int YSize, uint8_t *Dispbuff, unsigned int offset, uint8_t label);
|
||||
void EPD_WriteDispRam(unsigned int XSize, unsigned int YSize, uint8_t *Dispbuff, unsigned int offset, uint8_t label);
|
||||
void EPD_SetRamPointer(uint16_t addrX, uint8_t addrY, uint8_t addrY1);
|
||||
|
||||
|
||||
private:
|
||||
uint8_t _CS;
|
||||
uint8_t _RST;
|
||||
@@ -489,14 +503,13 @@ private:
|
||||
void driver_delay_xms(unsigned long xms);
|
||||
|
||||
void EPD_WriteDispRam_RED(unsigned int XSize, unsigned int YSize, uint8_t *Dispbuff, unsigned int offset, uint8_t label);
|
||||
void EPD_WriteDispRam(unsigned int XSize, unsigned int YSize, uint8_t *Dispbuff, unsigned int offset, uint8_t label);
|
||||
// void EPD_SetRamArea(uint16_t Xstart,uint16_t Xend,uint8_t Ystart,uint8_t Ystart1,uint8_t Yend,uint8_t Yend1);
|
||||
void EPD_SetRamPointer(uint16_t addrX, uint8_t addrY, uint8_t addrY1);
|
||||
|
||||
void EPD_WirteLUT(uint8_t *LUTvalue, uint8_t Size);
|
||||
|
||||
void EPD_Init(void);
|
||||
void EPD_WriteCMD_p1(uint8_t command, uint8_t para);
|
||||
void EPD_WriteDispRam_Old(unsigned int XSize, unsigned int YSize, uint8_t *Dispbuff, unsigned int offset, uint8_t label);
|
||||
|
||||
void EPD_SetRamArea(uint16_t Xstart, uint16_t Xend, uint8_t Ystart, uint8_t Ystart1, uint8_t Yend, uint8_t Yend1);
|
||||
|
||||
int getIcon(int weathercodeindex);
|
||||
|
||||
@@ -814,8 +814,8 @@ const uint8_t lut_bb_part_WFT0290CZ10[]={
|
||||
const uint8_t LUTDefault_full_GDEY042Z98[] = {
|
||||
0x32,
|
||||
//VCOM
|
||||
0x01, 0x28, 0x28, 0x14, 0x3C, 0x01, 0x01,
|
||||
0x01, 0x28, 0x28, 0x14, 0x3C, 0x01, 0x01,
|
||||
0x01, 0x23, 0x23, 0x05, 0x3C, 0x02, 0x03,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -823,8 +823,8 @@ const uint8_t LUTDefault_full_GDEY042Z98[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
//RED
|
||||
0x01, 0x28, 0x28, 0x94, 0xFC, 0x01, 0x01,
|
||||
0x01, 0x28, 0x28, 0x94, 0xFC, 0x01, 0x01,
|
||||
0x01, 0x63, 0xA3, 0x85, 0xFC, 0x02, 0x03,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -832,8 +832,8 @@ const uint8_t LUTDefault_full_GDEY042Z98[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
//WHITE
|
||||
0x01, 0x68, 0xA8, 0x14, 0x3C, 0x01, 0x01,
|
||||
0x01, 0x68, 0xA8, 0x14, 0x3C, 0x01, 0x01,
|
||||
0x01, 0x63, 0xA3, 0x05, 0x3C, 0x02, 0x03,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -841,8 +841,8 @@ const uint8_t LUTDefault_full_GDEY042Z98[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
//BLACK
|
||||
0x01, 0xA8, 0x68, 0x14, 0x3C, 0x01, 0x01,
|
||||
0x01, 0xA8, 0x68, 0x14, 0x3C, 0x01, 0x01,
|
||||
0x01, 0xA3, 0x63, 0x05, 0x3C, 0x02, 0x03,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -850,9 +850,10 @@ const uint8_t LUTDefault_full_GDEY042Z98[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x02, 0x00, 0x00, 0x22, 0x17, 0x41, 0xA8,
|
||||
0x03, 0x00, 0x00, 0x22, 0x17, 0x41, 0xA8,
|
||||
0x32, 0x48,
|
||||
|
||||
|
||||
};
|
||||
|
||||
const uint8_t LUTDefault_part_GDEY042Z98[] = {
|
||||
@@ -907,6 +908,94 @@ const uint8_t LUTDefault_part_GDEY042Z98[] = {
|
||||
0x32, 0x08,
|
||||
};
|
||||
|
||||
const uint8_t LUT_gray_GDEY042Z98[] = {
|
||||
0x32,
|
||||
//VCOM
|
||||
0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
//RED
|
||||
0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
//WHITE
|
||||
0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
//BLACK
|
||||
0x01, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x02, 0x00, 0x00, 0x22, 0x17, 0x4B, 0xA8,
|
||||
0x32, 0x48,
|
||||
|
||||
};
|
||||
|
||||
const uint8_t LUT_gray_red_GDEY042Z98[] = {
|
||||
0x32,
|
||||
//VCOM
|
||||
0x01, 0x09, 0x00, 0x00, 0x00, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
//RED
|
||||
0x01, 0x09, 0x00, 0x00, 0x00, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
//WHITE
|
||||
0x01, 0x09, 0x00, 0x00, 0x00, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
//BLACK
|
||||
0x01, 0xC9, 0x00, 0x00, 0x00, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x03, 0x00, 0x00, 0x22, 0x17, 0x4B, 0xA8,
|
||||
0x32, 0x48,
|
||||
|
||||
};
|
||||
|
||||
static const uint8_t LUTDefault_full_HINKE0266A15A0[] = {
|
||||
0x32, // command
|
||||
|
||||
|
||||
Reference in New Issue
Block a user