Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??


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 # # - 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 # 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 }


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

In reply to Re^4: [partially OT] - [Update] wiringPi deprecated by jmlynesjr
in thread [partially OT] - wiringPi deprecated by marto

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2022-07-07 13:32 GMT
Find Nodes?
    Voting Booth?

    No recent polls found