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
4 changed files with 99 additions and 52 deletions

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)
@@ -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 在图像缓存中画字符串
* *