"""test.py: Tests the functionality of tft_printer, SensorsInterface and NetworkingTools""" import time import tft_printer import SensorsInterface import PiTools import CloudTools __author__ = "Dylan Kauling" __maintainer__ = "Dylan Kauling" __status__ = "Development" SensorsInterface.setupSensorian() # Prepare the sensors on the Sensorian Shield SensorsInterface.ledOn() # Turn on the Sensorian Orange LED # Print White Hello World to the display in Portrait mode tft_printer.screen_print_rotated("Hello world!", 0) time.sleep(2) # Wait for 2 seconds before continuing. # Print a longer black string on a white background to the display in Landscape mode tft_printer.screen_print_rotated("This is a longer string to demonstrate the wrapping and text background", 1, colour=(0, 0, 0, 0), background=(255, 255, 255)) time.sleep(2) # Wait for 2 seconds before continuing. sensor_string = "" # Prepare an empty string to be printed to the screen sensor_string += " Light: " + str(SensorsInterface.getAmbientLight()) # Add the light value to the string
"""test.py: Tests the functionality of tft_printer, SensorsInterface and NetworkingTools""" import time import tft_printer import SensorsInterface import PiTools import CloudTools __author__ = "Dylan Kauling" __maintainer__ = "Dylan Kauling" __status__ = "Development" SensorsInterface.setupSensorian( ) # Prepare the sensors on the Sensorian Shield SensorsInterface.ledOn() # Turn on the Sensorian Orange LED # Print White Hello World to the display in Portrait mode tft_printer.screen_print_rotated("Hello world!", 0) time.sleep(2) # Wait for 2 seconds before continuing. # Print a longer black string on a white background to the display in Landscape mode tft_printer.screen_print_rotated( "This is a longer string to demonstrate the wrapping and text background", 1, colour=(0, 0, 0, 0), background=(255, 255, 255)) time.sleep(2) # Wait for 2 seconds before continuing.
def output_handler(pin, value): # Sensorian-led if pin == 0: if value == "1": SensorsInterface.ledOn() else: SensorsInterface.ledOff() # Sensorian-tft elif pin == 1: print "update sensorian-tft was called" # Check TFT availablity print "waiting for TFT_available_lock" TFT_available_lock.acquire() print "acquired TFT_available_lock" availability = TFT_available TFT_available_lock.release() print "released TFT_available_lock" if availability == False: print "dropping TFT write." return print "waiting for TFT_orientation_lock" TFT_orientation_lock.acquire() print "acquired TFT_orientation_lock" orientation = TFT_orientation # orientation = 1 TFT_orientation_lock.release() print "released TFT_orientation_lock" print "Writing to tft" # tft_printer.screen_print(str(value)) print "Trying to acquire TFT_Lock" TFT_Lock.acquire() print "Acquired TFT_Lock" my_tft_writer = TFT_Thread(value, orientation) my_tft_writer.start() print "End of output handler" # Sensorian-rtcc.time elif pin == 2: try: # Extract the time time = str(value).split(",") year = int(time[0]) month = int(time[1]) date = int(time[2]) hour = int(time[3]) minute = int(time[4]) second = int(time[5]) # Set the time SensorsInterface.setRTCCtime(year, month, date, hour, minute, second) print "Time has been set" except: print "Error setting the time" # Sensorian-rtcc.alarmtime elif pin == 3: try: # Extract the time and alarm mode time = str(value).split(",") year = int(time[0]) month = int(time[1]) date = int(time[2]) hour = int(time[3]) minute = int(time[4]) second = int(time[5]) mode = int(time[6]) # Set the alarm SensorsInterface.setRTCCalarm(year, month, date, hour, minute, second, mode) print "Alarm time has been set" except: print "Error setting the alarm" # Sensorian-rtcc.resetalarm elif pin == 4: SensorsInterface.resetRTCCalarm()
def output_handler(pin, value): #Sensorian-led if pin == 0: if value == "1": SensorsInterface.ledOn() else: SensorsInterface.ledOff() #Sensorian-tft elif pin == 1: print "update sensorian-tft was called" #Check TFT availablity print "waiting for TFT_available_lock" TFT_available_lock.acquire() print "acquired TFT_available_lock" availability = TFT_available TFT_available_lock.release() print "released TFT_available_lock" if availability == False: print "dropping TFT write." return print "waiting for TFT_orientation_lock" TFT_orientation_lock.acquire() print "acquired TFT_orientation_lock" orientation = TFT_orientation #orientation = 1 TFT_orientation_lock.release() print "released TFT_orientation_lock" print "Writing to tft" #tft_printer.screen_print(str(value)) print "Trying to acquire TFT_Lock" TFT_Lock.acquire() print "Acquired TFT_Lock" my_tft_writer = TFT_Thread(value, orientation) my_tft_writer.start() print "End of output handler" #Sensorian-rtcc.time elif pin == 2: try: #Extract the time time = str(value).split(",") year = int(time[0]) month = int(time[1]) date = int(time[2]) hour = int(time[3]) minute = int(time[4]) second = int(time[5]) #Set the time SensorsInterface.setRTCCtime(year, month, date, hour, minute, second) print "Time has been set" except: print "Error setting the time" #Sensorian-rtcc.alarmtime elif pin == 3: try: #Extract the time and alarm mode time = str(value).split(",") year = int(time[0]) month = int(time[1]) date = int(time[2]) hour = int(time[3]) minute = int(time[4]) second = int(time[5]) mode = int(time[6]) #Set the alarm SensorsInterface.setRTCCalarm(year, month, date, hour, minute, second, mode) print "Alarm time has been set" except: print "Error setting the alarm" #Sensorian-rtcc.resetalarm elif pin == 4: SensorsInterface.resetRTCCalarm()