예제 #1
0
def cleanup(signum, frame):
    """
    Signal handler to ensure we disconnect cleanly
    in the event of a SIGTERM or SIGINT.
    """
    # Cleanup  modules
    MQTT.cleanup()
    lcd.clear()

    # Exit from application
    print "LCD daemon stopped"
    sys.exit(signum)
예제 #2
0
def cleanup(signum, frame):
    """
    Signal handler to ensure we disconnect cleanly
    in the event of a SIGTERM or SIGINT.
    """
    # Cleanup  modules
    logging.debug("Clean up modules")
    move.cleanup()
    VSS.cleanup()
    MQTT.cleanup()

    # Exit from application
    logging.info("Exiting on signal %d" % (signum))
    sys.exit(signum)
예제 #3
0
def cleanup(signum, frame):
    """
    Signal handler to ensure we disconnect cleanly
    in the event of a SIGTERM or SIGINT.
    """
    # Cleanup  modules
    logging.debug("Clean up modules")
    move.cleanup()
    VSS.cleanup()
    MQTT.cleanup()

    # Exit from application
    logging.info("Exiting on signal %d" % (signum))
    sys.exit(signum)
예제 #4
0
#!/usr/bin/python

__author__ = 'Bernd Gewehr'

import time

import lib_mqtt as MQTT
from  lib_hmc5883l import  hmc5883l
import os

DEBUG = False

if __name__ == '__main__':
    os.nice(10)
    try:
        MQTT.init()
        while True:
            time.sleep(0.1)
            compass = hmc5883l(gauss = 4.7, declination = (1,36))
            if DEBUG:
                print ("\rHeading: " + str(compass.heading()))
            MQTT.mqttc.publish("/RPiMower/Compass", str(compass.heading()))

    # interrupt
    except KeyboardInterrupt:
        print("Programm interrupted")
        MQTT.cleanup()
        sys.exit(2)

예제 #5
0
    elif (hue > 160) and (hue <= 250):
        colour = "blue"
    else:
        colour = "red"
    if DEBUG:
        print rgb, hue, std, mean, colour
    return colour

if __name__ == '__main__':
    # os.nice(10)
    try:
        MQTT.init()
        while True:
            with picamera.PiCamera() as camera:
                with picamera.array.PiRGBArray(camera) as stream:
                     camera.start_preview()
                     camera.resolution = (100, 100)
                     for foo in camera.capture_continuous(stream, 'rgb', use_video_port=False, resize=None, splitter_port=0, burst=True):
                         stream.truncate()
                         stream.seek(0)
                         RGBavg = stream.array.mean(axis=0).mean(axis=0)
                         colour = get_colour_name(RGBavg)
                         MQTT.mqttc.publish("/RPiMower/Ground_Colour", colour)

    # interrupt
    except KeyboardInterrupt:
        print("Programm interrupted")
        camera.stop_preview()
        MQTT.cleanup()
        sys.exit(2)