HiPi::GPIO::Pin
Provides wrappers around the pin functions provided by the HiPi::GPIO module.
use HiPi qw( :rpi ); use HiPi::GPIO; my $gpio = HiPi::GPIO->new; my $pin = $gpio->get_pin( RPI_PIN_11 ); $pin->value( RPI_HIGH );
Methods
Get or set the pin level
$pin->value( 1 ); my $level = $pin->value;
Get or set the current pin mode. Normally RPI_MODE_INPUT or RPI_MODE_OUTPUT but can use any of the following constants:
RPI_MODE_INPUT RPI_MODE_OUTPUT RPI_MODE_ALT0 RPI_MODE_ALT1 RPI_MODE_ALT2 RPI_MODE_ALT3 RPI_MODE_ALT4 RPI_MODE_ALT5
$pin->mode( RPI_MODE_OUTPUT ); my $mode = $pin->mode;
Set or remove the internal Pull Up or Pull Down resistor on the pin. Uses constants:
RPI_PUD_OFF RPI_PUD_DOWN RPI_PUD_UP
$pin->set_pud( RPI_PUD_UP );
On the BCM2711 based Raspberry Pi 4 you can retrieve the current pull up / down setting for a gpio pin. Returns one of the constants:
RPI_PUD_OFF RPI_PUD_DOWN RPI_PUD_UP RPI_PUD_UNSET
For BCM2835/6/7 based Raspberry Pi's this method will always return RPI_PUD_UNSET
use HiPi qw( :rpi ); ... my $setting = $pin->get_pud();
Return descriptive text for the current pin function.
my $description = $pin->get_function();