5 Commits
main ... test

Author SHA1 Message Date
HalfSweet
19d7b3224f Update EPaperDrive.cpp 2022-12-16 20:35:14 +08:00
HalfSweet
c1ae182026 Update EPaperDrive.cpp 2022-12-16 20:31:59 +08:00
HalfSweet
4f1d375a1a Update EPaperDrive.cpp 2022-12-16 20:26:34 +08:00
HalfSweet
f847b5651c Update EPaperDrive.cpp 2022-12-16 20:20:07 +08:00
HalfSweet
1196c4f91a 修复2.9寸的局刷bug,增加字体制作文档 2022-12-16 20:13:28 +08:00
5 changed files with 113 additions and 66 deletions

View File

@@ -5,7 +5,7 @@
请着重参考[例程](https://github.com/HalfSweetStudio/EPaperDrive/tree/main/examples)、[API手册](docs/API手册.md)以及[用户手册](docs/用户手册.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模式。 事实上几乎所有的串口SPI的墨水屏驱动电路以及引脚定义都是相同的如果您有微雪或者大连佳显等厂商提供的驱动板开源直接使用它。如果您是裸屏,那么我建议您采用这款[驱动板](https://oshwhub.com/ludas/mo-shui-ping-qu-dong)。需要注意的是请您采用4-wire模式来驱动墨水屏我们暂不支持3-wire模式。
## 这个驱动库支持什么MCU ## 这个驱动库支持什么MCU
很遗憾目前为止该驱动库仅支持ESP8266/ESP32或者别的带文件系统的MCU我们会在之后重构整个驱动库来达到更好的兼容性。 很遗憾目前为止该驱动库仅支持ESP8266/ESP32或者别的带文件系统的MCU我们会在之后重构整个驱动库来达到更好的兼容性。

View File

@@ -18,3 +18,6 @@
## 如何显示图片? ## 如何显示图片?
想要在墨水屏上显示一些图片也许是个不错的主意。令人兴奋的是我们提供了一系列的API供您完成您绝妙的创意。您可以调用`drawXbm``DrawXbm_P`函数来向缓存中绘入您所期望的图片。这两个函数的区别在于`DrawXbm_P`绘制的是您采用PROGMEM类型存储的图像这会将数据存储在flash而不是RAM相信您会喜欢上这一点。 想要在墨水屏上显示一些图片也许是个不错的主意。令人兴奋的是我们提供了一系列的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()`函数进行定义文件路径和宽高。

View File

@@ -80,7 +80,7 @@ void EPaperDrive::SPI_Write(uint8_t value)
void EPaperDrive::SetFont(FONT fontindex) void EPaperDrive::SetFont(FONT fontindex)
{ {
FontIndex = fontindex; // FontIndex = fontindex;
switch (fontindex) switch (fontindex)
{ {
case 0: case 0:
@@ -150,6 +150,14 @@ void EPaperDrive::SetFont(FONT fontindex)
break; 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) void EPaperDrive::DrawCircle(int x, int y, int r, bool fill)
{ {
if (fill == 0) if (fill == 0)
@@ -314,30 +322,30 @@ void EPaperDrive::DrawCircleChart(int x, int y, int r, int w, int c1, int c2, in
int EPaperDrive::getIcon(int weathercodeindex) int EPaperDrive::getIcon(int weathercodeindex)
{ {
if (weathercodeindex == 0) if (weathercodeindex == 0)
return 12; //晴 return 12;
if (weathercodeindex == 1) if (weathercodeindex == 1)
return 58; //多云 return 58;
if (weathercodeindex == 2) if (weathercodeindex == 2)
return 58; //少云 return 58;
if (weathercodeindex == 3) if (weathercodeindex == 3)
return 58; //晴间多云 return 58;
if (weathercodeindex == 4) if (weathercodeindex == 4)
return 54; //阴 return 54;
if (weathercodeindex >= 5 && weathercodeindex <= 18) if (weathercodeindex >= 5 && weathercodeindex <= 18)
return 0; return 0;
if (weathercodeindex >= 19 && weathercodeindex <= 32) if (weathercodeindex >= 19 && weathercodeindex <= 32)
return 19; //雨 return 19;
if (weathercodeindex >= 33 && weathercodeindex <= 36) if (weathercodeindex >= 33 && weathercodeindex <= 36)
return 16; //雪 return 16;
if (weathercodeindex >= 37 && weathercodeindex <= 40) if (weathercodeindex >= 37 && weathercodeindex <= 40)
return 16; //雪(雨夹雪) return 16;
if (weathercodeindex == 41) if (weathercodeindex == 41)
return 37; //雾(薄雾) return 37;
if (weathercodeindex == 42) if (weathercodeindex == 42)
return 37; //雾 return 37;
if (weathercodeindex == 43) if (weathercodeindex == 43)
return 37; //雾(霾) return 37;
return 17; //阵雨夹雪 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) // 绘制天气温度变化曲线
{ {
@@ -680,15 +688,16 @@ void EPaperDrive::DrawUnicodeChar(int16_t x, int16_t y, uint8_t width, uint8_t h
}*/ }*/
// Serial.println("offset"); // Serial.println("offset");
// Serial.println(offset); // Serial.println(offset);
if (offset < 0xff * sizeofsinglechar && FontIndex < 10) /* if (offset < 0xff * sizeofsinglechar && FontIndex < 10)
{ {
drawXbm(x, y, width, height, (uint8_t *)zi); drawXbm(x, y, width, height, (uint8_t *)zi);
} }
else else
{ {
drawXbm(x, y, width, height, (uint8_t *)zi); drawXbm(x, y, width, height, (uint8_t *)zi);
} } */
// 上面这坨代码我也不知道是干啥的,看着好像没用就注释了
drawXbm(x, y, width, height, (uint8_t *)zi); // 上面注释里面需要的东西
// SPIFFS.end(); // SPIFFS.end();
} }
@@ -2502,12 +2511,38 @@ void EPaperDrive::EPD_Dis_Part(int xStart, int xEnd, int yStart, int yEnd, uint8
yEnd = yDot - temp1 - 2; yEnd = yDot - temp1 - 2;
yStart = yDot - temp2 - 3; 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 Xsize = xEnd - xStart;
unsigned int Ysize = yEnd - yStart + 1; unsigned int Ysize = yEnd - yStart + 1;
if (Xsize % 8 != 0)
{
Xsize = Xsize + (8 - Xsize % 8);
}
Xsize = Xsize / 8; Xsize = Xsize / 8;
unsigned int offset = yStart * xDot / 8 + xStart / 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) if (EPD_Type == WX29 || EPD_Type == OPM42 || EPD_Type == DKE42_3COLOR || EPD_Type == DKE29_3COLOR || EPD_Type == GDEY042Z98 || EPD_Type == HINKE0266A15A0)

View File

@@ -209,6 +209,15 @@ public:
*/ */
void SetFont(FONT fontindex); void SetFont(FONT fontindex);
/**
* @brief 设置字体,使用自定义的路径以及尺寸
*
* @param dir 字体文件的路径
* @param hight 字体高度
* @param width 字体宽度
*/
void SetFont(const char *dir, uint16_t hight, uint16_t width);
/** /**
* @brief 在图像缓存中画字符串 * @brief 在图像缓存中画字符串
* *