def __init__(
        self,
        imu_settings_file = 'RTIMULib',
        text_assets = 'sense_hat_text',
        sample_rate = 0.01):

        self.sample_rate = sample_rate
        
        AstroPi.__init__(self, imu_settings_file, text_assets)

        self._orientation = AstroPi.get_orientation(self)

        #start the orientation thread
        thread.start_new_thread(self._get_orientation_threaded, ())
 def _get_orientation_threaded(self):
     """
     Internal. called in a thread to continuously read the astro pi data
     """
     self.stopped = False
     self.running = True
     while(not self.stopped):
         self._orientation = AstroPi.get_orientation(self)
         sleep(self.sample_rate)
     self.running = False
Example #3
0
 def __init__(self):
     # Picamera object and horizontally flips it
     self.camera = picamera.PiCamera()
     self.camera.hflip = True
     self.camera.annotate_background = picamera.Color('black')
     self.camera.iso = 800
     self.astroPi = AstroPi()
     
     
     self.folder = "./Data"
     
     if not os.path.exists(self.folder):
         os.makedirs(self.folder)
        """
        Clears the mc astro pi
        """
        self.ap.clear()
        self.mcastropi.clear()

#run
if __name__ == "__main__":

    print("SpaceCRAFT - Minecraft Interactive Astro Pi")

    #create connection to minecraft
    mc = Minecraft.create()

    #create the astro pi object
    ap = AstroPi()
    #read data from the astro pi to initialise it
    ap.get_orientation()
    ap.get_humidity()
    ap.get_pressure()

    #find the players position and create the astro pi 10 blocks above them
    pos = mc.player.getTilePos()
    pos.y += 10
    mcap = MCInteractiveAstroPi(mc, ap, pos)

    try:
        print("CTRL C to quit")
        while(True):
            #each time a block is hit pass it to the interactive astro pi
            for blockHit in mc.events.pollBlockHits():
Example #5
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
Example #6
0
        Clears the mc astro pi
        """
        self.ap.clear()
        self.mcastropi.clear()


#run
if __name__ == "__main__":

    print("SpaceCRAFT - Minecraft Interactive Astro Pi")

    #create connection to minecraft
    mc = Minecraft.create()

    #create the astro pi object
    ap = AstroPi()
    #read data from the astro pi to initialise it
    ap.get_orientation()
    ap.get_humidity()
    ap.get_pressure()

    #find the players position and create the astro pi 10 blocks above them
    pos = mc.player.getTilePos()
    pos.y += 10
    mcap = MCInteractiveAstroPi(mc, ap, pos)

    try:
        print("CTRL C to quit")
        while (True):
            #each time a block is hit pass it to the interactive astro pi
            for blockHit in mc.events.pollBlockHits():
Example #7
0
###ENSURE THAT TIME IS CORRECTLY SET###
###USE UP TO DAY TLE FILE###
#Python2.79##

from random import randint
from sense_hat import AstroPi
import ephem
import datetime
import time
## [...]
ap = AstroPi()

name = "ISS (ZARYA)";            
#line1 = "1 25544U 98067A   15178.42973832  .00011523  00000-0  17276-3 0  9998"
#line2 = "2 25544  51.6456  32.8760 0003760  98.7829 323.8559 15.55421066949635"

line1 = "1 25544U 98067A   17236.92892593  .00001941  00000-0  36498-4 0  9995"
line2 = "2 25544  51.6393  55.6371 0005064 174.4795 337.0202 15.54195457 72448"

def countdown():
    for i in reversed(range(0, 6)):
        ap.show_letter(str(i))
        time.sleep(1)

countdown()        
ap.clear()
while True:
    temp = str(ap.get_temperature())
    pressure =  str(ap.get_pressure())
    orientation =  ap.get_orientation_degrees()
Example #8
0
#!/usr/bin/env python
from sense_hat import AstroPi
import time
import datetime
from pygame.locals import *
import requests

ap = AstroPi()

humid = int(ap.get_humidity())

print humid
Example #9
0
File: show.py Project: Xrle/piRay
from sense_hat import AstroPi
import time
ap = AstroPi()


def draw(rate, subtracted):
    ap.show_message(str(rate), scroll_speed=1,
                    text_colour=[255, 0, 0])  # red for count rate
    ap.show_message(str(subtracted), scroll_speed=1,
                    text_colour=[0, 0, 255])  #blue for faulty/noisy pixels


def calibrateMessage():
    ap.show_letter("C")


def running():
    ap.show_letter("R")


def detected():
    ap.show_letter("D")
#!/usr/bin/python
import pygame

from pygame.locals import *
from sense_hat import AstroPi

pygame.init()
pygame.display.set_mode((640,480))
ap = AstroPi()

import sys

ap.show_message ("Game 1",text_colour=[255,0,50])
from random import *

y = [randint(1, 6), randint(1, 6), randint(1, 6)]
print(y)

import time

ap.show_letter (str(y[0]),text_colour=[255,0,0])
time.sleep(1)
ap.clear()
ap.show_letter (str(y[1]),text_colour=[255,0,0])
time.sleep(1)
ap.clear()
ap.show_letter (str(y[2]),text_colour=[255,0,0])
time.sleep(1)

ap.clear()
time.sleep(3)
#columns in text file
dayColumn = 1 #the column number of the day column
tempColumn = 2 #the column number of the temperature column
rainColumn = 6 #the column number of the rainfall column
cloudColumn = 4 #the column number of the cloud cover column


#Arrays to read data into
dayArr = [] #the array to put the days into
avTempArr = [] #the array to put the temperatures into
avRainArr = [] #the array to put the rainfall data into
avCloudArr = [] #the array to put the cloud cover data into


#initiate AstroPi
ap = AstroPi()


#filenames
iconFileName = ""
sunPng= "sun.png" #this is the sunny weather icon
cloudPng = "cloud.png" #this is the cloudy weather icon
sunCloudPng = "sunncloud.png" #this is the sunny/cloudy weather icon
lightRainPng = "light rain.png" #this is the light rain weather icon
heavyRainPng = "heavy rain.png" #this is the heavy rain weather icon
pngPath = "./" #this is the path to the icons relative to this script


#weather range values
valueSun = 3 #less than 3 hours cloud therefore sunny
valueCloudSun = 5 #between valueSun and valueCloudSun then cloudy/sunny
Example #12
0
import time
import picamera
from sense_hat import AstroPi
from PIL import Image
import os

# Picamera object and horizontally flips it
camera = picamera.PiCamera()
camera.hflip = True
# Length of experiment in minutes - 6 days
lengthMins = 8640
# Length in secs between taking pictures, taking into account ~2 secs for loop to run
sleepSecs = 28
# Reference to astropi
ap = AstroPi()


# Function to check if image taken is mostly black, returns true if mostly black
def checkBlack(directory):
    im = Image.open(directory)
    # Splits image into pixels
    pixels = im.getdata()
    # RGB threshold at which pixel is defined as 'black'
    blackThresh = 15
    # Number of black pixels in image
    nblack = 0
    # Cycles through pixels, counting number of 'black' pixels
    for pixel in pixels:
        if sum(pixel) < blackThresh:
            nblack += 1
Example #13
0
import time
import picamera
from sense_hat import AstroPi
from PIL import Image
import os

# Picamera object and horizontally flips it
camera = picamera.PiCamera()
camera.hflip = True
# Length of experiment in minutes - 6 days
lengthMins = 8640
# Length in secs between taking pictures, taking into account ~2 secs for loop to run
sleepSecs = 28
# Reference to astropi
ap = AstroPi()

# Function to check if image taken is mostly black, returns true if mostly black
def checkBlack(directory):
    im = Image.open(directory)
    # Splits image into pixels
    pixels = im.getdata()
    # RGB threshold at which pixel is defined as 'black'
    blackThresh = 15
    # Number of black pixels in image
    nblack = 0
    # Cycles through pixels, counting number of 'black' pixels
    for pixel in pixels:
        if sum(pixel) < blackThresh:
            nblack +=1
    n = len(pixels)