Beispiel #1
0
    def __init__(
        self,
        *,
        url=None,
        headers=None,
        json_path=None,
        regexp_path=None,
        default_bg=0x000000,
        status_neopixel=None,
        json_transform=None,
        esp=None,
        external_spi=None,
        bit_depth=2,
        alt_addr_pins=None,
        color_order="RGB",
        debug=False,
        width=64,
        height=32,
        serpentine=True,
        tile_rows=1,
        rotation=0,
    ):

        graphics = Graphics(
            default_bg=default_bg,
            bit_depth=bit_depth,
            width=width,
            height=height,
            alt_addr_pins=alt_addr_pins,
            color_order=color_order,
            serpentine=serpentine,
            tile_rows=tile_rows,
            rotation=rotation,
            debug=debug,
        )

        network = Network(
            status_neopixel=status_neopixel,
            esp=esp,
            external_spi=external_spi,
            extract_values=False,
            debug=debug,
        )

        super().__init__(
            network,
            graphics,
            url=url,
            headers=headers,
            json_path=json_path,
            regexp_path=regexp_path,
            json_transform=json_transform,
            debug=debug,
        )

        self._scrolling_index = None

        gc.collect()
Beispiel #2
0
def cc_init(cc_state):
    grp_wifi = displayio.Group(max_size=2)
    rect = Rect(0, 0, 32, 32, fill=0x000020, outline=0x444444)
    grp_wifi.append(rect)
    #
    font = cc_state['fonts']['helvB12']
    lbl = label.Label(font, max_glyphs=4, color=0x800000)
    lbl.text = "WiFi"
    lbl.x = 4
    lbl.y = 14
    grp_wifi.append(lbl)
    #
    net = Network(status_neopixel=board.NEOPIXEL, debug=True)
    cc_state['network'] = net
    net.connect()
    #
    return grp_wifi
Beispiel #3
0
def cc_init(cc_state):
    net = Network(status_neopixel=board.NEOPIXEL, debug=True)
    cc_state['network'] = net
    cc_state['network_IP'] = "0.0.0.0"
    net.connect()
    #
    grp_ipaddr = displayio.Group(max_size=3)
    rect = Rect(0, 0, 32, 32, fill=0x000020, outline=0x444444)
    grp_ipaddr.append(rect)
    #
    grp_addr = cc_util.layout_group(IP_ADDR)
    grp_ipaddr.append(grp_addr)
    #
    grp_trip = cc_util.layout_group(IP_TRIPLETS, 0, 10, 15, 3)
    grp_ipaddr.append(grp_trip)
    #
    del IP_ADDR[:]
    del IP_TRIPLETS[:]
    #
    return grp_ipaddr
Beispiel #4
0
    'Violet': 0x663666,
    'White': 0x444444,
}

# Get wifi details and more from a secrets.py file
try:
    from secrets import secrets
except ImportError:
    print("WiFi secrets are kept in secrets.py, please add them there!")
    raise
print("Matrix Clock Plus")

# --- Display setup ---
matrix = Matrix()
display = matrix.display
network = Network(status_neopixel=board.NEOPIXEL, debug=False)
button_down = DigitalInOut(board.BUTTON_DOWN)
button_down.switch_to_input(pull=Pull.UP)
button_up = DigitalInOut(board.BUTTON_UP)
button_up.switch_to_input(pull=Pull.UP)

# --- Weather data setup ---
UNITS = "imperial"
DATA_LOCATION = []
DATA_SOURCE = ("http://api.openweathermap.org/data/2.5/weather?q=" +
               secrets["openweather_loc"] + "&units=" + UNITS)
DATA_SOURCE += "&appid=" + secrets["openweather_token"]
current_temp = '0'

# --- Drawing setup ---
group = displayio.Group(max_size=4)  # Create a Group
Beispiel #5
0
    def __init__(
        self,
        *,
        url=None,
        headers=None,
        json_path=None,
        regexp_path=None,
        default_bg=0x000000,
        status_neopixel=None,
        json_transform=None,
        esp=None,
        external_spi=None,
        bit_depth=2,
        alt_addr_pins=None,
        color_order="RGB",
        debug=False,
        width=64,
        height=32,
    ):

        self._debug = debug
        self.graphics = Graphics(
            default_bg=default_bg,
            bit_depth=bit_depth,
            width=width,
            height=height,
            alt_addr_pins=alt_addr_pins,
            color_order=color_order,
            debug=debug,
        )
        self.display = self.graphics.display

        self.network = Network(
            status_neopixel=status_neopixel,
            esp=esp,
            external_spi=external_spi,
            extract_values=False,
            debug=debug,
        )

        self._url = None
        self.url = url
        self._headers = headers
        self._json_path = None
        self.json_path = json_path

        self._regexp_path = regexp_path

        self.splash = self.graphics.splash

        # Add any JSON translators
        if json_transform:
            self.network.add_json_transform(json_transform)

        self._text = []
        self._text_color = []
        self._text_position = []
        self._text_wrap = []
        self._text_maxlen = []
        self._text_transform = []
        self._text_scrolling = []
        self._text_scale = []
        self._scrolling_index = None
        self._text_font = []
        self._text_line_spacing = []

        gc.collect()
Beispiel #6
0
import time
import board
from adafruit_matrixportal.network import Network

from secrets import secrets
from config import config

network = Network(status_neopixel=board.NEOPIXEL)

def clone_code_file(network, user, repo, branch):
    print("Fetching code updates")
    url = "https://raw.githubusercontent.com/" + user + "/" + repo + "/" + branch + "/portable.py"
    try:
        req = network.fetch(url)
    except RuntimeError as e:
        print(e)
        req = None

    if req:
        with open("portable.py", "w") as code_file:
            code_file.write(req.text)
        print("Success")
    else:
        print("Failure")


p = None
while not p:
    #clone_code_file(network, config['user'], config['repo'], config['branch'])
    try:
        import portable as p
Beispiel #7
0
from new_year import NEW_YEAR

BIT_DEPTH = 6
BLINK = True
DEBUG = False
global year
year = 2020

from secrets import secrets
print("Time will be set for {}".format(secrets["timezone"]))

# --- Display setup ---
matrix = Matrix(bit_depth=BIT_DEPTH)
display = matrix.display
display.brightness = 0.8
network = Network(debug=DEBUG)
BITMAP = displayio.OnDiskBitmap(open('balldrop.bmp', 'rb'))

TILE_GRID = displayio.TileGrid(
    BITMAP,
    pixel_shader=displayio.ColorConverter(),
)


class RowCountdown:
    def __init__(self, display, displayio):
        # --- Drawing setup ---
        self.group = displayio.Group(max_size=10)  # Create a Group
        self.bitmap = displayio.Bitmap(
            64, 32, 5)  # Create a bitmap object,width, height, bit depth
        self.color = displayio.Palette(256)  # Create a color palette