NAME
RPi::OLED::SSD1306::128_64 - Interface to the SSD1306-esque 128x64 OLED displays
DESCRIPTION
Provides the ability to use the 128x64 SSD1306 type OLED displays.
This distribution requires wiringPi version 2.36+ to be installed.
METHODS
new([$i2c_addr])
Instantiates and returns a new RPi::OLED::SSD1306::128x64 object.
Note that this module is a singleton; if you've already instantiated a new OLED device object, it will be returned if new()
is called again.
Parameters:
$i2c_addr
Optional, Integer. The I2C address of your OLED screen. Defaults to 0x3C
, which is extremely common.
clear
Wipes the display clean, and sets the cursor to the top-left position on the screen.
Returns 1
on success.
text_size($size)
By default, we use the smallest text size (1
) when displaying characters to the OLED. You can increase or decrease the text size with this call.
Parameters:
$size
Mandatory, Integer: A number to increase or decrease the font size to. Any number is valid, but be realistic... this screen is only 128x64 pixels.
Returns 1
on success.
display
Draws whatever you've put into the buffer to the screen. All calls that add to the buffer (eg: rect()
, string()
, pixel()
, char()
etc) require a call to this method after you've filled the buffer.
string($str, [$display])
Send a string to the display for printing.
Parameters:
$str
Mandatory, String: The string you want put into the buffer for display.
$display
Optional, Bool: All calls for displaying something to the screen require an additional call to display()
. Send in a positive value (1
) as the second parameter to this call and we'll call display automatically for you.
Returns 1
on success.
rect($x, $y, $w, $h, $colour)
Prepares a rectangle for display on the screen. To actually display the rectangle, a subsequent call to display()
is required.
Parameters:
$x
Mandatory, Integer: The X-axis (horizontal) position from the left of the screen to begin drawing the rectangle.
$y
Mandatory, Integer: The Y-axis (vertical) position from the top of the screen to begin drawing the rectangle.
$w
Mandatory, Integer: How many pixels wide to draw the rect.
$h
Mandatory, Integer: How many pixels tall (from the top) to draw the rect.
$colour
Optional, Bool: By default, we use 1
which is standard colour (white). Send in 0
and we'll use black, which will effectively wipe out whatever was on the display in the area of the rectangle.
Returns 1
on success.
char($x, $y, $char, $size, $colour)
Creates a buffer with a single ASCII char. As with other buffer calls, a call to display()
is required once you're ready to display the buffer.
Parameters:
$x
Mandatory, Integer: The X-axis (horizontal) position from the left of the screen to begin drawing the char.
$y
Mandatory, Integer: The Y-axis (vertical) position from the top of the screen to begin drawing the char.
$char
Mandatory, Integer: The integer representation of the ASCII char to draw. Valid values are 0-255
.
$size
Optional, Integer: The size of the char on the screen. Defaults to 2
.
$colour
Optional, Bool: By default, we use 1
which is standard colour (white). Send in 0
and we'll use black, which will effectively wipe out whatever was on the display in the area of the char.
Returns 1
on success.
pixel($x, $y, $colour)
Draw a single pixel to the screen.
Parameters:
$x
Mandatory, Integer: The X-axis (horizontal) position from the left of the screen to place the pixel.
$y
Mandatory, Integer: The Y-axis (vertical) position from the top of the screen to place the pixel.
$colour
Optional, Bool: By default, we use 1
which is standard colour (white). Send in 0
and we'll use black, which will effectively wipe out whatever was on the display in the area of the pixel.
Returns 1
on success.
horizontal_line($x, $y, $w, $colour)
Draw a single pixel wide horizontal line.
Parameters:
$x
Mandatory, Integer: The X-axis (horizontal) position from the left of the screen to begin drawing the horizontal line.
$y
Mandatory, Integer: The Y-axis (vertical) position from the top of the screen to begin drawing the horizontal line.
$w
Mandatory, Integer: How many pixels wide to draw the horizontal line.
$colour
Optional, Bool: By default, we use 1
which is standard colour (white). Send in 0
and we'll use black, which will effectively wipe out whatever was on the display in the area of the rectangle.
Returns 1
on success.
vertical_line($x, $y, $h, $colour)
Draw a single-pixel wide vertical line.
Parameters:
$x
Mandatory, Integer: The X-axis (horizontal) position from the left of the screen to begin drawing the vertical line.
$y
Mandatory, Integer: The Y-axis (vertical) position from the top of the screen to begin drawing the vertical line.
$w
Mandatory, Integer: How many pixels tall to draw the vertical line.
$colour
Optional, Bool: By default, we use 1
which is standard colour (white). Send in 0
and we'll use black, which will effectively wipe out whatever was on the display in the area of the rectangle.
Returns 1
on success.
dim($bool)
The screen has two brightness levels, dim and full.
Parameters:
$bool
Optional, Bool: Send in 1
to dim the display, and 0
to turn it to its maximum brightness. Defaults to 0
if not sent in.
Returns 1
on success.
invert_display($bool)
By default, the screen background is black, and anything you draw will be white. Inverting the screen will reverse those two colours.
Parameters:
$bool
Optional, Bool: 1
will invert the screen (black on white background), and 0
will set it back to normal (white on black background). Defaults to 0
if not sent in.
Returns 1
on success.
AUTHOR
Steve Bertrand, <steveb at cpan.org>
LICENSE AND COPYRIGHT
Copyright 2018 Steve Bertrand.
BSD License