Display-o-Tron HAT¶
This documentation will guide you through the methods available in the Display-o-Tron HAT library.
At A Glance¶
LCD¶
-
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
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_cursor_position
(column, row) Sets the cursor position in DRAM based on a row and column offset.
- Args:
- column (int): column to move the cursor to row (int): row to move the cursor to
- Raises:
- ValueError: if row and column are not within defined screen size
-
lcd.
set_display_mode
(enable=True, cursor=False, blink=False) Set the cursor position in DRAM
Parameters: offset – DRAM offset to place cursor
-
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 backlight 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) Does nothing.
Implemented for library compatibility with Dot3k backlight.
-
backlight.
set_graph
(percentage) Light a number of bargraph LEDs depending upon value
Parameters: hue – hue value between 0.0 and 1.0
-
backlight.
single_rgb
(led, r, g, b, auto_update=True) A single backlight LED to the supplied r, g, b colour
The auto_update parameter will trigger a write to the LEDs after the r, g, b colour has been set. Omit it and manually call update() to batch multiple LED changes into one update.
Parameters: - r – red value between 0 and 255
- g – green value between 0 and 255
- b – blue value between 0 and 255
- auto_update – autmatically update the LEDs
-
backlight.
sweep
(hue, sweep_range=0.0833) 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
() Does nothing.
Implemented for library compatibility with Dot3k backlight.
Touch¶
-
touch.
bind_defaults
(menu) Bind the default controls to a menu instance
This should be used in conjunction with a menu class instance to bind touch inputs to the default controls.
-
touch.
enable_repeat
(enable) Enable touch hold repeat
If enable is true, repeat will be enabled. This will trigger new touch events at the set repeat_rate when a touch input is held.
Parameters: enable – enable/disable repeat: True/False
-
touch.
high_sensitivity
() Switch to high sensitivity mode
This predetermined high sensitivity mode is for using touch through 3mm perspex or similar materials.
-
touch.
on
(buttons, bounce=-1) Handle a press of one or more buttons
Decorator. Use with @captouch.on(UP)
Parameters: - buttons – List, or single instance of cap touch button constant
- bounce – Maintained for compatibility with Dot3k joystick, unused
-
touch.
set_repeat_rate
(rate) Set hold repeat rate
Repeat rate values are clamped to the nearest 35ms, values from 35 to 560 are valid.
Parameters: rate – time in ms from 35 to 560