Display-o-Tron 3000¶
This documentation will guide you through the methods available in the Display-o-Tron 3000 and Display-o-Tron HAT libraries.
At A Glance¶
LCD¶
-
lcd.
clear
() Clear the display and reset the cursor.
-
lcd.
clear
() Clear the display and reset the cursor.
-
lcd.
create_animation
(anim_pos, anim_map, frame_rate) Create an animation in a given custom character slot
Each definition should be a list of 8 bytes describing the custom character for that frame,
Parameters: - anim_pos – Character slot from 0 to 7 to store animation
- anim_map – A list of custom character definitions
- frame_rate – Speed of animation in frames-per-second
-
lcd.
create_char
(char_pos, char_map) Create a character in the LCD memory
The st7036 has 8 slots for custom characters.
A char is defined as a list of 8 integers with the upper 5 bits setting the state of each row of pixels.
Note: These slots are also used for animations!
Parameters: - char_pos – Char slot to use (0-7)
- char_map – List of 8 integers containing bitmap
-
lcd.
set_contrast
(contrast) Set the display contrast.
Raises TypeError if contrast is not an int Raises ValueError if contrast is not in the range 0..0x3F
Parameters: contrast – contrast value
-
lcd.
set_cursor_offset
(offset) Set the cursor position in DRAM
Parameters: offset – DRAM offset to place cursor
-
lcd.
set_cursor_position
(column, row) Set the cursor position in DRAM
Calculates the cursor offset based on a row and column offset.
Raises ValueError if row and column are not within defined screen size
Parameters: - column – column to move the cursor to
- row – row to move the cursor to
-
lcd.
set_display_mode
(enable=True, cursor=False, blink=False) Set the display mode.
Parameters: - enable – enable display output: True/False
- cursor – show cursor: True/False
- blink – blink cursor (if shown): True/False
-
lcd.
update_animations
() Update animations onto the LCD
Uses wall time to figure out which frame is current for each animation, and then updates the animations character slot to the contents of that frame.
Only one frame, the current one, is ever stored on the LCD.
-
lcd.
write
(value) Write a string to the current cursor position.
Parameters: value – The string to write
Backlight¶
-
backlight.
hue
(hue) Set the backlight LEDs to supplied hue
Parameters: hue – hue value between 0.0 and 1.0
-
backlight.
hue_to_rgb
(hue) Convert a hue to RGB brightness values
Parameters: hue – hue value between 0.0 and 1.0
-
backlight.
left_hue
(hue) Set the left backlight to supplied hue
Parameters: hue – hue value between 0.0 and 1.0
-
backlight.
left_rgb
(r, g, b) Set the left backlight to supplied r, g, b colour
Parameters: - r – red value between 0 and 255
- g – green value between 0 and 255
- b – blue value between 0 and 255
-
backlight.
mid_hue
(hue) Set the middle backlight to supplied hue
Parameters: hue – hue value between 0.0 and 1.0
-
backlight.
mid_rgb
(r, g, b) Set the middle backlight to supplied r, g, b colour
Parameters: - r – red value between 0 and 255
- g – green value between 0 and 255
- b – blue value between 0 and 255
-
backlight.
off
() Turn off the backlight.
-
backlight.
rgb
(r, g, b) Set all backlights to supplied r, g, b colour
Parameters: - r – red value between 0 and 255
- g – green value between 0 and 255
- b – blue value between 0 and 255
-
backlight.
right_hue
(hue) Set the right backlight to supplied hue
Parameters: hue – hue value between 0.0 and 1.0
-
backlight.
right_rgb
(r, g, b) Set the right backlight to supplied r, g, b colour
Parameters: - r – red value between 0 and 255
- g – green value between 0 and 255
- b – blue value between 0 and 255
-
backlight.
set
(index, value) Set a specific LED to a value
Parameters: - (int) (value) – index of the LED from 0 to 18
- (int) – brightness value from 0 to 255
-
backlight.
set_bar
(index, value) Set a value or values to one or more LEDs
Parameters: - index – starting index
- value – a single int, or list of brightness values from 0 to 255
-
backlight.
set_graph
(value) Light a number of bargraph LEDs depending upon value
Parameters: hue – hue value between 0.0 and 1.0
-
backlight.
sweep
(hue, range=0.08) Set the backlight LEDs to a gradient centered on supplied hue
Supplying zero to range would be the same as hue()
Parameters: - hue – hue value between 0.0 and 1.0
- range – range value to deviate the left and right hue
-
backlight.
update
() Update backlight with changes to the LED buffer
-
backlight.
use_rbg
() Swap the Green and Blue channels on the LED backlight
Use if you have a first batch Display-o-Tron 3K
Joystick¶
-
joystick.
millis
() Return the current time in milliseconds.
-
joystick.
on
(buttons, bounce=300) Handle a joystick direction or button push
Decorator. Use with @joystick.on(joystick.UP)
Parameters: - buttons – List, or single instance of joystick button constant
- bounce – Debounce delay in milliseconds: default 300
-
joystick.
repeat
(button, handler, delay=0.1, ramp=1.0) Detect a held direction and repeat
If you want to hold a direction and have it auto-repeat, call this within a joystick direction handler.
Parameters: - button – Joystick button constant to watch
- handler – Function to call every repeat
- delay – Delay, in seconds, before repeat starts and between each repeat
- ramp – Multiplier applied to delay after each repeat, 1.0=linear speed up