IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 嵌入式 -> ESP8266+1.54英寸e-paper墨水屏物联网时间天气显示 -> 正文阅读

[嵌入式]ESP8266+1.54英寸e-paper墨水屏物联网时间天气显示

项目总览

先上图,看效果!
该项目主要是通过esp8266-12e连接wifi获取心知天气数据和苏宁时间api,通过解析json代码得到数据,然后通过e-paper墨水屏显示出来,本项目基于墨水屏例程,添加了部分中文字体以及天气图标,通过文字取模软件对图标和文字进行了编码与取模。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

元器件清单

  1. 主控板:esp8266-12e nodemcu
  2. 显示屏:heltec1.54inch e-link display的高亮样式** 进行展示;
  3. 杜邦线,usb线;

接线方式

  • D/C–>D2
  • SDI–>D7
  • CS–>D8
  • CLK–>D5
  • BUSY–>D1
  • VCC–>D0(一定要保证3.3v)
  • GND–>GND

用到的网站与API

  1. 心知天气:https://www.seniverse.com/
  • 天气解析获取三天天气地址:
    http://api.seniverse.com/v3/weather/daily.json?key=YOUR EY&location=jinan&language=zh-Hans&unit=c
  • 记得修改标记位置,分别是心知天气私钥城市代码
  • 私钥获取方式>>官网注册>>购买免费版>>控制台>>添加私钥
    获取到的json代码块示例
{
  "results": [
    {
      "location": {
        "id": "WWE0TGW4PX6N",
        "name": "济南",
        "country": "CN",
        "path": "济南,济南,山东,中国",
        "timezone": "Asia/Shanghai",
        "timezone_offset": "+08:00"
      },
      "daily": [
        {
          "date": "2021-08-14",
          "text_day": "晴",
          "code_day": "0",
          "text_night": "晴",
          "code_night": "1",
          "high": "30",
          "low": "21",
          "rainfall": "1.2",
          "precip": "0.34",
          "wind_direction": "东",
          "wind_direction_degree": "90",
          "wind_speed": "23.4",
          "wind_scale": "4",
          "humidity": "66"
        },
        {
          "date": "2021-08-15",
          "text_day": "多云",
          "code_day": "4",
          "text_night": "多云",
          "code_night": "4",
          "high": "31",
          "low": "21",
          "rainfall": "1.2",
          "precip": "0.34",
          "wind_direction": "东北",
          "wind_direction_degree": "45",
          "wind_speed": "8.4",
          "wind_scale": "2",
          "humidity": "66"
        },
        {
          "date": "2021-08-16",
          "text_day": "多云",
          "code_day": "4",
          "text_night": "多云",
          "code_night": "4",
          "high": "31",
          "low": "21",
          "rainfall": "1.2",
          "precip": "0.35",
          "wind_direction": "无持续风向",
          "wind_direction_degree": "",
          "wind_speed": "3.0",
          "wind_scale": "1",
          "humidity": "71"
        }
      ],
      "last_update": "2021-08-14T08:00:00+08:00"
    }
  ]
}
  1. 苏宁时间api:http://quan.suning.com/getSysTime.do
  • 获取到的代码块示例
{
  "sysTime2": "2021-08-15 11:34:54",
  "sysTime1": "20210815113454"
}
  1. arduinojson:https://arduinojson.org/assistant/
  • 主要是用来esp8266解析获取到的网页数据
  • 注意选择v5版本
  • 示例:需要解析的数据
{
  "sysTime2": "2021-08-15 11:34:54",
  "sysTime1": "20210815113454"
}
  • 解析后的代码
const size_t capacity = JSON_OBJECT_SIZE(2) + 60;
DynamicJsonBuffer jsonBuffer(capacity);

const char* json = "{\"sysTime2\":\"2021-08-15 11:34:54\",\"sysTime1\":\"20210815113454\"}";

JsonObject& root = jsonBuffer.parseObject(json);

const char* sysTime2 = root["sysTime2"]; // "2021-08-15 11:34:54"
const char* sysTime1 = root["sysTime1"]; // "20210815113454"

只需要将const char* json = 注释掉,然后将json改为通过http获取到的字符串就可以了。

显示屏部分

屏幕文档介绍

https://heltec.org/project/154-e-ink/
通信协议:

  • 三线spi:CLK+SDI+CS
  • DC引脚+BUSY引脚

供电电压:

  • 3.3v (高电压或低电压都会造成乱码显示)

屏幕分辨率(1.54英寸黑白墨水屏):

  • 200像素*200像素

屏幕文字图像取模

取模软件:PCtoLCD2002完美版

取模方式

  • 取模选项

在这里插入图片描述

  • 取模示例:
    在这里插入图片描述
    如何理解:
    每一行代表了像素点的位置,14号字体,宽度14像素,高度14像素,一共14行,每一行是两个8为16进制数,最大可以表示16号字。
    若需要表示更大的字,值需要在每一行加一个16进制数即可,依然是每一行表示对应的像素点位置。

{
0x02,0x00,
0x02,0x00,
0x05,0x00,
0x08,0x80,
0x14,0x40,
0x22,0x20,
0xC2,0x18,
0x00,0x00,
0x3F,0xC0,
0x00,0x40,
0x00,0x80,
0x00,0x80,
0x01,0x00,
0x02,0x00},/*"今",0*/
  • 对应程序中的函数:
    paint.DrawCharAt(120, 0, ’ '+9, &Fontzh14, COLORED);//今
    第一、二个参数是打印位置x,y
    第三个参数代表‘ ’字符加上第几个元素,因为函数是从‘ ’开始检索的
    第四个参数用来选择字号,需要用对应的font.c文件,还需要再font.h文件中进行结构体声明
    第五个参数用来选择打印颜色,colored即为前景色,黑色

此函数与打印ascii码的函数通用,需要显示中文只需要改动对应字库即可
在这里插入图片描述

添加字库方法(中文英文通用)

  • 首线复制一份font.c文件并重新命名
    在这里插入图片描述

  • 然后在文件中修改对应变量名,根据字号修改字符宽度和高度
    在这里插入图片描述

  • 在font.h文件重新声明变量
    在这里插入图片描述

程序总览

  1. 程序头文件
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
#include <SPI.h>
#include "epd1in54_V2.h"
#include "epdpaint.h"
#include "imagedata.h"
#include <ESP8266WiFi.h> 
#include <ESP8266HTTPClient.h> 
#include <ArduinoJson.h>  //版本为V5版本,最新的版本不适用下面的代码
  1. 程序变量常量定义
#define COLORED     0
#define UNCOLORED   1
int today_tianqi[5][2]={18,20,/*晴*/
                       17,29,/*阴*/
                        19,14,/*大雨*/
                        15,16,/*多云*/
                        13,14/*小雨*/};
int yearn,monthn,dayn;
int tianqinum[5]={0,0,0,0,0};                     
int getxingqi(int years,int months,int day);
String now_address="",now_weather="",now_temperature="",now_temperature_low="",now_day="",now_time="";//用来存储报文得到的字符串
String now_address_1="",now_weather_1="",now_temperature_1="",now_temperature_1_low="",now_day_1="";//用来存储报文得到的字符串
String now_address_2="",now_weather_2="",now_temperature_2="",now_temperature_2_low="",now_day_2="",now_weather_3="",now_weather_4="";//用来存储报文得到的字符串
String GetUrl;
String response;
char* strCat = "";
const char* ssid = "PandoraBox-2.4G-923A97"; // 你的WiFi账号
const char* password = "790338372"; // 你的WIFI密码
unsigned char image[1024];
unsigned long time_start_ms;
unsigned long time_now_s;
int today_day=0;
int tianqi_now=0;
HTTPClient http;  //开始登陆 获取天气
HTTPClient https;  //开始登陆 获取时间
Paint paint(image, 0, 0); 
Epd epd;
  1. 初始化函数
void setup() {
  get_WIFI();
  get_WIFI();
  SPI.pins(CLK_PIN,MISO,SDI_PIN,CS_PIN);
  SPI.begin();
  Serial.begin(115200);
  if (epd.Init() != 0) 
  {
      Serial.print("e-Paper init failed");
      return;
  }
  epd.ClearFrameMemory(0xFF);   // bit set = white, bit reset = black
  epd.DisplayFrameFull();
  Serial.println("e-Paper SetFrameMemory");
  time_start_ms = millis(); 
}

  1. 主循环
void loop() {
  get_weather();
  
  Serial.println("tianqi:");
  Serial.println(tianqinum[0]);
  Serial.println(tianqinum[1]);
  Serial.println(tianqinum[2]);
  Serial.println("now_address:");
  Serial.println(now_address);
  Serial.println("天气:");
  Serial.println(now_weather);
  Serial.println("温度:");
  Serial.println(now_temperature);
  setscreen();
  delay(10000);
}
  1. wifi链接

void get_WIFI()
{
   Serial.begin(115200);
   WiFi.begin(ssid, password);


   while (WiFi.status() != WL_CONNECTED) 
   { //等待wifi连接
     delay(500);
     Serial.print(".."); //重复打印 "Connecting..",直到连接成功
   }
     Serial.println(" ");
     Serial.println("Connected to ");
     Serial.println(ssid);
     Serial.println("IP address: ");
     Serial.println(WiFi.localIP());
}
  1. 获取网络天气与时间数据
void get_weather()
{
  if (WiFi.status() == WL_CONNECTED) { //如果 Wi-Fi 连接成功
    //此处往下是取得实况天气的程序

   //心知API的网址,记得修改自己的密码!!!!!!!
   //心知API的网址,记得修改自己的城市!!!!!!!
   //心知API获取未来三天的天气情况
   http.begin("http://api.seniverse.com/v3/weather/daily.json?key=SCZyJ9BUkrn8BfPpD&location=jinan&language=zh-Hans&unit=c");

   int httpget_now = http.GET(); //赋值
    Serial.println("httpget_now:");
    Serial.println(httpget_now);
    if (httpget_now == HTTP_CODE_OK) 
    { 
      //检查一下是否为0,应该是去检查缓存区是否为空
      Serial.println("that is ok");
      String respone =  http.getString();
      Serial.println(respone);
      /*数据解析:使用 https://arduinojson.org/assistant/ 一个工具可以直接生成程序,挑有用的复制就行*/
      /*记得选v5版本*/
      const size_t capacity = JSON_ARRAY_SIZE(1) + JSON_ARRAY_SIZE(3) + JSON_OBJECT_SIZE(1) + JSON_OBJECT_SIZE(3) + JSON_OBJECT_SIZE(6) + 3*JSON_OBJECT_SIZE(14) + 820;
      DynamicJsonBuffer jsonBuffer(capacity);

      JsonObject& root = jsonBuffer.parseObject(respone);
      
      JsonObject& results_0 = root["results"][0];
      
      JsonObject& results_0_location = results_0["location"];
      const char* results_0_location_id = results_0_location["id"]; // "WX4FBXXFKE4F"
      const char* results_0_location_name = results_0_location["name"]; // "北京"
      const char* results_0_location_country = results_0_location["country"]; // "CN"
      const char* results_0_location_path = results_0_location["path"]; // "北京,北京,中国"
      const char* results_0_location_timezone = results_0_location["timezone"]; // "Asia/Shanghai"
      const char* results_0_location_timezone_offset = results_0_location["timezone_offset"]; // "+08:00"
      
      JsonArray& results_0_daily = results_0["daily"];
      
      JsonObject& results_0_daily_0 = results_0_daily[0];
      const char* results_0_daily_0_date = results_0_daily_0["date"]; // "2021-08-14"
      const char* results_0_daily_0_text_day = results_0_daily_0["text_day"]; // "阴"
      const char* results_0_daily_0_code_day = results_0_daily_0["code_day"]; // "9"
      const char* results_0_daily_0_text_night = results_0_daily_0["text_night"]; // "雷阵雨"
      const char* results_0_daily_0_code_night = results_0_daily_0["code_night"]; // "11"
      const char* results_0_daily_0_high = results_0_daily_0["high"]; // "28"
      const char* results_0_daily_0_low = results_0_daily_0["low"]; // "22"
      const char* results_0_daily_0_rainfall = results_0_daily_0["rainfall"]; // "1.87"
      const char* results_0_daily_0_precip = results_0_daily_0["precip"]; // "0.4"
      const char* results_0_daily_0_wind_direction = results_0_daily_0["wind_direction"]; // "南"
      const char* results_0_daily_0_wind_direction_degree = results_0_daily_0["wind_direction_degree"]; // "180"
      const char* results_0_daily_0_wind_speed = results_0_daily_0["wind_speed"]; // "8.4"
      const char* results_0_daily_0_wind_scale = results_0_daily_0["wind_scale"]; // "2"
      const char* results_0_daily_0_humidity = results_0_daily_0["humidity"]; // "89"
      
      JsonObject& results_0_daily_1 = results_0_daily[1];
      const char* results_0_daily_1_date = results_0_daily_1["date"]; // "2021-08-15"
      const char* results_0_daily_1_text_day = results_0_daily_1["text_day"]; // "雷阵雨"
      const char* results_0_daily_1_code_day = results_0_daily_1["code_day"]; // "11"
      const char* results_0_daily_1_text_night = results_0_daily_1["text_night"]; // "雷阵雨"
      const char* results_0_daily_1_code_night = results_0_daily_1["code_night"]; // "11"
      const char* results_0_daily_1_high = results_0_daily_1["high"]; // "28"
      const char* results_0_daily_1_low = results_0_daily_1["low"]; // "22"
      const char* results_0_daily_1_rainfall = results_0_daily_1["rainfall"]; // "7.22"
      const char* results_0_daily_1_precip = results_0_daily_1["precip"]; // "0.92"
      const char* results_0_daily_1_wind_direction = results_0_daily_1["wind_direction"]; // "东"
      const char* results_0_daily_1_wind_direction_degree = results_0_daily_1["wind_direction_degree"]; // "90"
      const char* results_0_daily_1_wind_speed = results_0_daily_1["wind_speed"]; // "8.4"
      const char* results_0_daily_1_wind_scale = results_0_daily_1["wind_scale"]; // "2"
      const char* results_0_daily_1_humidity = results_0_daily_1["humidity"]; // "92"
      
      JsonObject& results_0_daily_2 = results_0_daily[2];
      const char* results_0_daily_2_date = results_0_daily_2["date"]; // "2021-08-16"
      const char* results_0_daily_2_text_day = results_0_daily_2["text_day"]; // "多云"
      const char* results_0_daily_2_code_day = results_0_daily_2["code_day"]; // "4"
      const char* results_0_daily_2_text_night = results_0_daily_2["text_night"]; // "多云"
      const char* results_0_daily_2_code_night = results_0_daily_2["code_night"]; // "4"
      const char* results_0_daily_2_high = results_0_daily_2["high"]; // "28"
      const char* results_0_daily_2_low = results_0_daily_2["low"]; // "21"
      const char* results_0_daily_2_rainfall = results_0_daily_2["rainfall"]; // "5.94"
      const char* results_0_daily_2_precip = results_0_daily_2["precip"]; // "0.84"
      const char* results_0_daily_2_wind_direction = results_0_daily_2["wind_direction"]; // "东南"
      const char* results_0_daily_2_wind_direction_degree = results_0_daily_2["wind_direction_degree"]; // "135"
      const char* results_0_daily_2_wind_speed = results_0_daily_2["wind_speed"]; // "3.0"
      const char* results_0_daily_2_wind_scale = results_0_daily_2["wind_scale"]; // "1"
      const char* results_0_daily_2_humidity = results_0_daily_2["humidity"]; // "87"
      
      const char* results_0_last_update = results_0["last_update"]; // "2021-08-14T08:00:00+08:00"
            

        //赋值,因为现在这些变量是在缓存区,一会将被清空
        now_day=results_0_daily_0_date;
        now_address=results_0_location_name;   //北京
        now_weather=results_0_daily_0_text_day;    //晴
        now_temperature=results_0_daily_0_high;    //19
        now_temperature_low=results_0_daily_0_low;

        now_day_1=results_0_daily_1_date;
        now_address_1=results_0_location_name;   //北京
        now_weather_1=results_0_daily_1_text_day;    //晴
        now_temperature_1=results_0_daily_1_high;    //19
        now_temperature_1_low=results_0_daily_1_low;

        now_day_2=results_0_daily_2_date;
        now_address_2=results_0_location_name;   //北京
        now_weather_2=results_0_daily_2_text_night;    //晴
        now_temperature_2=results_0_daily_2_high;    //19
        now_temperature_2_low=results_0_daily_2_low;

        now_weather_3=results_0_daily_2_text_day;    //晴
        now_weather_4=results_0_daily_2_text_night;    //晴
        
        String str0 = "晴";
        String str1 = "阴";
        String str2 = "大雨";
        String str3 = "多云";
        String str4 = "小雨";
        
        if(str0==now_weather)
        {
            tianqinum[0]=0;
        }
        else if (str1==now_weather)
        {
            tianqinum[0]=1;
        }
        else if (str2==now_weather)
        {
            tianqinum[0]=2;
        }
        else if (str3==now_weather)
        {
            tianqinum[0]=3;
        }
        else
        {
            tianqinum[0]=4;
        }

        if(str0==now_weather_1)
        {
            tianqinum[1]=0;
        }
        else if (str1==now_weather_1)
        {
            tianqinum[1]=1;
        }
        else if (str2==now_weather_1)
        {
            tianqinum[1]=2;
        }
        else if (str3==now_weather_1)
        {
            tianqinum[1]=3;
        }
        else
        {
            tianqinum[1]=4;
        }
        

        if(str0==now_weather_2)
        {
            tianqinum[2]=0;
        }
        else if (str1==now_weather_2)
        {
            tianqinum[2]=1;
        }
        else if (str2==now_weather_2)
        {
            tianqinum[2]=2;
        }
        else if (str3==now_weather_2)
        {
            tianqinum[2]=3;
        }
        else
        {
            tianqinum[2]=4;
        }

        if(str0==now_weather_3)
        {
            tianqinum[3]=0;
        }
        else if (str1==now_weather_3)
        {
            tianqinum[3]=1;
        }
        else if (str2==now_weather_3)
        {
            tianqinum[3]=2;
        }
        else if (str3==now_weather_3)
        {
            tianqinum[3]=3;
        }
        else
        {
            tianqinum[3]=4;
        }

        if(str0==now_weather_4)
        {
            tianqinum[4]=0;
        }
        else if (str1==now_weather_4)
        {
            tianqinum[4]=1;
        }
        else if (str2==now_weather_4)
        {
            tianqinum[4]=2;
        }
        else if (str3==now_weather_4)
        {
            tianqinum[4]=3;
        }
        else
        {
            tianqinum[4]=4;
        }

        yearn=(now_day[0]-'0')*1000+(now_day[1]-'0')*100+(now_day[2]-'0')*10+(now_day[3]-'0')*1;
        monthn=(now_day[5]-'0')*10+(now_day[6]-'0');
        dayn=(now_day[8]-'0')*10+(now_day[9]-'0');
        
        today_day=getxingqi(yearn,monthn,dayn);
        http.end();
        delay(100);
        }
        http.end();
        
        https.begin("http://quan.suning.com/getSysTime.do");
        // 从时间网站获得网页内容
        int httpCode = https.GET();
        if (httpCode > 0) 
        {
            Serial.printf("[HTTP] GET... code: %d\n", httpCode);
            if (httpCode == HTTP_CODE_OK) 
            {
                //读取响应内容
                response = https.getString();
                Serial.println(response);

                const size_t capacitys = JSON_OBJECT_SIZE(2) + 60;
                DynamicJsonBuffer jsonBuffers(capacitys);
                JsonObject& roots = jsonBuffers.parseObject(response);
                
                const char* sysTime2 = roots["sysTime2"]; // "2021-08-15 10:21:34"
                const char* sysTime1 = roots["sysTime1"]; // "20210815102134"
                
                now_time=sysTime1;
                https.end();
                delay(100);
            }
        } 
        else 
        {
            Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
        }
        https.end();

  }
}
  1. 日期转换为星期

int getxingqi(int years,int months,int day)
{

    int yd, md; // 定义年份和月份代码
    int dh; // 定义dh为代码和
    int xin;
    int yushu1,yushu2;
    
    yd = ((years%100)/4 + (years%100))%7;
    yushu1 = years%4;
    yushu2 = years%100;
    if(yushu1 = 0 && yushu2 != 0) // 能被4整除不能被100整除是闰年
    {
        if(months == 1)
        {
            md = 5;
        }
        if(months == 2)
        {
            md = 1;
        }
        if(months == 3)
        {
            md = 2;
        }
        if(months == 4)
        {
            md = 5;
        }
        if(months == 5)
        {
            md = 0;
        }
        if(months == 6)
        {
            md = 3;
        }
        if(months == 7)
        {
            md = 5;
        }
        if(months == 8)
        {
            md = 1;
        }
        if(months == 9)
        {
            md = 4;
        }
        if(months == 10)
        {
            md = 6;
        }
        if(months == 11)
        {
            md = 2;
        }
        if(months == 12)
        {
            md = 4;
        }
        xin = (day+md+yd)%7;
        switch(xin)
        {
            case 1:return(1);
            break;
            case 2:return(2);
            break;
            case 3:return(3);
            break;
            case 4:return(4);
            break;
            case 5:return(5);
            break;
            case 6:return(6);
            break;
            case 7:return(0);
            break;
        }
    }
    else
    {
        if(months == 1)
        {
            md = 6;
        }
        if(months == 2)
        {
            md = 2;
        }
        if(months == 3)
        {
            md = 2;
        }
        if(months == 4)
        {
            md = 5;
        }
        if(months == 5)
        {
            md = 0;
        }
        if(months == 6)
        {
            md = 3;
        }
        if(months == 7)
        {
            md = 5;
        }
        if(months == 8)
        {
            md = 1;
        }
        if(months == 9)
        {
            md = 4;
        }
        if(months == 10)
        {
            md = 6;
        }
        if(months == 11)
        {
            md = 2;
        }
        if(months == 12)
        {
            md = 4;
        }
        xin = (day+md+yd) % 7;
        switch(xin)
        {
            case 1:return(1);
            break;
            case 2:return(2);
            break;
            case 3:return(3);
            break;
            case 4:return(4);
            break;
            case 5:return(5);
            break;
            case 6:return(6);
            break;
            case 7:return(0);
            break;
      }
    }
    return 0;
}

  1. 屏幕刷新
void setscreen()
{
  epd.ClearFrameMemory(0xFF);   // bit set = white, bit reset = black
  epd.DisplayFrameFull();
  Serial.println("e-Paper SetFrameMemory");
  paint.SetRotate(ROTATE_270);
  paint.SetWidth(15);
  paint.SetHeight(200);

  paint.Clear(UNCOLORED);
  strCat="";
  sprintf(strCat,"%s             %c%c:%c%c",const_cast<char*>(now_day.c_str()),now_time[8],now_time[9],now_time[10],now_time[11]);
  paint.DrawStringAt(0, 2, strCat, &Font12, COLORED);
  epd.SetFrameMemory(paint.GetImage(), 0, 0, paint.GetWidth(), paint.GetHeight());

  paint.Clear(UNCOLORED);
  strCat="";
  paint.DrawFilledRectangle(0, 0, 200, 0, COLORED);
  sprintf(strCat,"%c%c-%c%c %c%c-%c%c %c%c-%c%c %c%c-%c%c%c%c-%c%c"
  ,monthn/10+'0',monthn%10+'0',dayn/10+'0',dayn%10+'0'
  ,monthn/10+'0',monthn%10+'0',(dayn+1)/10+'0',(dayn+1)%10+'0'
  ,monthn/10+'0',monthn%10+'0',(dayn+2)/10+'0',(dayn+2)%10+'0'
  ,monthn/10+'0',monthn%10+'0',(dayn+3)/10+'0',(dayn+3)%10+'0'
  ,monthn/10+'0',monthn%10+'0',(dayn+4)/10+'0',(dayn+4)%10+'0');
  paint.DrawStringAt(0, 2, strCat, &Font12, COLORED);
  epd.SetFrameMemory(paint.GetImage(), 102, 0, paint.GetWidth(), paint.GetHeight());

  paint.Clear(UNCOLORED);
  strCat="";
  paint.DrawFilledRectangle(0, 15, 200, 15, COLORED);
  sprintf(strCat," %s.   %s.   %s.   %s.   %s. ",
  const_cast<char*>(now_temperature.c_str()),
  const_cast<char*>(now_temperature_1.c_str()),
  const_cast<char*>(now_temperature_2.c_str()),
  const_cast<char*>(now_temperature_1_low.c_str()),
  const_cast<char*>(now_temperature_low.c_str()));
  paint.DrawStringAt(0, 2, strCat, &Font12, COLORED);
  epd.SetFrameMemory(paint.GetImage(), 141, 0, paint.GetWidth(), paint.GetHeight());

  paint.SetWidth(15);
  paint.SetHeight(200);
  paint.Clear(UNCOLORED);
  paint.DrawCharAt(0, 0, ' '+11, &Fontzh14, COLORED);//预
  paint.DrawCharAt(15, 0, ' '+12, &Fontzh14, COLORED);//报

  paint.DrawCharAt(120, 0, ' '+9, &Fontzh14, COLORED);//今
  paint.DrawCharAt(135, 0, ' '+10, &Fontzh14, COLORED);//天

  paint.DrawCharAt(155, 0, ' '+7, &Fontzh14, COLORED);//星
  paint.DrawCharAt(169, 0, ' '+8, &Fontzh14, COLORED);//期
  paint.DrawCharAt(184, 0, ' '+today_day, &Fontzh14, COLORED);//
  
  epd.SetFrameMemory(paint.GetImage(), 81, 0, paint.GetWidth(), paint.GetHeight());

  paint.SetWidth(22);
  paint.SetHeight(200);
  paint.Clear(UNCOLORED);
  paint.DrawCharAt(9, 0, ' '+tianqinum[0], &FontTQ, COLORED);
  paint.DrawCharAt(49, 0, ' '+tianqinum[1], &FontTQ, COLORED);
  paint.DrawCharAt(89, 0, ' '+tianqinum[2], &FontTQ, COLORED);
  paint.DrawCharAt(129, 0, ' '+tianqinum[3], &FontTQ, COLORED);
  paint.DrawCharAt(169, 0, ' '+tianqinum[4], &FontTQ, COLORED);
  epd.SetFrameMemory(paint.GetImage(), 118, 0, paint.GetWidth(), paint.GetHeight());
  
  paint.Clear(UNCOLORED);
  paint.DrawCharAt(0, 2, ' '+7, &Fontzh14, COLORED);//星
  paint.DrawCharAt(15, 2, ' '+8, &Fontzh14, COLORED);//期
  paint.DrawCharAt(30, 2, ' '+((today_day+1)%7), &Fontzh14, COLORED);//
  paint.DrawCharAt(89, 0, ' '+tianqinum[1], &FontTQ, COLORED);

  strCat="";
  sprintf(strCat,"%s.~%s.",const_cast<char*>(now_temperature_1_low.c_str()),const_cast<char*>(now_temperature_1.c_str()));
  paint.DrawStringAt(120, 2, strCat, &Font16, COLORED);
  epd.SetFrameMemory(paint.GetImage(), 157, 0, paint.GetWidth(), paint.GetHeight());

  paint.Clear(UNCOLORED);
  paint.DrawCharAt(0, 2, ' '+7, &Fontzh14, COLORED);//星
  paint.DrawCharAt(15, 2, ' '+8, &Fontzh14, COLORED);//期
  paint.DrawCharAt(30, 2, ' '+((today_day+2)%7), &Fontzh14, COLORED);///
  paint.DrawCharAt(89, 0, ' '+tianqinum[2], &FontTQ, COLORED);

  strCat="";
  sprintf(strCat,"%s.~%s.",const_cast<char*>(now_temperature_2_low.c_str()),const_cast<char*>(now_temperature_2.c_str()));
  paint.DrawStringAt(120, 2, strCat, &Font16, COLORED);
  epd.SetFrameMemory(paint.GetImage(), 178, 0, paint.GetWidth(), paint.GetHeight());

  paint.SetWidth(64);
  paint.SetHeight(100);
  
  paint.Clear(UNCOLORED);
  paint.DrawCharAt(0, 0, now_temperature[0]+' '-'0', &Font64, COLORED);
  paint.DrawCharAt(34, 0, now_temperature[1]+' '-'0', &Font64, COLORED);
  paint.DrawCharAt(66, 0, ' '+10, &Font64, COLORED);
  paint.DrawFilledRectangle(99, 0, 99, 64, COLORED);
  epd.SetFrameMemory(paint.GetImage(), 18, 85, paint.GetWidth(), paint.GetHeight());
  
  paint.SetWidth(64);
  paint.SetHeight(80);
  paint.Clear(UNCOLORED);
  paint.DrawCharAt(25, 3, ' '+tianqinum[0], &FontTQ, COLORED);
  paint.DrawCharAt(25, 28, ' '+today_tianqi[tianqinum[0]][0], &Fontzh14, COLORED);//天气
  paint.DrawCharAt(40, 28, ' '+today_tianqi[tianqinum[0]][1], &Fontzh14, COLORED);//天气

  strCat="";
  sprintf(strCat,"%s.~%s.",const_cast<char*>(now_temperature_low.c_str()),const_cast<char*>(now_temperature.c_str()));
  paint.DrawStringAt(15, 50, strCat, &Font12, COLORED);
  epd.SetFrameMemory(paint.GetImage(), 18, 0, paint.GetWidth(), paint.GetHeight());

  epd.DisplayFrameFull();

}
void setup() {
  get_WIFI();
  get_WIFI();
  SPI.pins(CLK_PIN,MISO,SDI_PIN,CS_PIN);
  SPI.begin();
  Serial.begin(115200);
  if (epd.Init() != 0) 
  {
      Serial.print("e-Paper init failed");
      return;
  }
  epd.ClearFrameMemory(0xFF);   // bit set = white, bit reset = black
  epd.DisplayFrameFull();
  Serial.println("e-Paper SetFrameMemory");
  time_start_ms = millis(); 
}

完整工程下载地址

https://download.csdn.net/download/qq_39541326/21090151?spm=1001.2014.3001.5503

  嵌入式 最新文章
基于高精度单片机开发红外测温仪方案
89C51单片机与DAC0832
基于51单片机宠物自动投料喂食器控制系统仿
《痞子衡嵌入式半月刊》 第 68 期
多思计组实验实验七 简单模型机实验
CSC7720
启明智显分享| ESP32学习笔记参考--PWM(脉冲
STM32初探
STM32 总结
【STM32】CubeMX例程四---定时器中断(附工
上一篇文章      下一篇文章      查看所有文章
加:2021-08-16 11:54:30  更:2021-08-16 11:55:46 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年12日历 -2024/12/28 2:35:05-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码
数据统计