from astro_pi import AstroPi ap = AstroPi() import time ap.show_letter("J") while True: x,y,z = ap.get_accelerometer_raw().values() x=round(x,0) y=round(y,0) if x == -1: ap.set_rotation(180) elif y == 1: ap.set_rotation(90) elif y == -1: ap.set_rotation(270) else: ap.set_rotation(0) time.sleep(0.1)
from astro_pi import AstroPi ap = AstroPi() import time while True: x,y,z = ap.get_accelerometer_raw().values() x=abs(x) y=abs(y) z=abs(z) if x > 1 or y > 1 or z>1: ap.show_letter("!",text_colour=[255,0,0]) else: ap.clear() time.sleep(0.1
from astro_pi import AstroPi import time import random ap = AstroPi() r = random.randint(0,255) ap.show_letter("O",text_colour=[r,0,0]) time.sleep(1) r = random.randint(0,255) ap.show_letter("M",text_colour=[0,0,r]) time.sleep(1) r = random.randint(0,255) ap.show_letter("G",text_colour=[0,r,0]) time.sleep(1) ap.show_letter("!",text_colour=[0,0,0],back_colour=[255,255,255]) time.sleep(1) ap.clear()
r = [0,255,0] # green if higher elif hum_int == hum_prev: r = [0,0,255] # blue if the same else: r = [0,255,255] # light blue if lower hum_prev = hum_int image=TDG.numToMatrix(hum_int,back_colour=[0,0,0],text_colour=r) ap.set_pixels(image) elif y == -1 and x != -1: # temp display if USB ports pointing upwards ap.set_rotation(180) if temp_int > temp_prev: # Is the latest reading higher than the last? r = [255,0,0] # red if higher elif temp_int == temp_prev: r = [255,128,0] # orange if the same else: r = [255,215,0] # yellow if lower temp_prev = temp_int # use numToMatrix to turn the number into a 64 item list suitable for the LED image=TDG.numToMatrix(temp_int,back_colour=[0,0,0],text_colour=r) ap.set_pixels(image) elif x == 0 and y == 0: # if the Pi is flat on its back ap.show_message("Recording", text_colour=[150,150,150],scroll_speed=0.03) else: ap.show_letter("?") # display a ? if at some other orientation time.sleep(dataDisplayInterval) sec_count+=1