






Started logging.

<<<
Content-Length: 3505

{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":2616,"clientInfo":{"name":"vscode","version":"1.50.0"},"rootPath":"c:\\Users\\zhang'pei\\Desktop\\ESP32视频游戏开发板程序\\圆屏天气预报\\时钟\\时钟\\SmallDesktopDisplay","rootUri":"file:///c%3A/Users/zhang%27pei/Desktop/ESP32%E8%A7%86%E9%A2%91%E6%B8%B8%E6%88%8F%E5%BC%80%E5%8F%91%E6%9D%BF%E7%A8%8B%E5%BA%8F/%E5%9C%86%E5%B1%8F%E5%A4%A9%E6%B0%94%E9%A2%84%E6%8A%A5/%E6%97%B6%E9%92%9F/%E6%97%B6%E9%92%9F/SmallDesktopDisplay","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional"},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"versionSupport":false,"tagSupport":{"valueSet":[1,2]}},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}},"contextSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"declaration":{"dynamicRegistration":true,"linkSupport":true},"selectionRange":{"dynamicRegistration":true}},"window":{"workDoneProgress":true}},"initializationOptions":{},"trace":"off","workspaceFolders":[{"uri":"file:///c%3A/Users/zhang%27pei/Desktop/ESP32%E8%A7%86%E9%A2%91%E6%B8%B8%E6%88%8F%E5%BC%80%E5%8F%91%E6%9D%BF%E7%A8%8B%E5%BA%8F/%E5%9C%86%E5%B1%8F%E5%A4%A9%E6%B0%94%E9%A2%84%E6%8A%A5/%E6%97%B6%E9%92%9F/%E6%97%B6%E9%92%9F/SmallDesktopDisplay","name":"SmallDesktopDisplay"}]}}
>>>
Content-Length: 598

{"id":0,"result":{"capabilities":{"textDocumentSync":2,"hoverProvider":true,"completionProvider":{"triggerCharacters":[".","\u003e",":"]},"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"workspaceSymbolProvider":true,"codeActionProvider":true,"documentFormattingProvider":true,"documentRangeFormattingProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"\n"},"renameProvider":false,"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]}}},"jsonrpc":"2.0"}
<<<
Content-Length: 52

{"jsonrpc":"2.0","method":"initialized","params":{}}Content-Length: 25992

{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///c%3A/Users/zhang%27pei/Desktop/ESP32%E8%A7%86%E9%A2%91%E6%B8%B8%E6%88%8F%E5%BC%80%E5%8F%91%E6%9D%BF%E7%A8%8B%E5%BA%8F/%E5%9C%86%E5%B1%8F%E5%A4%A9%E6%B0%94%E9%A2%84%E6%8A%A5/%E6%97%B6%E9%92%9F/%E6%97%B6%E9%92%9F/SmallDesktopDisplay/SmallDesktopDisplay.ino","languageId":"cpp","version":1,"text":"/*\r\n * \r\n * 原  作  者：私の名はMisaka\r\n * 创 建 日 期：2021.07.19\r\n * 最后更改日期：2021.08.26\r\n * 软 件 版 本：V1.2\r\n * \r\n * 必读！！！\r\n * 编译时 工具-Partition Scheme 这里改成 Huqe APP （3MB No OTA / 1MB SPIFFS）否则会报错内存不够 \r\n * \r\n * \r\n * B站原作者视频及资料：\r\n * https://www.bilibili.com/video/BV17f4y1G77n\r\n * 原作者QQ群号：887171863\r\n * \r\n * 请自行修改WIFI信息和城市代码\r\n *             \r\n * *****************************************************************/\r\n#include \"ArduinoJson.h\"\r\n#include <TimeLib.h>\r\n// #include <ESP8266WiFi.h>\r\n// #include <ESP8266HTTPClient.h>\r\n#include <HTTPClient.h>\r\n// WiFiClient wifiClient;\r\n#include <WiFiUdp.h>\r\n#include <TFT_eSPI.h> \r\n#include <SPI.h>\r\n#include <TJpg_Decoder.h>\r\n#include <EEPROM.h>\r\n#include \"qr.h\"\r\n#include \"number.h\"\r\n#include \"weathernum.h\"\r\n\r\n#define LCD_BL_PIN 5\r\n\r\n\r\n//---------------修改此处\"\"内的信息--------------------\r\nconst char ssid[] = \"PandoraBox\";      //WIFI名称 修改这2个就可以了\r\nconst char pass[] = \"myzhazha.top\";    //WIFI密码\r\n//----------------------------------------------------\r\n\r\n\r\n\r\n#include \"font/ZdyLwFont_20.h\"\r\n#include \"img/misaka.h\"\r\n#include \"img/temperature.h\"\r\n#include \"img/humidity.h\"\r\n#include \"img/pangzi/i0.h\"\r\n#include \"img/pangzi/i1.h\"\r\n#include \"img/pangzi/i2.h\"\r\n#include \"img/pangzi/i3.h\"\r\n#include \"img/pangzi/i4.h\"\r\n#include \"img/pangzi/i5.h\"\r\n#include \"img/pangzi/i6.h\"\r\n#include \"img/pangzi/i7.h\"\r\n#include \"img/pangzi/i8.h\"\r\n#include \"img/pangzi/i9.h\"\r\n\r\nTFT_eSPI tft = TFT_eSPI();  \r\nTFT_eSprite clk = TFT_eSprite(&tft);\r\n\r\n/*** Component objects ***/\r\nNumber      dig;\r\nWeatherNum  wrat;\r\n\r\n\r\nuint32_t targetTime = 0;   \r\nuint16_t bgColor = 0x0000;\r\nString cityCode = \"101280301\";  //天气城市代码查询地址https://www.it610.com/article/1291702105907732480.htm 打开后按CTRL+F搜索你所在的城市\r\nint LCD_BL_PWM = 2;//屏幕亮度0-100\r\nint tempnum = 0;   //温度百分比\r\nint huminum = 0;   //湿度百分比\r\nint tempcol =0xffff;\r\nint humicol =0xffff;\r\nint Anim = 0;\r\nint prevTime = 0;\r\nint AprevTime = 0;\r\nint BL_addr = 1;//被写入数据的EEPROM地址编号  0亮度\r\nint CC_addr = 10;//被写入数据的EEPROM地址编号  10城市\r\n\r\n//NTP服务器\r\nstatic const char ntpServerName[] = \"ntp6.aliyun.com\";\r\nconst int timeZone = 8;     //东八区\r\n\r\n\r\nWiFiUDP Udp;\r\nWiFiClient wificlient;\r\nunsigned int localPort = 8000;\r\nfloat duty=0;\r\ntime_t getNtpTime();\r\nvoid digitalClockDisplay();\r\nvoid printDigits(int digits);\r\nString num2str(int digits);\r\nvoid sendNTPpacket(IPAddress &address);\r\n\r\n\r\nbool tft_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t* bitmap)\r\n{\r\n  if ( y >= tft.height() ) return 0;\r\n  tft.pushImage(x, y, w, h, bitmap);\r\n  // Return 1 to decode next block\r\n  return 1;\r\n}\r\n\r\nbyte loadNum = 6;\r\nvoid loading(byte delayTime)//绘制进度条\r\n{\r\n  clk.setColorDepth(8);\r\n  \r\n  clk.createSprite(200, 100);//创建窗口\r\n  clk.fillSprite(0x0000);   //填充率\r\n\r\n  clk.drawRoundRect(0,0,200,16,8,0xFFFF);       //空心圆角矩形\r\n  clk.fillRoundRect(3,3,loadNum,10,5,0xFFFF);   //实心圆角矩形\r\n  clk.setTextDatum(CC_DATUM);   //设置文本数据\r\n  clk.setTextColor(TFT_GREEN, 0x0000); \r\n  clk.drawString(\"Connecting to WiFi......\",100,40,2);\r\n  clk.setTextColor(TFT_WHITE, 0x0000); \r\n  clk.drawRightString(\"SDD V1.2\",180,60,2);\r\n  clk.pushSprite(20,110);  //窗口位置\r\n  \r\n  //clk.setTextDatum(CC_DATUM);\r\n  //clk.setTextColor(TFT_WHITE, 0x0000); \r\n  //clk.pushSprite(130,180);\r\n  \r\n  clk.deleteSprite();\r\n  loadNum += 1;\r\n  delay(delayTime);\r\n}\r\n\r\nvoid humidityWin()\r\n{\r\n  clk.setColorDepth(8);\r\n  \r\n  huminum = huminum/2;\r\n  clk.createSprite(52, 6);  //创建窗口\r\n  clk.fillSprite(0x0000);    //填充率\r\n  clk.drawRoundRect(0,0,52,6,3,0xFFFF);  //空心圆角矩形  起始位x,y,长度，宽度，圆弧半径，颜色\r\n  clk.fillRoundRect(1,1,huminum,4,2,humicol);   //实心圆角矩形\r\n  clk.pushSprite(45,222);  //窗口位置\r\n  clk.deleteSprite();\r\n}\r\nvoid tempWin()\r\n{\r\n  clk.setColorDepth(8);\r\n  \r\n  clk.createSprite(52, 6);  //创建窗口\r\n  clk.fillSprite(0x0000);    //填充率\r\n  clk.drawRoundRect(0,0,52,6,3,0xFFFF);  //空心圆角矩形  起始位x,y,长度，宽度，圆弧半径，颜色\r\n  clk.fillRoundRect(1,1,tempnum,4,2,tempcol);   //实心圆角矩形\r\n  clk.pushSprite(45,192);  //窗口位置\r\n  clk.deleteSprite();\r\n}\r\n\r\nvoid SmartConfig(void)//微信配网\r\n{\r\n  WiFi.mode(WIFI_STA);    //设置STA模式\r\n  //tft.pushImage(0, 0, 240, 240, qr);\r\n  tft.pushImage(0, 0, 240, 240, qr);\r\n  Serial.println(\"\\r\\nWait for Smartconfig...\");    //打印log信息\r\n  WiFi.beginSmartConfig();      //开始SmartConfig，等待手机端发出用户名和密码\r\n  while (1)\r\n  {\r\n    Serial.print(\".\");\r\n    delay(100);                   // wait for a second\r\n    if (WiFi.smartConfigDone())//配网成功，接收到SSID和密码\r\n    {\r\n    Serial.println(\"SmartConfig Success\");\r\n    Serial.printf(\"SSID:%s\\r\\n\", WiFi.SSID().c_str());\r\n    Serial.printf(\"PSW:%s\\r\\n\", WiFi.psk().c_str());\r\n    break;\r\n    }\r\n  }\r\n  loadNum = 194;\r\n}\r\n\r\nString SMOD = \"\";//0亮度\r\n\r\nvoid Serial_set()//串口设置\r\n{\r\n  String incomingByte = \"\";\r\n  if(Serial.available()>0)\r\n  {\r\n    \r\n    while(Serial.available()>0)//监测串口缓存，当有数据输入时，循环赋值给incomingByte\r\n    {\r\n      incomingByte += char(Serial.read());//读取单个字符值，转换为字符，并按顺序一个个赋值给incomingByte\r\n      delay(2);//不能省略，因为读取缓冲区数据需要时间\r\n    }    \r\n    if(SMOD==\"0x01\")//设置1亮度设置\r\n    {\r\n      int LCDBL = atoi(incomingByte.c_str());//int n = atoi(xxx.c_str());//String转int\r\n      if(LCDBL>=0 && LCDBL<=100)\r\n      {\r\n        EEPROM.write(BL_addr, LCDBL);//亮度地址写入亮度值\r\n        EEPROM.commit();//保存更改的数据\r\n        delay(5);\r\n        LCD_BL_PWM = EEPROM.read(BL_addr); \r\n        delay(5);\r\n        SMOD = \"\";\r\n        Serial.printf(\"亮度调整为：\");\r\n//        analogWrite(LCD_BL_PIN, 1023 - (LCD_BL_PWM*10));\r\n        Serial.println(LCD_BL_PWM);\r\n        Serial.println(\"\");\r\n      }\r\n      else\r\n        Serial.println(\"亮度调整错误，请输入0-100\");\r\n    } \r\n    if(SMOD==\"0x02\")//设置2地址设置\r\n    {\r\n      int CityCODE = 0;\r\n      int CityC = atoi(incomingByte.c_str());//int n = atoi(xxx.c_str());//String转int\r\n      if(CityC>=101000000 && CityC<=102000000 || CityC == 0)\r\n      {\r\n        for(int cnum=0;cnum<5;cnum++)\r\n        {\r\n          EEPROM.write(CC_addr+cnum,CityC%100);//城市地址写入城市代码\r\n          EEPROM.commit();//保存更改的数据\r\n          CityC = CityC/100;\r\n          delay(5);\r\n        }\r\n        for(int cnum=5;cnum>0;cnum--)\r\n        {          \r\n          CityCODE = CityCODE*100;\r\n          CityCODE += EEPROM.read(CC_addr+cnum-1); \r\n          delay(5);\r\n        }\r\n        \r\n        cityCode = CityCODE;\r\n        \r\n        if(cityCode == \"0\")\r\n        {\r\n          Serial.println(\"城市代码调整为：自动\");\r\n          getCityCode();  //获取城市代码\r\n        }\r\n        else\r\n        {\r\n          Serial.printf(\"城市代码调整为：\");\r\n          Serial.println(cityCode);\r\n        }\r\n        Serial.println(\"\");\r\n        getCityWeater();//更新城市天气  \r\n        SMOD = \"\";\r\n      }\r\n      else\r\n        Serial.println(\"城市调整错误，请输入9位城市代码，自动获取请输入0\");\r\n    }   \r\n    else\r\n    {\r\n      SMOD = incomingByte;\r\n      delay(2);\r\n      if(SMOD==\"0x01\")\r\n        Serial.println(\"请输入亮度值，范围0-100\");\r\n      else if(SMOD==\"0x02\")\r\n        Serial.println(\"请输入9位城市代码，自动获取请输入0\"); \r\n      else\r\n      {\r\n        Serial.println(\"\");\r\n        Serial.println(\"请输入需要修改的代码：\");\r\n        Serial.println(\"亮度设置输入    0x01\");\r\n        Serial.println(\"地址设置输入    0x02\");\r\n        Serial.println(\"\");\r\n      }\r\n    }\r\n\r\n\r\n  }\r\n}\r\n\r\nvoid setup()\r\n{\r\n  Serial.begin(115200);\r\n  EEPROM.begin(1024);\r\n\r\n  if(EEPROM.read(BL_addr)>0&&EEPROM.read(BL_addr)<100)\r\n    LCD_BL_PWM = EEPROM.read(BL_addr); \r\n  \r\n  pinMode(LCD_BL_PIN, OUTPUT);\r\n // analogWrite(LCD_BL_PIN, 1023 - (LCD_BL_PWM*10));\r\n  \r\n  tft.begin(); /* TFT init */\r\n  tft.invertDisplay(1);//反转所有显示颜色：1反转，0正常\r\n  tft.fillScreen(0x0000);\r\n  tft.setTextColor(TFT_BLACK, bgColor);\r\n\r\n  targetTime = millis() + 1000; \r\n\r\n  Serial.print(\"正在连接WIFI \");\r\n  Serial.println(ssid);\r\n  WiFi.begin(ssid, pass);\r\n  \r\n  TJpgDec.setJpgScale(1);\r\n  TJpgDec.setSwapBytes(true);\r\n  TJpgDec.setCallback(tft_output);\r\n\r\n  while (WiFi.status() != WL_CONNECTED) \r\n  {\r\n    loading(70);  \r\n      \r\n    if(loadNum>=194)\r\n    {\r\n      SmartConfig();   \r\n      break;\r\n    }\r\n  }\r\n  delay(10); \r\n  while(loadNum < 194) //让动画走完\r\n  { \r\n    loading(1);\r\n  }\r\n\r\n  Serial.print(\"本地IP： \");\r\n  Serial.println(WiFi.localIP());\r\n  Serial.println(\"启动UDP\");\r\n  Udp.begin(localPort);\r\n  Serial.println(\"等待同步...\");\r\n  setSyncProvider(getNtpTime);\r\n  setSyncInterval(300);\r\n\r\n  \r\n  TJpgDec.setJpgScale(1);\r\n  TJpgDec.setSwapBytes(true);\r\n  TJpgDec.setCallback(tft_output);\r\n  \r\n  //tft.pushImage(0,0,240,240,misaka);\r\n  //TJpgDec.drawJpg(120,120,misaka, sizeof(misaka));//显示logo\r\n  //delay(1000); \r\n  int CityCODE = 0;\r\n  for(int cnum=5;cnum>0;cnum--)\r\n  {          \r\n    CityCODE = CityCODE*100;\r\n    CityCODE += EEPROM.read(CC_addr+cnum-1); \r\n    delay(5);\r\n  }\r\n  if(CityCODE>=101000000 && CityCODE<=102000000) \r\n    cityCode = CityCODE;  \r\n  else\r\n    getCityCode();  //获取城市代码\r\n   \r\n  tft.fillScreen(TFT_BLACK);//清屏\r\n  \r\n  TJpgDec.drawJpg(15,183,temperature, sizeof(temperature));  //温度图标\r\n  TJpgDec.drawJpg(15,213,humidity, sizeof(humidity));  //湿度图标\r\n\r\n  getCityWeater();\r\n}\r\ntime_t prevDisplay = 0; // 显示时间\r\nunsigned long weaterTime = 0;\r\n\r\nvoid loop()\r\n{\r\n  \r\n  if (now() != prevDisplay) {\r\n    prevDisplay = now();\r\n    digitalClockDisplay();\r\n    prevTime=0;  \r\n  }\r\n  \r\n  if(millis() - weaterTime > 300000){ //5分钟更新一次天气\r\n    weaterTime = millis();\r\n    getCityWeater();\r\n  }\r\n  scrollBanner();\r\n  imgAnim();\r\n  Serial_set();\r\n\r\n}\r\n\r\n\r\n// 发送HTTP请求并且将服务器响应通过串口输出\r\nvoid getCityCode(){\r\n String URL = \"http://wgeo.weather.com.cn/ip/?_=\"+String(now());\r\n  //创建 HTTPClient 对象\r\n  HTTPClient httpClient;\r\n \r\n  //配置请求地址。此处也可以不使用端口号和PATH而单纯的\r\n  httpClient.begin(URL); \r\n  \r\n  //设置请求头中的User-Agent\r\n  httpClient.setUserAgent(\"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1\");\r\n  httpClient.addHeader(\"Referer\", \"http://www.weather.com.cn/\");\r\n \r\n  //启动连接并发送HTTP请求\r\n  int httpCode = httpClient.GET();\r\n  Serial.print(\"Send GET request to URL: \");\r\n  Serial.println(URL);\r\n  \r\n  //如果服务器响应OK则从服务器获取响应体信息并通过串口输出\r\n  if (httpCode == HTTP_CODE_OK) {\r\n    String str = httpClient.getString();\r\n    \r\n    int aa = str.indexOf(\"id=\");\r\n    if(aa>-1)\r\n    {\r\n       //cityCode = str.substring(aa+4,aa+4+9).toInt();\r\n       cityCode = str.substring(aa+4,aa+4+9);\r\n       Serial.println(cityCode); \r\n       getCityWeater();\r\n    }\r\n    else\r\n    {\r\n      Serial.println(\"获取城市代码失败\");  \r\n    }\r\n    \r\n    \r\n  } else {\r\n    Serial.println(\"请求城市代码错误：\");\r\n    Serial.println(httpCode);\r\n  }\r\n \r\n  //关闭ESP8266与服务器连接\r\n  httpClient.end();\r\n}\r\n\r\n\r\n\r\n// 获取城市天气\r\nvoid getCityWeater(){\r\n //String URL = \"http://d1.weather.com.cn/dingzhi/\" + cityCode + \".html?_=\"+String(now());//新\r\n String URL = \"http://d1.weather.com.cn/weather_index/\" + cityCode + \".html?_=\"+String(now());//原来\r\n  //创建 HTTPClient 对象\r\n  HTTPClient httpClient;\r\n  \r\n  httpClient.begin(wificlient,URL); \r\n  \r\n  //设置请求头中的User-Agent\r\n  httpClient.setUserAgent(\"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1\");\r\n  httpClient.addHeader(\"Referer\", \"http://www.weather.com.cn/\");\r\n \r\n  //启动连接并发送HTTP请求\r\n  int httpCode = httpClient.GET();\r\n  Serial.println(\"正在获取天气数据\");\r\n  Serial.println(URL);\r\n  \r\n  //如果服务器响应OK则从服务器获取响应体信息并通过串口输出\r\n  if (httpCode == HTTP_CODE_OK) {\r\n\r\n    String str = httpClient.getString();\r\n    int indexStart = str.indexOf(\"weatherinfo\\\":\");\r\n    int indexEnd = str.indexOf(\"};var alarmDZ\");\r\n\r\n    String jsonCityDZ = str.substring(indexStart+13,indexEnd);\r\n    //Serial.println(jsonCityDZ);\r\n\r\n    indexStart = str.indexOf(\"dataSK =\");\r\n    indexEnd = str.indexOf(\";var dataZS\");\r\n    String jsonDataSK = str.substring(indexStart+8,indexEnd);\r\n    //Serial.println(jsonDataSK);\r\n\r\n    \r\n    indexStart = str.indexOf(\"\\\"f\\\":[\");\r\n    indexEnd = str.indexOf(\",{\\\"fa\");\r\n    String jsonFC = str.substring(indexStart+5,indexEnd);\r\n    //Serial.println(jsonFC);\r\n    \r\n    weaterData(&jsonCityDZ,&jsonDataSK,&jsonFC);\r\n    Serial.println(\"获取成功\");\r\n    \r\n  } else {\r\n    Serial.println(\"请求城市天气错误：\");\r\n    Serial.print(httpCode);\r\n  }\r\n \r\n  //关闭ESP8266与服务器连接\r\n  httpClient.end();\r\n}\r\n\r\n\r\nString scrollText[7];\r\n//int scrollTextWidth = 0;\r\n//天气信息写到屏幕上\r\nvoid weaterData(String *cityDZ,String *dataSK,String *dataFC)\r\n{\r\n  //解析第一段JSON\r\n  DynamicJsonDocument doc(1024);\r\n  deserializeJson(doc, *dataSK);\r\n  JsonObject sk = doc.as<JsonObject>();\r\n\r\n  //TFT_eSprite clkb = TFT_eSprite(&tft);\r\n  \r\n  /***绘制相关文字***/\r\n  clk.setColorDepth(8);\r\n  clk.loadFont(ZdyLwFont_20);\r\n  \r\n  //温度\r\n  clk.createSprite(58, 24); \r\n  clk.fillSprite(bgColor);\r\n  clk.setTextDatum(CC_DATUM);\r\n  clk.setTextColor(TFT_WHITE, bgColor); \r\n  clk.drawString(sk[\"temp\"].as<String>()+\"℃\",28,13);\r\n  clk.pushSprite(100,184);\r\n  clk.deleteSprite();\r\n  tempnum = sk[\"temp\"].as<int>();\r\n  tempnum = tempnum+10;\r\n  if(tempnum<10)\r\n    tempcol=0x00FF;\r\n  else if(tempnum<28)\r\n    tempcol=0x0AFF;\r\n  else if(tempnum<34)\r\n    tempcol=0x0F0F;\r\n  else if(tempnum<41)\r\n    tempcol=0xFF0F;\r\n  else if(tempnum<49)\r\n    tempcol=0xF00F;\r\n  else\r\n  {\r\n    tempcol=0xF00F;\r\n    tempnum=50;\r\n  }\r\n  tempWin();\r\n  \r\n  //湿度\r\n  clk.createSprite(58, 24); \r\n  clk.fillSprite(bgColor);\r\n  clk.setTextDatum(CC_DATUM);\r\n  clk.setTextColor(TFT_WHITE, bgColor); \r\n  clk.drawString(sk[\"SD\"].as<String>(),28,13);\r\n  //clk.drawString(\"100%\",28,13);\r\n  clk.pushSprite(100,214);\r\n  clk.deleteSprite();\r\n  //String A = sk[\"SD\"].as<String>();\r\n  huminum = atoi((sk[\"SD\"].as<String>()).substring(0,2).c_str());\r\n  \r\n  if(huminum>90)\r\n    humicol=0x00FF;\r\n  else if(huminum>70)\r\n    humicol=0x0AFF;\r\n  else if(huminum>40)\r\n    humicol=0x0F0F;\r\n  else if(huminum>20)\r\n    humicol=0xFF0F;\r\n  else\r\n    humicol=0xF00F;\r\n  humidityWin();\r\n\r\n  \r\n  //城市名称\r\n  clk.createSprite(94, 30); \r\n  clk.fillSprite(bgColor);\r\n  clk.setTextDatum(CC_DATUM);\r\n  clk.setTextColor(TFT_WHITE, bgColor); \r\n  clk.drawString(sk[\"cityname\"].as<String>(),44,16);\r\n  clk.pushSprite(15,15);\r\n  clk.deleteSprite();\r\n\r\n  //PM2.5空气指数\r\n  uint16_t pm25BgColor = tft.color565(156,202,127);//优\r\n  String aqiTxt = \"优\";\r\n  int pm25V = sk[\"aqi\"];\r\n  if(pm25V>200){\r\n    pm25BgColor = tft.color565(136,11,32);//重度\r\n    aqiTxt = \"重度\";\r\n  }else if(pm25V>150){\r\n    pm25BgColor = tft.color565(186,55,121);//中度\r\n    aqiTxt = \"中度\";\r\n  }else if(pm25V>100){\r\n    pm25BgColor = tft.color565(242,159,57);//轻\r\n    aqiTxt = \"轻度\";\r\n  }else if(pm25V>50){\r\n    pm25BgColor = tft.color565(247,219,100);//良\r\n    aqiTxt = \"良\";\r\n  }\r\n  clk.createSprite(56, 24); \r\n  clk.fillSprite(bgColor);\r\n  clk.fillRoundRect(0,0,50,24,4,pm25BgColor);\r\n  clk.setTextDatum(CC_DATUM);\r\n  clk.setTextColor(0x0000); \r\n  clk.drawString(aqiTxt,25,13);\r\n  clk.pushSprite(104,18);\r\n  clk.deleteSprite();\r\n  \r\n  scrollText[0] = \"实时天气 \"+sk[\"weather\"].as<String>();\r\n  scrollText[1] = \"空气质量 \"+aqiTxt;\r\n  scrollText[2] = \"风向 \"+sk[\"WD\"].as<String>()+sk[\"WS\"].as<String>();\r\n\r\n  //scrollText[6] = atoi((sk[\"weathercode\"].as<String>()).substring(1,3).c_str()) ;\r\n\r\n  //天气图标\r\n  wrat.printfweather(170,15,atoi((sk[\"weathercode\"].as<String>()).substring(1,3).c_str()));\r\n\r\n  \r\n  //左上角滚动字幕\r\n  //解析第二段JSON\r\n  deserializeJson(doc, *cityDZ);\r\n  JsonObject dz = doc.as<JsonObject>();\r\n  //Serial.println(sk[\"ws\"].as<String>());\r\n  //横向滚动方式\r\n  //String aa = \"今日天气:\" + dz[\"weather\"].as<String>() + \"，温度:最低\" + dz[\"tempn\"].as<String>() + \"，最高\" + dz[\"temp\"].as<String>() + \" 空气质量:\" + aqiTxt + \"，风向:\" + dz[\"wd\"].as<String>() + dz[\"ws\"].as<String>();\r\n  //scrollTextWidth = clk.textWidth(scrollText);\r\n  //Serial.println(aa);\r\n  scrollText[3] = \"今日\"+dz[\"weather\"].as<String>();\r\n  \r\n  deserializeJson(doc, *dataFC);\r\n  JsonObject fc = doc.as<JsonObject>();\r\n  \r\n  scrollText[4] = \"最低温度\"+fc[\"fd\"].as<String>()+\"℃\";\r\n  scrollText[5] = \"最高温度\"+fc[\"fc\"].as<String>()+\"℃\";\r\n  \r\n  //Serial.println(scrollText[0]);\r\n  \r\n  clk.unloadFont();\r\n}\r\n\r\nint currentIndex = 0;\r\nTFT_eSprite clkb = TFT_eSprite(&tft);\r\n\r\nvoid scrollBanner(){\r\n  //if(millis() - prevTime > 2333) //3秒切换一次\r\n  if(second()%2 ==0&& prevTime == 0)\r\n  { \r\n    if(scrollText[currentIndex])\r\n    {\r\n      clkb.setColorDepth(8);\r\n      clkb.loadFont(ZdyLwFont_20);\r\n      clkb.createSprite(150, 30); \r\n      clkb.fillSprite(bgColor);\r\n      clkb.setTextWrap(false);\r\n      clkb.setTextDatum(CC_DATUM);\r\n      clkb.setTextColor(TFT_WHITE, bgColor); \r\n      clkb.drawString(scrollText[currentIndex],74, 16);\r\n      clkb.pushSprite(10,45);\r\n       \r\n      clkb.deleteSprite();\r\n      clkb.unloadFont();\r\n      \r\n      if(currentIndex>=5)\r\n        currentIndex = 0;  //回第一个\r\n      else\r\n        currentIndex += 1;  //准备切换到下一个        \r\n    }\r\n    prevTime = 1;\r\n  }\r\n}\r\n/*\r\nvoid imgAnim()\r\n{\r\n  int x=160,y=160,dt=43;\r\n\r\n  TJpgDec.drawJpg(x,y,i0, sizeof(i0));\r\n  delay(dt);\r\n  TJpgDec.drawJpg(x,y,i1, sizeof(i1));\r\n  delay(dt);\r\n  TJpgDec.drawJpg(x,y,i2, sizeof(i2));\r\n  delay(dt);\r\n  TJpgDec.drawJpg(x,y,i3, sizeof(i3));\r\n  delay(dt);  \r\n  TJpgDec.drawJpg(x,y,i4, sizeof(i4));\r\n  delay(dt);  \r\n  TJpgDec.drawJpg(x,y,i5, sizeof(i5));\r\n  delay(dt);  \r\n  TJpgDec.drawJpg(x,y,i6, sizeof(i6));\r\n  delay(dt);  \r\n  TJpgDec.drawJpg(x,y,i7, sizeof(i7));\r\n  delay(dt);  \r\n  TJpgDec.drawJpg(x,y,i8, sizeof(i8));\r\n  delay(dt);  \r\n  TJpgDec.drawJpg(x,y,i9, sizeof(i9));\r\n  delay(dt);  \r\n}\r\n*/\r\n\r\n\r\nvoid imgAnim()\r\n{\r\n  int x=160,y=160;\r\n  if(millis() - AprevTime > 37) //x ms切换一次\r\n  {\r\n    Anim++;\r\n    AprevTime = millis();\r\n  }\r\n  if(Anim==10)\r\n    Anim=0;\r\n\r\n  switch(Anim)\r\n  {\r\n    case 0:\r\n      TJpgDec.drawJpg(x,y,i0, sizeof(i0));\r\n      break;\r\n    case 1:\r\n      TJpgDec.drawJpg(x,y,i1, sizeof(i1));\r\n      break;\r\n    case 2:\r\n      TJpgDec.drawJpg(x,y,i2, sizeof(i2));\r\n      break;\r\n    case 3:\r\n      TJpgDec.drawJpg(x,y,i3, sizeof(i3));\r\n      break;\r\n    case 4:\r\n      TJpgDec.drawJpg(x,y,i4, sizeof(i4));\r\n      break;\r\n    case 5:\r\n      TJpgDec.drawJpg(x,y,i5, sizeof(i5));\r\n      break;\r\n    case 6:\r\n      TJpgDec.drawJpg(x,y,i6, sizeof(i6));\r\n      break;\r\n    case 7:\r\n      TJpgDec.drawJpg(x,y,i7, sizeof(i7));\r\n      break;\r\n    case 8: \r\n      TJpgDec.drawJpg(x,y,i8, sizeof(i8));\r\n      break;\r\n    case 9: \r\n      TJpgDec.drawJpg(x,y,i9, sizeof(i9));\r\n      break;\r\n    default:\r\n      Serial.println(\"显示Anim错误\");\r\n      break;\r\n  }\r\n}\r\n\r\nunsigned char Hour_sign   = 60;\r\nunsigned char Minute_sign = 60;\r\nunsigned char Second_sign = 60;\r\nvoid digitalClockDisplay()\r\n{ \r\n  int timey=82;\r\n  if(hour()!=Hour_sign)//时钟刷新\r\n  {\r\n    dig.printfW3660(20,timey,hour()/10);\r\n    dig.printfW3660(60,timey,hour()%10);\r\n    Hour_sign = hour();\r\n  }\r\n  if(minute()!=Minute_sign)//分钟刷新\r\n  {\r\n    dig.printfO3660(101,timey,minute()/10);\r\n    dig.printfO3660(141,timey,minute()%10);\r\n    Minute_sign = minute();\r\n  }\r\n  if(second()!=Second_sign)//分钟刷新\r\n  {\r\n    dig.printfW1830(182,timey+30,second()/10);\r\n    dig.printfW1830(202,timey+30,second()%10);\r\n    Second_sign = second();\r\n  }\r\n  \r\n  /***日期****/\r\n  clk.setColorDepth(8);\r\n  clk.loadFont(ZdyLwFont_20);\r\n  \r\n  //星期\r\n  clk.createSprite(58, 30);\r\n  clk.fillSprite(bgColor);\r\n  clk.setTextDatum(CC_DATUM);\r\n  clk.setTextColor(TFT_WHITE, bgColor);\r\n  clk.drawString(week(),29,16);\r\n  clk.pushSprite(102,150);\r\n  clk.deleteSprite();\r\n  \r\n  //月日\r\n  clk.createSprite(95, 30);\r\n  clk.fillSprite(bgColor);\r\n  clk.setTextDatum(CC_DATUM);\r\n  clk.setTextColor(TFT_WHITE, bgColor);  \r\n  clk.drawString(monthDay(),49,16);\r\n  clk.pushSprite(5,150);\r\n  clk.deleteSprite();\r\n  \r\n  clk.unloadFont();\r\n  /***日期****/\r\n}\r\n\r\n//星期\r\nString week()\r\n{\r\n  String wk[7] = {\"日\",\"一\",\"二\",\"三\",\"四\",\"五\",\"六\"};\r\n  String s = \"周\" + wk[weekday()-1];\r\n  return s;\r\n}\r\n\r\n//月日\r\nString monthDay()\r\n{\r\n  String s = String(month());\r\n  s = s + \"月\" + day() + \"日\";\r\n  return s;\r\n}\r\n\r\n/*-------- NTP code ----------*/\r\n\r\nconst int NTP_PACKET_SIZE = 48; // NTP时间在消息的前48字节中\r\nbyte packetBuffer[NTP_PACKET_SIZE]; //buffer to hold incoming & outgoing packets\r\n\r\ntime_t getNtpTime()\r\n{\r\n  IPAddress ntpServerIP; // NTP server's ip address\r\n\r\n  while (Udp.parsePacket() > 0) ; // discard any previously received packets\r\n  //Serial.println(\"Transmit NTP Request\");\r\n  // get a random server from the pool\r\n  WiFi.hostByName(ntpServerName, ntpServerIP);\r\n  //Serial.print(ntpServerName);\r\n  //Serial.print(\": \");\r\n  //Serial.println(ntpServerIP);\r\n  sendNTPpacket(ntpServerIP);\r\n  uint32_t beginWait = millis();\r\n  while (millis() - beginWait < 1500) {\r\n    int size = Udp.parsePacket();\r\n    if (size >= NTP_PACKET_SIZE) {\r\n      Serial.println(\"Receive NTP Response\");\r\n      Udp.read(packetBuffer, NTP_PACKET_SIZE);  // read packet into the buffer\r\n      unsigned long secsSince1900;\r\n      // convert four bytes starting at location 40 to a long integer\r\n      secsSince1900 =  (unsigned long)packetBuffer[40] << 24;\r\n      secsSince1900 |= (unsigned long)packetBuffer[41] << 16;\r\n      secsSince1900 |= (unsigned long)packetBuffer[42] << 8;\r\n      secsSince1900 |= (unsigned long)packetBuffer[43];\r\n      //Serial.println(secsSince1900 - 2208988800UL + timeZone * SECS_PER_HOUR);\r\n      return secsSince1900 - 2208988800UL + timeZone * SECS_PER_HOUR;\r\n    }\r\n  }\r\n  Serial.println(\"No NTP Response :-(\");\r\n  return 0; // 无法获取时间时返回0\r\n}\r\n\r\n// 向NTP服务器发送请求\r\nvoid sendNTPpacket(IPAddress &address)\r\n{\r\n  // set all bytes in the buffer to 0\r\n  memset(packetBuffer, 0, NTP_PACKET_SIZE);\r\n  // Initialize values needed to form NTP request\r\n  // (see URL above for details on the packets)\r\n  packetBuffer[0] = 0b11100011;   // LI, Version, Mode\r\n  packetBuffer[1] = 0;     // Stratum, or type of clock\r\n  packetBuffer[2] = 6;     // Polling Interval\r\n  packetBuffer[3] = 0xEC;  // Peer Clock Precision\r\n  // 8 bytes of zero for Root Delay & Root Dispersion\r\n  packetBuffer[12] = 49;\r\n  packetBuffer[13] = 0x4E;\r\n  packetBuffer[14] = 49;\r\n  packetBuffer[15] = 52;\r\n  // all NTP fields have been given values, now\r\n  // you can send a packet requesting a timestamp:\r\n  Udp.beginPacket(address, 123); //NTP requests are to port 123\r\n  Udp.write(packetBuffer, NTP_PACKET_SIZE);\r\n  Udp.endPacket();\r\n}\r\n"}}}






Started logging.

<<<
Content-Length: 3137

{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":23464,"clientInfo":{"name":"vscode","version":"1.50.0"},"rootPath":"c:\\Users\\zhang'pei\\Desktop\\SmallDesktopDisplay\\SmallDesktopDisplay","rootUri":"file:///c%3A/Users/zhang%27pei/Desktop/SmallDesktopDisplay/SmallDesktopDisplay","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional"},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"versionSupport":false,"tagSupport":{"valueSet":[1,2]}},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}},"contextSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"declaration":{"dynamicRegistration":true,"linkSupport":true},"selectionRange":{"dynamicRegistration":true}},"window":{"workDoneProgress":true}},"initializationOptions":{},"trace":"off","workspaceFolders":[{"uri":"file:///c%3A/Users/zhang%27pei/Desktop/SmallDesktopDisplay/SmallDesktopDisplay","name":"SmallDesktopDisplay"}]}}
>>>
Content-Length: 598

{"id":0,"result":{"capabilities":{"textDocumentSync":2,"hoverProvider":true,"completionProvider":{"triggerCharacters":[".","\u003e",":"]},"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"workspaceSymbolProvider":true,"codeActionProvider":true,"documentFormattingProvider":true,"documentRangeFormattingProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"\n"},"renameProvider":false,"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]}}},"jsonrpc":"2.0"}
<<<
Content-Length: 52

{"jsonrpc":"2.0","method":"initialized","params":{}}Content-Length: 25824

{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///c%3A/Users/zhang%27pei/Desktop/SmallDesktopDisplay/SmallDesktopDisplay/SmallDesktopDisplay.ino","languageId":"cpp","version":1,"text":"/*\r\n * \r\n * 原  作  者：私の名はMisaka\r\n * 创 建 日 期：2021.07.19\r\n * 最后更改日期：2021.08.26\r\n * 软 件 版 本：V1.2\r\n * \r\n * 必读！！！\r\n * 编译时 工具-Partition Scheme 这里改成 Huqe APP （3MB No OTA / 1MB SPIFFS）否则会报错内存不够 \r\n * \r\n * \r\n * B站原作者视频及资料：\r\n * https://www.bilibili.com/video/BV17f4y1G77n\r\n * 原作者QQ群号：887171863\r\n * \r\n * 请自行修改WIFI信息和城市代码\r\n *             \r\n * *****************************************************************/\r\n#include \"ArduinoJson.h\"\r\n#include <TimeLib.h>\r\n// #include <ESP8266WiFi.h>\r\n// #include <ESP8266HTTPClient.h>\r\n#include <HTTPClient.h>\r\n// WiFiClient wifiClient;\r\n#include <WiFiUdp.h>\r\n#include <TFT_eSPI.h> \r\n#include <SPI.h>\r\n#include <TJpg_Decoder.h>\r\n#include <EEPROM.h>\r\n#include \"qr.h\"\r\n#include \"number.h\"\r\n#include \"weathernum.h\"\r\n\r\n#define LCD_BL_PIN 5\r\n\r\n\r\n//---------------修改此处\"\"内的信息--------------------\r\nconst char ssid[] = \"CMCC-404\";      //WIFI名称 修改这2个就可以了\r\nconst char pass[] = \"zp198612\";    //WIFI密码\r\n//----------------------------------------------------\r\n\r\n\r\n\r\n#include \"font/ZdyLwFont_20.h\"\r\n#include \"img/misaka.h\"\r\n#include \"img/temperature.h\"\r\n#include \"img/humidity.h\"\r\n#include \"img/pangzi/i0.h\"\r\n#include \"img/pangzi/i1.h\"\r\n#include \"img/pangzi/i2.h\"\r\n#include \"img/pangzi/i3.h\"\r\n#include \"img/pangzi/i4.h\"\r\n#include \"img/pangzi/i5.h\"\r\n#include \"img/pangzi/i6.h\"\r\n#include \"img/pangzi/i7.h\"\r\n#include \"img/pangzi/i8.h\"\r\n#include \"img/pangzi/i9.h\"\r\n\r\nTFT_eSPI tft = TFT_eSPI();  \r\nTFT_eSprite clk = TFT_eSprite(&tft);\r\n\r\n/*** Component objects ***/\r\nNumber      dig;\r\nWeatherNum  wrat;\r\n\r\n\r\nuint32_t targetTime = 0;   \r\nuint16_t bgColor = 0x0000;\r\nString cityCode = \"101280301\";  //天气城市代码查询地址https://www.it610.com/article/1291702105907732480.htm 打开后按CTRL+F搜索你所在的城市\r\nint LCD_BL_PWM = 2;//屏幕亮度0-100\r\nint tempnum = 0;   //温度百分比\r\nint huminum = 0;   //湿度百分比\r\nint tempcol =0xffff;\r\nint humicol =0xffff;\r\nint Anim = 0;\r\nint prevTime = 0;\r\nint AprevTime = 0;\r\nint BL_addr = 1;//被写入数据的EEPROM地址编号  0亮度\r\nint CC_addr = 10;//被写入数据的EEPROM地址编号  10城市\r\n\r\n//NTP服务器\r\nstatic const char ntpServerName[] = \"ntp6.aliyun.com\";\r\nconst int timeZone = 8;     //东八区\r\n\r\n\r\nWiFiUDP Udp;\r\nWiFiClient wificlient;\r\nunsigned int localPort = 8000;\r\nfloat duty=0;\r\ntime_t getNtpTime();\r\nvoid digitalClockDisplay();\r\nvoid printDigits(int digits);\r\nString num2str(int digits);\r\nvoid sendNTPpacket(IPAddress &address);\r\n\r\n\r\nbool tft_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t* bitmap)\r\n{\r\n  if ( y >= tft.height() ) return 0;\r\n  tft.pushImage(x, y, w, h, bitmap);\r\n  // Return 1 to decode next block\r\n  return 1;\r\n}\r\n\r\nbyte loadNum = 6;\r\nvoid loading(byte delayTime)//绘制进度条\r\n{\r\n  clk.setColorDepth(8);\r\n  \r\n  clk.createSprite(200, 100);//创建窗口\r\n  clk.fillSprite(0x0000);   //填充率\r\n\r\n  clk.drawRoundRect(0,0,200,16,8,0xFFFF);       //空心圆角矩形\r\n  clk.fillRoundRect(3,3,loadNum,10,5,0xFFFF);   //实心圆角矩形\r\n  clk.setTextDatum(CC_DATUM);   //设置文本数据\r\n  clk.setTextColor(TFT_GREEN, 0x0000); \r\n  clk.drawString(\"Connecting to WiFi......\",100,40,2);\r\n  clk.setTextColor(TFT_WHITE, 0x0000); \r\n  clk.drawRightString(\"SDD V1.2\",180,60,2);\r\n  clk.pushSprite(20,110);  //窗口位置\r\n  \r\n  //clk.setTextDatum(CC_DATUM);\r\n  //clk.setTextColor(TFT_WHITE, 0x0000); \r\n  //clk.pushSprite(130,180);\r\n  \r\n  clk.deleteSprite();\r\n  loadNum += 1;\r\n  delay(delayTime);\r\n}\r\n\r\nvoid humidityWin()\r\n{\r\n  clk.setColorDepth(8);\r\n  \r\n  huminum = huminum/2;\r\n  clk.createSprite(52, 6);  //创建窗口\r\n  clk.fillSprite(0x0000);    //填充率\r\n  clk.drawRoundRect(0,0,52,6,3,0xFFFF);  //空心圆角矩形  起始位x,y,长度，宽度，圆弧半径，颜色\r\n  clk.fillRoundRect(1,1,huminum,4,2,humicol);   //实心圆角矩形\r\n  clk.pushSprite(45,222);  //窗口位置\r\n  clk.deleteSprite();\r\n}\r\nvoid tempWin()\r\n{\r\n  clk.setColorDepth(8);\r\n  \r\n  clk.createSprite(52, 6);  //创建窗口\r\n  clk.fillSprite(0x0000);    //填充率\r\n  clk.drawRoundRect(0,0,52,6,3,0xFFFF);  //空心圆角矩形  起始位x,y,长度，宽度，圆弧半径，颜色\r\n  clk.fillRoundRect(1,1,tempnum,4,2,tempcol);   //实心圆角矩形\r\n  clk.pushSprite(45,192);  //窗口位置\r\n  clk.deleteSprite();\r\n}\r\n\r\nvoid SmartConfig(void)//微信配网\r\n{\r\n  WiFi.mode(WIFI_STA);    //设置STA模式\r\n  //tft.pushImage(0, 0, 240, 240, qr);\r\n  tft.pushImage(0, 0, 240, 240, qr);\r\n  Serial.println(\"\\r\\nWait for Smartconfig...\");    //打印log信息\r\n  WiFi.beginSmartConfig();      //开始SmartConfig，等待手机端发出用户名和密码\r\n  while (1)\r\n  {\r\n    Serial.print(\".\");\r\n    delay(100);                   // wait for a second\r\n    if (WiFi.smartConfigDone())//配网成功，接收到SSID和密码\r\n    {\r\n    Serial.println(\"SmartConfig Success\");\r\n    Serial.printf(\"SSID:%s\\r\\n\", WiFi.SSID().c_str());\r\n    Serial.printf(\"PSW:%s\\r\\n\", WiFi.psk().c_str());\r\n    break;\r\n    }\r\n  }\r\n  loadNum = 194;\r\n}\r\n\r\nString SMOD = \"\";//0亮度\r\n\r\nvoid Serial_set()//串口设置\r\n{\r\n  String incomingByte = \"\";\r\n  if(Serial.available()>0)\r\n  {\r\n    \r\n    while(Serial.available()>0)//监测串口缓存，当有数据输入时，循环赋值给incomingByte\r\n    {\r\n      incomingByte += char(Serial.read());//读取单个字符值，转换为字符，并按顺序一个个赋值给incomingByte\r\n      delay(2);//不能省略，因为读取缓冲区数据需要时间\r\n    }    \r\n    if(SMOD==\"0x01\")//设置1亮度设置\r\n    {\r\n      int LCDBL = atoi(incomingByte.c_str());//int n = atoi(xxx.c_str());//String转int\r\n      if(LCDBL>=0 && LCDBL<=100)\r\n      {\r\n        EEPROM.write(BL_addr, LCDBL);//亮度地址写入亮度值\r\n        EEPROM.commit();//保存更改的数据\r\n        delay(5);\r\n        LCD_BL_PWM = EEPROM.read(BL_addr); \r\n        delay(5);\r\n        SMOD = \"\";\r\n        Serial.printf(\"亮度调整为：\");\r\n//        analogWrite(LCD_BL_PIN, 1023 - (LCD_BL_PWM*10));\r\n        Serial.println(LCD_BL_PWM);\r\n        Serial.println(\"\");\r\n      }\r\n      else\r\n        Serial.println(\"亮度调整错误，请输入0-100\");\r\n    } \r\n    if(SMOD==\"0x02\")//设置2地址设置\r\n    {\r\n      int CityCODE = 0;\r\n      int CityC = atoi(incomingByte.c_str());//int n = atoi(xxx.c_str());//String转int\r\n      if((CityC>=101000000&&CityC<=102000000)||CityC == 0)\r\n      {\r\n        for(int cnum=0;cnum<5;cnum++)\r\n        {\r\n          EEPROM.write(CC_addr+cnum,CityC%100);//城市地址写入城市代码\r\n          EEPROM.commit();//保存更改的数据\r\n          CityC = CityC/100;\r\n          delay(5);\r\n        }\r\n        for(int cnum=5;cnum>0;cnum--)\r\n        {          \r\n          CityCODE = CityCODE*100;\r\n          CityCODE += EEPROM.read(CC_addr+cnum-1); \r\n          delay(5);\r\n        }\r\n        \r\n        cityCode = CityCODE;\r\n        \r\n        if(cityCode == \"0\")\r\n        {\r\n          Serial.println(\"城市代码调整为：自动\");\r\n          getCityCode();  //获取城市代码\r\n        }\r\n        else\r\n        {\r\n          Serial.printf(\"城市代码调整为：\");\r\n          Serial.println(cityCode);\r\n        }\r\n        Serial.println(\"\");\r\n        getCityWeater();//更新城市天气  \r\n        SMOD = \"\";\r\n      }\r\n      else\r\n        Serial.println(\"城市调整错误，请输入9位城市代码，自动获取请输入0\");\r\n    }   \r\n    else\r\n    {\r\n      SMOD = incomingByte;\r\n      delay(2);\r\n      if(SMOD==\"0x01\")\r\n        Serial.println(\"请输入亮度值，范围0-100\");\r\n      else if(SMOD==\"0x02\")\r\n        Serial.println(\"请输入9位城市代码，自动获取请输入0\"); \r\n      else\r\n      {\r\n        Serial.println(\"\");\r\n        Serial.println(\"请输入需要修改的代码：\");\r\n        Serial.println(\"亮度设置输入    0x01\");\r\n        Serial.println(\"地址设置输入    0x02\");\r\n        Serial.println(\"\");\r\n      }\r\n    }\r\n\r\n\r\n  }\r\n}\r\n\r\nvoid setup()\r\n{\r\n  Serial.begin(115200);\r\n  EEPROM.begin(1024);\r\n\r\n  if(EEPROM.read(BL_addr)>0&&EEPROM.read(BL_addr)<100)\r\n    LCD_BL_PWM = EEPROM.read(BL_addr); \r\n  \r\n  pinMode(LCD_BL_PIN, OUTPUT);\r\n // analogWrite(LCD_BL_PIN, 1023 - (LCD_BL_PWM*10));\r\n  \r\n  tft.begin(); /* TFT init */\r\n  tft.invertDisplay(1);//反转所有显示颜色：1反转，0正常\r\n  tft.fillScreen(0x0000);\r\n  tft.setTextColor(TFT_BLACK, bgColor);\r\n\r\n  targetTime = millis() + 1000; \r\n\r\n  Serial.print(\"正在连接WIFI \");\r\n  Serial.println(ssid);\r\n  WiFi.begin(ssid, pass);\r\n  \r\n  TJpgDec.setJpgScale(1);\r\n  TJpgDec.setSwapBytes(true);\r\n  TJpgDec.setCallback(tft_output);\r\n\r\n  while (WiFi.status() != WL_CONNECTED) \r\n  {\r\n    loading(70);  \r\n      \r\n    if(loadNum>=194)\r\n    {\r\n      SmartConfig();   \r\n      break;\r\n    }\r\n  }\r\n  delay(10); \r\n  while(loadNum < 194) //让动画走完\r\n  { \r\n    loading(1);\r\n  }\r\n\r\n  Serial.print(\"本地IP： \");\r\n  Serial.println(WiFi.localIP());\r\n  Serial.println(\"启动UDP\");\r\n  Udp.begin(localPort);\r\n  Serial.println(\"等待同步...\");\r\n  setSyncProvider(getNtpTime);\r\n  setSyncInterval(300);\r\n\r\n  \r\n  TJpgDec.setJpgScale(1);\r\n  TJpgDec.setSwapBytes(true);\r\n  TJpgDec.setCallback(tft_output);\r\n  \r\n  //tft.pushImage(0,0,240,240,misaka);\r\n  //TJpgDec.drawJpg(120,120,misaka, sizeof(misaka));//显示logo\r\n  //delay(1000); \r\n  int CityCODE = 0;\r\n  for(int cnum=5;cnum>0;cnum--)\r\n  {          \r\n    CityCODE = CityCODE*100;\r\n    CityCODE += EEPROM.read(CC_addr+cnum-1); \r\n    delay(5);\r\n  }\r\n  if(CityCODE>=101000000 && CityCODE<=102000000) \r\n    cityCode = CityCODE;  \r\n  else\r\n    getCityCode();  //获取城市代码\r\n   \r\n  tft.fillScreen(TFT_BLACK);//清屏\r\n  \r\n  TJpgDec.drawJpg(15,183,temperature, sizeof(temperature));  //温度图标\r\n  TJpgDec.drawJpg(15,213,humidity, sizeof(humidity));  //湿度图标\r\n\r\n  getCityWeater();\r\n}\r\ntime_t prevDisplay = 0; // 显示时间\r\nunsigned long weaterTime = 0;\r\n\r\nvoid loop()\r\n{\r\n  \r\n  if (now() != prevDisplay) {\r\n    prevDisplay = now();\r\n    digitalClockDisplay();\r\n    prevTime=0;  \r\n  }\r\n  \r\n  if(millis() - weaterTime > 300000){ //5分钟更新一次天气\r\n    weaterTime = millis();\r\n    getCityWeater();\r\n  }\r\n  scrollBanner();\r\n  imgAnim();\r\n  Serial_set();\r\n\r\n}\r\n\r\n\r\n// 发送HTTP请求并且将服务器响应通过串口输出\r\nvoid getCityCode(){\r\n String URL = \"http://wgeo.weather.com.cn/ip/?_=\"+String(now());\r\n  //创建 HTTPClient 对象\r\n  HTTPClient httpClient;\r\n \r\n  //配置请求地址。此处也可以不使用端口号和PATH而单纯的\r\n  httpClient.begin(URL); \r\n  \r\n  //设置请求头中的User-Agent\r\n  httpClient.setUserAgent(\"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1\");\r\n  httpClient.addHeader(\"Referer\", \"http://www.weather.com.cn/\");\r\n \r\n  //启动连接并发送HTTP请求\r\n  int httpCode = httpClient.GET();\r\n  Serial.print(\"Send GET request to URL: \");\r\n  Serial.println(URL);\r\n  \r\n  //如果服务器响应OK则从服务器获取响应体信息并通过串口输出\r\n  if (httpCode == HTTP_CODE_OK) {\r\n    String str = httpClient.getString();\r\n    \r\n    int aa = str.indexOf(\"id=\");\r\n    if(aa>-1)\r\n    {\r\n       //cityCode = str.substring(aa+4,aa+4+9).toInt();\r\n       cityCode = str.substring(aa+4,aa+4+9);\r\n       Serial.println(cityCode); \r\n       getCityWeater();\r\n    }\r\n    else\r\n    {\r\n      Serial.println(\"获取城市代码失败\");  \r\n    }\r\n    \r\n    \r\n  } else {\r\n    Serial.println(\"请求城市代码错误：\");\r\n    Serial.println(httpCode);\r\n  }\r\n \r\n  //关闭ESP8266与服务器连接\r\n  httpClient.end();\r\n}\r\n\r\n\r\n\r\n// 获取城市天气\r\nvoid getCityWeater(){\r\n //String URL = \"http://d1.weather.com.cn/dingzhi/\" + cityCode + \".html?_=\"+String(now());//新\r\n String URL = \"http://d1.weather.com.cn/weather_index/\" + cityCode + \".html?_=\"+String(now());//原来\r\n  //创建 HTTPClient 对象\r\n  HTTPClient httpClient;\r\n  \r\n  httpClient.begin(wificlient,URL); \r\n  \r\n  //设置请求头中的User-Agent\r\n  httpClient.setUserAgent(\"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1\");\r\n  httpClient.addHeader(\"Referer\", \"http://www.weather.com.cn/\");\r\n \r\n  //启动连接并发送HTTP请求\r\n  int httpCode = httpClient.GET();\r\n  Serial.println(\"正在获取天气数据\");\r\n  Serial.println(URL);\r\n  \r\n  //如果服务器响应OK则从服务器获取响应体信息并通过串口输出\r\n  if (httpCode == HTTP_CODE_OK) {\r\n\r\n    String str = httpClient.getString();\r\n    int indexStart = str.indexOf(\"weatherinfo\\\":\");\r\n    int indexEnd = str.indexOf(\"};var alarmDZ\");\r\n\r\n    String jsonCityDZ = str.substring(indexStart+13,indexEnd);\r\n    //Serial.println(jsonCityDZ);\r\n\r\n    indexStart = str.indexOf(\"dataSK =\");\r\n    indexEnd = str.indexOf(\";var dataZS\");\r\n    String jsonDataSK = str.substring(indexStart+8,indexEnd);\r\n    //Serial.println(jsonDataSK);\r\n\r\n    \r\n    indexStart = str.indexOf(\"\\\"f\\\":[\");\r\n    indexEnd = str.indexOf(\",{\\\"fa\");\r\n    String jsonFC = str.substring(indexStart+5,indexEnd);\r\n    //Serial.println(jsonFC);\r\n    \r\n    weaterData(&jsonCityDZ,&jsonDataSK,&jsonFC);\r\n    Serial.println(\"获取成功\");\r\n    \r\n  } else {\r\n    Serial.println(\"请求城市天气错误：\");\r\n    Serial.print(httpCode);\r\n  }\r\n \r\n  //关闭ESP8266与服务器连接\r\n  httpClient.end();\r\n}\r\n\r\n\r\nString scrollText[7];\r\n//int scrollTextWidth = 0;\r\n//天气信息写到屏幕上\r\nvoid weaterData(String *cityDZ,String *dataSK,String *dataFC)\r\n{\r\n  //解析第一段JSON\r\n  DynamicJsonDocument doc(1024);\r\n  deserializeJson(doc, *dataSK);\r\n  JsonObject sk = doc.as<JsonObject>();\r\n\r\n  //TFT_eSprite clkb = TFT_eSprite(&tft);\r\n  \r\n  /***绘制相关文字***/\r\n  clk.setColorDepth(8);\r\n  clk.loadFont(ZdyLwFont_20);\r\n  \r\n  //温度\r\n  clk.createSprite(58, 24); \r\n  clk.fillSprite(bgColor);\r\n  clk.setTextDatum(CC_DATUM);\r\n  clk.setTextColor(TFT_WHITE, bgColor); \r\n  clk.drawString(sk[\"temp\"].as<String>()+\"℃\",28,13);\r\n  clk.pushSprite(100,184);\r\n  clk.deleteSprite();\r\n  tempnum = sk[\"temp\"].as<int>();\r\n  tempnum = tempnum+10;\r\n  if(tempnum<10)\r\n    tempcol=0x00FF;\r\n  else if(tempnum<28)\r\n    tempcol=0x0AFF;\r\n  else if(tempnum<34)\r\n    tempcol=0x0F0F;\r\n  else if(tempnum<41)\r\n    tempcol=0xFF0F;\r\n  else if(tempnum<49)\r\n    tempcol=0xF00F;\r\n  else\r\n  {\r\n    tempcol=0xF00F;\r\n    tempnum=50;\r\n  }\r\n  tempWin();\r\n  \r\n  //湿度\r\n  clk.createSprite(58, 24); \r\n  clk.fillSprite(bgColor);\r\n  clk.setTextDatum(CC_DATUM);\r\n  clk.setTextColor(TFT_WHITE, bgColor); \r\n  clk.drawString(sk[\"SD\"].as<String>(),28,13);\r\n  //clk.drawString(\"100%\",28,13);\r\n  clk.pushSprite(100,214);\r\n  clk.deleteSprite();\r\n  //String A = sk[\"SD\"].as<String>();\r\n  huminum = atoi((sk[\"SD\"].as<String>()).substring(0,2).c_str());\r\n  \r\n  if(huminum>90)\r\n    humicol=0x00FF;\r\n  else if(huminum>70)\r\n    humicol=0x0AFF;\r\n  else if(huminum>40)\r\n    humicol=0x0F0F;\r\n  else if(huminum>20)\r\n    humicol=0xFF0F;\r\n  else\r\n    humicol=0xF00F;\r\n  humidityWin();\r\n\r\n  \r\n  //城市名称\r\n  clk.createSprite(94, 30); \r\n  clk.fillSprite(bgColor);\r\n  clk.setTextDatum(CC_DATUM);\r\n  clk.setTextColor(TFT_WHITE, bgColor); \r\n  clk.drawString(sk[\"cityname\"].as<String>(),44,16);\r\n  clk.pushSprite(15,15);\r\n  clk.deleteSprite();\r\n\r\n  //PM2.5空气指数\r\n  uint16_t pm25BgColor = tft.color565(156,202,127);//优\r\n  String aqiTxt = \"优\";\r\n  int pm25V = sk[\"aqi\"];\r\n  if(pm25V>200){\r\n    pm25BgColor = tft.color565(136,11,32);//重度\r\n    aqiTxt = \"重度\";\r\n  }else if(pm25V>150){\r\n    pm25BgColor = tft.color565(186,55,121);//中度\r\n    aqiTxt = \"中度\";\r\n  }else if(pm25V>100){\r\n    pm25BgColor = tft.color565(242,159,57);//轻\r\n    aqiTxt = \"轻度\";\r\n  }else if(pm25V>50){\r\n    pm25BgColor = tft.color565(247,219,100);//良\r\n    aqiTxt = \"良\";\r\n  }\r\n  clk.createSprite(56, 24); \r\n  clk.fillSprite(bgColor);\r\n  clk.fillRoundRect(0,0,50,24,4,pm25BgColor);\r\n  clk.setTextDatum(CC_DATUM);\r\n  clk.setTextColor(0x0000); \r\n  clk.drawString(aqiTxt,25,13);\r\n  clk.pushSprite(104,18);\r\n  clk.deleteSprite();\r\n  \r\n  scrollText[0] = \"实时天气 \"+sk[\"weather\"].as<String>();\r\n  scrollText[1] = \"空气质量 \"+aqiTxt;\r\n  scrollText[2] = \"风向 \"+sk[\"WD\"].as<String>()+sk[\"WS\"].as<String>();\r\n\r\n  //scrollText[6] = atoi((sk[\"weathercode\"].as<String>()).substring(1,3).c_str()) ;\r\n\r\n  //天气图标\r\n  wrat.printfweather(170,15,atoi((sk[\"weathercode\"].as<String>()).substring(1,3).c_str()));\r\n\r\n  \r\n  //左上角滚动字幕\r\n  //解析第二段JSON\r\n  deserializeJson(doc, *cityDZ);\r\n  JsonObject dz = doc.as<JsonObject>();\r\n  //Serial.println(sk[\"ws\"].as<String>());\r\n  //横向滚动方式\r\n  //String aa = \"今日天气:\" + dz[\"weather\"].as<String>() + \"，温度:最低\" + dz[\"tempn\"].as<String>() + \"，最高\" + dz[\"temp\"].as<String>() + \" 空气质量:\" + aqiTxt + \"，风向:\" + dz[\"wd\"].as<String>() + dz[\"ws\"].as<String>();\r\n  //scrollTextWidth = clk.textWidth(scrollText);\r\n  //Serial.println(aa);\r\n  scrollText[3] = \"今日\"+dz[\"weather\"].as<String>();\r\n  \r\n  deserializeJson(doc, *dataFC);\r\n  JsonObject fc = doc.as<JsonObject>();\r\n  \r\n  scrollText[4] = \"最低温度\"+fc[\"fd\"].as<String>()+\"℃\";\r\n  scrollText[5] = \"最高温度\"+fc[\"fc\"].as<String>()+\"℃\";\r\n  \r\n  //Serial.println(scrollText[0]);\r\n  \r\n  clk.unloadFont();\r\n}\r\n\r\nint currentIndex = 0;\r\nTFT_eSprite clkb = TFT_eSprite(&tft);\r\n\r\nvoid scrollBanner(){\r\n  //if(millis() - prevTime > 2333) //3秒切换一次\r\n  if(second()%2 ==0&& prevTime == 0)\r\n  { \r\n    if(scrollText[currentIndex])\r\n    {\r\n      clkb.setColorDepth(8);\r\n      clkb.loadFont(ZdyLwFont_20);\r\n      clkb.createSprite(150, 30); \r\n      clkb.fillSprite(bgColor);\r\n      clkb.setTextWrap(false);\r\n      clkb.setTextDatum(CC_DATUM);\r\n      clkb.setTextColor(TFT_WHITE, bgColor); \r\n      clkb.drawString(scrollText[currentIndex],74, 16);\r\n      clkb.pushSprite(10,45);\r\n       \r\n      clkb.deleteSprite();\r\n      clkb.unloadFont();\r\n      \r\n      if(currentIndex>=5)\r\n        currentIndex = 0;  //回第一个\r\n      else\r\n        currentIndex += 1;  //准备切换到下一个        \r\n    }\r\n    prevTime = 1;\r\n  }\r\n}\r\n/*\r\nvoid imgAnim()\r\n{\r\n  int x=160,y=160,dt=43;\r\n\r\n  TJpgDec.drawJpg(x,y,i0, sizeof(i0));\r\n  delay(dt);\r\n  TJpgDec.drawJpg(x,y,i1, sizeof(i1));\r\n  delay(dt);\r\n  TJpgDec.drawJpg(x,y,i2, sizeof(i2));\r\n  delay(dt);\r\n  TJpgDec.drawJpg(x,y,i3, sizeof(i3));\r\n  delay(dt);  \r\n  TJpgDec.drawJpg(x,y,i4, sizeof(i4));\r\n  delay(dt);  \r\n  TJpgDec.drawJpg(x,y,i5, sizeof(i5));\r\n  delay(dt);  \r\n  TJpgDec.drawJpg(x,y,i6, sizeof(i6));\r\n  delay(dt);  \r\n  TJpgDec.drawJpg(x,y,i7, sizeof(i7));\r\n  delay(dt);  \r\n  TJpgDec.drawJpg(x,y,i8, sizeof(i8));\r\n  delay(dt);  \r\n  TJpgDec.drawJpg(x,y,i9, sizeof(i9));\r\n  delay(dt);  \r\n}\r\n*/\r\n\r\n\r\nvoid imgAnim()\r\n{\r\n  int x=160,y=160;\r\n  if(millis() - AprevTime > 37) //x ms切换一次\r\n  {\r\n    Anim++;\r\n    AprevTime = millis();\r\n  }\r\n  if(Anim==10)\r\n    Anim=0;\r\n\r\n  switch(Anim)\r\n  {\r\n    case 0:\r\n      TJpgDec.drawJpg(x,y,i0, sizeof(i0));\r\n      break;\r\n    case 1:\r\n      TJpgDec.drawJpg(x,y,i1, sizeof(i1));\r\n      break;\r\n    case 2:\r\n      TJpgDec.drawJpg(x,y,i2, sizeof(i2));\r\n      break;\r\n    case 3:\r\n      TJpgDec.drawJpg(x,y,i3, sizeof(i3));\r\n      break;\r\n    case 4:\r\n      TJpgDec.drawJpg(x,y,i4, sizeof(i4));\r\n      break;\r\n    case 5:\r\n      TJpgDec.drawJpg(x,y,i5, sizeof(i5));\r\n      break;\r\n    case 6:\r\n      TJpgDec.drawJpg(x,y,i6, sizeof(i6));\r\n      break;\r\n    case 7:\r\n      TJpgDec.drawJpg(x,y,i7, sizeof(i7));\r\n      break;\r\n    case 8: \r\n      TJpgDec.drawJpg(x,y,i8, sizeof(i8));\r\n      break;\r\n    case 9: \r\n      TJpgDec.drawJpg(x,y,i9, sizeof(i9));\r\n      break;\r\n    default:\r\n      Serial.println(\"显示Anim错误\");\r\n      break;\r\n  }\r\n}\r\n\r\nunsigned char Hour_sign   = 60;\r\nunsigned char Minute_sign = 60;\r\nunsigned char Second_sign = 60;\r\nvoid digitalClockDisplay()\r\n{ \r\n  int timey=82;\r\n  if(hour()!=Hour_sign)//时钟刷新\r\n  {\r\n    dig.printfW3660(20,timey,hour()/10);\r\n    dig.printfW3660(60,timey,hour()%10);\r\n    Hour_sign = hour();\r\n  }\r\n  if(minute()!=Minute_sign)//分钟刷新\r\n  {\r\n    dig.printfO3660(101,timey,minute()/10);\r\n    dig.printfO3660(141,timey,minute()%10);\r\n    Minute_sign = minute();\r\n  }\r\n  if(second()!=Second_sign)//分钟刷新\r\n  {\r\n    dig.printfW1830(182,timey+30,second()/10);\r\n    dig.printfW1830(202,timey+30,second()%10);\r\n    Second_sign = second();\r\n  }\r\n  \r\n  /***日期****/\r\n  clk.setColorDepth(8);\r\n  clk.loadFont(ZdyLwFont_20);\r\n  \r\n  //星期\r\n  clk.createSprite(58, 30);\r\n  clk.fillSprite(bgColor);\r\n  clk.setTextDatum(CC_DATUM);\r\n  clk.setTextColor(TFT_WHITE, bgColor);\r\n  clk.drawString(week(),29,16);\r\n  clk.pushSprite(102,150);\r\n  clk.deleteSprite();\r\n  \r\n  //月日\r\n  clk.createSprite(95, 30);\r\n  clk.fillSprite(bgColor);\r\n  clk.setTextDatum(CC_DATUM);\r\n  clk.setTextColor(TFT_WHITE, bgColor);  \r\n  clk.drawString(monthDay(),49,16);\r\n  clk.pushSprite(5,150);\r\n  clk.deleteSprite();\r\n  \r\n  clk.unloadFont();\r\n  /***日期****/\r\n}\r\n\r\n//星期\r\nString week()\r\n{\r\n  String wk[7] = {\"日\",\"一\",\"二\",\"三\",\"四\",\"五\",\"六\"};\r\n  String s = \"周\" + wk[weekday()-1];\r\n  return s;\r\n}\r\n\r\n//月日\r\nString monthDay()\r\n{\r\n  String s = String(month());\r\n  s = s + \"月\" + day() + \"日\";\r\n  return s;\r\n}\r\n\r\n/*-------- NTP code ----------*/\r\n\r\nconst int NTP_PACKET_SIZE = 48; // NTP时间在消息的前48字节中\r\nbyte packetBuffer[NTP_PACKET_SIZE]; //buffer to hold incoming & outgoing packets\r\n\r\ntime_t getNtpTime()\r\n{\r\n  IPAddress ntpServerIP; // NTP server's ip address\r\n\r\n  while (Udp.parsePacket() > 0) ; // discard any previously received packets\r\n  //Serial.println(\"Transmit NTP Request\");\r\n  // get a random server from the pool\r\n  WiFi.hostByName(ntpServerName, ntpServerIP);\r\n  //Serial.print(ntpServerName);\r\n  //Serial.print(\": \");\r\n  //Serial.println(ntpServerIP);\r\n  sendNTPpacket(ntpServerIP);\r\n  uint32_t beginWait = millis();\r\n  while (millis() - beginWait < 1500) {\r\n    int size = Udp.parsePacket();\r\n    if (size >= NTP_PACKET_SIZE) {\r\n      Serial.println(\"Receive NTP Response\");\r\n      Udp.read(packetBuffer, NTP_PACKET_SIZE);  // read packet into the buffer\r\n      unsigned long secsSince1900;\r\n      // convert four bytes starting at location 40 to a long integer\r\n      secsSince1900 =  (unsigned long)packetBuffer[40] << 24;\r\n      secsSince1900 |= (unsigned long)packetBuffer[41] << 16;\r\n      secsSince1900 |= (unsigned long)packetBuffer[42] << 8;\r\n      secsSince1900 |= (unsigned long)packetBuffer[43];\r\n      //Serial.println(secsSince1900 - 2208988800UL + timeZone * SECS_PER_HOUR);\r\n      return secsSince1900 - 2208988800UL + timeZone * SECS_PER_HOUR;\r\n    }\r\n  }\r\n  Serial.println(\"No NTP Response :-(\");\r\n  return 0; // 无法获取时间时返回0\r\n}\r\n\r\n// 向NTP服务器发送请求\r\nvoid sendNTPpacket(IPAddress &address)\r\n{\r\n  // set all bytes in the buffer to 0\r\n  memset(packetBuffer, 0, NTP_PACKET_SIZE);\r\n  // Initialize values needed to form NTP request\r\n  // (see URL above for details on the packets)\r\n  packetBuffer[0] = 0b11100011;   // LI, Version, Mode\r\n  packetBuffer[1] = 0;     // Stratum, or type of clock\r\n  packetBuffer[2] = 6;     // Polling Interval\r\n  packetBuffer[3] = 0xEC;  // Peer Clock Precision\r\n  // 8 bytes of zero for Root Delay & Root Dispersion\r\n  packetBuffer[12] = 49;\r\n  packetBuffer[13] = 0x4E;\r\n  packetBuffer[14] = 49;\r\n  packetBuffer[15] = 52;\r\n  // all NTP fields have been given values, now\r\n  // you can send a packet requesting a timestamp:\r\n  Udp.beginPacket(address, 123); //NTP requests are to port 123\r\n  Udp.write(packetBuffer, NTP_PACKET_SIZE);\r\n  Udp.endPacket();\r\n}\r\n"}}}






Started logging.

<<<
Content-Length: 3422

{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":14188,"clientInfo":{"name":"vscode","version":"1.50.0"},"rootPath":"e:\\晶彩\\开发资料\\ESP32模块\\ESP32-2432S028例子\\arduino\\Source code\\4_11_SmallDesktopDisplay\\SmallDesktopDisplay","rootUri":"file:///e%3A/%E6%99%B6%E5%BD%A9/%E5%BC%80%E5%8F%91%E8%B5%84%E6%96%99/ESP32%E6%A8%A1%E5%9D%97/ESP32-2432S028%E4%BE%8B%E5%AD%90/arduino/Source%20code/4_11_SmallDesktopDisplay/SmallDesktopDisplay","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional"},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"versionSupport":false,"tagSupport":{"valueSet":[1,2]}},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}},"contextSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"declaration":{"dynamicRegistration":true,"linkSupport":true},"selectionRange":{"dynamicRegistration":true}},"window":{"workDoneProgress":true}},"initializationOptions":{},"trace":"off","workspaceFolders":[{"uri":"file:///e%3A/%E6%99%B6%E5%BD%A9/%E5%BC%80%E5%8F%91%E8%B5%84%E6%96%99/ESP32%E6%A8%A1%E5%9D%97/ESP32-2432S028%E4%BE%8B%E5%AD%90/arduino/Source%20code/4_11_SmallDesktopDisplay/SmallDesktopDisplay","name":"SmallDesktopDisplay"}]}}
>>>
Content-Length: 598

{"id":0,"result":{"capabilities":{"textDocumentSync":2,"hoverProvider":true,"completionProvider":{"triggerCharacters":[".","\u003e",":"]},"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"workspaceSymbolProvider":true,"codeActionProvider":true,"documentFormattingProvider":true,"documentRangeFormattingProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"\n"},"renameProvider":false,"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]}}},"jsonrpc":"2.0"}
<<<
Content-Length: 52

{"jsonrpc":"2.0","method":"initialized","params":{}}Content-Length: 25789

{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///e%3A/%E6%99%B6%E5%BD%A9/%E5%BC%80%E5%8F%91%E8%B5%84%E6%96%99/ESP32%E6%A8%A1%E5%9D%97/ESP32-2432S028%E4%BE%8B%E5%AD%90/arduino/Source%20code/4_11_SmallDesktopDisplay/SmallDesktopDisplay/SmallDesktopDisplay.ino","languageId":"cpp","version":1,"text":"/*******************************************************************\r\n * 软 件 版 本：V1.2\r\n * \r\n * 必读！！！\r\n * 编译时 工具-Partition Scheme 这里改成 Huqe APP （3MB No OTA / 1MB SPIFFS）否则会报错内存不够 \r\n * https://www.bilibili.com/video/BV17f4y1G77n\r\n * 请自行修改WIFI信息和城市代码\r\n *             \r\n * *****************************************************************/\r\n#include \"ArduinoJson.h\"\r\n#include <TimeLib.h>\r\n// #include <ESP8266WiFi.h>\r\n// #include <ESP8266HTTPClient.h>\r\n#include <HTTPClient.h>\r\n// WiFiClient wifiClient;\r\n#include <WiFiUdp.h>\r\n#include <TFT_eSPI.h> \r\n#include <SPI.h>\r\n#include <TJpg_Decoder.h>\r\n#include <EEPROM.h>\r\n#include \"qr.h\"\r\n#include \"number.h\"\r\n#include \"weathernum.h\"\r\n\r\n#define LCD_BL_PIN 5\r\n\r\n\r\n//---------------修改此处\"\"内的信息--------------------\r\nconst char ssid[] = \"CMCC-404\";     //WIFI名称 修改这2个就可以了\r\nconst char pass[] = \"zp198612\";    //WIFI密码\r\n//----------------------------------------------------\r\n\r\n\r\n\r\n#include \"font/ZdyLwFont_20.h\"\r\n#include \"img/misaka.h\"\r\n#include \"img/temperature.h\"\r\n#include \"img/humidity.h\"\r\n#include \"img/pangzi/i0.h\"\r\n#include \"img/pangzi/i1.h\"\r\n#include \"img/pangzi/i2.h\"\r\n#include \"img/pangzi/i3.h\"\r\n#include \"img/pangzi/i4.h\"\r\n#include \"img/pangzi/i5.h\"\r\n#include \"img/pangzi/i6.h\"\r\n#include \"img/pangzi/i7.h\"\r\n#include \"img/pangzi/i8.h\"\r\n#include \"img/pangzi/i9.h\"\r\n\r\nTFT_eSPI tft = TFT_eSPI();  \r\nTFT_eSprite clk = TFT_eSprite(&tft);\r\n\r\n/*** Component objects ***/\r\nNumber      dig;\r\nWeatherNum  wrat;\r\n\r\n\r\nuint32_t targetTime = 0;   \r\nuint16_t bgColor = 0x0000;\r\nString cityCode = \"101280601\";  //天气城市代码查询地址https://www.it610.com/article/1291702105907732480.htm 打开后按CTRL+F搜索你所在的城市\r\nint LCD_BL_PWM = 100;//屏幕亮度0-100\r\nint tempnum = 0;   //温度百分比\r\nint huminum = 0;   //湿度百分比\r\nint tempcol =0xffff;\r\nint humicol =0xffff;\r\nint Anim = 0;\r\nint prevTime = 0;\r\nint AprevTime = 0;\r\nint BL_addr = 1;//被写入数据的EEPROM地址编号  0亮度\r\nint CC_addr = 10;//被写入数据的EEPROM地址编号  10城市\r\n\r\n//NTP服务器\r\nstatic const char ntpServerName[] = \"ntp6.aliyun.com\";\r\nconst int timeZone = 8;     //东八区\r\n\r\n\r\nWiFiUDP Udp;\r\nWiFiClient wificlient;\r\nunsigned int localPort = 8000;\r\nfloat duty=0;\r\ntime_t getNtpTime();\r\nvoid digitalClockDisplay();\r\nvoid printDigits(int digits);\r\nString num2str(int digits);\r\nvoid sendNTPpacket(IPAddress &address);\r\n\r\n\r\nbool tft_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t* bitmap)\r\n{\r\n  if ( y >= tft.height() ) return 0;\r\n  tft.pushImage(x, y, w, h, bitmap);\r\n  // Return 1 to decode next block\r\n  return 1;\r\n}\r\n\r\nbyte loadNum = 6;\r\nvoid loading(byte delayTime)//绘制进度条\r\n{\r\n  clk.setColorDepth(8);\r\n  \r\n  clk.createSprite(200, 100);//创建窗口\r\n  clk.fillSprite(0x0000);   //填充率\r\n\r\n  clk.drawRoundRect(0,0,200,16,8,0xFFFF);       //空心圆角矩形\r\n  clk.fillRoundRect(3,3,loadNum,10,5,0xFFFF);   //实心圆角矩形\r\n  clk.setTextDatum(CC_DATUM);   //设置文本数据\r\n  clk.setTextColor(TFT_GREEN, 0x0000); \r\n  clk.drawString(\"Connecting to WiFi......\",100,40,2);\r\n  clk.setTextColor(TFT_WHITE, 0x0000); \r\n  clk.drawRightString(\"SDD V1.2\",180,60,2);\r\n  clk.pushSprite(20,110);  //窗口位置\r\n  \r\n  //clk.setTextDatum(CC_DATUM);\r\n  //clk.setTextColor(TFT_WHITE, 0x0000); \r\n  //clk.pushSprite(130,180);\r\n  \r\n  clk.deleteSprite();\r\n  loadNum += 1;\r\n  delay(delayTime);\r\n}\r\n\r\nvoid humidityWin()\r\n{\r\n  clk.setColorDepth(8);\r\n  \r\n  huminum = huminum/2;\r\n  clk.createSprite(52, 6);  //创建窗口\r\n  clk.fillSprite(0x0000);    //填充率\r\n  clk.drawRoundRect(0,0,52,6,3,0xFFFF);  //空心圆角矩形  起始位x,y,长度，宽度，圆弧半径，颜色\r\n  clk.fillRoundRect(1,1,huminum,4,2,humicol);   //实心圆角矩形\r\n  clk.pushSprite(45,222);  //窗口位置\r\n  clk.deleteSprite();\r\n}\r\nvoid tempWin()\r\n{\r\n  clk.setColorDepth(8);\r\n  \r\n  clk.createSprite(52, 6);  //创建窗口\r\n  clk.fillSprite(0x0000);    //填充率\r\n  clk.drawRoundRect(0,0,52,6,3,0xFFFF);  //空心圆角矩形  起始位x,y,长度，宽度，圆弧半径，颜色\r\n  clk.fillRoundRect(1,1,tempnum,4,2,tempcol);   //实心圆角矩形\r\n  clk.pushSprite(45,192);  //窗口位置\r\n  clk.deleteSprite();\r\n}\r\n\r\nvoid SmartConfig(void)//微信配网\r\n{\r\n  WiFi.mode(WIFI_STA);    //设置STA模式\r\n  //tft.pushImage(0, 0, 240, 240, qr);\r\n  tft.pushImage(0, 0, 240, 240, qr);\r\n  Serial.println(\"\\r\\nWait for Smartconfig...\");    //打印log信息\r\n  WiFi.beginSmartConfig();      //开始SmartConfig，等待手机端发出用户名和密码\r\n  while (1)\r\n  {\r\n    Serial.print(\".\");\r\n    delay(100);                   // wait for a second\r\n    if (WiFi.smartConfigDone())//配网成功，接收到SSID和密码\r\n    {\r\n    Serial.println(\"SmartConfig Success\");\r\n    Serial.printf(\"SSID:%s\\r\\n\", WiFi.SSID().c_str());\r\n    Serial.printf(\"PSW:%s\\r\\n\", WiFi.psk().c_str());\r\n    break;\r\n    }\r\n  }\r\n  loadNum = 194;\r\n}\r\n\r\nString SMOD = \"\";//0亮度\r\n\r\nvoid Serial_set()//串口设置\r\n{\r\n  String incomingByte = \"\";\r\n  if(Serial.available()>0)\r\n  {\r\n    \r\n    while(Serial.available()>0)//监测串口缓存，当有数据输入时，循环赋值给incomingByte\r\n    {\r\n      incomingByte += char(Serial.read());//读取单个字符值，转换为字符，并按顺序一个个赋值给incomingByte\r\n      delay(2);//不能省略，因为读取缓冲区数据需要时间\r\n    }    \r\n    if(SMOD==\"0x01\")//设置1亮度设置\r\n    {\r\n      int LCDBL = atoi(incomingByte.c_str());//int n = atoi(xxx.c_str());//String转int\r\n      if(LCDBL>=0 && LCDBL<=100)\r\n      {\r\n        EEPROM.write(BL_addr, LCDBL);//亮度地址写入亮度值\r\n        EEPROM.commit();//保存更改的数据\r\n        delay(5);\r\n        LCD_BL_PWM = EEPROM.read(BL_addr); \r\n        delay(5);\r\n        SMOD = \"\";\r\n        Serial.printf(\"亮度调整为：\");\r\n//        analogWrite(LCD_BL_PIN, 1023 - (LCD_BL_PWM*10));\r\n        Serial.println(LCD_BL_PWM);\r\n        Serial.println(\"\");\r\n      }\r\n      else\r\n        Serial.println(\"亮度调整错误，请输入0-100\");\r\n    } \r\n    if(SMOD==\"0x02\")//设置2地址设置\r\n    {\r\n      int CityCODE = 0;\r\n      int CityC = atoi(incomingByte.c_str());//int n = atoi(xxx.c_str());//String转int\r\n      if((CityC>=101000000&&CityC<=102000000)||CityC == 0)\r\n      {\r\n        for(int cnum=0;cnum<5;cnum++)\r\n        {\r\n          EEPROM.write(CC_addr+cnum,CityC%100);//城市地址写入城市代码\r\n          EEPROM.commit();//保存更改的数据\r\n          CityC = CityC/100;\r\n          delay(5);\r\n        }\r\n        for(int cnum=5;cnum>0;cnum--)\r\n        {          \r\n          CityCODE = CityCODE*100;\r\n          CityCODE += EEPROM.read(CC_addr+cnum-1); \r\n          delay(5);\r\n        }\r\n        \r\n        cityCode = CityCODE;\r\n        \r\n        if(cityCode == \"0\")\r\n        {\r\n          Serial.println(\"城市代码调整为：自动\");\r\n          getCityCode();  //获取城市代码\r\n        }\r\n        else\r\n        {\r\n          Serial.printf(\"城市代码调整为：\");\r\n          Serial.println(cityCode);\r\n        }\r\n        Serial.println(\"\");\r\n        getCityWeater();//更新城市天气  \r\n        SMOD = \"\";\r\n      }\r\n      else\r\n        Serial.println(\"城市调整错误，请输入9位城市代码，自动获取请输入0\");\r\n    }   \r\n    else\r\n    {\r\n      SMOD = incomingByte;\r\n      delay(2);\r\n      if(SMOD==\"0x01\")\r\n        Serial.println(\"请输入亮度值，范围0-100\");\r\n      else if(SMOD==\"0x02\")\r\n        Serial.println(\"请输入9位城市代码，自动获取请输入0\"); \r\n      else\r\n      {\r\n        Serial.println(\"\");\r\n        Serial.println(\"请输入需要修改的代码：\");\r\n        Serial.println(\"亮度设置输入    0x01\");\r\n        Serial.println(\"地址设置输入    0x02\");\r\n        Serial.println(\"\");\r\n      }\r\n    }\r\n\r\n\r\n  }\r\n}\r\n\r\nvoid setup()\r\n{\r\n  Serial.begin(115200);\r\n  EEPROM.begin(1024);\r\n\r\n  if(EEPROM.read(BL_addr)>0&&EEPROM.read(BL_addr)<100)\r\n    LCD_BL_PWM = EEPROM.read(BL_addr); \r\n  \r\n  pinMode(LCD_BL_PIN, OUTPUT);\r\n // analogWrite(LCD_BL_PIN, 1023 - (LCD_BL_PWM*10));\r\n  \r\n  tft.begin(); /* TFT init */\r\n  tft.invertDisplay(1);//反转所有显示颜色：1反转，0正常\r\n  tft.fillScreen(0x0000);\r\n  tft.setTextColor(TFT_BLACK, bgColor);\r\n\r\n  targetTime = millis() + 1000; \r\n\r\n  Serial.print(\"正在连接WIFI \");\r\n  Serial.println(ssid);\r\n  WiFi.begin(ssid, pass);\r\n  \r\n  TJpgDec.setJpgScale(1);\r\n  TJpgDec.setSwapBytes(true);\r\n  TJpgDec.setCallback(tft_output);\r\n\r\n  while (WiFi.status() != WL_CONNECTED) \r\n  {\r\n    loading(70);  \r\n      \r\n    if(loadNum>=194)\r\n    {\r\n      SmartConfig();   \r\n      break;\r\n    }\r\n  }\r\n  delay(10); \r\n  while(loadNum < 194) //让动画走完\r\n  { \r\n    loading(1);\r\n  }\r\n\r\n  Serial.print(\"本地IP： \");\r\n  Serial.println(WiFi.localIP());\r\n  Serial.println(\"启动UDP\");\r\n  Udp.begin(localPort);\r\n  Serial.println(\"等待同步...\");\r\n  setSyncProvider(getNtpTime);\r\n  setSyncInterval(300);\r\n\r\n  \r\n  TJpgDec.setJpgScale(1);\r\n  TJpgDec.setSwapBytes(true);\r\n  TJpgDec.setCallback(tft_output);\r\n  \r\n  //tft.pushImage(0,0,240,240,misaka);\r\n  //TJpgDec.drawJpg(120,120,misaka, sizeof(misaka));//显示logo\r\n  //delay(1000); \r\n  int CityCODE = 0;\r\n  for(int cnum=5;cnum>0;cnum--)\r\n  {          \r\n    CityCODE = CityCODE*100;\r\n    CityCODE += EEPROM.read(CC_addr+cnum-1); \r\n    delay(5);\r\n  }\r\n  if(CityCODE>=101000000 && CityCODE<=102000000) \r\n    cityCode = CityCODE;  \r\n  else\r\n    getCityCode();  //获取城市代码\r\n   \r\n  tft.fillScreen(TFT_BLACK);//清屏\r\n  \r\n  TJpgDec.drawJpg(15,183,temperature, sizeof(temperature));  //温度图标\r\n  TJpgDec.drawJpg(15,213,humidity, sizeof(humidity));  //湿度图标\r\n\r\n  getCityWeater();\r\n}\r\ntime_t prevDisplay = 0; // 显示时间\r\nunsigned long weaterTime = 0;\r\n\r\nvoid loop()\r\n{\r\n  \r\n  if (now() != prevDisplay) {\r\n    prevDisplay = now();\r\n    digitalClockDisplay();\r\n    prevTime=0;  \r\n  }\r\n  \r\n  if(millis() - weaterTime > 300000){ //5分钟更新一次天气\r\n    weaterTime = millis();\r\n    getCityWeater();\r\n  }\r\n  scrollBanner();\r\n  imgAnim();\r\n  Serial_set();\r\n\r\n}\r\n\r\n\r\n// 发送HTTP请求并且将服务器响应通过串口输出\r\nvoid getCityCode(){\r\n String URL = \"http://wgeo.weather.com.cn/ip/?_=\"+String(now());\r\n  //创建 HTTPClient 对象\r\n  HTTPClient httpClient;\r\n \r\n  //配置请求地址。此处也可以不使用端口号和PATH而单纯的\r\n  httpClient.begin(URL); \r\n  \r\n  //设置请求头中的User-Agent\r\n  httpClient.setUserAgent(\"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1\");\r\n  httpClient.addHeader(\"Referer\", \"http://www.weather.com.cn/\");\r\n \r\n  //启动连接并发送HTTP请求\r\n  int httpCode = httpClient.GET();\r\n  Serial.print(\"Send GET request to URL: \");\r\n  Serial.println(URL);\r\n  \r\n  //如果服务器响应OK则从服务器获取响应体信息并通过串口输出\r\n  if (httpCode == HTTP_CODE_OK) {\r\n    String str = httpClient.getString();\r\n    \r\n    int aa = str.indexOf(\"id=\");\r\n    if(aa>-1)\r\n    {\r\n       //cityCode = str.substring(aa+4,aa+4+9).toInt();\r\n       cityCode = str.substring(aa+4,aa+4+9);\r\n       Serial.println(cityCode); \r\n       getCityWeater();\r\n    }\r\n    else\r\n    {\r\n      Serial.println(\"获取城市代码失败\");  \r\n    }\r\n    \r\n    \r\n  } else {\r\n    Serial.println(\"请求城市代码错误：\");\r\n    Serial.println(httpCode);\r\n  }\r\n \r\n  //关闭ESP8266与服务器连接\r\n  httpClient.end();\r\n}\r\n\r\n\r\n\r\n// 获取城市天气\r\nvoid getCityWeater(){\r\n //String URL = \"http://d1.weather.com.cn/dingzhi/\" + cityCode + \".html?_=\"+String(now());//新\r\n String URL = \"http://d1.weather.com.cn/weather_index/\" + cityCode + \".html?_=\"+String(now());//原来\r\n  //创建 HTTPClient 对象\r\n  HTTPClient httpClient;\r\n  \r\n  httpClient.begin(wificlient,URL); \r\n  \r\n  //设置请求头中的User-Agent\r\n  httpClient.setUserAgent(\"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1\");\r\n  httpClient.addHeader(\"Referer\", \"http://www.weather.com.cn/\");\r\n \r\n  //启动连接并发送HTTP请求\r\n  int httpCode = httpClient.GET();\r\n  Serial.println(\"正在获取天气数据\");\r\n  Serial.println(URL);\r\n  \r\n  //如果服务器响应OK则从服务器获取响应体信息并通过串口输出\r\n  if (httpCode == HTTP_CODE_OK) {\r\n\r\n    String str = httpClient.getString();\r\n    int indexStart = str.indexOf(\"weatherinfo\\\":\");\r\n    int indexEnd = str.indexOf(\"};var alarmDZ\");\r\n\r\n    String jsonCityDZ = str.substring(indexStart+13,indexEnd);\r\n    //Serial.println(jsonCityDZ);\r\n\r\n    indexStart = str.indexOf(\"dataSK =\");\r\n    indexEnd = str.indexOf(\";var dataZS\");\r\n    String jsonDataSK = str.substring(indexStart+8,indexEnd);\r\n    //Serial.println(jsonDataSK);\r\n\r\n    \r\n    indexStart = str.indexOf(\"\\\"f\\\":[\");\r\n    indexEnd = str.indexOf(\",{\\\"fa\");\r\n    String jsonFC = str.substring(indexStart+5,indexEnd);\r\n    //Serial.println(jsonFC);\r\n    \r\n    weaterData(&jsonCityDZ,&jsonDataSK,&jsonFC);\r\n    Serial.println(\"获取成功\");\r\n    \r\n  } else {\r\n    Serial.println(\"请求城市天气错误：\");\r\n    Serial.print(httpCode);\r\n  }\r\n \r\n  //关闭ESP8266与服务器连接\r\n  httpClient.end();\r\n}\r\n\r\n\r\nString scrollText[7];\r\n//int scrollTextWidth = 0;\r\n//天气信息写到屏幕上\r\nvoid weaterData(String *cityDZ,String *dataSK,String *dataFC)\r\n{\r\n  //解析第一段JSON\r\n  DynamicJsonDocument doc(1024);\r\n  deserializeJson(doc, *dataSK);\r\n  JsonObject sk = doc.as<JsonObject>();\r\n\r\n  //TFT_eSprite clkb = TFT_eSprite(&tft);\r\n  \r\n  /***绘制相关文字***/\r\n  clk.setColorDepth(8);\r\n  clk.loadFont(ZdyLwFont_20);\r\n  \r\n  //温度\r\n  clk.createSprite(58, 24); \r\n  clk.fillSprite(bgColor);\r\n  clk.setTextDatum(CC_DATUM);\r\n  clk.setTextColor(TFT_WHITE, bgColor); \r\n  clk.drawString(sk[\"temp\"].as<String>()+\"℃\",28,13);\r\n  clk.pushSprite(100,184);\r\n  clk.deleteSprite();\r\n  tempnum = sk[\"temp\"].as<int>();\r\n  tempnum = tempnum+10;\r\n  if(tempnum<10)\r\n    tempcol=0x00FF;\r\n  else if(tempnum<28)\r\n    tempcol=0x0AFF;\r\n  else if(tempnum<34)\r\n    tempcol=0x0F0F;\r\n  else if(tempnum<41)\r\n    tempcol=0xFF0F;\r\n  else if(tempnum<49)\r\n    tempcol=0xF00F;\r\n  else\r\n  {\r\n    tempcol=0xF00F;\r\n    tempnum=50;\r\n  }\r\n  tempWin();\r\n  \r\n  //湿度\r\n  clk.createSprite(58, 24); \r\n  clk.fillSprite(bgColor);\r\n  clk.setTextDatum(CC_DATUM);\r\n  clk.setTextColor(TFT_WHITE, bgColor); \r\n  clk.drawString(sk[\"SD\"].as<String>(),28,13);\r\n  //clk.drawString(\"100%\",28,13);\r\n  clk.pushSprite(100,214);\r\n  clk.deleteSprite();\r\n  //String A = sk[\"SD\"].as<String>();\r\n  huminum = atoi((sk[\"SD\"].as<String>()).substring(0,2).c_str());\r\n  \r\n  if(huminum>90)\r\n    humicol=0x00FF;\r\n  else if(huminum>70)\r\n    humicol=0x0AFF;\r\n  else if(huminum>40)\r\n    humicol=0x0F0F;\r\n  else if(huminum>20)\r\n    humicol=0xFF0F;\r\n  else\r\n    humicol=0xF00F;\r\n  humidityWin();\r\n\r\n  \r\n  //城市名称\r\n  clk.createSprite(94, 30); \r\n  clk.fillSprite(bgColor);\r\n  clk.setTextDatum(CC_DATUM);\r\n  clk.setTextColor(TFT_WHITE, bgColor); \r\n  clk.drawString(sk[\"cityname\"].as<String>(),44,16);\r\n  clk.pushSprite(15,15);\r\n  clk.deleteSprite();\r\n\r\n  //PM2.5空气指数\r\n  uint16_t pm25BgColor = tft.color565(156,202,127);//优\r\n  String aqiTxt = \"优\";\r\n  int pm25V = sk[\"aqi\"];\r\n  if(pm25V>200){\r\n    pm25BgColor = tft.color565(136,11,32);//重度\r\n    aqiTxt = \"重度\";\r\n  }else if(pm25V>150){\r\n    pm25BgColor = tft.color565(186,55,121);//中度\r\n    aqiTxt = \"中度\";\r\n  }else if(pm25V>100){\r\n    pm25BgColor = tft.color565(242,159,57);//轻\r\n    aqiTxt = \"轻度\";\r\n  }else if(pm25V>50){\r\n    pm25BgColor = tft.color565(247,219,100);//良\r\n    aqiTxt = \"良\";\r\n  }\r\n  clk.createSprite(56, 24); \r\n  clk.fillSprite(bgColor);\r\n  clk.fillRoundRect(0,0,50,24,4,pm25BgColor);\r\n  clk.setTextDatum(CC_DATUM);\r\n  clk.setTextColor(0x0000); \r\n  clk.drawString(aqiTxt,25,13);\r\n  clk.pushSprite(104,18);\r\n  clk.deleteSprite();\r\n  \r\n  scrollText[0] = \"实时天气 \"+sk[\"weather\"].as<String>();\r\n  scrollText[1] = \"空气质量 \"+aqiTxt;\r\n  scrollText[2] = \"风向 \"+sk[\"WD\"].as<String>()+sk[\"WS\"].as<String>();\r\n\r\n  //scrollText[6] = atoi((sk[\"weathercode\"].as<String>()).substring(1,3).c_str()) ;\r\n\r\n  //天气图标\r\n  wrat.printfweather(170,15,atoi((sk[\"weathercode\"].as<String>()).substring(1,3).c_str()));\r\n\r\n  \r\n  //左上角滚动字幕\r\n  //解析第二段JSON\r\n  deserializeJson(doc, *cityDZ);\r\n  JsonObject dz = doc.as<JsonObject>();\r\n  //Serial.println(sk[\"ws\"].as<String>());\r\n  //横向滚动方式\r\n  //String aa = \"今日天气:\" + dz[\"weather\"].as<String>() + \"，温度:最低\" + dz[\"tempn\"].as<String>() + \"，最高\" + dz[\"temp\"].as<String>() + \" 空气质量:\" + aqiTxt + \"，风向:\" + dz[\"wd\"].as<String>() + dz[\"ws\"].as<String>();\r\n  //scrollTextWidth = clk.textWidth(scrollText);\r\n  //Serial.println(aa);\r\n  scrollText[3] = \"今日\"+dz[\"weather\"].as<String>();\r\n  \r\n  deserializeJson(doc, *dataFC);\r\n  JsonObject fc = doc.as<JsonObject>();\r\n  \r\n  scrollText[4] = \"最低温度\"+fc[\"fd\"].as<String>()+\"℃\";\r\n  scrollText[5] = \"最高温度\"+fc[\"fc\"].as<String>()+\"℃\";\r\n  \r\n  //Serial.println(scrollText[0]);\r\n  \r\n  clk.unloadFont();\r\n}\r\n\r\nint currentIndex = 0;\r\nTFT_eSprite clkb = TFT_eSprite(&tft);\r\n\r\nvoid scrollBanner(){\r\n  //if(millis() - prevTime > 2333) //3秒切换一次\r\n  if(second()%2 ==0&& prevTime == 0)\r\n  { \r\n    if(scrollText[currentIndex])\r\n    {\r\n      clkb.setColorDepth(8);\r\n      clkb.loadFont(ZdyLwFont_20);\r\n      clkb.createSprite(150, 30); \r\n      clkb.fillSprite(bgColor);\r\n      clkb.setTextWrap(false);\r\n      clkb.setTextDatum(CC_DATUM);\r\n      clkb.setTextColor(TFT_WHITE, bgColor); \r\n      clkb.drawString(scrollText[currentIndex],74, 16);\r\n      clkb.pushSprite(10,45);\r\n       \r\n      clkb.deleteSprite();\r\n      clkb.unloadFont();\r\n      \r\n      if(currentIndex>=5)\r\n        currentIndex = 0;  //回第一个\r\n      else\r\n        currentIndex += 1;  //准备切换到下一个        \r\n    }\r\n    prevTime = 1;\r\n  }\r\n}\r\n/*\r\nvoid imgAnim()\r\n{\r\n  int x=160,y=160,dt=43;\r\n\r\n  TJpgDec.drawJpg(x,y,i0, sizeof(i0));\r\n  delay(dt);\r\n  TJpgDec.drawJpg(x,y,i1, sizeof(i1));\r\n  delay(dt);\r\n  TJpgDec.drawJpg(x,y,i2, sizeof(i2));\r\n  delay(dt);\r\n  TJpgDec.drawJpg(x,y,i3, sizeof(i3));\r\n  delay(dt);  \r\n  TJpgDec.drawJpg(x,y,i4, sizeof(i4));\r\n  delay(dt);  \r\n  TJpgDec.drawJpg(x,y,i5, sizeof(i5));\r\n  delay(dt);  \r\n  TJpgDec.drawJpg(x,y,i6, sizeof(i6));\r\n  delay(dt);  \r\n  TJpgDec.drawJpg(x,y,i7, sizeof(i7));\r\n  delay(dt);  \r\n  TJpgDec.drawJpg(x,y,i8, sizeof(i8));\r\n  delay(dt);  \r\n  TJpgDec.drawJpg(x,y,i9, sizeof(i9));\r\n  delay(dt);  \r\n}\r\n*/\r\n\r\n\r\nvoid imgAnim()\r\n{\r\n  int x=160,y=160;\r\n  if(millis() - AprevTime > 37) //x ms切换一次\r\n  {\r\n    Anim++;\r\n    AprevTime = millis();\r\n  }\r\n  if(Anim==10)\r\n    Anim=0;\r\n\r\n  switch(Anim)\r\n  {\r\n    case 0:\r\n      TJpgDec.drawJpg(x,y,i0, sizeof(i0));\r\n      break;\r\n    case 1:\r\n      TJpgDec.drawJpg(x,y,i1, sizeof(i1));\r\n      break;\r\n    case 2:\r\n      TJpgDec.drawJpg(x,y,i2, sizeof(i2));\r\n      break;\r\n    case 3:\r\n      TJpgDec.drawJpg(x,y,i3, sizeof(i3));\r\n      break;\r\n    case 4:\r\n      TJpgDec.drawJpg(x,y,i4, sizeof(i4));\r\n      break;\r\n    case 5:\r\n      TJpgDec.drawJpg(x,y,i5, sizeof(i5));\r\n      break;\r\n    case 6:\r\n      TJpgDec.drawJpg(x,y,i6, sizeof(i6));\r\n      break;\r\n    case 7:\r\n      TJpgDec.drawJpg(x,y,i7, sizeof(i7));\r\n      break;\r\n    case 8: \r\n      TJpgDec.drawJpg(x,y,i8, sizeof(i8));\r\n      break;\r\n    case 9: \r\n      TJpgDec.drawJpg(x,y,i9, sizeof(i9));\r\n      break;\r\n    default:\r\n      Serial.println(\"显示Anim错误\");\r\n      break;\r\n  }\r\n}\r\n\r\nunsigned char Hour_sign   = 60;\r\nunsigned char Minute_sign = 60;\r\nunsigned char Second_sign = 60;\r\nvoid digitalClockDisplay()\r\n{ \r\n  int timey=82;\r\n  if(hour()!=Hour_sign)//时钟刷新\r\n  {\r\n    dig.printfW3660(20,timey,hour()/10);\r\n    dig.printfW3660(60,timey,hour()%10);\r\n    Hour_sign = hour();\r\n  }\r\n  if(minute()!=Minute_sign)//分钟刷新\r\n  {\r\n    dig.printfO3660(101,timey,minute()/10);\r\n    dig.printfO3660(141,timey,minute()%10);\r\n    Minute_sign = minute();\r\n  }\r\n  if(second()!=Second_sign)//分钟刷新\r\n  {\r\n    dig.printfW1830(182,timey+30,second()/10);\r\n    dig.printfW1830(202,timey+30,second()%10);\r\n    Second_sign = second();\r\n  }\r\n  \r\n  /***日期****/\r\n  clk.setColorDepth(8);\r\n  clk.loadFont(ZdyLwFont_20);\r\n  \r\n  //星期\r\n  clk.createSprite(58, 30);\r\n  clk.fillSprite(bgColor);\r\n  clk.setTextDatum(CC_DATUM);\r\n  clk.setTextColor(TFT_WHITE, bgColor);\r\n  clk.drawString(week(),29,16);\r\n  clk.pushSprite(102,150);\r\n  clk.deleteSprite();\r\n  \r\n  //月日\r\n  clk.createSprite(95, 30);\r\n  clk.fillSprite(bgColor);\r\n  clk.setTextDatum(CC_DATUM);\r\n  clk.setTextColor(TFT_WHITE, bgColor);  \r\n  clk.drawString(monthDay(),49,16);\r\n  clk.pushSprite(5,150);\r\n  clk.deleteSprite();\r\n  \r\n  clk.unloadFont();\r\n  /***日期****/\r\n}\r\n\r\n//星期\r\nString week()\r\n{\r\n  String wk[7] = {\"日\",\"一\",\"二\",\"三\",\"四\",\"五\",\"六\"};\r\n  String s = \"周\" + wk[weekday()-1];\r\n  return s;\r\n}\r\n\r\n//月日\r\nString monthDay()\r\n{\r\n  String s = String(month());\r\n  s = s + \"月\" + day() + \"日\";\r\n  return s;\r\n}\r\n\r\n/*-------- NTP code ----------*/\r\n\r\nconst int NTP_PACKET_SIZE = 48; // NTP时间在消息的前48字节中\r\nbyte packetBuffer[NTP_PACKET_SIZE]; //buffer to hold incoming & outgoing packets\r\n\r\ntime_t getNtpTime()\r\n{\r\n  IPAddress ntpServerIP; // NTP server's ip address\r\n\r\n  while (Udp.parsePacket() > 0) ; // discard any previously received packets\r\n  //Serial.println(\"Transmit NTP Request\");\r\n  // get a random server from the pool\r\n  WiFi.hostByName(ntpServerName, ntpServerIP);\r\n  //Serial.print(ntpServerName);\r\n  //Serial.print(\": \");\r\n  //Serial.println(ntpServerIP);\r\n  sendNTPpacket(ntpServerIP);\r\n  uint32_t beginWait = millis();\r\n  while (millis() - beginWait < 1500) {\r\n    int size = Udp.parsePacket();\r\n    if (size >= NTP_PACKET_SIZE) {\r\n      Serial.println(\"Receive NTP Response\");\r\n      Udp.read(packetBuffer, NTP_PACKET_SIZE);  // read packet into the buffer\r\n      unsigned long secsSince1900;\r\n      // convert four bytes starting at location 40 to a long integer\r\n      secsSince1900 =  (unsigned long)packetBuffer[40] << 24;\r\n      secsSince1900 |= (unsigned long)packetBuffer[41] << 16;\r\n      secsSince1900 |= (unsigned long)packetBuffer[42] << 8;\r\n      secsSince1900 |= (unsigned long)packetBuffer[43];\r\n      //Serial.println(secsSince1900 - 2208988800UL + timeZone * SECS_PER_HOUR);\r\n      return secsSince1900 - 2208988800UL + timeZone * SECS_PER_HOUR;\r\n    }\r\n  }\r\n  Serial.println(\"No NTP Response :-(\");\r\n  return 0; // 无法获取时间时返回0\r\n}\r\n\r\n// 向NTP服务器发送请求\r\nvoid sendNTPpacket(IPAddress &address)\r\n{\r\n  // set all bytes in the buffer to 0\r\n  memset(packetBuffer, 0, NTP_PACKET_SIZE);\r\n  // Initialize values needed to form NTP request\r\n  // (see URL above for details on the packets)\r\n  packetBuffer[0] = 0b11100011;   // LI, Version, Mode\r\n  packetBuffer[1] = 0;     // Stratum, or type of clock\r\n  packetBuffer[2] = 6;     // Polling Interval\r\n  packetBuffer[3] = 0xEC;  // Peer Clock Precision\r\n  // 8 bytes of zero for Root Delay & Root Dispersion\r\n  packetBuffer[12] = 49;\r\n  packetBuffer[13] = 0x4E;\r\n  packetBuffer[14] = 49;\r\n  packetBuffer[15] = 52;\r\n  // all NTP fields have been given values, now\r\n  // you can send a packet requesting a timestamp:\r\n  Udp.beginPacket(address, 123); //NTP requests are to port 123\r\n  Udp.write(packetBuffer, NTP_PACKET_SIZE);\r\n  Udp.endPacket();\r\n}\r\n"}}}






Started logging.

<<<
Content-Length: 3422

{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":18364,"clientInfo":{"name":"vscode","version":"1.50.0"},"rootPath":"e:\\晶彩\\开发资料\\ESP32模块\\ESP32-2432S028例子\\arduino\\Source code\\4_11_SmallDesktopDisplay\\SmallDesktopDisplay","rootUri":"file:///e%3A/%E6%99%B6%E5%BD%A9/%E5%BC%80%E5%8F%91%E8%B5%84%E6%96%99/ESP32%E6%A8%A1%E5%9D%97/ESP32-2432S028%E4%BE%8B%E5%AD%90/arduino/Source%20code/4_11_SmallDesktopDisplay/SmallDesktopDisplay","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional"},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"versionSupport":false,"tagSupport":{"valueSet":[1,2]}},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}},"contextSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"declaration":{"dynamicRegistration":true,"linkSupport":true},"selectionRange":{"dynamicRegistration":true}},"window":{"workDoneProgress":true}},"initializationOptions":{},"trace":"off","workspaceFolders":[{"uri":"file:///e%3A/%E6%99%B6%E5%BD%A9/%E5%BC%80%E5%8F%91%E8%B5%84%E6%96%99/ESP32%E6%A8%A1%E5%9D%97/ESP32-2432S028%E4%BE%8B%E5%AD%90/arduino/Source%20code/4_11_SmallDesktopDisplay/SmallDesktopDisplay","name":"SmallDesktopDisplay"}]}}
>>>
Content-Length: 598

{"id":0,"result":{"capabilities":{"textDocumentSync":2,"hoverProvider":true,"completionProvider":{"triggerCharacters":[".","\u003e",":"]},"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"workspaceSymbolProvider":true,"codeActionProvider":true,"documentFormattingProvider":true,"documentRangeFormattingProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"\n"},"renameProvider":false,"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]}}},"jsonrpc":"2.0"}
<<<
Content-Length: 52

{"jsonrpc":"2.0","method":"initialized","params":{}}Content-Length: 1305

{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///e%3A/%E6%99%B6%E5%BD%A9/%E5%BC%80%E5%8F%91%E8%B5%84%E6%96%99/ESP32%E6%A8%A1%E5%9D%97/ESP32-2432S028%E4%BE%8B%E5%AD%90/arduino/Source%20code/4_11_SmallDesktopDisplay/SmallDesktopDisplay/weathernum.h","languageId":"cpp","version":1,"text":"#ifndef WEATHERNUM_H\r\n#define WEATHERNUM_H\r\n\r\n#include <TFT_eSPI.h> \r\n\r\n#include \"img/tianqi/t0.h\"\r\n#include \"img/tianqi/t1.h\"\r\n#include \"img/tianqi/t2.h\"\r\n#include \"img/tianqi/t3.h\"\r\n#include \"img/tianqi/t4.h\"\r\n#include \"img/tianqi/t5.h\"\r\n#include \"img/tianqi/t6.h\"\r\n#include \"img/tianqi/t7.h\"\r\n#include \"img/tianqi/t9.h\"\r\n#include \"img/tianqi/t11.h\"\r\n#include \"img/tianqi/t13.h\"\r\n#include \"img/tianqi/t14.h\"\r\n#include \"img/tianqi/t15.h\"\r\n#include \"img/tianqi/t16.h\"\r\n#include \"img/tianqi/t18.h\"\r\n#include \"img/tianqi/t19.h\"\r\n#include \"img/tianqi/t20.h\"\r\n#include \"img/tianqi/t26.h\"\r\n#include \"img/tianqi/t29.h\"\r\n#include \"img/tianqi/t30.h\"\r\n#include \"img/tianqi/t31.h\"\r\n#include \"img/tianqi/t53.h\"\r\n#include \"img/tianqi/t99.h\"\r\n\r\n\r\nclass WeatherNum\r\n{\r\nprivate:\r\n\r\n\r\npublic:\r\n  void printfweather(int numx,int numy,int numw);\r\n};\r\n\r\n\r\n#endif\r\n"}}}Content-Length: 2683

{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///e%3A/%E6%99%B6%E5%BD%A9/%E5%BC%80%E5%8F%91%E8%B5%84%E6%96%99/ESP32%E6%A8%A1%E5%9D%97/ESP32-2432S028%E4%BE%8B%E5%AD%90/arduino/Source%20code/4_11_SmallDesktopDisplay/SmallDesktopDisplay/weathernum.cpp","languageId":"cpp","version":1,"text":"#include \"weathernum.h\"\r\n\r\n#include <TJpg_Decoder.h>\r\n//int numx;\r\n//int numy;\r\n//int numw;\r\n\r\n//显示天气图标\r\nvoid WeatherNum::printfweather(int numx,int numy,int numw)\r\n{\r\n  if(numw==00)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t0, sizeof(t0));\r\n  }\r\n  else if(numw==01)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t1, sizeof(t1));\r\n  }\r\n  else if(numw==02)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t2, sizeof(t2));\r\n  }\r\n  else if(numw==03)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t3, sizeof(t3));\r\n  }\r\n  else if(numw==04)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t4, sizeof(t4));\r\n  }\r\n  else if(numw==05)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t5, sizeof(t5));\r\n  }\r\n  else if(numw==06)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t6, sizeof(t6));\r\n  }\r\n  else if(numw==07||numw==8||numw==21||numw==22)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t7, sizeof(t7));\r\n  }\r\n  else if(numw==9||numw==10||numw==23||numw==24)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t9, sizeof(t9));\r\n  }\r\n  else if(numw==11||numw==12||numw==25||numw==301)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t11, sizeof(t11));\r\n  }\r\n  else if(numw==13)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t13, sizeof(t13));\r\n  }\r\n  else if(numw==14||numw==26)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t14, sizeof(t14));\r\n  }\r\n  else if(numw==15||numw==27)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t15, sizeof(t15));\r\n  }\r\n  else if(numw==16||numw==17||numw==28||numw==302)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t16, sizeof(t16));\r\n  }\r\n  else if(numw==18)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t18, sizeof(t18));\r\n  }\r\n  else if(numw==19)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t19, sizeof(t19));\r\n  }\r\n  else if(numw==20)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t20, sizeof(t20));\r\n  }\r\n  else if(numw==29)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t29, sizeof(t29));\r\n  }\r\n  else if(numw==30)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t30, sizeof(t30));\r\n  }\r\n  else if(numw==31)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t31, sizeof(t31));\r\n  }\r\n  else if(numw==53||numw==32||numw==49||numw==54||numw==55||numw==56||numw==57||numw==58)\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t53, sizeof(t53));\r\n  }\r\n  else\r\n  {\r\n    TJpgDec.drawJpg(numx,numy,t99, sizeof(t99));\r\n  }\r\n\r\n  \r\n}\r\n"}}}Content-