infopanel package¶
Subpackages¶
Submodules¶
infopanel.colors module¶
Colors.
-
infopanel.colors.
interpolate_color
(current, minv=0.0, maxv=1.0, cmap=None)¶ Get a color from a colormap based on interpolation.
-
infopanel.colors.
rgb_from_name
(color_name)¶ Get a rgb color from a color name.
infopanel.config module¶
Configuration file stuff.
-
infopanel.config.
load_config_yaml
(path)¶ Load and validate config file as an alternative to command line options.
infopanel.data module¶
Input data that might come over MQTT or whatever.
-
class
infopanel.data.
InputData
¶ Bases:
collections.defaultdict
Container for all the live data.
infopanel.display module¶
Displays to present stuff.
-
class
infopanel.display.
Display
¶ Bases:
object
A display screen.
This is a common interface to whatever kind of display you have.
-
brightness
¶ Brightness of display from 0 to 100.
-
draw_box
(xmin, ymin, xmax, ymax)¶ Don’t use PIL because it blanks. NOTE: Use graphics.DrawLine.
-
height
¶ Height of the display in pixels.
-
rainbow_text
(font, x, y, text, box=True)¶ Make rainbow text.
-
set_image
(image, x=0, y=0)¶ Apply an image to the screen.
-
set_pixel
(x, y, red, green, blue)¶ Set a pixel to a color.
-
text
(font, x, y, red, green, blue, text)¶ Render text in a font to a place on the screen in a certain color.
-
width
¶ Width of the display in pixels.
-
-
class
infopanel.display.
RGBMatrixDisplay
(matrix)¶ Bases:
infopanel.display.Display
An RGB LED Matrix running off of the rgbmatrix library.
-
brightness
¶ Brightness of display from 0 to 100.
-
buffer
()¶ Swap the off-display canvas/buffer with the on-display one.
-
clear
()¶ Clear the canvas.
-
height
¶ Height of the display in pixels.
-
set_image
(image, x=0, y=0)¶ Apply an image to the screen.
-
set_pixel
(x, y, red, green, blue)¶ Set a pixel to a color.
-
text
(font, x, y, red, green, blue, text)¶ Render text in a font to a place on the screen in a certain color.
-
width
¶ Width of the display in pixels.
-
-
infopanel.display.
display_factory
(config)¶ Build a display based on config settings.
-
infopanel.display.
rgbmatrix_options_factory
(config)¶ Build RGBMatrix options object.
infopanel.driver module¶
The infopanel driver. This is the main controller for the system.
-
class
infopanel.driver.
Driver
(disp, data_source)¶ Bases:
object
Main controller for the infopanel.
-
apply_mode
(mode)¶ Apply a different sequence of scenes with different durations.
If the mode is the name of a scene, set that scene instead.
-
change_image_path
(pathsetting)¶ Change the image path.
The pathsetting is a special string in the form: spritename=newpath.
-
draw_frame
()¶ Perform a double-buffered draw frame and frame switch.
-
init_modes
(conf)¶ Process modes from configuration.
-
run
()¶ Draw frames forever or until the main thread stops us.
Uses the clock to figure out when to switch scenes instead of the number of frames because some scenes are way slower than others.
-
stop
()¶ Shut down the thread.
-
-
infopanel.driver.
apply_global_config
(conf)¶ Apply config items that are global in nature.
-
infopanel.driver.
driver_factory
(disp, data_src, conf)¶ Build factory and add scenes and sprites.
-
infopanel.driver.
run
(conf_file=None)¶ Run the screen.
infopanel.helpers module¶
Helpers.
-
infopanel.helpers.
date
()¶ Get date today, like: FEB 02.
-
infopanel.helpers.
day_of_week
()¶ Get day of week, like MONDAY.
-
infopanel.helpers.
load_font
(name)¶ Load a font.
-
infopanel.helpers.
time_now
()¶ Get current time like 17:05.
infopanel.mqtt module¶
MQTT client to get data into the display from some data source.
-
class
infopanel.mqtt.
MQTTClient
(data_container, conf)¶ Bases:
object
MQTT Client.
-
on_connect
(client, userdata, flags, rc)¶ Do callback for when MQTT server connects.
-
on_message
(client, userdata, msg)¶ Do callback for when MQTT receives a message.
-
start
()¶ Connect to the MQTT server.
-
stop
()¶ End the MQTT connection.
-
infopanel.scenes module¶
Scenes. One of these will be active at any given time.
-
class
infopanel.scenes.
Blank
(width, height)¶ Bases:
infopanel.scenes.Scene
Just a blank screen.
-
draw_frame
(display)¶ Draw a blank frame.
-
-
class
infopanel.scenes.
Giraffes
(width, height, extra_phrases=None, extra_phrase_frequency=None)¶ Bases:
infopanel.scenes.Scene
A field of giraffes saying things.
-
apply_config
(conf, existing_sprites)¶ Apply Giraffe-specific configuration entries.
-
-
class
infopanel.scenes.
Scene
(width, height)¶ Bases:
object
A single screen’s worth of sprites.
-
apply_config
(conf, existing_sprites)¶ Apply optional extra config.
-
draw_frame
(display)¶ Render all sprites in this scene to display.
-
reinit
()¶ Reinitialize when scene comes back up on the screen.
-
-
class
infopanel.scenes.
Time
(width, height)¶ Bases:
infopanel.scenes.Scene
Basic clock.
-
draw_frame
(display)¶ Draw the current time.
-
-
class
infopanel.scenes.
Welcome
(width, height)¶ Bases:
infopanel.scenes.Scene
Just a welcome message.
-
draw_frame
(display)¶ Draw the welcome frame.
-
-
infopanel.scenes.
scene_factory
(width, height, conf, existing_sprites)¶ Build scenes from config.
infopanel.sprites module¶
There are multiple sprites in any given scene.
-
class
infopanel.sprites.
AnimatedGif
(max_x, max_y, data_source=None)¶ Bases:
infopanel.sprites.BaseImage
Animated gif sprite.
-
check_frame_bounds
()¶ Roll back to first frame if all have been seen.
-
height
¶ Height of the sprite.
-
set_source_path
(path)¶ Set this image source to a new path.
-
width
¶ Width of the sprite.
-
-
class
infopanel.sprites.
BaseImage
(max_x, max_y, data_source=None)¶ Bases:
infopanel.sprites.Sprite
Abstract image.
-
CONF
= <Schema({'dx': <class 'int'>, 'dy': <class 'int'>, 'ticks_per_frame': <class 'int'>, 'ticks_per_movement': <class 'int'>, 'ticks_per_phrase': <class 'int'>, 'min_ticks_per_phrase': <class 'int'>, 'max_ticks_per_phrase': <class 'int'>, 'x': <class 'int'>, 'y': <class 'int'>, 'font_name': <class 'str'>, 'phrases': <class 'list'>, 'pallete': <Schema({Any(<class 'int'>, <class 'str'>, msg=None): <class 'list'>}, extra=PREVENT_EXTRA, required=False) object>, 'frames': <Schema([<class 'str'>], extra=PREVENT_EXTRA, required=False) object>, 'text': <class 'str'>, 'can_flip': <class 'bool'>, 'reverse_frame_loop': <class 'bool'>, 'path': Coerce(str, msg=None)}, extra=PREVENT_EXTRA, required=False) object>¶
-
apply_config
(conf)¶ Validate and apply configuration to this sprite.
-
flip_horizontal
()¶ Images can’t flip… yet.
-
set_source_path
(path)¶ Set this image source to a new path.
-
-
class
infopanel.sprites.
Duration
(max_x, max_y, data_source)¶ Bases:
infopanel.sprites.DynamicFancyText
Text that renders a number (maybe a duration?) with a green-to-red color.
-
CONF
= <Schema({'dx': <class 'int'>, 'dy': <class 'int'>, 'ticks_per_frame': <class 'int'>, 'ticks_per_movement': <class 'int'>, 'ticks_per_phrase': <class 'int'>, 'min_ticks_per_phrase': <class 'int'>, 'max_ticks_per_phrase': <class 'int'>, 'x': <class 'int'>, 'y': <class 'int'>, 'font_name': <class 'str'>, 'phrases': <class 'list'>, 'pallete': <Schema({Any(<class 'int'>, <class 'str'>, msg=None): <class 'list'>}, extra=PREVENT_EXTRA, required=False) object>, 'frames': <Schema([<class 'str'>], extra=PREVENT_EXTRA, required=False) object>, 'text': <class 'str'>, 'can_flip': <class 'bool'>, 'reverse_frame_loop': <class 'bool'>, 'label': Coerce(str, msg=None), 'data_label': Coerce(str, msg=None), 'label_fmt': <class 'str'>, 'val_fmt': <class 'str'>, 'label_color': <class 'str'>, 'value_color': <class 'str'>, 'low_val': Coerce(float, msg=None), 'high_val': Coerce(float, msg=None)}, extra=PREVENT_EXTRA, required=False) object>¶
-
-
class
infopanel.sprites.
DynamicFancyText
(max_x, max_y, data_source)¶ Bases:
infopanel.sprites.FancyText
FancyText that can have a changing/live data source.
This has a
label
configuration to render something like:Label: [value]
-
CONF
= <Schema({'dx': <class 'int'>, 'dy': <class 'int'>, 'ticks_per_frame': <class 'int'>, 'ticks_per_movement': <class 'int'>, 'ticks_per_phrase': <class 'int'>, 'min_ticks_per_phrase': <class 'int'>, 'max_ticks_per_phrase': <class 'int'>, 'x': <class 'int'>, 'y': <class 'int'>, 'font_name': <class 'str'>, 'phrases': <class 'list'>, 'pallete': <Schema({Any(<class 'int'>, <class 'str'>, msg=None): <class 'list'>}, extra=PREVENT_EXTRA, required=False) object>, 'frames': <Schema([<class 'str'>], extra=PREVENT_EXTRA, required=False) object>, 'text': <class 'str'>, 'can_flip': <class 'bool'>, 'reverse_frame_loop': <class 'bool'>, 'label': Coerce(str, msg=None), 'data_label': Coerce(str, msg=None), 'label_fmt': <class 'str'>, 'val_fmt': <class 'str'>, 'label_color': <class 'str'>, 'value_color': <class 'str'>}, extra=PREVENT_EXTRA, required=False) object>¶
-
apply_config
(conf)¶ Validate and apply configuration to this sprite.
-
render
(display)¶ Render a frame and advance.
-
update_value
()¶ Update, but only if the value has changed.
-
-
class
infopanel.sprites.
FancyText
(max_x, max_y, data_source=None)¶ Bases:
infopanel.sprites.Sprite
Text with multiple colors and stuff that can move.
-
add
(text, color)¶ Add a section of text with a constant color.
Color should be a r,g,b tuple.
-
apply_config
(conf)¶ Validate and apply configuration to this sprite.
-
check_frame_bounds
()¶ No frames, no frame delta. .
-
clear
()¶ Remove all text.
-
flip_horizontal
()¶ Flip the sprite horizontally.
-
height
¶ Height of the sprite.
-
render
(display)¶ Render fancy text to screen.
Can have lines that end with newline, and can have multiple colors.
-
width
¶ Width of the sprite.
-
-
class
infopanel.sprites.
Giraffe
(max_x, max_y, data_source=None)¶ Bases:
infopanel.sprites.Sprite
An animated Giraffe.
-
class
infopanel.sprites.
Image
(*args, **kwargs)¶ Bases:
infopanel.sprites.BaseImage
Bitmap image that doesn’t animate.
-
frame
¶ Get the current frame.
-
height
¶ Height of the sprite.
-
set_source_path
(path)¶ Set this image source to a new path.
-
width
¶ Width of the sprite.
-
-
class
infopanel.sprites.
Plant
(max_x, max_y, data_source=None)¶ Bases:
infopanel.sprites.Sprite
A tropical plant.
-
class
infopanel.sprites.
Reddit
(*args, **kwargs)¶ Bases:
infopanel.sprites.FancyText
The titles of some top posts in various subreddits.
-
CONF
= <Schema({'dx': <class 'int'>, 'dy': <class 'int'>, 'ticks_per_frame': <class 'int'>, 'ticks_per_movement': <class 'int'>, 'ticks_per_phrase': <class 'int'>, 'min_ticks_per_phrase': <class 'int'>, 'max_ticks_per_phrase': <class 'int'>, 'x': <class 'int'>, 'y': <class 'int'>, 'font_name': <class 'str'>, 'phrases': <class 'list'>, 'pallete': <Schema({Any(<class 'int'>, <class 'str'>, msg=None): <class 'list'>}, extra=PREVENT_EXTRA, required=False) object>, 'frames': <Schema([<class 'str'>], extra=PREVENT_EXTRA, required=False) object>, 'text': <class 'str'>, 'can_flip': <class 'bool'>, 'reverse_frame_loop': <class 'bool'>, 'client_id': <class 'str'>, 'client_secret': <class 'str'>, 'user_agent': <class 'str'>, 'subreddits': <class 'list'>, 'num_headlines': <class 'int'>, 'update_minutes': <class 'int'>}, extra=PREVENT_EXTRA, required=False) object>¶
-
apply_config
(conf)¶ Validate and apply configuration to this sprite.
-
update_headlines
()¶ Update sprite text based on current subreddit contents.
-
update_phrase
()¶ Occasionally update the headlines.
-
-
class
infopanel.sprites.
Sprite
(max_x, max_y, data_source=None)¶ Bases:
object
A thing that may be animated or not, and may move or not.
-
CONF
= <Schema({'dx': <class 'int'>, 'dy': <class 'int'>, 'ticks_per_frame': <class 'int'>, 'ticks_per_movement': <class 'int'>, 'ticks_per_phrase': <class 'int'>, 'min_ticks_per_phrase': <class 'int'>, 'max_ticks_per_phrase': <class 'int'>, 'x': <class 'int'>, 'y': <class 'int'>, 'font_name': <class 'str'>, 'phrases': <class 'list'>, 'pallete': <Schema({Any(<class 'int'>, <class 'str'>, msg=None): <class 'list'>}, extra=PREVENT_EXTRA, required=False) object>, 'frames': <Schema([<class 'str'>], extra=PREVENT_EXTRA, required=False) object>, 'text': <class 'str'>, 'can_flip': <class 'bool'>, 'reverse_frame_loop': <class 'bool'>}, extra=PREVENT_EXTRA, required=False) object>¶
-
apply_config
(conf)¶ Validate and apply configuration to this sprite.
Generally, each config item becomes a instance attribute.
-
check_frame_bounds
()¶ Reverse back to first frame if all have been seen.
If
reverse_frame_loop
isFalse
, then this just loops the frames continuously.
-
check_movement
()¶ Move if there have been enough ticks, and wrap.
-
check_tick_bounds
()¶ Reset ticks when it reaches some high bound.
This allows you to not have individual counters for everything.
-
flip_horizontal
()¶ Flip the sprite horizontally.
-
frame
¶ Get the current frame.
-
height
¶ Height of the sprite.
-
move
()¶ Move around on the screen.
-
reinit
()¶ Perform actions when the sprite gets put back on the screen.
You could reset position or whatever here.
-
render
(display)¶ Render a frame and advance.
-
tick
()¶ Update the animation ticks.
-
update_frame_num
()¶ Change frame num when there have been enough ticks.
-
update_phrase
()¶ Change the phrase the thing is saying.
-
width
¶ Width of the sprite.
-
-
class
infopanel.sprites.
Temperature
(max_x, max_y, data_source=None)¶ Bases:
infopanel.sprites.Duration
A temperature with color dependent on a high and low bound.
-
infopanel.sprites.
sprite_factory
(config, data_source, disp)¶ Build sprites from config file.
Module contents¶
Infopanel package.