Exemple #1
0
sensor_string += " Time: " + str(SensorsInterface.getRTCCtime())  # Add the date and time to the string

tft_printer.screen_print_rotated(sensor_string, 1)  # Print the completed string to the landscape display

time.sleep(2)  # Wait for 2 seconds before proceeding

tools_string = ""  # Prepare an empty string to be printed to the screen

tools_string += " Serial: " + PiTools.get_cpu_serial()  # Add the RPi's CPU Serial number to the string

tools_string += " CPU Temp: " + str(PiTools.get_cpu_temperature())  # Add the RPi's CPU Serial number to the string

tools_string += " Local: " + PiTools.get_interface_ip("eth0")  # Add the local IP of eth0 to the string

tools_string += " Public: " + CloudTools.get_public_ip()  # Add the public IP of the RPi to the string

tft_printer.screen_print_rotated(tools_string, 1)  # Print the completed string to the landscape display

# Send a trigger to a recipe created using the Maker Channel on IFTTT.com
CloudTools.ifttt_trigger("YourIFTTTMakerChannelKey", "YourRecipeEventName", 5)

# Send a trigger to a recipe created using the Maker Channel on IFTTT.com along with variables in a JSON
CloudTools.ifttt_trigger("YourIFTTTMakerChannelKey", "YourRecipeEventName", 5, "1", 2, 3.0)

# print("Telling Pi to reboot in 10")
# PI_TOOLS.reboot_pi(10)
# print("Rebooting in 10, Ctrl+C to cancel")

SensorsInterface.ledOff()  # Turn off the Sensorian Orange LED
Exemple #2
0
tools_string = ""  # Prepare an empty string to be printed to the screen

tools_string += " Serial: " + PiTools.get_cpu_serial(
)  # Add the RPi's CPU Serial number to the string

tools_string += " CPU Temp: " + str(PiTools.get_cpu_temperature(
))  # Add the RPi's CPU Serial number to the string

tools_string += " Local: " + PiTools.get_interface_ip(
    "eth0")  # Add the local IP of eth0 to the string

tools_string += " Public: " + CloudTools.get_public_ip(
)  # Add the public IP of the RPi to the string

tft_printer.screen_print_rotated(
    tools_string, 1)  # Print the completed string to the landscape display

# Send a trigger to a recipe created using the Maker Channel on IFTTT.com
CloudTools.ifttt_trigger("YourIFTTTMakerChannelKey", "YourRecipeEventName", 5)

# Send a trigger to a recipe created using the Maker Channel on IFTTT.com along with variables in a JSON
CloudTools.ifttt_trigger("YourIFTTTMakerChannelKey", "YourRecipeEventName", 5,
                         "1", 2, 3.0)

# print("Telling Pi to reboot in 10")
# PI_TOOLS.reboot_pi(10)
# print("Rebooting in 10, Ctrl+C to cancel")

SensorsInterface.ledOff()  # Turn off the Sensorian Orange LED
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()
Exemple #4
0
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()