# random quotes are displayed, updates periodically to look for new quotes
# avoids repeating the same quote twice in a row

import time
import random
import board
import terminalio
from adafruit_matrixportal.matrixportal import MatrixPortal

# --- Display setup ---
matrixportal = MatrixPortal(status_neopixel=board.NEOPIXEL, debug=True)

# Create a new label with the color and text selected
matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(0, (matrixportal.graphics.display.height // 2) - 1),
    scrolling=True,
)

# Static 'Connecting' Text
matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(2, (matrixportal.graphics.display.height // 2) - 1),
)

QUOTES_FEED = "sign-quotes.signtext"
COLORS_FEED = "sign-quotes.signcolor"
SCROLL_DELAY = 0.02
UPDATE_DELAY = 600

quotes = []
Example #2
0
import time
import board
import terminalio
from adafruit_matrixportal.matrixportal import MatrixPortal

# --- Display setup ---
matrixportal = MatrixPortal(status_neopixel=board.NEOPIXEL, debug=False)

RED_COLOR = 0xAA0000
BLUE_COLOR = 0x0000AA

# Red Score
matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(4, int(matrixportal.graphics.display.height * 0.75) - 3),
    text_color=RED_COLOR,
    text_scale=2,
)

# Blue Score
matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(36, int(matrixportal.graphics.display.height * 0.75) - 3),
    text_color=BLUE_COLOR,
    text_scale=2,
)

# Red Team name
matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(4, int(matrixportal.graphics.display.height * 0.25) - 4),
Example #3
0
DATA_SOURCE = "https://www.purpleair.com/json?show=" + str(SENSOR_ID)
SCROLL_DELAY = 0.02
DATA_LOCATION = ["results", 0, "PM2_5Value"]  # navigate the JSON response

# --- Display setup ---
matrixportal = MatrixPortal(
    status_neopixel=board.NEOPIXEL,
    debug=True,
    url=DATA_SOURCE,
    json_path=(DATA_LOCATION, DATA_LOCATION),
)

# Create a static label to show AQI
matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(8, 7),
    text_transform=aqi_transform,
)

# Create a scrolling label to show level message
matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(0, 23),
    scrolling=True,
    text_transform=message_transform,
)


# pylint: disable=too-many-return-statements
def aqi_to_list_index(aqi):
    aqi_groups = (301, 201, 151, 101, 51, 0)
Example #4
0
    "MINUTES",
    "Until",
    "Christmas",
)

SYNCHRONIZE_CLOCK = True

# --- Display setup ---
matrixportal = MatrixPortal(status_neopixel=board.NEOPIXEL, debug=True)

current_frame = None

# Create a new label with the color and text selected
matrixportal.add_text(
    text_font="fonts/Arial-12.bdf",
    text_position=(4, (matrixportal.graphics.display.height // 2) - 1),
    text_color=0xFF0000,
)


def set_time_until(unit=None):
    event_time = time.struct_time((
        EVENT_YEAR,
        EVENT_MONTH,
        EVENT_DAY,
        EVENT_HOUR,
        EVENT_MINUTE,
        0,
        -1,
        -1,
        False,
Example #5
0
mqtt = MQTT.MQTT(
    broker=secrets.get("mqtt_broker"),
    username=secrets.get("mqtt_user"),
    password=secrets.get("mqtt_password"),
    port=1883,
)

MQTT.set_socket(socket, network._wifi.esp)

TEAM_1_COLOR = 0x00AA00
TEAM_2_COLOR = 0xAAAAAA

# Team 1 Score
matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(2, int(matrixportal.graphics.display.height * 0.75) - 3),
    text_color=TEAM_1_COLOR,
    text_scale=2,
)

# Team 2 Score
matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(40, int(matrixportal.graphics.display.height * 0.75) - 3),
    text_color=TEAM_2_COLOR,
    text_scale=2,
)

# Team 1 name
matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(2, int(matrixportal.graphics.display.height * 0.25) - 4),
Example #6
0
# --- Display Setup --- #

# Colors for guide name
colors = [0xFFA500, 0xFFFF00, 0x008000, 0x0000FF, 0x4B0082, 0xEE82EE]

# Delay for scrolling the text
SCROLL_DELAY = 0.03

FONT = "/IBMPlexMono-Medium-24_jep.bdf"

# Learn guide count (ID = 0)
matrixportal.add_text(
    text_font=FONT,
    text_position=(
        (matrixportal.graphics.display.width // 12) - 1,
        (matrixportal.graphics.display.height // 2) - 4,
    ),
    text_color=0x800000,
)
matrixportal.preload_font("0123456789")

# Learn guide title (ID = 1)
matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(2, 25),
    text_color=0x000080,
    scrolling=True,
)


def get_guide_info(index):

# the current working directory (where this file is)
cwd = ("/" + __file__).rsplit("/", 1)[0]

matrixportal = MatrixPortal(
    url=DATA_SOURCE,
    json_path=DATA_LOCATION,
    status_neopixel=board.NEOPIXEL,
    default_bg=cwd + "/bitcoin_background.bmp",
    debug=False,
)

matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(27, 16),
    text_color=0x3d1f5c,
    text_transform=text_transform,
)
matrixportal.preload_font(b"$012345789")  # preload numbers
matrixportal.preload_font((0x00A3, 0x20AC))  # preload gbp/euro symbol

while True:
    try:
        value = matrixportal.fetch()
        print("Response is", value)
    except (ValueError, RuntimeError) as e:
        print("Some error occured, retrying! -", e)

    time.sleep(3 * 60)  # wait 3 minutes
Example #8
0
    TICKER, secrets["apiKey"])
DATA_LOCATION = ["Global Quote", "05. price"]

# the current working directory (where this file is)
cwd = ("/" + __file__).rsplit("/", 1)[0]

matrixportal = MatrixPortal(
    url=DATA_SOURCE,
    json_path=DATA_LOCATION,
    status_neopixel=board.NEOPIXEL,
    debug=False,
)

matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(0, 5),
    text_color=0xAF1F5C,
)

matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(22, 16),
    text_color=0x3D1F5C,
)
matrixportal.preload_font(b"$012345789")  # preload numbers
matrixportal.preload_font(b"ABCDEFGHIJKLMNOPQRSTUVWXYZ")

while True:
    try:
        matrixportal.set_text(TICKER, 0)
Example #9
0
                            headers=HEADERS)

# --- (X,Y) related constants --- #

TEAM_ONE_X = 32
TEAM_ONE_SHADOW_X = TEAM_ONE_X + 1
TEAM_TWO_X = 49
TEAM_TWO_SHADOW_X = TEAM_TWO_X + 1

TOP_ROW_HEIGHT = int(matrixportal.graphics.display.height * 0.25) - 5
BOTTOM_ROW_HEIGHT = int(matrixportal.graphics.display.height * 0.75) - 4

# --- Text Fields --- #

# Team One Score Shadow
matrixportal.add_text(text_font=FONT,
                      text_position=(TEAM_ONE_SHADOW_X, BOTTOM_ROW_HEIGHT))

# Team Two Score Shadow
matrixportal.add_text(text_font=FONT,
                      text_position=(TEAM_TWO_SHADOW_X, BOTTOM_ROW_HEIGHT))

# Team One Score
matrixportal.add_text(text_font=FONT,
                      text_position=(TEAM_ONE_X, BOTTOM_ROW_HEIGHT))

# Team Two Score
matrixportal.add_text(text_font=FONT,
                      text_position=(TEAM_TWO_X, BOTTOM_ROW_HEIGHT))

# Team One Name Shadow
matrixportal.add_text(text_font=FONT,
        return "£%d" % val
    return "%d" % val


# the current working directory (where this file is)
cwd = ("/" + __file__).rsplit("/", 1)[0]

matrixportal = MatrixPortal(
    url=DATA_SOURCE,
    json_path=DATA_LOCATION,
    status_neopixel=board.NEOPIXEL,
)

matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(16, 16),
    text_color=0xFFFFFF,
    text_transform=text_transform,
)
matrixportal.preload_font(b"$012345789")  # preload numbers
matrixportal.preload_font((0x00A3, 0x20AC))  # preload gbp/euro symbol

while True:
    try:
        value = matrixportal.fetch()
        print("Response is", value)
    except (ValueError, RuntimeError) as e:
        print("Some error occured, retrying! -", e)

    time.sleep(3 * 60)  # wait 3 minutes
Example #11
0
    return "$%g Low" % val


def text_Prevoius(val):
    return "$%g Previous" % val


def text_Change(val):
    return "%" + "%g Change" % val


#Price
matrixportal.add_text(
    text_transform=text_Current,
    text_font=FONT,
    text_position=(6, 12),
    text_color=(0xC0C0C0),
    text_scale=1.4,
    scrolling=True,
)

#High
matrixportal.add_text(
    text_transform=text_High,
    text_font=FONT2,
    #text_font=terminalio.FONT,
    text_position=(1, 14),
    text_color=(0x0000AA),
    scrolling=True,
)

#Low
Example #12
0

def text_transform(val):
    if CURRENCY == "USD":
        return "$%d" % val
    if CURRENCY == "EUR":
        return "‎€%d" % val
    if CURRENCY == "GBP":
        return "£%d" % val
    return "%d" % val


#Text1 Price
matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(33, 22),
    text_color=0xffffff,
    text_transform=text_transform,
)

matrixportal.preload_font(b"$012345789")  # preload numbers
matrixportal.preload_font((0x00A3, 0x20AC))  # preload gbp/euro symbol aa

time.sleep(1)  #show first image


def getstonksdata(stonk, profileid):
    print("getstonksdata start")
    print("profile id:", profileid)
    APIKEY = secrets["stonks_key"]
    # Set up where we'll be fetching data from
    DATA_SOURCE = "https://finnhub.io/api/v1/quote?symbol=" + stonk + "&token=" + APIKEY
Example #13
0
matrixportal = MatrixPortal(
    status_neopixel=board.NEOPIXEL,
    bit_depth = 4
)

weather = None

def refresh_data():
    global weather
    temp = matrixportal.network.fetch_data(OPENWEATHER_API_URL, json_path=(TEMP_PATH))[0]
    weather = int(temp)
    matrixportal.get_local_time()

matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(3, 9),
    text_color=TEXT_COLOR,
    text_scale=2,
)
matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(3, 24),
    text_color=TEXT_COLOR,
)

matrixportal.set_text("Connecting", 1)
matrixportal.network.connect()
matrixportal.set_text("Get time", 1)
# matrixportal.get_local_time()
refresh_data()

last_time_refresh = time.time()