You could add this two methods to your class
The code which should setup the inputs and set the event detection.
In Main():
More info about the GPIO functions are here: https://sourceforge.net/p/raspberry-gpio...ki/Inputs/
StopWatch
.def cb_start(self, channel): self.Start() def cb_stop(self, channel): self.Stop()This two methods are called from outside by
GPIO.add_event_detect
.The code which should setup the inputs and set the event detection.
def set_gpio(start_pin, stop_pin, start_cb, stop_cb): GPIO.setmode(GPIO.BOARD) GPIO.setup(start_pin, GPIO.IN) GPIO.setup(stop_pin, GPIO.IN) GPIO.add_event_detect(start_pin, GPIO.RISING, callback=start_cb, bouncetime=200) GPIO.add_event_detect(stop_pin, GPIO.RISING, callback=stop_cb, bouncetime=200)Then add to
Main
after creation of a StopWatch instance, the set_gpio function call:In Main():
stopWatch = StopWatch(root) set_gpio(38, 36, stopWatch.cb_start, stopWatch.cb_stop) stopWatch.pack(side=TOP)
More info about the GPIO functions are here: https://sourceforge.net/p/raspberry-gpio...ki/Inputs/
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!