def stopClk(self,gpio,val):
		if self.timer_running==True: 
			print "tagid %s ended run on track %s"%(self.tag_id,self.track_id)
			self.timer_running=False
			RPIO.del_interrupt_callback(self.gpio_e)
			self.timer_clk.stop()
			self.track_clk.start(5)			
Beispiel #2
0
	def sendBtnPush(self):
		
		# reset ctr so we get a full count
		self.ctrRising2 = 0
		
		# create callbacks that will get called to register counts
		# when we get to a count of 2000 these callbacks will call sendBtnPushDone()
		RPIO.add_interrupt_callback(4, self.on_q8_rising_btn, edge='rising', threaded_callback=False)
		RPIO.add_interrupt_callback(25, self.on_q7_rising_btn, edge='rising', threaded_callback=False)
		
		self.log.info("Inside sendBtnPush(). Added callback for buttons to read square wave for pin %s" % 4)
		self.log.info("Inside sendBtnPush(). Added callback for buttons to read square wave for pin %s" % 25)
		
		RPIO.wait_for_interrupts()
		self.log.info("Inside sendBtnPush(). We just got passed RPIO.wait_for_interrupts() which is awesome cuz thought blocking here never ended.")
		
		# now remove the callbacks because we're done sending and no need
		# to keep the load on our script of handling callcacks
		RPIO.del_interrupt_callback(4)
		RPIO.del_interrupt_callback(25)
		self.log.info("Removed interrupt callbacks for GPIO 4 and 25 for button pushing.")

		# Make sure to send high to opto-coupler to ensure
		# espresso side is back to low
		RPIO.output(9, True)
		RPIO.output(10, True)
		
		'''
Beispiel #3
0
    def start(self, pin_interrupts):
        if self.__pin_interrupts:
            GPIO.del_interrupt_callback(self.__pin_interrupts)
        self.__pin_interrupts = pin_interrupts

        GPIO.add_interrupt_callback(self.__pin_interrupts, self.__add_pulse, edge='rising', debounce_timeout_ms=100)
        GPIO.wait_for_interrupts(threaded=True)
Beispiel #4
0
 def _disable_event_detect(self):
     try:
         RPIO.del_interrupt_callback(self.number)
     except KeyError:
         # Ignore this exception which occurs during shutdown; this
         # simply means RPIO's built-in cleanup has already run and
         # removed the handler
         pass
Beispiel #5
0
 def _disable_event_detect(self):
     try:
         RPIO.del_interrupt_callback(self.number)
     except KeyError:
         # Ignore this exception which occurs during shutdown; this
         # simply means RPIO's built-in cleanup has already run and
         # removed the handler
         pass
 def stopClk(self, gpio, val):
     if self.timer_running == True:
         print "tagid %s ended run on track %s" % (self.tag_id,
                                                   self.track_id)
         self.timer_running = False
         RPIO.del_interrupt_callback(self.gpio_e)
         self.timer_clk.stop()
         self.track_clk.start(5)
	def startClk(self,gpio,val):
		if self.timer_enable==True:
			print "tagid %s started run on track %s"%(self.tag_id,self.track_id)
			self.timer_enable=False
			RPIO.del_interrupt_callback(self.gpio_b)
			self.t_0=datetime.datetime.now()
			self.timer_clk.start(5)
			self.track_clk.stop()
			self.timer_running=True
			self.gui_data.update()
			RPIO.add_interrupt_callback(self.gpio_e,self.stopClk,edge='rising',pull_up_down=RPIO.PUD_UP,debounce_timeout_ms=None)
Beispiel #8
0
	def startReadingState(self):
		# start reading state from leds for 2 seconds
		# that should give us enough time to get a decent sample in case
		# the Raspi is busy and thus our callbacks aren't accurate in their reading
		self.log.info("Starting to read state off LEDs for 2 sec")
		
		# Reset global ctr
		self.ctrRising = 0
		
		# Reset data
		for e in self.indx:
			self.dataq7[e] = 0
			self.dataq8[e] = 0
			
		RPIO.add_interrupt_callback(4, self.on_q8_rising, edge='rising', threaded_callback=False)
		RPIO.add_interrupt_callback(25, self.on_q7_rising, edge='rising', threaded_callback=False)
		self.log.info("Inside startReadingState(). Added callback for pin %s" % 4)
		self.log.info("Inside startReadingState(). Added callback for pin %s" % 25)
	
		#pdb.set_trace()
		RPIO.wait_for_interrupts()
		self.log.info("Inside startReadingState(). We just got passed RPIO.wait_for_interrupts() which is awesome cuz thought blocking here never ended.")

		# if we've gottent this far, that's awesome cuz we were finding we never
		# got here. so now we can remove callbacks. we know we only get here once
		# so this is clean.
		RPIO.del_interrupt_callback(4)
		RPIO.del_interrupt_callback(25)
		self.log.info("Inside startReadingState(). Removed interrupt callbacks for GPIO 4 and 25.")

		# let's make sure the doneReadingState() method is finished
		# this is because it does a sleep() and we don't want
		# to return from here until that sleep is finished
		
		'''
		# make sure our ctrRising hasn't changed in a second or so
		start_time = time.time()
		elapsed_time = 0
		loc_ctr = self.ctrRising
		self.log.info("Going to do yield loop for 1 second. Seems to ensure all callbacks are completed before I return.")
		loopCtr = 0
		while (elapsed_time < 1):
			loopCtr += 1
			# if we are having a moving ctrRising, reset our start time. i want 1 full second
			# of no movement on ctrRising
			if (loc_ctr != self.ctrRising):
				self.log.info("ctrRising was still changing. resetting start_time to now to extend our wait.")
				start_time = time.time()
			sleep(0.001)
			#self.log.info("In yield loop to make sure all our interrupt callbacks came back. self.ctrRising: %s, elapsed_time: %s" % (self.ctrRising, elapsed_time))
			elapsed_time = time.time() - start_time
		self.log.info("Returning from startReadingState(). Done with yield loop. Looped: %s" % loopCtr)
		'''
		self.log.info("Done with startReadingState(). Only here should main zwtextspressod continue on.")
    def disableTrack(self, in_number=None):
        clean = False
        self.track_clk.stop()  #closing it's self
        if in_number == None:
            if self.timer_running == False and self.timer_enable == True:
                print "tagid %s made no run on track %s disabling it " % (
                    self.tag_id, self.track_id)
                RPIO.del_interrupt_callback(self.gpio_b)
                clean = True
            if self.timer_running == False and self.timer_enable == False:
                print "tagid %s completed successfull run on track %s disabling it" % (
                    self.tag_id, self.track_id)
                self.gui_data.update()
                time.sleep(5)
                self.sortTree(reset=False)
                clean = True
        if in_number == 'MASTER':
            if self.timer_running == False and self.timer_enable == False and self.rfid_enable == False:
                print "%s is canceling after run, tagid %s and disabling track %s" % (
                    in_number, self.tag_id, self.track_id)
                self.rfid_label.setStyleSheet(rfid_style_invalid)
                self.timer_label.setStyleSheet(timer_style_invalid)
                self.gui_data.update()
                time.sleep(5)
                self.sortTree(reset=True)
                clean = True
            if self.timer_running == False and self.timer_enable == True:
                self.timer_enable = False
                print "%s is canceling before run, tagid %s and disabling track %s" % (
                    in_number, self.tag_id, self.track_id)
                clean = True
            if self.timer_running == True and self.timer_enable == False:
                self.timer_running = False
                self.timer_clk.stop()
                RPIO.del_interrupt_callback(self.gpio_e)
                self.rfid_label.setStyleSheet(rfid_style_invalid)
                self.timer_label.setStyleSheet(timer_style_invalid)
                print "%s is canceling during run, tagid %s and disabling track %s" % (
                    in_number, self.tag_id, self.track_id)
                self.gui_data.update()
                time.sleep(5)
                self.sortTree(reset=True)
                clean = True

        if clean == True:
            self.rfid_label.setStyleSheet(rfid_style)
            self.timer_label.setStyleSheet(timer_style)
            self.rfid_label.setText('')
            self.timer_label.setText('0:000')
            self.rfid_enable = True

        self.gui_data.update()
 def startClk(self, gpio, val):
     if self.timer_enable == True:
         print "tagid %s started run on track %s" % (self.tag_id,
                                                     self.track_id)
         self.timer_enable = False
         RPIO.del_interrupt_callback(self.gpio_b)
         self.t_0 = datetime.datetime.now()
         self.timer_clk.start(5)
         self.track_clk.stop()
         self.timer_running = True
         self.gui_data.update()
         RPIO.add_interrupt_callback(self.gpio_e,
                                     self.stopClk,
                                     edge='rising',
                                     pull_up_down=RPIO.PUD_UP,
                                     debounce_timeout_ms=None)
	def disableTrack(self,in_number=None):
		clean=False
		self.track_clk.stop() #closing it's self
		if in_number==None:
			if self.timer_running==False and self.timer_enable==True:
				print "tagid %s made no run on track %s disabling it "%(self.tag_id,self.track_id)
				RPIO.del_interrupt_callback(self.gpio_b)
				clean=True
			if self.timer_running==False and self.timer_enable==False: 
				print "tagid %s completed successfull run on track %s disabling it"%(self.tag_id,self.track_id)
				self.gui_data.update()
				time.sleep(5)
				self.sortTree(reset=False)	
				clean=True
		if in_number=='MASTER' :
			if self.timer_running==False and self.timer_enable==False and self.rfid_enable==False:
				print "%s is canceling after run, tagid %s and disabling track %s"%(in_number,self.tag_id,self.track_id)
				self.rfid_label.setStyleSheet(rfid_style_invalid)
				self.timer_label.setStyleSheet(timer_style_invalid)	
				self.gui_data.update()
				time.sleep(5)	
				self.sortTree(reset=True)
				clean=True
			if self.timer_running==False and self.timer_enable==True:
				self.timer_enable=False
				print "%s is canceling before run, tagid %s and disabling track %s"%(in_number,self.tag_id,self.track_id)
				clean=True
			if self.timer_running==True and self.timer_enable==False:
				self.timer_running=False
				self.timer_clk.stop()
				RPIO.del_interrupt_callback(self.gpio_e)
				self.rfid_label.setStyleSheet(rfid_style_invalid)
				self.timer_label.setStyleSheet(timer_style_invalid)	
				print "%s is canceling during run, tagid %s and disabling track %s"%(in_number,self.tag_id,self.track_id)
				self.gui_data.update()
				time.sleep(5)	
				self.sortTree(reset=True)	
				clean=True

		if clean==True:
			self.rfid_label.setStyleSheet(rfid_style)
			self.timer_label.setStyleSheet(timer_style)	
			self.rfid_label.setText('')	
			self.timer_label.setText('0:000')	
			self.rfid_enable=True

		self.gui_data.update()
Beispiel #12
0
 def _set_when_changed(self, value):
     if self._when_changed is None and value is not None:
         self._when_changed = value
         RPIO.add_interrupt_callback(
             self._number, lambda channel, value: self._when_changed(),
             self._edges, self.GPIO_PULL_UPS[self._pull], self._bounce)
     elif self._when_changed is not None and value is None:
         try:
             RPIO.del_interrupt_callback(self._number)
         except KeyError:
             # Ignore this exception which occurs during shutdown; this
             # simply means RPIO's built-in cleanup has already run and
             # removed the handler
             pass
         self._when_changed = None
     else:
         self._when_changed = value
Beispiel #13
0
 def _set_when_changed(self, value):
     if self._when_changed is None and value is not None:
         self._when_changed = value
         RPIO.add_interrupt_callback(
             self._number,
             lambda channel, value: self._when_changed(),
             self._edges, self.GPIO_PULL_UPS[self._pull], self._bounce)
     elif self._when_changed is not None and value is None:
         try:
             RPIO.del_interrupt_callback(self._number)
         except KeyError:
             # Ignore this exception which occurs during shutdown; this
             # simply means RPIO's built-in cleanup has already run and
             # removed the handler
             pass
         self._when_changed = None
     else:
         self._when_changed = value
Beispiel #14
0
 def cleanup():
     RPIO.del_interrupt_callback(GPIO.radio_pin)
     RPIO.cleanup()
Beispiel #15
0
	def stop(self):
		logging.debug("InputTrigger on GPIO %s stopping..." % self.inPin)
		RPIO.stop_waiting_for_interrupts()
		RPIO.del_interrupt_callback(self.inPin)
Beispiel #16
0
 def stop(self):
     RPIO.del_interrupt_callback(self.pPanicBtn)
     PWM.clear_channel(0)
     PWM.cleanup()
Beispiel #17
0
def call_C2(gpio_id,val):
	print "C2-18"
	RPIO.del_interrupt_callback(18)
	RPIO.add_interrupt_callback(17,call_P2,edge='falling',pull_up_down=RPIO.PUD_UP,debounce_timeout_ms=tb)
Beispiel #18
0
 def removeReader(self):
     RPIO.del_interrupt_callback(self.GPIO_0)
     RPIO.del_interrupt_callback(self.GPIO_1)
Beispiel #19
0
	def removeReader(self):
		RPIO.del_interrupt_callback(self.GPIO_0)
		RPIO.del_interrupt_callback(self.GPIO_1)
Beispiel #20
0
def call_C3(gpio_id,val):
	print "C3-22"
	RPIO.del_interrupt_callback(22)
	RPIO.add_interrupt_callback(21,call_P3,edge='falling',pull_up_down=RPIO.PUD_UP,debounce_timeout_ms=tb)
Beispiel #21
0
def call_P2(gpio,val):
	print "P2-17"
        RPIO.del_interrupt_callback(17)
	RPIO.add_interrupt_callback(18,call_C2,edge='falling',pull_up_down=RPIO.PUD_UP,debounce_timeout_ms=tb)
Beispiel #22
0
def call_P4(gpio,val):
	print "P4-7"
        RPIO.del_interrupt_callback(7)
	RPIO.add_interrupt_callback(8,call_C4,edge='falling',pull_up_down=RPIO.PUD_UP,debounce_timeout_ms=tb)
Beispiel #23
0
def call_P1(gpio,val):
	print "P1-4"
        RPIO.del_interrupt_callback(4)
	RPIO.add_interrupt_callback(25,call_C1,edge='falling',pull_up_down=RPIO.PUD_UP,debounce_timeout_ms=tb)
Beispiel #24
0
 def cleanup(self):
     """Call on unload so that the raspberry pi releases its gpio pins"""
     GPIO.cleanup()
     for pin in inputs.values():
         GPIO.del_interrupt_callback(pin)
     GPIO.stop_waiting_for_interrupts()
Beispiel #25
0
def call_C4(gpio_id,val):
	print "C4-8"
	RPIO.del_interrupt_callback(8)
	RPIO.add_interrupt_callback(7,call_P4,edge='falling',pull_up_down=RPIO.PUD_UP,debounce_timeout_ms=tb)
Beispiel #26
0
def call_C1(gpio_id,val):
	print "C1-25"
	RPIO.del_interrupt_callback(25)
	RPIO.add_interrupt_callback(4,call_P1,edge='falling',pull_up_down=RPIO.PUD_UP,debounce_timeout_ms=tb)
Beispiel #27
0
def call_P3(gpio,val):
	print "P3-21"
        RPIO.del_interrupt_callback(21)
	RPIO.add_interrupt_callback(22,call_C3,edge='falling',pull_up_down=RPIO.PUD_UP,debounce_timeout_ms=tb)