-
Notifications
You must be signed in to change notification settings - Fork 0
/
LED_displays.py
42 lines (34 loc) · 1.17 KB
/
LED_displays.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Provide routines to update connected displays such as SenseHat or another LED matrix
TODO
Create OOP implementation. methods: display_text,init,display_color,...
"""
from time import sleep
from loguru import logger
logger.remove() # stop any default logger
LOGGING_LEVEL = "INFO"
# detect various add-on Rpi hats
try:
SenseHatLoaded = True
from sense_hat import SenseHat
from random_colors import Set_Random_Pixels, random_to_solid
SENSEHAT = SenseHat()
except ImportError as e:
SenseHatLoaded = False
logger.info(f"Sense Hat loaded: {SenseHatLoaded}")
@logger.catch
def DisplayMessage(message):
global SENSEHAT
if SenseHatLoaded:
# TODO add additonal data like temp and humidity of server hat
SENSEHAT.show_message(message)
sleep(1)
# TODO monitor joystick input to exit pixel display early
lastColor = Set_Random_Pixels(SENSEHAT)
random_to_solid(SENSEHAT, colorName=lastColor, fast=True)
return True
if __name__ == "__main__":
from pathlib import Path
this_file = Path(__file__)
print(f'This file {this_file} has no current standalone function.')