数码之家

 找回密码
 立即注册
搜索
查看: 7617|回复: 41

[Arduino] 超简单DIY之二~制作64*32 LED单色大屏天气预报(开源)

[复制链接]
发表于 2021-2-26 20:01:53 | 显示全部楼层 |阅读模式
上次发的大屏时钟。

[Arduino] 超简单DIY~制作自动授时64*32 LED单色大屏时钟(开源)
https://www.mydigit.cn/forum.php?mod=viewthread&tid=235844

代码内置了中文字库,但是还没用上,今天折腾了一下,把天气预报的部分也搞好了,让新手也能简单上路,搞个带天气预报的时钟。

本次硬件还是和上次的一样,只做了些软件的修改。
需要自己去"心知天气"申请一个帐号,获得api-key。然后填到代码开头的相应位置。注意后面城市名,我写的是nanjing,各人自己修改好。有重名的话,去心知天气网站找到自己城市的代号填上去,更准确。

我写的屏幕布局只是个例子,自己可以随意修改。就在代码的最后部分。那些都是在屏幕上打印字符串的函数,其中两个数字参数就是屏幕的x,y坐标,根据自己需要修改试验就行了。

在我家的墙上挂的是这个,只是很久以前做的,不管是硬件还是软件都很烂,就不分享了。怕麻烦的同学直接做两个,并排放就可以了。

  1. //D0 = GPIO16;
  2. //D1 = GPIO5;
  3. //D2 = GPIO4;        LED on esp8266
  4. //D3 = GPIO0;can not download when connected to low
  5. //D4 = GPIO2;       
  6. //D5 = GPIO14;  
  7. //D6 = GPIO12;
  8. //D7 = GPIO13;
  9. //D8 = GPIO15;  can not start when high input
  10. //D9 = GPIO3; UART RX
  11. //D10 = GPIO1; UART TX
  12. //LED_BUILTIN = GPIO16 (auxiliary constant for the board LED, not a board pin);

  13. #include<ESP8266WiFi.h>
  14. #include<WiFiUdp.h>
  15. #include<ESP8266mDNS.h>
  16. #include<ArduinoOTA.h>
  17. #include<ESP8266WiFiMulti.h>
  18. #include<ESP8266WiFiGeneric.h>
  19. #include<time.h>

  20. #include <U8g2lib.h>
  21. u8g2_t u8g2;

  22. //Include the client
  23. //#include <WiFiClientSecure.h>
  24. #include <WiFiClient.h>

  25. //Add a client
  26. WiFiClient client;

  27. #define timezone 8

  28. unsigned long Cycle = 1000;//刷新间隔,微秒
  29. unsigned long DisplayLight = 50;//亮度

  30. //一定要修改这里,使用自己的wifi信息
  31. #include "D:\GitHub\Private\wifi_config.h"
  32. //const char* ssid = "wang";  //Wifi名称
  33. //const char* password = "12345678";  //Wifi密码

  34. //我自己用的key保存在配置文件里了,不公开了。
  35. //要改用下面那一行URL,并把xxxxxxxxxxxxxxxxxxx改成你在“心知天气”申请到的key。
  36. #include "D:\GitHub\Private\weather_config.h"
  37. //String URL = "/v3/weather/daily.json?key=xxxxxxxxxxxxxxxxxxx&location=nanjing&language=zh-Hans&unit=c&start=0&days=3";


  38. char *time_str;   
  39. char H1,H2,M1,M2,S1,S2;

  40. unsigned long SecondsSinceStart = 0;
  41. unsigned long TenthSecondsSinceStart = 0;
  42. void TenthSecondsSinceStartTask();
  43. void OnSecond();
  44. void OnHour();
  45. void NonStopTask();

  46. unsigned long TimeOut = 30;
  47. bool ssl_getValue(const char* string, unsigned char* Value, unsigned char* Len, unsigned char Start, unsigned char Max);
  48. bool ssl_waitFor(const char* string);
  49. bool ssl_getch(char* RetData);
  50. char Weather[3][7];//"中雨"
  51. char Date[3][6];//"02-28"
  52. char HighTemperature[3][4];//-15
  53. char LowTemperature[3][4];


  54. #define RowA D8                    //行信号,驱动138  
  55. #define RowB D7
  56. #define RowC D6
  57. #define RowD D5
  58. #define STB D2         //595 刷新显示  SS  
  59. #define CLK D1         //时钟    SCK  
  60. #define OE D0                         //  使能  
  61. #define R1 D4          //上半屏列信号输出   
  62. #define R2 D3          //下半屏列信号输出   

  63. void setup()
  64. {      
  65.         delay(50);                     
  66.         Serial.begin(115200);

  67.         pinMode(RowA, OUTPUT);
  68.         pinMode(RowB, OUTPUT);
  69.         pinMode(RowC, OUTPUT);
  70.         pinMode(RowD, OUTPUT); //138片选
  71.         pinMode(OE, OUTPUT); //138 使能
  72.         pinMode(R1, OUTPUT);//595 数据
  73.         pinMode(R2, OUTPUT);//595 数据
  74.         pinMode(CLK, OUTPUT); //595 时钟
  75.         pinMode(STB, OUTPUT); //595 使能

  76.         WiFi.disconnect();
  77.         WiFi.mode(WIFI_STA);//设置模式为STA
  78.         byte mac[6];
  79.         WiFi.softAPmacAddress(mac);
  80.         printf("macAddress 0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X\r\n",mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]);

  81.         Serial.print("Is connection routing, please wait");  
  82.         WiFi.begin(ssid, password); //Wifi接入到网络
  83.         Serial.println("\nConnecting to WiFi");
  84.         //如果Wifi状态不是WL_CONNECTED,则表示连接失败
  85.         unsigned char WiFiTimeOut = 0;
  86.         while (WiFi.status() != WL_CONNECTED) {  
  87.                 Serial.print(".");
  88.                 delay(1000);    //延时等待接入网络
  89.                 WiFiTimeOut++;
  90.                 if (WiFiTimeOut>10)
  91.                 {
  92.                         break;
  93.                         Serial.println("\nConnecting to WiFi Failed");
  94.                 }
  95.         }

  96.         //设置时间格式以及时间服务器的网址
  97.         configTime(timezone * 3600, 0, "pool.ntp.org", "time.nist.gov");
  98.         Serial.println("\nWaiting for time");
  99.         while (!time(nullptr)) {
  100.                 Serial.print(".");
  101.                 delay(1000);   
  102.         }
  103.         Serial.println("");


  104.         //开启OTA功能。除了第一次需要用USB下载,以后就可以使用WiFi下载程序了。
  105.         ArduinoOTA.onStart([]() {
  106.                 String type;
  107.                 if (ArduinoOTA.getCommand() == U_FLASH) {
  108.                         type = "sketch";
  109.                 } else { // U_SPIFFS
  110.                         type = "filesystem";
  111.                 }
  112.                 // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
  113.                 Serial.println("Start updating " + type);
  114.         });
  115.         ArduinoOTA.onEnd([]() {
  116.                 Serial.println("\nEnd");
  117.         });
  118.         ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
  119.                 Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  120.         });
  121.         ArduinoOTA.onError([](ota_error_t error) {
  122.                 Serial.printf("Error[%u]: ", error);
  123.                 if (error == OTA_AUTH_ERROR) {
  124.                         Serial.println("Auth Failed");
  125.                 } else if (error == OTA_BEGIN_ERROR) {
  126.                         Serial.println("Begin Failed");
  127.                 } else if (error == OTA_CONNECT_ERROR) {
  128.                         Serial.println("Connect Failed");
  129.                 } else if (error == OTA_RECEIVE_ERROR) {
  130.                         Serial.println("Receive Failed");
  131.                 } else if (error == OTA_END_ERROR) {
  132.                         Serial.println("End Failed");
  133.                 }
  134.         });
  135.         ArduinoOTA.begin();
  136.         Serial.println("Ready");
  137.         Serial.print("IP address: ");
  138.         Serial.println(WiFi.localIP());

  139.         u8g2_Setup_ssd1306_64x32_noname_f(&u8g2, U8G2_R0, NULL, NULL);  // init u8g2 structure

  140. }

  141. void hc138sacn(byte r)   //输出行线状态ABCD (A低,D高)
  142. {
  143.         digitalWrite(RowA,(r & 0x01));
  144.         digitalWrite(RowB,(r & 0x02));
  145.         digitalWrite(RowC,(r & 0x04));
  146.         digitalWrite(RowD,(r & 0x08));
  147. }

  148. void DisplayOneLine()
  149. {
  150.         //显示缓存扫描
  151.         static unsigned char row=0;
  152.         for (int i=0; i<64; i++)
  153.         {
  154.                 digitalWrite(CLK,0);
  155.                 digitalWrite(R1, ((u8g2.tile_buf_ptr[i%64+(row/8)*64]>>(row%8))&1));//发送上半屏
  156.                 digitalWrite(R2, ((u8g2.tile_buf_ptr[i%64+(row/8)*64+128]>>(row%8))&1));//发送下半屏
  157.                 digitalWrite(CLK,1);
  158.         }

  159.         hc138sacn(row);            //选行
  160.         digitalWrite(STB, 1);      //数据确认
  161.         digitalWrite(STB, 0);
  162.         if (DisplayLight>0)
  163.         {
  164.                 digitalWrite(OE, 0);  //开启显示
  165.         }
  166.         delayMicroseconds(DisplayLight) ;  //亮度调节
  167.         digitalWrite(OE, 1);  //关闭显示
  168.         row++;
  169.         if (row>15)
  170.         {
  171.                 row = 0;
  172.                 NonStopTask();
  173.         }
  174. }

  175. unsigned long CurrentDisplayTime;
  176. unsigned long LastDisplayTime;
  177. void DisplayTimerTask()
  178. {
  179.         CurrentDisplayTime = micros();
  180.         if (abs(CurrentDisplayTime - LastDisplayTime) > Cycle)
  181.         {
  182.                 LastDisplayTime = CurrentDisplayTime;
  183.                 DisplayOneLine();
  184.         }
  185. }

  186. void loop()
  187. {
  188.         DisplayTimerTask();
  189. }

  190. void NonStopTask()
  191. {
  192.         TenthSecondsSinceStartTask();
  193.         ArduinoOTA.handle();
  194. }

  195. void OnTenthSecond()
  196. {
  197.         if (TenthSecondsSinceStart % 10 == 0)
  198.         {
  199.                 OnSecond();
  200.                 SecondsSinceStart++;

  201.                 if (SecondsSinceStart % 3600 == 5)//每小时运行,并且保证启动5秒后也运行一次
  202.                 {
  203.                         OnHour();
  204.                 }

  205.         }

  206. }

  207. unsigned long LastMillis = 0;
  208. void TenthSecondsSinceStartTask()
  209. {
  210.         unsigned long CurrentMillis = millis();
  211.         if (abs(CurrentMillis - LastMillis) > 100)
  212.         {
  213.                 LastMillis = CurrentMillis;
  214.                 TenthSecondsSinceStart++;
  215.                 OnTenthSecond();
  216.         }
  217. }


  218. char* WeekStr[7] = { "Sunday"
  219.                                                         ,"Monday"
  220.                                                         ,"Tuesday"
  221.                                                         ,"Wednesday"
  222.                                                         ,"Thursday"
  223.                                                         ,"Friday"
  224.                                                         ,"Saturday" };




  225. bool ssl_waitFor(const char* string) {
  226.         char so_far = 0;
  227.         char received;
  228.         int counter = 0;
  229.         do {
  230.                 if (!ssl_getch(&received))
  231.                 {
  232.                         return false;
  233.                 }
  234.                 counter++;
  235.                 if (received == string[so_far]) {
  236.                         so_far++;
  237.                 }
  238.                 else {
  239.                         so_far = 0;
  240.                 }
  241.         } while (string[so_far] != 0);
  242.         return true;
  243. }

  244. bool ssl_getValue(const char* string, unsigned char* Value, unsigned char* Len, unsigned char Start, unsigned char Max)
  245. {
  246.         char received;
  247.         *Len = 0;
  248.         unsigned char CurrentChar = 0;

  249.         if (!ssl_waitFor(string)) return false;

  250.         unsigned long RecvStartTime = SecondsSinceStart;
  251.         while (1)
  252.         {
  253.                 if (!ssl_getch(&received))
  254.                 {
  255.                         return false;
  256.                 }

  257.                 if ((received == '"') || ((*Len) >= Max))
  258.                 {
  259.                         return true;
  260.                 }
  261.                 else
  262.                 {
  263.                         if (CurrentChar >= Start)
  264.                         {
  265.                                 *(Value + (*Len)) = received;
  266.                                 (*Len) = (*Len) + 1;
  267.                         }
  268.                         else
  269.                         {
  270.                                 CurrentChar++;
  271.                         }
  272.                 }

  273.                 if (SecondsSinceStart - RecvStartTime > TimeOut)
  274.                 {
  275.                         return false;
  276.                 }
  277.         }
  278. }

  279. bool ssl_getch(char* RetData)
  280. {
  281.         //static bool WaitFinsih = false;
  282.         //static unsigned char CompareIndex = 0;
  283.         //static bool NewLine = false;

  284.         unsigned long RecvStartTime = SecondsSinceStart;
  285.         while (1)
  286.         {
  287.                 if (client.available() > 0)
  288.                 {
  289.                         *RetData = client.read();
  290.                         return true;
  291.                 }
  292.                 else
  293.                 {
  294.                         //NonStopTask();
  295.                         DisplayTimerTask();
  296.                 }

  297.                 if (SecondsSinceStart - RecvStartTime > TimeOut)
  298.                 {
  299.                         return false;
  300.                 }
  301.         }
  302. }

  303. //收到的天气数据,举例:
  304. //{"results":[{"location":{"id":"WTSQQYHVQ973","name":"南京","country":"CN","path":"南京,南京,江苏,中国","timezone":"Asia/Shanghai",
  305. //"timezone_offset":"+08:00"},"daily":[
  306. //{"date":"2021-02-26","text_day":"小雨","code_day":"13","text_night":"小雨","code_night":"13","high":"7","low":"5","rainfall":"6.1","precip":"","wind_direction":"东北","wind_direction_degree":"45","wind_speed":"23.4","wind_scale":"4","humidity":"91"},
  307. //{"date":"2021-02-27","text_day":"阴","code_day":"9","text_night":"阴","code_night":"9","high":"14","low":"6","rainfall":"0.0","precip":"","wind_direction":"东","wind_direction_degree":"90","wind_speed":"32.8","wind_scale":"5","humidity":"71"},
  308. //{"date":"2021-02-28","text_day":"阴","code_day":"9","text_night":"小雨","code_night":"13","high":"17","low":"11","rainfall":"0.0","precip":"","wind_direction":"东南","wind_direction_degree":"135","wind_speed":"32.8","wind_scale":"5","humidity":"77"}],
  309. //"last_update":"2021-02-26T11:00:00+08:00"}]}
  310. void OnHour()
  311. {



  312.         long now;
  313.         char host[] = "api.seniverse.com";

  314.         printf("Conneting weather server\r\n");
  315.         if (client.connect(host, 80)) {
  316.                 Serial.println("connected");

  317.                 client.println("GET " + URL + " HTTP/1.1");
  318.                 client.print("Host: "); client.println(host);
  319.                 client.println("User-Agent: arduino/1.0");
  320.                 client.println("");

  321.                 TimeOut = 10;
  322.                 if(!ssl_waitFor("200 OK")) return;
  323.                 TimeOut = 2;

  324.                
  325.                 printf("Got weather info OK\r\n");

  326.                 //print everything recived
  327.                 //now = millis();
  328.                 //while (millis() - now < 1500)
  329.                 //{
  330.                 //        while (client.available())
  331.                 //        {
  332.                 //                char c = client.read();
  333.                 //                printf("%c", c);
  334.                 //        }
  335.                 //}


  336.                 unsigned char valueLen;

  337.                 for (int i = 0; i < 3; i++)//循环取3天的天气信息
  338.                 {
  339.                         //先找到 date":", 往后跳5个字符,然后最多取5个字符,得到日期。
  340.                         ssl_getValue("date":"", (unsigned char*)Date[i], &valueLen, 5, 5);
  341.                         Date[i][valueLen] = 0;
  342.                         printf("date:%s\r\n", Date[i]);

  343.                         //先找到 t_day":", 往后跳0个字符,然后最多取6个字符,得到白天天气。
  344.                         ssl_getValue("t_day":"", (unsigned char*)Weather[i], &valueLen, 0, 6);
  345.                         Weather[i][valueLen] = 0;
  346.                         printf("Weather:%s\r\n", Weather[i]);

  347.                         //先找到 high":", 往后跳0个字符,然后最多取3个字符,得到温度。
  348.                         ssl_getValue("high":"", (unsigned char*)HighTemperature[i], &valueLen, 0, 3);
  349.                         HighTemperature[i][valueLen] = 0;
  350.                         printf("High:%s\r\n", HighTemperature[i]);

  351.                         //先找到 low":", 往后跳0个字符,然后最多取3个字符,得到温度。
  352.                         ssl_getValue("low":"", (unsigned char*)LowTemperature[i], &valueLen, 0, 3);
  353.                         LowTemperature[i][valueLen] = 0;
  354.                         printf("Low:%s\r\n", LowTemperature[i]);
  355.                 }

  356.         }
  357.         else
  358.         {
  359.                 Serial.println("connecte failed");
  360.         }
  361. }

  362. void OnSecond()
  363. {
  364.         static char sprint_buf[20];

  365.         time_t now = time(nullptr); //获取当前时间


  366.         //转换成年月日的数字,可以更加自由的显示。
  367.         struct   tm* timenow;
  368.         timenow = localtime(&now);
  369.         unsigned char tempHour = timenow->tm_hour;
  370.         unsigned char tempMinute = timenow->tm_min;
  371.         unsigned char tempSecond = timenow->tm_sec;
  372.         unsigned char tempDay = timenow->tm_mday;
  373.         unsigned char tempMonth = timenow->tm_mon + 1;
  374.         unsigned int tempYear = timenow->tm_year + 1900;
  375.         unsigned char tempWeek = timenow->tm_wday;


  376.         u8g2_ClearBuffer(&u8g2);//清空显存
  377.         //u8g2_SetFont(&u8g2, u8g2_font_crox3t_tn);
  378.         ////第一行大字,显示时间
  379.         //sprintf(sprint_buf, "%02d:%02d:%02d"
  380.         //        , tempHour
  381.         //        , tempMinute
  382.         //        , tempSecond
  383.         //);
  384.         //u8g2_DrawStr(&u8g2, 3, 12, sprint_buf);

  385.         ////第二行小字,显示日期
  386.         //u8g2_SetFont(&u8g2, u8g2_font_IPAandRUSLCD_tf);//字体5*7
  387.         //sprintf(sprint_buf, "%04d-%02d-%02d"
  388.         //        , tempYear
  389.         //        , tempMonth
  390.         //        , tempDay
  391.         //);
  392.         //u8g2_DrawStr(&u8g2, 0, 22, sprint_buf);

  393.         ////第三行小字,显示星期
  394.         //sprintf(sprint_buf, "%s"
  395.         //        , WeekStr[tempWeek]
  396.         //);
  397.         //u8g2_DrawStr(&u8g2, 0, 31, sprint_buf);

  398.         u8g2_SetFont(&u8g2, u8g2_font_IPAandRUSLCD_tf);//字体5*7

  399.         u8g2_DrawStr(&u8g2, 0, 8, Date[0]);
  400.         u8g2_DrawStr(&u8g2, 0, 16, LowTemperature[0]);
  401.         u8g2_DrawStr(&u8g2, 18, 16, HighTemperature[0]);

  402.         u8g2_DrawStr(&u8g2, 32, 8, Date[1]);
  403.         u8g2_DrawStr(&u8g2, 32, 16, LowTemperature[1]);
  404.         u8g2_DrawStr(&u8g2, 18+32, 16, HighTemperature[1]);

  405.         //显示中文
  406.         u8g2_SetFont(&u8g2, u8g2_font_wqy16_t_gb2312);
  407.         u8g2_DrawUTF8(&u8g2, 0, 30, Weather[0]);
  408.         u8g2_DrawUTF8(&u8g2, 32, 30, Weather[1]);
  409. }
复制代码



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

打赏

参与人数 1家元 +10 收起 理由
jf201006 + 10 謝謝分享

查看全部打赏

发表于 2021-2-27 12:23:26 | 显示全部楼层
这个内置中文字库是怎么做的
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-2-27 12:45:37 | 显示全部楼层
dujq 发表于 2021-2-27 12:23
这个内置中文字库是怎么做的

Arduino的库管理器里可以下载一个u8g2的显示屏驱动,自带16*·16的中文字库。而且还有超多的英文字库,各种图标。可以到它的github页面去看样式。
回复 支持 反对

使用道具 举报

发表于 2021-2-27 14:48:04 | 显示全部楼层
fryefryefrye 发表于 2021-2-27 12:45
Arduino的库管理器里可以下载一个u8g2的显示屏驱动,自带16*·16的中文字库。而且还有超多的英文字库,各 ...

感谢回复,我去看看:praise:
回复 支持 反对

使用道具 举报

发表于 2021-3-1 17:16:58 | 显示全部楼层
这个更高端了,收藏
回复 支持 反对

使用道具 举报

发表于 2021-3-2 13:38:40 来自手机浏览器 | 显示全部楼层
厉害了,不错不错
回复 支持 反对

使用道具 举报

发表于 2021-3-5 21:23:12 来自手机浏览器 | 显示全部楼层
看着大气、智能
回复 支持 反对

使用道具 举报

发表于 2021-4-1 15:58:51 | 显示全部楼层
谢谢分享 这个能显示天气和时间比较实用了
回复 支持 反对

使用道具 举报

发表于 2021-4-25 11:10:28 | 显示全部楼层
#include "D:\GitHub\Private\wifi_config.h"

#include "D:\GitHub\Private\weather_config.h"

你好,这两个地方编译不过,要更改还是删除呀
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-4-25 19:28:49 | 显示全部楼层
barve 发表于 2021-4-25 11:10
#include "D:\GitHub\Private\wifi_config.h"

#include "D:\GitHub\Private\weather_config.h"

看看这部分代码的上下文好不好。我把我自己的密码写在了那些h文件里。你只要删除掉这些包含,把附近的设置信息修改好就行了。
回复 支持 反对

使用道具 举报

发表于 2021-4-25 21:26:33 | 显示全部楼层
fryefryefrye 发表于 2021-4-25 19:28
看看这部分代码的上下文好不好。我把我自己的密码写在了那些h文件里。你只要删除掉这些包含,把附近的设置 ...

wifi_config.h
weather_config.h

我改了自己的Wifi用户名密码和天气key了,是想问一下这两个.h文件是自己生成的还是下载的呀,我总找不到
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-4-25 21:40:32 | 显示全部楼层
barve 发表于 2021-4-25 21:26
wifi_config.h
weather_config.h

那两个文件里面保存了我家的密码做测试用的。你不需要这两个文件。直接删除包含文件的这一行就行了。
回复 支持 反对

使用道具 举报

发表于 2021-4-25 21:48:06 | 显示全部楼层
fryefryefrye 发表于 2021-4-25 21:40
那两个文件里面保存了我家的密码做测试用的。你不需要这两个文件。直接删除包含文件的这一行就行了。 ...

//一定要修改这里,使用自己的wifi信息
//const char* ssid = "用户名";  //Wifi名称
//const char* password = "密码";  //Wifi密码

//要改用下面那一行URL,并把xxxxxxxxxxxxxxxxxxx改成你在“心知天气”申请到的key。
//String URL = "/v3/weather/daily.json?key=秘钥​选择公钥&location=puning&language=zh-Hans&unit=c&start=0&days=3";

你好,是不是这样就好
回复 支持 反对

使用道具 举报

发表于 2021-4-25 21:50:25 | 显示全部楼层

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-4-26 08:47:46 | 显示全部楼层
barve 发表于 2021-4-25 21:48
//一定要修改这里,使用自己的wifi信息
//const char* ssid = "用户名";  //Wifi名称
//const char* passw ...

晕。
//意思就是这个符号后面的代码是无效。 在//后面的代码是不会运行的。
要改成这样:


//一定要修改这里,使用自己的wifi信息
const char* ssid = "用户名";  //Wifi名称
const char* password = "密码";  //Wifi密码

//要改用下面那一行URL,并把xxxxxxxxxxxxxxxxxxx改成你在“心知天气”申请到的key。
String URL = "/v3/weather/daily.json?key=秘钥​选择公钥&location=puning&language=zh-Hans&unit=c&start=0&days=3";
回复 支持 反对

使用道具 举报

发表于 2021-4-26 12:13:25 | 显示全部楼层
fryefryefrye 发表于 2021-4-26 08:47
晕。
//意思就是这个符号后面的代码是无效。 在//后面的代码是不会运行的。
要改成这样:

嗯嗯,改好了,也过啦,不过下边的又问题
回复 支持 反对

使用道具 举报

发表于 2021-4-26 12:14:01 | 显示全部楼层

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-4-26 14:34:57 | 显示全部楼层
barve 发表于 2021-4-26 12:13
嗯嗯,改好了,也过啦,不过下边的又问题

论坛发的代码,有些转意符号被删了。从下面的地址看源文件吧。

https://gitee.com/fryefryefrye/O ... unit_u8g2_weather.h
回复 支持 反对

使用道具 举报

发表于 2021-4-27 12:51:39 | 显示全部楼层
fryefryefrye 发表于 2021-4-26 14:34
论坛发的代码,有些转意符号被删了。从下面的地址看源文件吧。

https://gitee.com/fryefryefrye/Open-So ...

看您的帖子学习您的代码时,看了您在 github 和 gitee 的代码库,看后有个建议和您共同探讨一下。我建议您把不同的项目代码分别创建git仓库,来存储在本地以及远程服务器上,而不是像当前这样全部存储在一个同一个仓库中。

这样建议有两个原因:
1、因为现在你所有的项目代码全在一个库中,别人如果想要克隆你的某个项目代码,就需要把你全部的代码都克隆下来,而这并不是必要的。
2、更重要的原因在于,这其中你任何一个项目的代码产生了更新时,都需要做一次commit,这样非常不利于你管理每个单独项目。比如你某个项目需要回滚操作,那么你发现这将会严重影响其他并不需要回滚操作的项目代码。

只是在学习过程中产生的一点个人想法,不一定正确,仅供参考:smile:
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

APP|手机版|小黑屋|关于我们|联系我们|法律条款|技术知识分享平台

闽公网安备35020502000485号

闽ICP备2021002735号-2

GMT+8, 2024-4-25 23:37 , Processed in 0.156000 second(s), 10 queries , Redis On.

Powered by Discuz!

© 2006-2023 smzj.net

快速回复 返回顶部 返回列表