예제 #1
0
#!/usr/bin/env python
from sense_hat import AstroPi
import time
import datetime
import pygame
from pygame.locals import *

ap = AstroPi()
ap.clear()

pygame.init()
pygame.display.set_mode((640, 480))

pressure = 'P: ' + str(int(ap.get_pressure()))
temp = 'T: ' + str(int(ap.get_temperature_from_pressure()))
humidity = 'H: ' + str(int(ap.get_humidity()))
blah = 'blah!'


def handle_event(event):
    if event.key == pygame.K_DOWN:
        ap.show_message(pressure)
    elif event.key == pygame.K_UP:
        ap.show_message(temp)
    elif event.key == pygame.K_LEFT:
        ap.show_message(humidity)
    elif event.key == pygame.K_RIGHT:
        ap.show_message(blah)


running = True
예제 #2
0
        ap.set_pixel(3, 3, 255, 0, 0)
        ap.set_pixel(4, 3, 255, 0, 0)
        ap.set_pixel(4, 4, 255, 0, 0)
        x += 1
        secondsPassed += sleepSecs
        print(time.time() - currentTime)
    # Displays completion message
    astroPi.show_message('Completed!')
    time.sleep(10)
    blue = (0, 0, 255)
    ap.clear(blue)


# Waits for user input (middle button on joystick) before starting and makes LED green
green = (0, 255, 0)
ap.clear(green)
# Prevens EOF error
try:
    input()
except EOFError:
    print('eof error')
ap.clear()

# 5 second countdown
ap.show_message('5')
time.sleep(1)
ap.show_message('4')
time.sleep(1)
ap.show_message('3')
time.sleep(1)
ap.show_message('2')
예제 #3
0
    if chosen == thisday: #if the date in the row matches the current month and day
        avTemp = round(float(avTempArr[find_match]),1)
        avRain = round(float(avRainArr[find_match]),1)
        avCloud = round(float(avCloudArr[find_match]), 1)
        break
    find_match = find_match + 1 #add one so it checks the next row 
    

#print temp data
tempDiff = round(StationTemp - avTemp,1)
ap.show_message("The likely UK temp is %sC" % avTemp)
if tempDiff < 0:
    ap.show_message("ISS is %sC colder" % tempDiff,text_colour=[0, 0, 255]) #display the difference in blue if ISS is colder
else:
    ap.show_message("ISS is %sC warmer" % tempDiff,text_colour=[255, 0, 0]) #display the difference in red if ISS is warmer
ap.clear()


#compare the values and set the icon 
if avRain < NoRain: #if there is no rain
    if avCloud < valueSun: #if it is sunny
        iconFileName = sunPng
    elif valueSun >= avCloudArr < valueCloudSun: #if it is cloudy
        iconFileName = cloudPng
    else:   #otherwise it is sunny/cloudy
        iconFileName = suncloudPng
elif avRain <= LightRain: #if there is light rain
    iconFileName = lightRainPng
else:       #otherwise it is heavy rain
    iconFileName = heavyRainPng
    
예제 #4
0
        ap.set_pixel(4, 3, 255, 0, 0)
        ap.set_pixel(4, 4, 255, 0, 0)
        x += 1
        secondsPassed += sleepSecs
        print(time.time() - currentTime)
    # Displays completion message
    astroPi.show_message('Completed!')
    time.sleep(10)
    blue = (0,0,255)
    ap.clear(blue)



# Waits for user input (middle button on joystick) before starting and makes LED green
green = (0,255,0)
ap.clear(green)
# Prevens EOF error
try:
    input()
except EOFError:
    print('eof error')
ap.clear()

# 5 second countdown
ap.show_message('5')
time.sleep(1)
ap.show_message('4')
time.sleep(1)
ap.show_message('3')
time.sleep(1)
ap.show_message('2')