• 大小: 910KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-19
  • 语言: 其他
  • 标签: esp8266  esp32  天气  

资源简介

esp8266自动获取天气及时钟在oled显示。。

资源截图

代码片段和文件信息

import json

class GDJson():

    def __init__(self):

        pass

    def jsonParse(selfdata):

        return json.loads(data)

    def parseHeWeather(selfdata):
        jsonData = self.jsonParse(data)
        base = jsonData[‘HeWeather5‘][0]
        daily_forecast = base[‘daily_forecast‘]
        now = base[‘now‘]
        suggestion = base[‘suggestion‘]


        return {
            “value“: {
                ‘tody‘:{
                    ‘status‘:int(daily_forecast[0][‘cond‘][‘code_d‘])
                    ‘date‘:daily_forecast[0][‘date‘]
                    ‘now‘:now[‘tmp‘] + ‘C‘
                    ‘range‘: self.range(daily_forecast[0][‘tmp‘][‘max‘]daily_forecast[0][‘tmp‘][‘min‘])
                    ‘s‘:daily_forecast[0][‘cond‘][‘txt_d‘]
                }
                ‘tom‘: {
                    ‘status‘:int(daily_forecast[1][‘cond‘][‘code_d‘])
                    ‘date‘: daily_forecast[1][‘date‘]
                    ‘range‘: self.range(daily_forecast[1][‘tmp‘][‘max‘]daily_forecast[1][‘tmp‘][‘min‘])
                    ‘s‘: daily_forecast[1][‘cond‘][‘txt_d‘]
                }
                ‘afterTom‘: {
                    ‘status‘: int(daily_forecast[1][‘cond‘][‘code_d‘])
                    ‘date‘: daily_forecast[2][‘date‘]
                    ‘range‘:self.range(daily_forecast[2][‘tmp‘][‘max‘]daily_forecast[2][‘tmp‘][‘min‘])
                    ‘s‘: daily_forecast[2][‘cond‘][‘txt_d‘]
                }
                ‘pm25‘:‘PM25: ‘ + base[‘aqi‘][‘city‘][‘pm25‘]
                ‘qlty‘: base[‘aqi‘][‘city‘][‘qlty‘] # 污染评价
                ‘city‘: base[‘basic‘][‘city‘]
                # ‘mes‘: suggestion[‘comf‘][‘brf‘] + ‘,‘ + suggestion[‘comf‘][‘txt‘]
            }
        }

    def range(selfmaxmin):
        if int(max) > 0:
            max = max + ‘ ‘

        if int(min) > 0:
            min = ‘ ‘ + min

        return  max + ‘|‘ + min + ‘C‘


    def parseQiushi(selfdata):
        jsonData = self.jsonParse(data)
        items = jsonData[‘items‘]
        m = 0
        num = 0
        # print (len(items))
        for index in range(len(items)):
            x = items[index][‘votes‘][‘up‘]
            if x > m:
                if len(items[num][‘content‘]) < 100:
                    print (len(items[num][‘content‘]))
                    m = x
                    num = index



        # print (items[num][‘content‘])
        return {
            “value“: [items[num][‘content‘]]
        }









 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-01-10 06:45  GDWeatherStation-ESP8266\
     目录           0  2019-01-10 06:45  GDWeatherStation-ESP8266\GDWeatherStation\
     文件        6552  2019-01-10 06:45  GDWeatherStation-ESP8266\GDWeatherStation\GDDraw.h
     文件       16869  2019-01-10 06:45  GDWeatherStation-ESP8266\GDWeatherStation\GDIcon.h
     文件        1108  2019-01-10 06:45  GDWeatherStation-ESP8266\GDWeatherStation\GDWeatherStation.ino
     文件        5519  2019-01-10 06:45  GDWeatherStation-ESP8266\GDWeatherStation\GDWifi.h
     文件        8083  2019-01-10 06:45  GDWeatherStation-ESP8266\README.md
     目录           0  2019-01-10 06:45  GDWeatherStation-ESP8266\Service\
     文件        2486  2019-01-10 06:45  GDWeatherStation-ESP8266\Service\GDParseJson.py
     文件         692  2019-01-10 06:45  GDWeatherStation-ESP8266\Service\GDUserData.py
     文件        4773  2019-01-10 06:45  GDWeatherStation-ESP8266\Service\GDWeatherJson.py
     文件         527  2019-01-10 06:45  GDWeatherStation-ESP8266\Service\Main.py
     文件        1981  2019-01-10 06:45  GDWeatherStation-ESP8266\Service\test.py
     文件         290  2019-01-10 06:45  GDWeatherStation-ESP8266\Service\urwidTest.py
     文件         276  2019-01-10 06:45  GDWeatherStation-ESP8266\Service\userData.json
     文件       13902  2019-01-10 06:45  GDWeatherStation-ESP8266\Service\userIcon.txt
     目录           0  2019-01-10 06:45  GDWeatherStation-ESP8266\UI_Design\
     文件     1941504  2019-01-10 06:45  GDWeatherStation-ESP8266\UI_Design\65 Weather Icons.sketch
     文件       67362  2019-01-10 06:45  GDWeatherStation-ESP8266\UI_Design\UI.sketch
     目录           0  2019-01-10 06:45  GDWeatherStation-ESP8266\UI_Design\icon\
     文件         382  2019-01-10 06:45  GDWeatherStation-ESP8266\UI_Design\icon\1136818.bmp
     文件         615  2019-01-10 06:45  GDWeatherStation-ESP8266\UI_Design\icon\1136818.png
     文件         102  2019-01-10 06:45  GDWeatherStation-ESP8266\UI_Design\icon\1136821.bmp
     文件         759  2019-01-10 06:45  GDWeatherStation-ESP8266\UI_Design\icon\1136821.png
     文件         382  2019-01-10 06:45  GDWeatherStation-ESP8266\UI_Design\icon\1136822.bmp
     文件         637  2019-01-10 06:45  GDWeatherStation-ESP8266\UI_Design\icon\1136822.png
     文件         102  2019-01-10 06:45  GDWeatherStation-ESP8266\UI_Design\icon\1136904.bmp
     文件         657  2019-01-10 06:45  GDWeatherStation-ESP8266\UI_Design\icon\1136904.png
     文件         382  2019-01-10 06:45  GDWeatherStation-ESP8266\UI_Design\icon\1137170.bmp
     文件         668  2019-01-10 06:45  GDWeatherStation-ESP8266\UI_Design\icon\1137170.png
     文件         382  2019-01-10 06:45  GDWeatherStation-ESP8266\UI_Design\icon\1137171.bmp
............此处省略64个文件信息

评论

共有 条评论