def DisplayWeather(): while 1 == 1: #Draw Background lcd.fill(GREY) #Set Icon if carbondale['current_conditions']['icon'] == 24 : iconimg = pygame.image.load('wind.png') elif carbondale['current_conditions']['icon'] == 14 : iconimg = pygame.image.load('snow.png') elif int(carbondale['current_conditions']['icon']) > 24 and int(carbondale['current_conditions']['icon']) < 32 : iconimg = pygame.image.load('cloudy.png') elif int(carbondale['current_conditions']['icon']) > 31 and int(carbondale['current_conditions']['icon']) < 35 : iconimg = pygame.image.load('clear-day.png') elif int(carbondale['current_conditions']['icon']) > 35 and int(carbondale['current_conditions']['icon']) < 41 : iconimg = pygame.image.load('rain.png') else : iconimg = pygame.image.load('unknown.png') #Draw Icon lcd.blit(iconimg, (16,16)) #Grab Variables day = carbondale['forecasts'][0]['date'][4:] temperature = str(int((float(carbondale['current_conditions']['temperature'])*1.8)+32)) dayofweek = carbondale['forecasts'][0]['day_of_week'] text = carbondale['current_conditions']['text'][:7] chanceprecip = carbondale['forecasts'][0]['day']['chance_precip'] high = str(int((float(carbondale['forecasts'][0]['high'])*1.8)+32)) low = str(int((float(carbondale['forecasts'][0]['low'])*1.8)+32)) #Write Temperature fontimg = bigFont.render(temperature + "F",1,WHITE) lcd.blit(fontimg, (145,38)) #Write Day fontimg = mediumFont.render(dayofweek + " " + day,1,WHITE) lcd.blit(fontimg, (135,6)) #Write Forecast fontimg = smallFont.render(text,1,WHITE) lcd.blit(fontimg, (23,118)) #Write Chance of Rain fontimg = chanceFont.render("CoR: " + chanceprecip + "%",1,WHITE) lcd.blit(fontimg, (15,210)) #Write High Temp fontimg = smallFont.render("Hi: " + high,1,WHITE) lcd.blit(fontimg, (141,117)) #Write Low Temp fontimg = smallFont.render("Lo: " + low,1,WHITE) lcd.blit(fontimg, (225,117)) pygame.display.update() if GPIO.input(k) == False: if k == 17: MainMenu.MenuButtons()
import pygame import os import time import DisplayImage import MainMenu os.putenv('SDL_FBDEV', '/dev/fb1') pygame.init() pygame.mouse.set_visible(False) DisplayImage.LoadingScreen(0) MainMenu.DrawMenu() MainMenu.MenuButtons()
def DisplayTime(): #Color Palette WHITE = (255, 255, 255) GREY = (54, 54, 54) BLACK = (0, 0, 0) #Clear Screen lcd.fill(GREY) pygame.display.update() #Set Clock Font font = pygame.font.Font('Quicksand-Bold.otf', 63) #Load Clock Background bg = item("WatchBkg.jpg", 0, 0, 0) bg.setaxis((bg.width / 2, 86)) #Load Hand Images longhand = item("minute-hand.bmp", -1, 90, 23) shorthand = item("hour-hand.bmp", -1, 90, 40) secondhand = item("second-hand.bmp", -1, 90, 23) showingClock = 1 #Displays the Clock while showingClock == 1: #Time Variables dt = str(datetime.datetime.today()) hr = float(dt[11:13]) min = float(dt[14:16]) sec = float(dt[17:19]) time = dt[11:19] #Redraw Background bg.draw() #Calculate Angles For Times second = -360.0 / 60 * sec + 1 minute = -360.0 / 60 * min + 1 hour = hr % 12 hour1 = -360.0 / 12 * hour + 1 #Calculate Rotation offset = 360.0 / 12 / 60 * min hour = hour1 - offset #Draw The Hands longhand.drawrot(bg.axis, minute) shorthand.drawrot(bg.axis, hour) secondhand.drawrot(bg.axis, second) #Font Border fontimg = font.render(time, 1, BLACK) lcd.blit(fontimg, (36, 165)) fontimg = font.render(time, 1, BLACK) lcd.blit(fontimg, (44, 165)) fontimg = font.render(time, 1, BLACK) lcd.blit(fontimg, (40, 161)) fontimg = font.render(time, 1, BLACK) lcd.blit(fontimg, (40, 169)) fontimg = font.render(time, 1, BLACK) lcd.blit(fontimg, (38, 163)) fontimg = font.render(time, 1, BLACK) lcd.blit(fontimg, (42, 167)) fontimg = font.render(time, 1, BLACK) lcd.blit(fontimg, (42, 163)) fontimg = font.render(time, 1, BLACK) lcd.blit(fontimg, (38, 167)) #Actual Font fontimg = font.render(time, 1, WHITE) lcd.blit(fontimg, (40, 165)) pygame.display.update() if GPIO.input(k) == False: if k == 17: MainMenu.MenuButtons() pygame.time.delay(500)