From 65410e2efe7ea6666f988f8d21222929b0bd5a2c Mon Sep 17 00:00:00 2001 From: Tommy Falgout Date: Mon, 9 Nov 2020 19:32:25 -0600 Subject: [PATCH 1/3] Update readme with simpler Hello World As per #41 --- README.rst | 61 ++++++++++++++++++++++-------------------------------- 1 file changed, 25 insertions(+), 36 deletions(-) diff --git a/README.rst b/README.rst index a503dd2..635e075 100644 --- a/README.rst +++ b/README.rst @@ -37,56 +37,45 @@ Usage Example .. code:: python import time + import random import board import terminalio from adafruit_matrixportal.matrixportal import MatrixPortal - # You can display in 'GBP', 'EUR' or 'USD' - CURRENCY = "USD" - # Set up where we'll be fetching data from - DATA_SOURCE = "https://api.coindesk.com/v1/bpi/currentprice.json" - DATA_LOCATION = ["bpi", CURRENCY, "rate_float"] + # --- Display setup --- + matrixportal = MatrixPortal(status_neopixel=board.NEOPIXEL, debug=True) - - 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 - - - # 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=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=(16, 16), - text_color=0xFFFFFF, - text_transform=text_transform, + text_position=(2, (matrixportal.graphics.display.height // 2) - 1), ) - 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) + SCROLL_DELAY = 0.03 - time.sleep(3 * 60) # wait 3 minutes + contents = [ + { 'text': 'THIS IS RED', 'color': '#cf2727'}, + { 'text': 'THIS IS BLUE', 'color': '#0846e4'}, + ] + + matrixportal.set_text(" ", 1) + while True: + for content in contents: + matrixportal.set_text(content['text']) + # Set the text color + matrixportal.set_text_color(content['color']) + # Scroll it + matrixportal.scroll_text(SCROLL_DELAY) + Contributing ============ From e61c537148cd6a5d13d97e6444e5d3971c5737e9 Mon Sep 17 00:00:00 2001 From: Tommy Falgout Date: Tue, 10 Nov 2020 06:21:56 -0600 Subject: [PATCH 2/3] Removed extra whitespace I had some extra whitespace at the end of my code. Thanks GH actions for catching that! --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 635e075..e73a86d 100644 --- a/README.rst +++ b/README.rst @@ -75,7 +75,7 @@ Usage Example # Scroll it matrixportal.scroll_text(SCROLL_DELAY) - + Contributing ============ From ca5cafcd23a487d5b6dfb7c66ec2b52f524e773d Mon Sep 17 00:00:00 2001 From: Tommy Falgout Date: Thu, 12 Nov 2020 11:37:51 -0600 Subject: [PATCH 3/3] Incorporated comments from PR --- README.rst | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.rst b/README.rst index e73a86d..9dade1a 100644 --- a/README.rst +++ b/README.rst @@ -37,7 +37,6 @@ Usage Example .. code:: python import time - import random import board import terminalio from adafruit_matrixportal.matrixportal import MatrixPortal @@ -52,12 +51,6 @@ Usage Example scrolling=True, ) - # Static 'Connecting' Text - matrixportal.add_text( - text_font=terminalio.FONT, - text_position=(2, (matrixportal.graphics.display.height // 2) - 1), - ) - SCROLL_DELAY = 0.03 contents = [ @@ -65,7 +58,6 @@ Usage Example { 'text': 'THIS IS BLUE', 'color': '#0846e4'}, ] - matrixportal.set_text(" ", 1) while True: for content in contents: matrixportal.set_text(content['text'])