QwiicOledDisplay¶
- class qwiic_oled_display.QwiicOledDisplay(address=None, i2c_driver=None)[source]¶
Bases:
QwiicOledBase
- 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 OLED Display device object.
- Return type
Object
Attributes Summary
Determine if a SSD1306 OLED device is conntected to the system..
The height of the current font
Return the font type number of the current font.
The width of the current font
The height of the display in pixels
The width of the display in pixels
Methods Summary
begin
()Initialize the operation of the SSD1306 display driver for the OLED module
circle
(x0, y0, radius[, color, mode])Draw a circle on the diplay.
clear
(mode[, value])Clear the display on the OLED Device.
contrast
(contrast)Set the OLED contract value from 0 to 255.
display
()Display the current screen buffer on the Display device.
draw_bitmap
(bitArray)Draw Bitmap image on screen.
draw_char
(x, y, c[, color, mode])Draw character c using color and draw mode at x,y.
flip_horizontal
(flip)Flip the graphics on the OLED horizontally.
flip_vertical
(flip)Flip the graphics on the OLED vertically.
The height of the current font
Return the starting ASCII character of the currnet font, not all fonts start with ASCII character 0.
The total number of characters in the current font.
Return the font type number of the current font.
The width of the current font
The height of the display in pixels
The width of the display in pixels
Return a pointer to the start of the RAM screen buffer for direct access.
Return the total number of fonts loaded into the OLED's flash memory.
invert
(inv)Invert the display of the display.
Determine if a SSD1306 OLED device is conntected to the system..
line
(x0, y0, x1, y1[, color, mode])Draw a line starting at and ending at specified coordinates, with a given color.
line_h
(x, y, width[, color, mode])Draw a horizontal line defined by a starting position and width.
line_v
(x, y, height[, color, mode])Draw a vertical line defined by a starting position and width.
pixel
(x, y[, color, mode])Draw a pixel at a given position, with a given color.
print
(text)Print a line of text on the display using the current font, starting at the current position.
rect
(x, y, width, height[, color, mode])Draw a rectangle on the diplay.
rect_fill
(x, y, width, height[, color, mode])Draw a filled rectangle on the diplay.
scroll_right
(start, stop)Set row start to row stop on the OLED to scroll right.
Stop scrolling operation.
set_color
(color)Set the current draw's color.
set_column_address
(colAddress)Set SSD1306 column address.
set_cursor
(x, y)Set the current cusor position for writing text
set_draw_modee
(mode)Set current draw mode with NORM or XOR.
set_font_type
(font_type)Set the current font type number, ie changing to different fonts base on the type provided.
set_page_address
(pageAddress)Set SSD1306 page address.
write
(c)Write a character on the display using the current font, at the current position.
Attributes Documentation
- ALL = 1¶
- BLACK = 0¶
- NORM = 0¶
- PAGE = 0¶
- WHITE = 1¶
- XOR = 1¶
- available_addresses = [60, 61]¶
- connected¶
Determine if a SSD1306 OLED device is conntected to the system..
- Returns
True if the device is connected, otherwise False.
- Return type
bool
- device_name = 'Qwiic OLED Display (128x32)'¶
- font_height¶
The height of the current font
- Returns
height of the font
- Rvalue
integer
- font_type¶
Return the font type number of the current font.
- Returns
Font type number.
- Rvalue
integer
- font_width¶
The width of the current font
- Returns
width of the font
- Rvalue
integer
- height¶
The height of the display in pixels
- Returns
height of the display
- Rvalue
integer
- width¶
The width of the display in pixels
- Returns
width of the display
- Rvalue
integer
Methods Documentation
- begin()¶
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)¶
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)¶
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
- contrast(contrast)¶
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()¶
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)¶
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)¶
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
- flip_horizontal(flip)¶
Flip the graphics on the OLED horizontally.
- Returns
No return value
- flip_vertical(flip)¶
Flip the graphics on the OLED vertically.
- Returns
No return value
- get_font_height()¶
The height of the current font
- Returns
height of the font
- Rvalue
integer
- get_font_start_char()¶
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()¶
The total number of characters in the current font.
- Returns
Total number of characters
- Rvalue
integer
- get_font_type()¶
Return the font type number of the current font.
- Returns
Font type number.
- Rvalue
integer
- get_font_width()¶
The width of the current font
- Returns
width of the font
- Rvalue
integer
- get_lcd_height()¶
The height of the display in pixels
- Returns
height of the display
- Rvalue
integer
- get_lcd_width()¶
The width of the display in pixels
- Returns
width of the display
- Rvalue
integer
- get_screenbuffer()¶
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()¶
Return the total number of fonts loaded into the OLED’s flash memory.
- Returns
Total number of fonts available
- Rvalue
integer
- invert(inv)¶
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()¶
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)¶
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)¶
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)¶
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)¶
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)¶
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)¶
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)¶
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)¶
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
- scroll_stop()¶
Stop scrolling operation.
- Returns
No return value
- set_color(color)¶
Set the current draw’s color. Only WHITE and BLACK available.
- Parameters
color – Color Value
- Returns
No return value
- set_column_address(colAddress)¶
Set SSD1306 column address.
- Parameters
colAddress – The column address command and address
- Returns
No return value
- set_cursor(x, y)¶
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)¶
Set current draw mode with NORM or XOR.
- Parameters
mode – Draw Mode
- Returns
No return value
- set_font_type(font_type)¶
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)¶
Set SSD1306 page address.
- Parameters
pageAddress – The page address command and address
- Returns
No return value
- write(c)¶
Write a character on the display using the current font, at the current position.
- Parameters
c – Character to write. A value of ‘\n’ starts a new line.
- Returns
1 on success