Python get wind speed and direction and display them on the clock

Task: Get wind speed and direction and display them on my clock's screen

Implementation:

...
        wind_direction = int(weather_json["wind"]["deg"])
        wind_direction_str = "*"
        if   wind_direction > 315-45/2 and wind_direction <= 315+45/2: wind_direction_str = "↘"
        elif wind_direction > 270-45/2 and wind_direction <= 270+45/2: wind_direction_str = "→"
        elif wind_direction > 225-45/2 and wind_direction <= 225+45/2: wind_direction_str = "↗"
        elif wind_direction > 180-45/2 and wind_direction <= 180+45/2: wind_direction_str = "↑"
        elif wind_direction > 135-45/2 and wind_direction <= 135+45/2: wind_direction_str = "↖"
        elif wind_direction >  90-45/2 and wind_direction <=  90+45/2: wind_direction_str = "←"
        elif wind_direction >  45-45/2 and wind_direction <=  45+45/2: wind_direction_str = "↙"
        elif wind_direction > 360-45/2  or wind_direction <=   0+45/2: wind_direction_str = "↓"

        # Current temperature
        text = "t" + str(int(weather_json["main"]["temp"])) + "/" + str(int(weather_json["main"]["feels_like"])) + "℃ " + str(int(weather_json["wind"]["speed"])) + wind_direction_str
...

Result you can see on this post image (third line at the end number and arrow).

Done.

Leave a Reply

Your email address will not be published. Required fields are marked *




Enter Captcha Here :