Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: ST7789V2 LCD Controller

by Bod (Parson)
on Sep 28, 2024 at 21:41 UTC ( [id://11161993]=note: print w/replies, xml ) Need Help??


in reply to ST7789V2 LCD Controller

Not wanting to delve into C programming just yet (I had to do some C++ at uni and didn't get very far!), I have been trying to approach the problem with just Perl. This is what I have got.

use strict; use warnings; use RPi::SPI; # Initialize SPI: bus 0, 8 MHz my $spi = RPi::SPI->new(0, 8000000); # Reset display (if necessary) sub reset_display { # Handle reset } # Send command to the display sub send_command { my ($cmd) = @_; my $data = \[ $cmd ]; # Create an array reference for a single co +mmand byte print "Sending command\n"; $spi->rw($data, 1); # Send command via SPI } # Send data to the display (ensure data is an array reference) sub send_data { my ($data_ref) = @_; print "Sending data\n"; $spi->rw($data_ref); # Send data via SPI } # Initialize the display (according to the display's datasheet) sub init_display { send_command(0x01); # Command: software reset } reset_display(); init_display();

I'm getting an error from $spi->rw($data, 1); that doesn't seem to make sense. The error is data param must be an array reference but the RPi::SPI documentation says that rw takes buf (arrayref) and len (integer). It doesn't mention a data parameter and I am giving it an arrayref and an integer!

I've searched the source code and the error text is not there.

Some help debugging this would be appreciated please

Replies are listed 'Best First'.
Re^2: ST7789V2 LCD Controller
by tybalt89 (Monsignor) on Sep 28, 2024 at 23:36 UTC
    my $data = \[ $cmd ]; # Create an array reference for a single comman +d byte

    should be

    my $data = [ $cmd ]; # Create an array reference for a single command + byte

    You were sending a reference to a reference to an array :(

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2026-03-16 05:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.