check_gpio_in

Watches the GPIO input pin and prints every change, without launching Village.

For testing what is wired to GPIO_IN (a switch, a TTL, …). It uses the same logic as village/devices/gpio.py: a gpiozero DigitalInputDevice with the internal resistor of GPIO_IN_PULL, and callbacks on OFF -> ON (trigger_on) and ON -> OFF (trigger_off).

Village must not be running (the pin would be busy). Run it on the Raspberry:

python3 village/scripts/check_gpio_in.py # GPIO_IN and GPIO_IN_PULL python3 village/scripts/check_gpio_in.py –pin 17 python3 village/scripts/check_gpio_in.py –pull up # internal pull-up

Stop it with Ctrl+C.

Each change is printed with the time since the previous one: a mechanical switch usually bounces, which shows up as several changes a few ms apart.

(Not named test_*.py on purpose: pytest would collect it as a test.)

Functions

default_pull()

The pull set in GPIO_IN_PULL, as gpio.py uses it ("down" if the settings cannot be read).

main()

Parses the arguments and watches the pin until Ctrl+C.