for json_data in color_data:
            colors.append(
                matrixportal.network.json_traverse(json_data, ["value"]))
        print(colors)
    # pylint: disable=broad-except
    except Exception as error:
        print(error)

    if not quotes or not colors:
        raise "Please add at least one quote and color to your feeds"
    matrixportal.set_text(" ", 1)


update_data()
last_update = time.monotonic()
matrixportal.set_text(" ", 1)
quote_index = None
color_index = None

while True:
    # Choose a random quote from quotes
    if len(quotes) > 1 and last_quote is not None:
        while quote_index == last_quote:
            quote_index = random.randrange(0, len(quotes))
    else:
        quote_index = random.randrange(0, len(quotes))
    last_quote = quote_index

    # Choose a random color from colors
    if len(colors) > 1 and last_color is not None:
        while color_index == last_color:
Esempio n. 2
0
# Create library object, use 'slow' 100KHz frequency!
i2c = busio.I2C(board.SCL, board.SDA, frequency=100000)
# Connect to a PM2.5 sensor over I2C
pm25 = PM25_I2C(i2c, reset_pin)

print("Found PM2.5 sensor, reading data...")

while True:
    if (not sensor_refresh) or (time.monotonic() -
                                sensor_refresh) > SENSOR_REFRESH_PERIOD:
        try:
            value = matrixportal.fetch()
            print("PurpleAir response is", value[0])
            matrixportal.set_text_color(get_color(pm_to_aqi(value[0])))
            sensor_refresh = time.monotonic()
        except RuntimeError as e:
            print("Unable to read from PurpleAir, retrying...", e)
            continue
        try:
            aqdata = pm25.read()
            print("Local PlanTower PM2.5 reading is", aqdata["particles 25um"])
            matrixportal.set_text(
                aqi_transform(value[0]) + " " +
                str(pm_to_aqi(aqdata["particles 25um"])), 0)
        except RuntimeError as e:
            print("Unable to read from local sensor, retrying...", e)
        continue

    # Scroll it
    matrixportal.scroll_text(SCROLL_DELAY)
Esempio n. 3
0
    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)

        newdata = matrixportal.network.fetch(DATA_SOURCE)
        current_price = matrixportal.network.json_traverse(
            newdata.json(), DATA_LOCATION)
        matrixportal.set_text("$" + current_price, 1)

    except (ValueError, RuntimeError) as e:
        print("Some error occured, retrying! -", e)

    time.sleep(3 * 60)
Esempio n. 4
0
)

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

SCROLL_DELAY = 0.02
UPDATE_DELAY = 600
UPDATE_DATA_INTERVAL = 1

# PATH to your JSON URL
JSON_URL = "http://your_url_here/"

matrixportal.set_text(" ", 1)
# data = matrixportal.network.fetch(JSON_URL)


def get_new_data(JSON_URL):
    return matrixportal.network.fetch(JSON_URL)


def get_new_json():
    data = get_new_data(JSON_URL)
    new_dict = data.json()
    return new_dict


def get_minute():
    new_time = str(time.localtime())
Esempio n. 5
0
    scrolling=True,
)
 
# Static 'Connecting' Text
matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(2, (matrixportal.graphics.display.height // 2) - 1),
)

QUOTES_FEED = "christmas-messages.display-messages"
SCROLL_DELAY = 0.02
UPDATE_DELAY = 600 
 
quotes = []
colors = ["FF0000", "#2C6F3C" ]
matrixportal.set_text("Starting", 1)

last_update = time.monotonic()
matrixportal.set_text(" ", 1)

def get_quotes_from_feed():
    print("Updating data from Adafruit IO")
 
    matrixportal.set_text("Retrieving", 1)

    try:
        print(QUOTES_FEED)
        quotes_data = matrixportal.get_io_data(QUOTES_FEED)
        quotes.clear()

        for json_data in quotes_data:
Esempio n. 6
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()

epoch = 1584576000 #march 19, 2020 00:00 UTC
seconds_per_day = 24 * 60 * 60

days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']

matrixportal.preload_font(b"012345789Quarantinedy")  # preload numbers
try:
    while True: