I've been playing around with the different classes available in Gpiozero and I've created over thirty little programs to test the inputs and outputs. All worked fine with no problems at all. However, I get an unexpected error when using the 'active_state' parameter in the InputDevice class.
According to the documentation at: https://gpiozero.readthedocs.io/en/stab ... input.html the class is defined thus:
class: gpiozero.InputDevice(pin, *, pull_up=False, active_state=None, pin_factory=None)
The relevant parameters are:
pull_up (bool or None) – If True, the pin will be pulled high with an internal resistor. If False (the default), the pin will be pulled low. If None, the pin will be floating. As gpiozero cannot automatically guess the active state when not pulling the pin, the active_state parameter must be passed.
active_state (bool or None) – If True, when the hardware pin state is HIGH, the software pin is HIGH. If False, the input polarity is reversed: when the hardware pin state is HIGH, the software pin state is LOW. Use this parameter to set the active state of the underlying pin when configuring it as not pulled (when pull_up is None). When pull_up is True or False, the active state is automatically set to the proper value.
Clearly, if pull_up is set to None (for example, when interfacing to digital devices which don't require a pull up or down) it is necessary to set active_state to True or False in order to define the active state. To test this, I created the following simple program:
When I run the program I get the following error:
Code: Select all
from gpiozero import InputDevice input = InputDevice(pin=4, pull_up=None, active_state=True) input.wait_for_active() print ("input is active")
TypeError: __init__() got an unexpected keyword argument 'active_state'
Incidentally, I get exactly the same error if I set 'active_state' to False. Can you guys give me a sanity check? Am I doing something stupid?