校友录网站开发设计投资网站模板
- 作者: 五速梦信息网
- 时间: 2026年04月20日 07:09
当前位置: 首页 > news >正文
校友录网站开发设计,投资网站模板,wordpress如何汉化版,做网站的主要作用Arduin ESP32 epaper(电子墨水屏)时钟相册制作教程 #x1f516;epaper(电子墨水屏)采用的是#xff1a;合宙1.54“ 电子墨水屏#xff08;e-paper#xff09;#x1f4cd;相关篇《Arduino框架下ESP32/ESP8266合宙1.54“ 电子墨水屏#xff08;e-paper#xff09;驱动显… Arduin ESP32 epaper(电子墨水屏)时钟相册制作教程 epaper(电子墨水屏)采用的是合宙1.54“ 电子墨水屏e-paper相关篇《Arduino框架下ESP32/ESP8266合宙1.54“ 电子墨水屏e-paper驱动显示示例》电子屏幕相关资料https://www.waveshare.net/wiki/1.54inch_e-Paper_Module图片取模教程和工具介绍https://www.waveshare.net/wiki/Image2Lcd%E5%9B%BE%E7%89%87%E5%8F%96%E6%A8%A1%E6%AD%A5%E9%AA%A4同类型的微雪品牌的相关资料参考提供了包含约50种规格的电子墨水屏e-paperhttps://www.waveshare.net/wiki/1.54inch_e-Paper_Module个人采用的是esp32测试,esp8266应该也可以的。 ✨功能实现说明电子屏驱动显示采用LittleFS文件系统存储需要显示图片的字模数据读取图片字模数据并通过墨水屏显示。 有关数据管理和更新可以参考以下内容
通过网页实现图片数据管理可以参考《Arduino ESP32当作FTP服务器 访问SD卡文件》《Arduino ESP32 Web服务器SD卡文件管理》 图片取模制作
制作软件Image2Lcd图片尺寸要求200X200像素点 图片素材获取源https://icons8.com/icons/set/raspberry-pi图片素材获取源2https://fontawesome.com/icons?dgalleryp2
字模数据转BIN文件
需要借助c代码使用C编译器指令或VSCode 将字模数组转bin文件。200X200像素的图片去取模转BIN文件后的大小都是5KB。
#include stdio.h
const unsigned char gImage_yun[5000] {图片字符数组}
int main()
{size_t size sizeof(gImage_yun[0]);size_t count sizeof(gImage_yun) / size;FILE fp fopen(gImage_yun.bin, wb);if (fp NULL){printf(Failed to open file.\n);return 1;}size_t elements_written fwrite(gImage_yun, size, count, fp);if (elements_written ! count){printf(Failed to write data to file.\n);fclose(fp);return 1;}fclose(fp);printf(Data written successfully.\n);return 0;
}如何配合CodeRuner插件使用 如果不使用该插件的话可以在终端命令行中输入gcc .\Font.c命令按回车然后执行 .\a.exe命令回车。前提是安装了C编译器并且添加到了系统环境变量中 运行成功后会自动生成:.bin文件。 将生成的.BIN文件拷贝到工程项目的data文件夹内。如果使用SD卡配合文件系统也是可以的。
LittleFS文件系统配置
⚡Arduino平台的所有的文件系统SPIFFS/LittleFS/FatFS文件系统仅针对ESP32仅支持Arduino IDE 1.8.x.x版本下使用Arduino IDE 2.x.x不支持ESP8266支持Arduino IDE 2.x.x版本esp32文件系统上传插件下载地址https://github.com/lorol/arduino-esp32fs-plugin/releasesESP8266 littlefs文件系统下载地址https://github.com/earlephilhower/arduino-littlefs-upload/releases
LittleFS系统文件上传说明
✨首次上传程序时需要注意删除全部内容 上传LittleFS系统文件 电子墨水屏注意事项
支持局刷的屏幕注意使用的时候不能一直用局刷对屏幕进行刷新需要在做几次局刷之后对屏幕进行一次全刷清屏。否则会造成屏幕显示效果异常。注意屏幕不能长时间上电在屏幕不刷新的时候要将屏幕设置成睡眠模式或者进行断电处理。否则屏幕长时间保持高电压状态会损坏膜片无法修复。使用墨水屏的时候建议刷新时间间隔至少是180s, 并且至少每24小时做一次刷新如果长期不使用墨水屏的话要将墨水屏刷白存放。具体储存环境需求参考数据手册屏幕进入睡眠模式之后会忽略发送的图片数据只有重新初始化才能正常刷新。
电子墨水屏显示内容说明
对于黑白款的电子墨水屏内容支持全刷和局刷。在使用过程中如果需要切换不同的刷新方式时需要先停止使用SPI总线SPI.endTransaction(),推荐在刷完显示内容后调用epd.Sleep()之后停与屏幕的SPI通讯。再次刷新屏幕的时候再进行一次初始化。
⛳图片更新方式
通过Arduino IDE 1.8.x.x版本只需选择上传littleFS进行文件上传即可但是还是需要在当前工程目录下有data目录才可更新显示内容素材。 图片数据文件上传后进行复位打开串口如果文件系统初始化成功读取到文件会打印出来
主程序代码
/** filename : epd1in54-demo.ino* brief : 1.54inch e-paper display demo* author : Yehui from Waveshare** Copyright © Waveshare September 5 2017** Permission is hereby granted, free of charge, to any person obtaining a copy* of this software and associated documnetation files (the Software), to deal* in the Software without restriction, including without limitation the rights* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell* copies of the Software, and to permit persons to whom the Software is* furished to do so, subject to the following conditions:** The above copyright notice and this permission notice shall be included in* all copies or substantial portions of the Software.** ESP32引脚定义* BUSY - 13 || RES - 12 || DC - 14 || CS - 27 || SCL - 18 || SDA - 23 ||黑字COLORED 白色UNCOLORED支持局刷的屏幕注意使用的时候不能一直用局刷对屏幕进行刷新需要在做几次局刷之后对屏幕进行一次全刷清屏。否则会造成屏幕显示效果异常。
注意屏幕不能长时间上电在屏幕不刷新的时候要将屏幕设置成睡眠模式或者进行断电处理。否则屏幕长时间保持高电压状态会损坏膜片无法修复。
使用墨水屏的时候建议刷新时间间隔至少是180s, 并且至少每24小时做一次刷新如果长期不使用墨水屏的话要将墨水屏刷白存放。具体储存环境需求参考数据手册
屏幕进入睡眠模式之后会忽略发送的图片数据只有重新初始化才能正常刷新。/#include SPI.h
#include epd1in54.h
#include epdpaint.h
#include imagedata.h#include WiFi.h // esp32开发板自带库
#include time.h
#include sys/time.h
#include Ticker.h
#include LittleFS.h // 如果使用LittleFS
#include FS.h
#include esp_task_wdt.h
//#include RTClib.h //by Adafruit库来实现软件RTC时间
#define TZ 8 // (utc) TZ in hours
#define DST_MN 0 // use 60mn for summer time in some countries
#define TZ_MN ((TZ)*60)
#define TZ_SEC ((TZ)3600)
#define daylightOffset_sec 3600#define LED_PIN 2
#define COLORED 0
#define UNCOLORED 1#define bitmapSize 5000#define PIC_TIME 75#define Conter_MAX 10 //图片最多显示数量const char ssid MERCURY_D268G;//填写wifi信息
const char* password pba5ayzk;
uint8_t Conter0;
String pic1[10];/*** Due to RAM not enough in Arduino UNO, a frame buffer is not allowed.* In this case, a smaller image buffer is allocated and you have to * update a partial display several times.* 1 byte 8 pixels, therefore you have to set 8N pixels at a time./
unsigned char image[1024];
Paint paint(image, 0, 0); // width should be the multiple of 8
Epd epd;Ticker Refresh; //图片切换
Ticker UPDATE; //时间显示
Ticker blinker;//unsigned long time_start_ms;
//unsigned long time_now_s;
const char * weekday[] { 7, 1,2, 3,4, 5, 6};
uint8_t blinkerPace 1; //seconds
static bool TOGGLE false;
//bool Refresh_flag true;void listDir(fs::FS fs, const char * dirname, uint8_t levels);
void Picture_Refresh();
void UP_Date_Data();void blink() {digitalWrite(LED_PIN, !digitalRead(LED_PIN));
}void setup() {// put your setup code here, to run once:Serial.begin(9600);Serial.println();pinMode(LED_PIN, OUTPUT);WiFi.mode(WIFI_STA);WiFi.begin(ssid, password);while (WiFi.status() ! WL_CONNECTED) {delay(500);Serial.println(Connecting to WiFi…);}// rtc.begin(DateTime(F(DATE), F(TIME)));//不联网使用编译时间// rtc.adjust(DateTime(2024,3, 9, 23, 12, 10));Serial.println(Connected to WiFi);if (!LittleFS.begin()) { // LittleFS初始化Serial.println(LittleFS Mount Failed);} else {Serial.println(LittleFS Mounted Successfully);}configTime(TZ_SEC, daylightOffset_sec , ntp3.aliyun.com, ntp.ntsc.ac.cn, 1.cn.pool.ntp.org);//asia.pool.ntp.org//rtc.begin(DateTime(F(DATE), F(TIME)));Refresh.attach(PIC_TIME, Picture_Refresh); // 每隔60秒执行一次blinker.attach(blinkerPace, blink);//lut_partial_update if (epd.Init(lut_full_update) ! 0) {Serial.print(e-Paper init failed);return;}epd.ClearFrameMemory(0xFF); // bit set white, bit reset blackepd.DisplayFrame();epd.ClearFrameMemory(0xff); // bit set white, bit reset blackepd.DisplayFrame();delay(2000);paint.SetRotate(ROTATE_0);//屏幕旋转 指定显示区域paint.Clear(UNCOLORED);//白色区域内容显示epd.SetFrameMemory(gImage_bird);//gImage_rp / gImage_birdepd.DisplayFrame();epd.SetFrameMemory(gImage_bird);epd.DisplayFrame();epd.Sleep();SPI.endTransaction();delay(2000);UPDATE.once(5,UP_Date_Data); //时间更新一次// epd.Reset();Serial.println(Display complete);listDir(LittleFS, /, 1);// 禁用硬件看门狗esp_task_wdt_init(10 * 1000 * 1000,false); // 参数为0表示不启用看门狗}void loop() {// put your main code here, to run repeatedly:
}void listDir(fs::FS fs, const char * dirname, uint8_t levels){Serial.printf(Listing directory: %s\r\n, dirname);File root fs.open(dirname);if(!root){Serial.println(- failed to open directory);return;}if(!root.isDirectory()){Serial.println( - not a directory);return;}File file root.openNextFile();while(file){if(file.isDirectory()){Serial.print( DIR : );Serial.println(file.name());if(levels){listDir(fs, file.path(), levels -1);}} else {Serial.print( FILE: );pic1[Conter]file.name();Serial.print( pic1[Conter].c_str());Serial.print(\tSIZE: );Serial.println(file.size());Conter;}file root.openNextFile();Conter %Conter_MAX;}
}void Picture_Refresh()
{// 读取文件内容到缓冲区static uint8_t buffer_imge[bitmapSize]; // 确保这里定义的缓冲区足够大以容纳字模数据static uint8_t CNT0;File bitmapFile;String pic_name / pic1[CNT];Serial.println(pic_name.c_str());//打印当前要显示图片的名称bitmapFile LittleFS.open(pic_name, r);CNT % Conter;if (!bitmapFile) {Serial.println(Failed to open bitmap file for reading!);return;}else
{
//Serial.print(Reading );
uint16_t len bitmapFile.size();
// uint32_t start millis();while(len){size_t toRead len;if(toRead bitmapSize){toRead bitmapSize;}bitmapFile.read(buffer_imge, toRead);len - toRead;}// uint32_t end millis() - start;
// Serial.printf(5000 bytes Reading in %u ms\r\n, end);epd.ClearFrameMemory(0xff); //刷白epd.DisplayFrame();epd.ClearFrameMemory(0xff); // bit set white, bit reset blackepd.DisplayFrame();delay(800);paint.SetRotate(ROTATE_0);epd.SetFrameMemory(buffer_imge);epd.DisplayFrame();epd.SetFrameMemory(buffer_imge);epd.DisplayFrame();epd.Sleep();SPI.endTransaction();}UPDATE.once(60,UP_Date_Data);//调用时间更新
}void UP_Date_Data()
{char buff[32];time_t now time(nullptr);struct tm* timeinfo;timeinfo localtime(now); // 转换为本地时间strftime(buff, sizeof(buff), %c, timeinfo);Serial.println(buff);Serial.printf(PSTR(20%02d-%02d-%02d %02d:%02d:%02d\r\n),(timeinfo-tm_year)%100,timeinfo-tm_mon1,timeinfo-tm_mday,\timeinfo-tm_hour,timeinfo-tm_min,timeinfo-tm_sec);String Date_data String(timeinfo-tm_mon1)-String(timeinfo-tm_mday) String(timeinfo-tm_hour):String(timeinfo-tm_min) Tweekday[timeinfo-tm_wday];String Time_data String(timeinfo-tm_hour):String(timeinfo-tm_min);//20String((timeinfo-tm_year)%100)- :String(timeinfo-tm_sec);Serial.println(Date_data);Serial.println(Time_data);delay(800);epd.ClearFrameMemory(0xFF); // bit set white, bit reset blackepd.DisplayFrame();epd.ClearFrameMemory(0xFF); // bit set white, bit reset blackepd.DisplayFrame();paint.SetRotate(ROTATE_0);paint.SetWidth(200);paint.SetHeight(26);paint.Clear(UNCOLORED);//白底paint.DrawStringAt(0, 3,Date_data.c_str(), Font24, COLORED);//UNCOLORED:白色epd.SetFrameMemory(paint.GetImage(), 0, 174, paint.GetWidth(), paint.GetHeight()); epd.DisplayFrame();epd.SetFrameMemory(paint.GetImage(), 0, 174, paint.GetWidth(), paint.GetHeight()); epd.DisplayFrame();epd.Sleep();}
工程源码
链接: https://pan.baidu.com/s/1jd7jHhtjmozOxTA38kuGsw?pwddngy
提取码: dngy 此文章仅作为个人学习探索知识的总结不作为他人或引用者的理论依据由于学识所限难免会出现错误或纰漏欢迎大家指正。
- 上一篇: 校网站建设方案做任务的设计网站
- 下一篇: 校友网站建设电商就业前景






