mirror of
https://github.com/HalfSweetStudio/EPaperDrive.git
synced 2026-03-29 06:19:48 +08:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19d7b3224f | ||
|
|
c1ae182026 | ||
|
|
4f1d375a1a | ||
|
|
f847b5651c | ||
|
|
1196c4f91a |
@@ -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()`函数进行定义文件路径和宽高。
|
||||||
@@ -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)
|
||||||
|
|||||||
@@ -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 在图像缓存中画字符串
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user