Пример #1
0
class HallEffectReceiverThread(ReceiverThread):
	def __init__(self, pin):
		from HallEffect import HallEffect
		self.component = HallEffect(pig, pin, callback=self.on_pick_up, release_callback=self.on_hang_up)

		super(HallEffectReceiverThread, self).__init__()

	def on_pick_up(self, gpio, level, tick):
		super(HallEffectReceiverThread, self).on_pick_up()

	def on_hang_up(self, gpio, level, tick):
		super(HallEffectReceiverThread, self).on_hang_up()

	def terminate(self):
		super(ButtonThread, self).terminate()
		self.component.unlisten()
Пример #2
0
	def __init__(self, pin):
		from HallEffect import HallEffect
		self.component = HallEffect(pig, pin, callback=self.on_pick_up, release_callback=self.on_hang_up)

		super(HallEffectReceiverThread, self).__init__()
Пример #3
0
import pigpio
from time import sleep
from HallEffect import HallEffect

def test_pick_up(gpio, level, tick):
	print "HallEffect pick up callback triggered!"
	print gpio, level, tick

def test_hang_up(gpio, level, tick):
	print "HallEffect hang up callback triggered!"
	print gpio, level, tick


if __name__ == "__main__":
	pig = pigpio.pi()
	hall_effect = HallEffect(pig, 17, callback=test_pick_up, release_callback=test_hang_up)

	raw_input("Press Enter when ready...")
	print "Waiting for input"

	while True:
		try:
			sleep(0.01)
		except KeyboardInterrupt:
			print "Interrupted!"
			break

	hall_effect.unlisten()
	pig.stop()