|
12 | 12 | *
|
13 | 13 | *
|
14 | 14 | * 引 脚 分 配:SCK GPIO14
|
15 |
| - * MOSI GPIO13 |
16 |
| - * RES GPIO2 |
17 |
| - * DC GPIO0 |
18 |
| - * LCDBL GPIO5 |
| 15 | + * MOSI GPIO13 |
| 16 | + * RES GPIO2 |
| 17 | + * DC GPIO0 |
| 18 | + * LCDBL GPIO5 |
19 | 19 | *
|
20 | 20 | * 增加DHT11温湿度传感器,传感器接口为 GPIO 12
|
21 | 21 | *
|
|
40 | 40 | #include <StaticThreadController.h> //协程控制
|
41 | 41 |
|
42 | 42 | #include "config.h" //配置文件
|
43 |
| -#include "number/number.h" //数字字库 |
44 | 43 | #include "weatherNum/weatherNum.h" //天气图库
|
45 | 44 | #include "Animate/Animate.h" //动画模块
|
46 | 45 | #include "wifiReFlash/wifiReFlash.h" //WIFI功能模块
|
@@ -70,15 +69,16 @@ Button2 Button_sw1 = Button2(4);
|
70 | 69 | /* *****************************************************************
|
71 | 70 | * 字库、图片库
|
72 | 71 | * *****************************************************************/
|
73 |
| -#include "font/ZdyLwFont_20.h" //字体库 |
74 |
| -#include "img/temperature.h" //温度图标 |
75 |
| -#include "img/humidity.h" //湿度图标 |
| 72 | +#include "font/ZdyLwFont_20.h" //字体库 |
| 73 | +#include "font/timeClockFont.h" //字体库 |
| 74 | +#include "img/temperature.h" //温度图标 |
| 75 | +#include "img/humidity.h" //湿度图标 |
76 | 76 |
|
77 | 77 | //函数声明
|
78 | 78 | void sendNTPpacket(IPAddress &address); //向NTP服务器发送请求
|
79 | 79 | time_t getNtpTime(); //从NTP获取时间
|
80 | 80 |
|
81 |
| -void digitalClockDisplay(int reflash_en); |
| 81 | +// void digitalClockDisplay(int reflash_en); |
82 | 82 | void printDigits(int digits);
|
83 | 83 | String num2str(int digits);
|
84 | 84 | void LCD_reflash();
|
@@ -119,7 +119,7 @@ struct config_type
|
119 | 119 | };
|
120 | 120 | //---------------修改此处""内的信息--------------------
|
121 | 121 | //如开启WEB配网则可不用设置这里的参数,前一个为wifi ssid,后一个为密码
|
122 |
| -config_type wificonf = {{"HUAWEI-0G17LY"}, {"19990823"}}; |
| 122 | +config_type wificonf = {{"WiFi名"}, {"密码"}}; |
123 | 123 |
|
124 | 124 | //天气更新时间 X 分钟
|
125 | 125 | unsigned int updateweater_time = 1;
|
@@ -151,7 +151,6 @@ time_t prevDisplay = 0; //显示时间显示记录
|
151 | 151 | int Amimate_reflash_Time = 0; //更新时间记录
|
152 | 152 |
|
153 | 153 | /*** Component objects ***/
|
154 |
| -Number dig; |
155 | 154 | WeatherNum wrat;
|
156 | 155 |
|
157 | 156 | uint32_t targetTime = 0;
|
@@ -346,7 +345,6 @@ void Serial_set()
|
346 | 345 | String incomingByte = "";
|
347 | 346 | if (Serial.available() > 0)
|
348 | 347 | {
|
349 |
| - |
350 | 348 | while (Serial.available() > 0) //监测串口缓存,当有数据输入时,循环赋值给incomingByte
|
351 | 349 | {
|
352 | 350 | incomingByte += char(Serial.read()); //读取单个字符值,转换为字符,并按顺序一个个赋值给incomingByte
|
@@ -1000,34 +998,74 @@ void scrollBanner()
|
1000 | 998 | // }
|
1001 | 999 | }
|
1002 | 1000 |
|
1003 |
| -unsigned char Hour_sign = 60; |
1004 |
| -unsigned char Minute_sign = 60; |
1005 |
| -unsigned char Second_sign = 60; |
1006 |
| -// 时钟刷新,输入1强制刷新 |
1007 |
| -void digitalClockDisplay(int reflash_en = 0) |
| 1001 | +// 用快速线方法绘制数字 |
| 1002 | +void drawLineFont(uint32_t _x, uint32_t _y, uint32_t _num, uint32_t _size, uint32_t _color) |
1008 | 1003 | {
|
1009 |
| - int now_hour = hour(); //获取小时 |
1010 |
| - int now_minu = minute(); //获取分钟 |
1011 |
| - int now_seco = second(); //获取秒针 |
| 1004 | + uint32_t fontSize; |
| 1005 | + const LineAtom *fontOne; |
| 1006 | + // 小号(9*14) |
| 1007 | + if (_size == 1) |
| 1008 | + { |
| 1009 | + fontOne = smallLineFont[_num]; |
| 1010 | + fontSize = smallLineFont_size[_num]; |
| 1011 | + // 绘制前清理字体绘制区域 |
| 1012 | + tft.fillRect(_x, _y, 9, 14, TFT_BLACK); |
| 1013 | + } |
| 1014 | + // 中号(18*30) |
| 1015 | + else if (_size == 2) |
| 1016 | + { |
| 1017 | + fontOne = middleLineFont[_num]; |
| 1018 | + fontSize = middleLineFont_size[_num]; |
| 1019 | + // 绘制前清理字体绘制区域 |
| 1020 | + tft.fillRect(_x, _y, 18, 30, TFT_BLACK); |
| 1021 | + } |
| 1022 | + // 大号(36*90) |
| 1023 | + else if (_size == 3) |
| 1024 | + { |
| 1025 | + fontOne = largeLineFont[_num]; |
| 1026 | + fontSize = largeLineFont_size[_num]; |
| 1027 | + // 绘制前清理字体绘制区域 |
| 1028 | + tft.fillRect(_x, _y, 36, 90, TFT_BLACK); |
| 1029 | + } |
| 1030 | + else |
| 1031 | + return; |
| 1032 | + |
| 1033 | + for (uint32_t i = 0; i < fontSize; i++) |
| 1034 | + { |
| 1035 | + tft.drawFastHLine(fontOne[i].xValue + _x, fontOne[i].yValue + _y, fontOne[i].lValue, _color); |
| 1036 | + } |
| 1037 | +} |
1012 | 1038 |
|
1013 |
| - int timey = 82; |
1014 |
| - if ((now_hour != Hour_sign) || (reflash_en == 1)) //时钟刷新 |
| 1039 | +int Hour_sign = 60; |
| 1040 | +int Minute_sign = 60; |
| 1041 | +int Second_sign = 60; |
| 1042 | +// 日期刷新 |
| 1043 | +void digitalClockDisplay(int reflash_en = 0) |
| 1044 | +{ |
| 1045 | + // 时钟刷新,输入1强制刷新 |
| 1046 | + int now_hour = hour(); //获取小时 |
| 1047 | + int now_minute = minute(); //获取分钟 |
| 1048 | + int now_second = second(); //获取秒针 |
| 1049 | + //小时刷新 |
| 1050 | + if ((now_hour != Hour_sign) || (reflash_en == 1)) |
1015 | 1051 | {
|
1016 |
| - dig.printfW3660(20, timey, now_hour / 10); |
1017 |
| - dig.printfW3660(60, timey, now_hour % 10); |
| 1052 | + drawLineFont(20, timeY, now_hour / 10, 3, SD_FONT_WHITE); |
| 1053 | + drawLineFont(60, timeY, now_hour % 10, 3, SD_FONT_WHITE); |
1018 | 1054 | Hour_sign = now_hour;
|
1019 | 1055 | }
|
1020 |
| - if ((now_minu != Minute_sign) || (reflash_en == 1)) //分钟刷新 |
| 1056 | + //分钟刷新 |
| 1057 | + if ((now_minute != Minute_sign) || (reflash_en == 1)) |
1021 | 1058 | {
|
1022 |
| - dig.printfO3660(101, timey, now_minu / 10); |
1023 |
| - dig.printfO3660(141, timey, now_minu % 10); |
1024 |
| - Minute_sign = now_minu; |
| 1059 | + drawLineFont(101, timeY, now_minute / 10, 3, SD_FONT_YELLOW); |
| 1060 | + drawLineFont(141, timeY, now_minute % 10, 3, SD_FONT_YELLOW); |
| 1061 | + Minute_sign = now_minute; |
1025 | 1062 | }
|
1026 |
| - if ((now_seco != Second_sign) || (reflash_en == 1)) //分钟刷新 |
| 1063 | + //秒针刷新 |
| 1064 | + if ((now_second != Second_sign) || (reflash_en == 1)) //分钟刷新 |
1027 | 1065 | {
|
1028 |
| - dig.printfW1830(182, timey + 30, now_seco / 10); |
1029 |
| - dig.printfW1830(202, timey + 30, now_seco % 10); |
1030 |
| - Second_sign = now_seco; |
| 1066 | + drawLineFont(182, timeY + 30, now_second / 10, 2, SD_FONT_WHITE); |
| 1067 | + drawLineFont(202, timeY + 30, now_second % 10, 2, SD_FONT_WHITE); |
| 1068 | + Second_sign = now_second; |
1031 | 1069 | }
|
1032 | 1070 |
|
1033 | 1071 | if (reflash_en == 1)
|
@@ -1139,7 +1177,8 @@ void wifi_reset(Button2 &btn)
|
1139 | 1177 | void reflashTime()
|
1140 | 1178 | {
|
1141 | 1179 | prevDisplay = now();
|
1142 |
| - digitalClockDisplay(1); |
| 1180 | + // timeClockDisplay(1); |
| 1181 | + digitalClockDisplay(); |
1143 | 1182 | prevTime = 0;
|
1144 | 1183 | }
|
1145 | 1184 |
|
@@ -1332,7 +1371,6 @@ void setup()
|
1332 | 1371 |
|
1333 | 1372 | reflash_Animate.setInterval(TMS / 10); //设置帧率
|
1334 | 1373 | reflash_openWifi.onRun(refresh_AnimatedImage);
|
1335 |
| - |
1336 | 1374 | controller.run();
|
1337 | 1375 | }
|
1338 | 1376 |
|
|
0 commit comments