Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: [partially OT] - wiringPi deprecated

by marto (Cardinal)
on Jun 08, 2020 at 08:07 UTC ( #11117804=note: print w/replies, xml ) Need Help??


in reply to Re^2: [partially OT] - wiringPi deprecated
in thread [partially OT] - wiringPi deprecated

Sort of related, HiPi has had recent updates to cater for the various v4 models.

  • Comment on Re^3: [partially OT] - wiringPi deprecated

Replies are listed 'Best First'.
Re^4: [partially OT] - [Update] wiringPi deprecated
by jmlynesjr (Chaplain) on Jun 08, 2020 at 23:05 UTC

    Marto

    Thank you for the links. I will check it out. I know Mark from his work on wxPerl.

    My current code is several single function scripts to test concepts. I will ultimately be interfacing some custom hardware to the Quisk Software Defined Radio(SDR) package via a localhost socket. The Perl TCP/IP support made this interface really simple. At this point porting to a different language/library wouldn't be too bad, but I really don't want to learn Python.

    Update: It looks like HiPi will do the trick. I got it loaded today on a RPi 3B+ and ported two of my test scripts over. They both ran fine.

    HiPi was updated this month to support the new RPi 4B 8GB board. Raspbian 64bit is in beta.

    #! /usr/bin/perl # # hipiiotest.pl - Test PB, Encoder, and LED Wiring - Uses Perl HiPi D +istribution # by Mark Dootson # # James M. Lynes Jr. - KE4MIQ # Created: October 18,2019 - Initial test version using RPi::Wir +ingPi # by Steve Bertran # Last Modified: 06/09/2020 - First version using HiPi # 06/12/2020 - Merge changes tested in hipiblink.pl # Target: Raspberry Pi 3B+ and 4B in the future # # Notes: Pin numbers below refer to the GPIO## numbers # ex: 4 -> GPIO4 17 -> GPIO17 # # RPI J8 - GPIO Pin Definitions # ----------------------------- # 3V3 (1) (2) 5V # SDA/GPIO2 (3) (4) 5V # SCL/GPIO3 (5) (6) GND # PB1/GPIO4 (7) (8) GPIO14 # GND (9) (10) GPIO15 # PB2/GPIO17 (11) (12) GPIO18 # ENCA/GPIO27 (13) (14) GND # ENCB/GPIO22 (15) (16) GPIO23 # 3V3 (17) (18) GPIO24 # RED/GPIO10 (19) (20) GND # YEL/ GPIO9 (21) (22) GPIO25 # GRN/GPIO11 (23) (24) GPIO8 # GND (25) (26) GPIO7 # GPIO0 (27) (28) GPIO1 # GPIO5 (29) (30) GND # GPIO6 (31) (32) GPIO12 # GPIO13 (33) (34) GND # GPIO19 (35) (36) GPIO16 # GPIO26 (37) (38) GPIO20 # GND (39) (40) GPIO21 use strict; use warnings; use HiPi qw( :rpi ); use HiPi::GPIO; use Time::HiRes qw(sleep); my $gpio = HiPi::GPIO->new; # Create a GPIO Object # Create two push button inputs my $pb1 = $gpio->get_pin(4); # Create pin object for pb1 $pb1->mode(RPI_MODE_INPUT); # Set pin to input $pb1->set_pud(RPI_PUD_UP); # Turn on internal pull-up resi +stor my $pb2 = $gpio->get_pin(17); # Create pin object for pb2 $pb2->mode(RPI_MODE_INPUT); # Set pin to input $pb2->set_pud(RPI_PUD_UP); # Turn on internal pull-up resi +stor # Create two encoder inputs my $enca = $gpio->get_pin(27); # Create pin object for ENCA $enca->mode(RPI_MODE_INPUT); # Set pin to input $enca->set_pud(RPI_PUD_UP); # Turn on internal pull-up resi +stor my $encb = $gpio->get_pin(22); # Create pin object for ENCB $encb->mode(RPI_MODE_INPUT); # Set pin to input $encb->set_pud(RPI_PUD_UP); # Turn on internal pull-up resi +stor # Create three LED outputs my $led1 = $gpio->get_pin(10); # Red $led1->mode(RPI_MODE_OUTPUT); $led1->value(RPI_HIGH); my $led2 = $gpio->get_pin(9); # Yellow $led2->mode(RPI_MODE_OUTPUT); $led2->value(RPI_HIGH); my $led3 = $gpio->get_pin(11); # Green $led3->mode(RPI_MODE_OUTPUT); $led3->value(RPI_HIGH); sleep(2); # Leave LEDs on for two seconds $led1->value(RPI_LOW); # Turn the LEDs back off $led2->value(RPI_LOW); $led3->value(RPI_LOW); while(1) { my $pb1v = $pb1->value; # Read the four input values my $pb2v = $pb2->value; my $encav = $enca->value; my $encbv = $encb->value; $led1->value($encav); # Echo encoder bits to leds $led2->value($encbv); print "PB1: $pb1v\n"; # Print the current values print "PB2: $pb2v\n"; print "ENCA: $encav\n"; print "ENCB: $encbv\n\n"; sleep(.1); # Delay 100ms }

    James

    There's never enough time to do it right, but always enough time to do it over...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11117804]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2021-02-26 16:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?