#!/usr/bin/env python
import PySimpleGUI as sg
import datetime
import calendar
import forecastio

'''
    Example of a weather App, using:
    - DARKSKY
    - google maps coordinates
'''



##### CHANGE these settings to match your location... check Google Maps #####
MY_LOCATION_LAT = 35.0
MY_LOCATION_LON = -79.0

##### You need a free dark-sky key. You get 1000 calls a month for free #####
# *** INSERT YOUR DARKSKY KEY HERE **
DARKSKY_KEY = "INSERT YOUR DARKSKY KEY HERE!"


# Changes number of days in forecast
NUM_COLS = 5


class GUI():
    def __init__(self):
        self.api_key = DARKSKY_KEY
        self.lat = MY_LOCATION_LAT
        self.lng = MY_LOCATION_LON
        self.blink_count = 0

        sg.set_options(border_width=0, text_color='white',
                       background_color='black', text_element_background_color='black')

        # Create clock layout
        clock = [
            [sg.Text('', pad=((120, 0), 0)),
             sg.Image(data=ledblank[22:], key='-hour1-'),
             sg.Image(data=ledblank[22:], key='-hour2-'),
             sg.Image(data=ledblank[22:], key='-colon-'),
             sg.Image(data=ledblank[22:], key='-min1-'),
             sg.Image(data=ledblank[22:], key='-min2-')], ]

        # Create the weather columns layout
        weather_cols = []
        for i in range(NUM_COLS):
            weather_cols.append(
                [[sg.Text('', size=(4, 1), font='Any 20',
                    justification='center', key='-DAY-' + str(i)), ],
                 [sg.Image(data=w1[22:], background_color='black',
                           key='-icon-'+str(i), pad=((4, 0), 3)), ],
                 [sg.Text('--', size=(3, 1), justification='center',
                       font='Any 20', key='-high-' + str(i), pad=((10, 0), 3))],
                 [sg.Text('--', size=(3, 1), justification='center',
                    font='Any 20', key='-low-' + str(i), pad=((10, 0), 3))]])

        # Create the overall layout
        layout = [[sg.Col(clock, background_color='black')],
                  [sg.Col(weather_cols[x], background_color='black')
                   for x in range(NUM_COLS)],

                  [sg.Button('Exit', button_color=('black', 'black'),
                        image_data=orangeround[22:],
                        tooltip='close window', pad=((450, 0), (10, 0)))]]

        # Create the window 
        self.window = sg.Window('My new window', layout, finalize=True,
                                background_color='black', grab_anywhere=True,
                                use_default_focus=False, no_titlebar=True,
                                alpha_channel=.8)

        self.colon_elem = self.window['-colon-']
        self.hour1 = self.window['-hour1-']
        self.hour2 = self.window['-hour2-']
        self.min1 = self.window['-min1-']
        self.min2 = self.window['-min2-']

    def update_clock(self):
        # update the clock
        now = datetime.datetime.now()
        real_hour = now.hour - 12 if now.hour > 12 else now.hour
        hour1_digit = led_digits[real_hour // 10]
        self.hour1.update(data=hour1_digit[22:])
        self.hour2.update(data=led_digits[real_hour % 10][22:])
        self.min2.update(data=led_digits[int(now.minute) % 10][22:])
        self.min1.update(data=led_digits[int(now.minute) // 10][22:])
        # Blink the :
        if self.blink_count % 2:
            self.colon_elem.update(data=ledcolon[22:])
        else:
            self.colon_elem.update(data=ledblank[22:])
        self.blink_count += 1

    def update_weather(self):
        forecast = forecastio.load_forecast(self.api_key, self.lat, self.lng)
        daily = forecast.daily()
        today_weekday = datetime.datetime.today().weekday()

        max_temps = []
        min_temps = []
        daily_icons = []
        for daily_data in daily.data:
            daily_icons.append(daily_data.d['icon'])
            max_temps.append(int(daily_data.d['temperatureMax']))
            min_temps.append(int(daily_data.d['temperatureMin']))

        for i in range(NUM_COLS):
            day_element = self.window['-DAY-' + str(i)]
            max_element = self.window['-high-' + str(i)]
            min_element = self.window['-low-' + str(i)]
            icon_element = self.window['-icon-' + str(i)]
            day_element.update(calendar.day_abbr[(today_weekday + i) % 7])
            max_element.update(max_temps[i])
            min_element.update(min_temps[i])
            icon_element.update(data=weather_icon_dict[daily_icons[i]][22:])


def led_clock():

    # Get the GUI object that is used to update the window
    gui = GUI()

    # ---------- EVENT LOOP ----------
    last_update_time = 0
    while True:
        # Wake up once a second to update the clock and weather
        event, values = gui.window.read(timeout=1000)
        if event in (sg.WIN_CLOSED, 'Exit'):
            break
        # update clock
        gui.update_clock()
        # update weather once ever 6 hours
        now = datetime.datetime.now()
        if last_update_time == 0 or (now-last_update_time).seconds >= 60*60*6:
            print('*** Updating Weather ***')
            last_update_time = now
            gui.update_weather()


led0 = 'data:image/png;base64,iVBOR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lyUFhelpUpR5oo+1xFYq3GVFd3Uo18Cd8CGuN+tgcem4VaErUjxFZtErYFr4ITY8K2AM2ILsy0JnDD36Pnk49a4mh49B2qtQUvX5zzZ8TdnVqVBR5jWD/x2C6Ko6av8UkwloQUuiImd32J64Bnb94TDqVNj5u7/9JYupUqnqtyQXZQWF6XFRWlxUVpclBYXpeUbS+1qOYf8HRgAAAAASUVORK5CYII='
ledblank = 'data:image/png;base64,[encoded data, 23696 characters]'
w1 = 'data:image/png;base64,[encoded data, 7120 characters]'
w2 = 'data:image/png;base64,[encoded data, 7188 characters]'
w3 = 'data:image/png;base64,[encoded data, 6940 characters]'
w4 = 'data:image/png;base64,[encoded data, 7176 characters]'
w5 = 'data:image/png;base64,[encoded data, 6572 characters]'
orangeround = 'data:image/png;base64,[encoded data, 5332 characters]'
weather_icon_dict = {'clear-day': w1, 'clear-night': w1, 'rain': w3, 'snow': w3, 'sleet': w3, 'wind': w3, 'fog': w3,
                     'cloudy': w4, 'partly-cloudy-day': w5, 'partly-cloudy-night': w5}
led_digits = [led0, led1, led2, led3, led4, led5, led6, led7, led8, led9]
if __name__ == '__main__':
    led_clock()
