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 command 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();