Ejemplo n.º 1
0
def Main():

    # SETUP KILL SIGNALS
    signal.signal(signal.SIGTERM, program_shutdown)
    signal.signal(signal.SIGINT, program_shutdown)

    # HACK FOR CLEANING UP GPIO IN A DOCKER CONTAINER
    UT.unexport_all()

    # CREATE OUR GIF CAMERA
    claptto = Claptto(GPIO, DEVICE, RESO, LOOP_COUNT, DELAY)
    claptto.setup_alsa()
    claptto.setup_gpio(SHUTTER)
    claptto.setup_notifier(SIGNAL, NOTIFY_ON_TIME, NOTIFY_LOOP_COUNT)
    claptto.start()

    dead = False
    try:
        while not dead:
            time.sleep(0.5)

    except ProgramExit, KeyboardInterrupt:
        dead = True
        print("CLEANUP")
        # KILL CLAPTTO OBJECT
        claptto.kill()
Ejemplo n.º 2
0
	def run(self):
		# GPIO.toggle_debug()

		try:
			# reset all
			ioutil.unexport_all()
			# GPIO.cleanup()  -- broken?

			# led
			GPIO.setup(LED, GPIO.OUT)
			GPIO.output(LED, GPIO.LOW)

			# handset
			GPIO.setup(HANDSET, GPIO.IN, pull_up_down=GPIO.PUD_UP, initial=1)
			GPIO.add_event_detect(HANDSET, GPIO.BOTH, self.off_hook)

			# rotary dial
			GPIO.setup(ROT_ENGAGED, GPIO.IN, pull_up_down=GPIO.PUD_UP)
			GPIO.add_event_detect(ROT_ENGAGED, GPIO.BOTH, self.rotary_engaged)
			GPIO.setup(ROT_PULSE, GPIO.IN, pull_up_down=GPIO.PUD_UP)
			GPIO.add_event_detect(ROT_PULSE, GPIO.FALLING, self.count_pulse)
		except Exception as e:
			logging.exception("exception encountered")

		GPIO.output(LED, GPIO.LOW) # signal process has started successfully

		# busy loop
		while True:
			time.sleep(0.02)
Ejemplo n.º 3
0
def pwm():

    rospy.init_node('pwm')
    rospy.Subscriber('speeds', Speeds, callback)

    while not rospy.is_shutdown():
        rospy.spin()

    SPWM.cleanup()
    UT.unexport_all()
Ejemplo n.º 4
0
try:
    while 1:
        encoder1_delta = encoder1.get_delta()
        if encoder1_delta != 0:
            pid.SetPoint = (encoder1_delta * .25) + pid.SetPoint

        temp = update_temp(celsius_unit)
        pid.update(temp)
        output = pid.output
        if output >= 0:
            gpio.output(relay_pin, GPIO.HIGH)
            lcd.set_color(1.0, 0.0, 0.0)  # Red
        else:
            gpio.output(relay_pin, GPIO.LOW)
            lcd.set_color(0.0, 0.0, 1.0)  # Blue

        lcd.clear()
        lcd.message('TEMP:{0:0.1f}\x01  \nGOAL:{1:0.1f}\x01'.format(temp, pid.SetPoint))

        # Provide some feedback at the terminal level
        # print("PID OUTOUT IS: " + str(output) +
        #       "and the temperature is: " + str(round(temp, 1)))
except KeyboardInterrupt:
    gpio.output(relay_pin, GPIO.HIGH)
    lcd.clear()
    if plat is 5:
        import CHIP_IO.Utilities as UT
        UT.unexport_all()
    pass
Ejemplo n.º 5
0
	def stop(self):
		ioutil.unexport_all()
		logging.debug('IO SHUT DOWN')
Ejemplo n.º 6
0
import rotary_encoder

A_PIN = "XIO-P0"
B_PIN = "XIO-P1"

encoder = rotary_encoder.RotaryEncoder.Worker(A_PIN, B_PIN)
encoder.start()


while 1:
    delta = encoder.get_cycles()
    if delta != 0:
        print "rotated %d cycles" % delta

except KeyboardInterrupt:
    import CHIP_IO.Utilities as UT
    UT.unexport_all()
Ejemplo n.º 7
0
 def api_unexport_all_pins():
     UT.unexport_all()
     resp = copy.deepcopy(self.CHIP_INFO)
     resp["connected"] = True
     resp["message"] = "Unexporting all the Pins"
     return jsonify(resp)