API Reference¶
qwiic_oled_base¶
The base SSD1306 display driver Python module for the OLED display packages
This python package is a ported from the [SparkFun Micro OLED Arduino Library](https://github.com/sparkfun/SparkFun_Micro_OLED_Arduino_Library)
This package can be used in conjunction with the overall [SparkFun qwiic Python Package](https://github.com/sparkfun/Qwiic_Py)
New to qwiic? Take a look at the entire [SparkFun qwiic ecosystem](https://www.sparkfun.com/qwiic).
- class qwiic_oled_base.QwiicOledBase(address=None, pixel_width=64, pixel_height=48, i2c_driver=None)[source]¶
- Parameters
address – The I2C address to use for the device. If not provided, the default address is used.
i2c_driver – An existing i2c driver object. If not provided a driver object is created.
- Returns
The SSD1306 OLED device object.
- Return type
Object
- begin()[source]¶
Initialize the operation of the SSD1306 display driver for the OLED module
- Returns
Returns true of the initializtion was successful, otherwise False.
- Return type
bool
- circle(x0, y0, radius, color=None, mode=None)[source]¶
Draw a circle on the diplay. A color can be specified. Pixel copy mode is either Normal (source copy) or XOR
- Parameters
x0 – The X center position for the circle
y0 – The Y center position for the circle.
radius – The radius of the circle
color – The color to draw. If not set, the default foreground color is used.
mode – The mode to draw the pixl to the screen bufffer. Value can be either XOR or NORM. Default is NORM
- Returns
No return value
- clear(mode, value=0)[source]¶
Clear the display on the OLED Device.
- Parameters
mode – To clear GDRAM inside the LCD controller, pass in the variable mode = ALL, and to clear screen page buffer pass in the variable mode = PAGE.
value – The value to clear the screen to. Default value is 0
- Returns
No return value
- property connected¶
Determine if a SSD1306 OLED device is conntected to the system..
- Returns
True if the device is connected, otherwise False.
- Return type
bool
- contrast(contrast)[source]¶
Set the OLED contract value from 0 to 255. Note: Contrast level is not very obvious on the display.
- Parameters
contrast – Contrast Value between 0-255
- Returns
No return value
- display()[source]¶
Display the current screen buffer on the Display device. Bulk move the screen buffer to the SSD1306 controller’s memory so that images/graphics drawn on the screen buffer will be displayed on the OLED.
- Returns
No return value
- draw_bitmap(bitArray)[source]¶
Draw Bitmap image on screen. To use, create int array that is 64x48 pixels (384 bytes). Then call .draw_bitmap and pass it the array.
- Parameters
bitArray – The bitmap to draw
- Returns
No return value
- draw_char(x, y, c, color=None, mode=None)[source]¶
Draw character c using color and draw mode at x,y. Pixel copy mode is either Normal (source copy) or XOR
- Parameters
x – The X position on the display
y – The Y position on the display
c – The character to draw
color – The color to draw. If not set, the default foreground color is used.
mode – The mode to draw the pixl to the screen bufffer. Value can be either XOR or NORM. Default is NORM
- Returns
No return value
- property font_height¶
The height of the current font
- Returns
height of the font
- Rvalue
integer
- property font_type¶
Return the font type number of the current font.
- Returns
Font type number.
- Rvalue
integer
- property font_width¶
The width of the current font
- Returns
width of the font
- Rvalue
integer
- get_font_start_char()[source]¶
Return the starting ASCII character of the currnet font, not all fonts start with ASCII character 0. Custom fonts can start from any ASCII character.
- Returns
Starting character of the current font.
- Rvalue
integer
- get_font_total_char()[source]¶
The total number of characters in the current font.
- Returns
Total number of characters
- Rvalue
integer
- get_font_type()[source]¶
Return the font type number of the current font.
- Returns
Font type number.
- Rvalue
integer
- get_lcd_height()[source]¶
The height of the display in pixels
- Returns
height of the display
- Rvalue
integer
- get_lcd_width()[source]¶
The width of the display in pixels
- Returns
width of the display
- Rvalue
integer
- get_screenbuffer()[source]¶
Return a pointer to the start of the RAM screen buffer for direct access.
- Returns
The internal screen buffer
- Return type
integer array
- get_total_fonts()[source]¶
Return the total number of fonts loaded into the OLED’s flash memory.
- Returns
Total number of fonts available
- Rvalue
integer
- property height¶
The height of the display in pixels
- Returns
height of the display
- Rvalue
integer
- invert(inv)[source]¶
Invert the display of the display. The WHITE color of the display will turn to BLACK and the BLACK will turn to WHITE.
- Parameters
inv – If True, the screen is inverted. If False the screen is set to Normal mode.
- Returns
No return value
- is_connected()[source]¶
Determine if a SSD1306 OLED device is conntected to the system..
- Returns
True if the device is connected, otherwise False.
- Return type
bool
- line(x0, y0, x1, y1, color=None, mode=None)[source]¶
Draw a line starting at and ending at specified coordinates, with a given color. Pixel copy mode is either Normal (source copy) or XOR
- Parameters
x0 – The X starting position for the line
y0 – The Y starting position for the line.
x1 – The X ending position for the line
y1 – The Y ending position for the line.
color – The color to draw. If not set, the default foreground color is used.
mode – The mode to draw the pixl to the screen bufffer. Value can be either XOR or NORM. Default is NORM
- Returns
No return value
- line_h(x, y, width, color=None, mode=None)[source]¶
Draw a horizontal line defined by a starting position and width. A color can be specified. Pixel copy mode is either Normal (source copy) or XOR
- Parameters
x – The X starting position for the line
y – The Y starting position for the line.
width – The width (length) of the line
color – The color to draw. If not set, the default foreground color is used.
mode – The mode to draw the pixl to the screen bufffer. Value can be either XOR or NORM. Default is NORM
- Returns
No return value
- line_v(x, y, height, color=None, mode=None)[source]¶
Draw a vertical line defined by a starting position and width. A color can be specified. Pixel copy mode is either Normal (source copy) or XOR
- Parameters
x – The X starting position for the line
y – The Y starting position for the line.
height – The height (length) of the line
color – The color to draw. If not set, the default foreground color is used.
mode – The mode to draw the pixl to the screen bufffer. Value can be either XOR or NORM. Default is NORM
- Returns
No return value
- pixel(x, y, color=None, mode=None)[source]¶
Draw a pixel at a given position, with a given color. Pixel copy mode is either Normal (source copy) or XOR
- Parameters
x – The X position on the display
y – The Y position on the display
color – The color to draw. If not set, the default foreground color is used.
mode – The mode to draw the pixl to the screen bufffer. Value can be either XOR or NORM. Default is NORM
- Returns
No return value
- print(text)[source]¶
Print a line of text on the display using the current font, starting at the current position.
- Parameters
text – The line of text to write.
- Returns
No return value
- rect(x, y, width, height, color=None, mode=None)[source]¶
Draw a rectangle on the diplay. A color can be specified. Pixel copy mode is either Normal (source copy) or XOR
- Parameters
x – The X starting position for the rectangle
y – The Y starting position for the rectangle.
width – The width of the rectangle
height – The height of the rectangle
color – The color to draw. If not set, the default foreground color is used.
mode – The mode to draw the pixl to the screen bufffer. Value can be either XOR or NORM. Default is NORM
- Returns
No return value
- rect_fill(x, y, width, height, color=None, mode=None)[source]¶
Draw a filled rectangle on the diplay. A color can be specified. Pixel copy mode is either Normal (source copy) or XOR
- Parameters
x – The X starting position for the rectangle
y – The Y starting position for the rectangle.
width – The width of the rectangle
height – The height of the rectangle
color – The color to draw. If not set, the default foreground color is used.
mode – The mode to draw the pixl to the screen bufffer. Value can be either XOR or NORM. Default is NORM
- Returns
No return value
- scroll_right(start, stop)[source]¶
Set row start to row stop on the OLED to scroll right. Refer to http://learn.microview.io/intro/general-overview-of-microview.html for explanation of the rows.
- Parameters
start – The staring position on the display
stop – The stopping position on the display
- Returns
No return value
- set_color(color)[source]¶
Set the current draw’s color. Only WHITE and BLACK available.
- Parameters
color – Color Value
- Returns
No return value
- set_column_address(colAddress)[source]¶
Set SSD1306 column address.
- Parameters
colAddress – The column address command and address
- Returns
No return value
- set_cursor(x, y)[source]¶
Set the current cusor position for writing text
- Parameters
x – The X position on the display
y – The Y position on the display
- Returns
No return value
- set_draw_modee(mode)[source]¶
Set current draw mode with NORM or XOR.
- Parameters
mode – Draw Mode
- Returns
No return value
- set_font_type(font_type)[source]¶
Set the current font type number, ie changing to different fonts base on the type provided.
- Parameters
type – The type to set the font to.
- Returns
No return value
- set_page_address(pageAddress)[source]¶
Set SSD1306 page address.
- Parameters
pageAddress – The page address command and address
- Returns
No return value
- property width¶
The width of the display in pixels
- Returns
width of the display
- Rvalue
integer