def test5_board_pin_numbers(self): logging.info(" ") logging.info(" ") logging.info("=== BCM AND BOARD NUMBERING TESTS ===") RPIO.setmode(RPIO.BCM) pins = RPIO.GPIO_LIST_R1 if RPIO.RPI_REVISION == 1 \ else RPIO.GPIO_LIST_R2 logging.info("testing bcm gpio numbering: %s", pins) for pin in pins: gpio_id = RPIO.channel_to_gpio(pin) logging.info("- BCM channel %s = gpio %s", pin, gpio_id) with self.assertRaises(RPIO._GPIO.InvalidChannelException): gpio_id = RPIO.channel_to_gpio(32) with self.assertRaises(RPIO._GPIO.InvalidChannelException): gpio_id = RPIO.channel_to_gpio(5) logging.info(" ") pins = RPIO.PIN_LIST RPIO.setmode(RPIO.BOARD) logging.info("testing board gpio numbering: %s", pins) for pin in pins: if pin >> 8 > 0: # py_gpio.c cannot deal with BOARD->BCM of P5 pins yet continue gpio_id = RPIO.channel_to_gpio(pin) logging.info("- BOARD channel %s = gpio %s", pin, gpio_id) with self.assertRaises(RPIO._GPIO.InvalidChannelException): gpio_id = RPIO.channel_to_gpio(0) RPIO.setmode(RPIO.BCM)
def __init__(self, encoderGPIO): #encoder GPIO self.encoderGPIO = encoderGPIO #setup the encoder pins - don't use internal pull-up/down #there is allready an external pull-down in place #from the 5v/3V conversion through 15k-gnd/10k-5v resistors # RPIO.setup(self.encoderGPIO, RPIO.IN) #append the encoder event to it's callback function # workaround new_gpio= RPIO.channel_to_gpio(self.encoderGPIO) RPIO.setmode(RPIO.BCM) RPIO.setup(new_gpio, RPIO.IN) RPIO.add_interrupt_callback(new_gpio, callback=self.encoder_callback, edge='both',pull_up_down=RPIO.PUD_OFF, debounce_timeout_ms=2,threaded_callback=True) RPIO.setmode(RPIO.BOARD) #counter variable self.encoder_count = 0 #which direction (-1=cw/1=ccw) self.direction = 1