From 76694786139480526aec076782ae3318ae175f13 Mon Sep 17 00:00:00 2001 From: Jason Shelton Date: Mon, 29 Apr 2019 12:29:32 -0700 Subject: [PATCH 01/22] Added IO_push added function to push a data point to an adafruitio.com feed. Creates feed if it does not exist --- adafruit_pyportal.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index beb03ad..4424142 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -53,7 +53,7 @@ import adafruit_touchscreen import neopixel -from adafruit_esp32spi import adafruit_esp32spi +from adafruit_esp32spi import adafruit_esp32spi, adafruit_esp32spi_wifimanager import adafruit_esp32spi.adafruit_esp32spi_requests as requests try: from adafruit_display_text.text_area import TextArea # pylint: disable=unused-import @@ -69,6 +69,8 @@ import rtc import supervisor +from adafruit_io.adafruit_io import RESTClient, AdafruitIO_RequestError + try: from secrets import secrets except ImportError: @@ -252,6 +254,9 @@ def __init__(self, *, url=None, headers=None, json_path=None, regexp_path=None, if url and not self._uselocal: self._connect_esp() + if self._debug: + print("My IP address is", self._esp.pretty_ip(self._esp.ip_address)) + # set the default background self.set_background(self._default_bg) board.DISPLAY.show(self.splash) @@ -648,7 +653,34 @@ def image_converter_url(image_url, width, height, color_depth=16): return IMAGE_CONVERTER_SERVICE % (aio_username, aio_key, width, height, color_depth, image_url) + + def io_push(self, feed, data): + # pylint: disable=line-too-long + """Push data to an adafruit.io feed + + :param str feed: Name of feed to push data to. + :param data: data to send to feed + + """ + # pylint: enable=line-too-long + + try: + aio_username = secrets['aio_username'] + aio_key = secrets['aio_key'] + except KeyError: + raise KeyError("\n\n") + + wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(self._esp, secrets, None) + io = RESTClient(aio_username, aio_key, wifi) + + try: + feedID = io.get_feed(feed) + except AdafruitIO_RequestError: + # If no feed exists, create one + feedID = io.create_new_feed(feed) + io.send_data(feedID['key'], data) + def fetch(self, refresh_url=None): """Fetch data from the url we initialized with, perfom any parsing, and display text or graphics. This function does pretty much everything From 74b4c5c17fdab67b86d94521174c3498873c7ad7 Mon Sep 17 00:00:00 2001 From: Jason Shelton Date: Mon, 29 Apr 2019 12:45:48 -0700 Subject: [PATCH 02/22] fixed pylint issues --- adafruit_pyportal.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index 4424142..57f394e 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -256,7 +256,7 @@ def __init__(self, *, url=None, headers=None, json_path=None, regexp_path=None, if self._debug: print("My IP address is", self._esp.pretty_ip(self._esp.ip_address)) - + # set the default background self.set_background(self._default_bg) board.DISPLAY.show(self.splash) @@ -669,18 +669,18 @@ def io_push(self, feed, data): aio_key = secrets['aio_key'] except KeyError: raise KeyError("\n\n") - + wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(self._esp, secrets, None) - io = RESTClient(aio_username, aio_key, wifi) + io_connect = RESTClient(aio_username, aio_key, wifi) try: - feedID = io.get_feed(feed) + feed_ID = io_connect.get_feed(feed) except AdafruitIO_RequestError: # If no feed exists, create one - feedID = io.create_new_feed(feed) + feed_ID = io_connect.create_new_feed(feed) + + io_connect.send_data(feed_ID['key'], data) - io.send_data(feedID['key'], data) - def fetch(self, refresh_url=None): """Fetch data from the url we initialized with, perfom any parsing, and display text or graphics. This function does pretty much everything From 0464b87faf27f84488d91df3db719c8198e1f1ca Mon Sep 17 00:00:00 2001 From: Jason Shelton Date: Mon, 29 Apr 2019 12:57:51 -0700 Subject: [PATCH 03/22] more pylint corrections --- adafruit_pyportal.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index 57f394e..1f232e8 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -653,7 +653,7 @@ def image_converter_url(image_url, width, height, color_depth=16): return IMAGE_CONVERTER_SERVICE % (aio_username, aio_key, width, height, color_depth, image_url) - + def io_push(self, feed, data): # pylint: disable=line-too-long """Push data to an adafruit.io feed @@ -674,12 +674,12 @@ def io_push(self, feed, data): io_connect = RESTClient(aio_username, aio_key, wifi) try: - feed_ID = io_connect.get_feed(feed) + feed_id = io_connect.get_feed(feed) except AdafruitIO_RequestError: # If no feed exists, create one - feed_ID = io_connect.create_new_feed(feed) + feed_id = io_connect.create_new_feed(feed) - io_connect.send_data(feed_ID['key'], data) + io_connect.send_data(feed_id['key'], data) def fetch(self, refresh_url=None): """Fetch data from the url we initialized with, perfom any parsing, From 989d77c39ebe5b83693f66adc881057c6e152a0b Mon Sep 17 00:00:00 2001 From: Jason Shelton Date: Mon, 29 Apr 2019 15:14:40 -0700 Subject: [PATCH 04/22] updated docs config --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 355f02b..02ae91b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -23,7 +23,7 @@ autodoc_mock_imports = ["rtc", "supervisor", "pulseio", "audioio", "displayio", "neopixel", "microcontroller", "adafruit_touchscreen", "adafruit_bitmap_font", "adafruit_display_text", "adafruit_esp32spi", "secrets", - "adafruit_sdcard", "storage"] + "adafruit_sdcard", "storage", "adafruit_io"] intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)} From a748fb036aaff6ac8fe5e24e48d29ab3a872dec5 Mon Sep 17 00:00:00 2001 From: Jason Shelton Date: Wed, 1 May 2019 14:27:16 -0700 Subject: [PATCH 05/22] Added exception catching to network related function calls to account for occasional timeout from the esp chip --- adafruit_pyportal.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index 1f232e8..cb0198c 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -678,8 +678,13 @@ def io_push(self, feed, data): except AdafruitIO_RequestError: # If no feed exists, create one feed_id = io_connect.create_new_feed(feed) + except RuntimeError as exception: + print("Some error occured, retrying! -", exception) - io_connect.send_data(feed_id['key'], data) + try: + io_connect.send_data(feed_id['key'], data) + except RuntimeError as exception: + print("Some error occured, retrying! -", exception) def fetch(self, refresh_url=None): """Fetch data from the url we initialized with, perfom any parsing, From 569adef0c64ad343b9771421ed471a16feb49b25 Mon Sep 17 00:00:00 2001 From: Jason Shelton Date: Fri, 3 May 2019 10:36:31 -0700 Subject: [PATCH 06/22] Improved error handling allowing pyportal to retry connections that faail instead of crashing out with an error --- adafruit_pyportal.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index cb0198c..b5193d7 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -673,18 +673,27 @@ def io_push(self, feed, data): wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(self._esp, secrets, None) io_connect = RESTClient(aio_username, aio_key, wifi) - try: - feed_id = io_connect.get_feed(feed) - except AdafruitIO_RequestError: - # If no feed exists, create one - feed_id = io_connect.create_new_feed(feed) - except RuntimeError as exception: - print("Some error occured, retrying! -", exception) - - try: - io_connect.send_data(feed_id['key'], data) - except RuntimeError as exception: - print("Some error occured, retrying! -", exception) + while True: + try: + feed_id = io_connect.get_feed(feed) + except AdafruitIO_RequestError: + # If no feed exists, create one + feed_id = io_connect.create_new_feed(feed) + except RuntimeError as exception: + print("An error occured, retrying! 1 -", exception) + continue + break + + while True: + try: + io_connect.send_data(feed_id['key'], data) + except RuntimeError as exception: + print("An error occured, retrying! 2 -", exception) + continue + except NameError as exception: + print(feed_id['key'], data, exception) + continue + break def fetch(self, refresh_url=None): """Fetch data from the url we initialized with, perfom any parsing, From eb238599e313adcef3ed12ff79d2600aa9a991d3 Mon Sep 17 00:00:00 2001 From: Jason Shelton Date: Mon, 6 May 2019 08:42:47 -0700 Subject: [PATCH 07/22] Style changes as requested --- adafruit_pyportal.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index b5193d7..8079672 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -654,11 +654,11 @@ def image_converter_url(image_url, width, height, color_depth=16): width, height, color_depth, image_url) - def io_push(self, feed, data): + def io_push(self, feed_key, data): # pylint: disable=line-too-long """Push data to an adafruit.io feed - :param str feed: Name of feed to push data to. + :param str feed_key: Name of feed to push data to. :param data: data to send to feed """ @@ -668,17 +668,17 @@ def io_push(self, feed, data): aio_username = secrets['aio_username'] aio_key = secrets['aio_key'] except KeyError: - raise KeyError("\n\n") + raise KeyError("Adafruit IO secrets are kept in secrets.py, please add them there!\n\n") wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(self._esp, secrets, None) - io_connect = RESTClient(aio_username, aio_key, wifi) + io_client = RESTClient(aio_username, aio_key, wifi) while True: try: - feed_id = io_connect.get_feed(feed) + feed_id = io_client.get_feed(feed_key) except AdafruitIO_RequestError: # If no feed exists, create one - feed_id = io_connect.create_new_feed(feed) + feed_id = io_client.create_new_feed(feed_key) except RuntimeError as exception: print("An error occured, retrying! 1 -", exception) continue @@ -686,7 +686,7 @@ def io_push(self, feed, data): while True: try: - io_connect.send_data(feed_id['key'], data) + io_client.send_data(feed_id['key'], data) except RuntimeError as exception: print("An error occured, retrying! 2 -", exception) continue From d2ab7fd98ea69bd3d05e39aeb40ae39d41086905 Mon Sep 17 00:00:00 2001 From: Jason Shelton Date: Tue, 4 Jun 2019 16:12:50 -0700 Subject: [PATCH 08/22] Style changes as requested --- adafruit_pyportal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index 8079672..942da58 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -654,11 +654,11 @@ def image_converter_url(image_url, width, height, color_depth=16): width, height, color_depth, image_url) - def io_push(self, feed_key, data): + def push_to_io(self, feed_key, data): # pylint: disable=line-too-long """Push data to an adafruit.io feed - :param str feed_key: Name of feed to push data to. + :param str feed_key: Name of feed key to push data to. :param data: data to send to feed """ From ace8e0d685d6e28b9941a36f13e6de90f19ac705 Mon Sep 17 00:00:00 2001 From: "Limor \"Ladyada\" Fried" Date: Mon, 8 Jul 2019 20:44:35 -0400 Subject: [PATCH 09/22] Update README.rst --- README.rst | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) diff --git a/README.rst b/README.rst index cdd6f51..472c8d2 100644 --- a/README.rst +++ b/README.rst @@ -39,52 +39,3 @@ Contributions are welcome! Please read our `Code of Conduct `_ before contributing to help this project stay welcoming. -Building locally -================ - -Zip release files ------------------ - -To build this library locally you'll need to install the -`circuitpython-build-tools `_ package. - -.. code-block:: shell - - python3 -m venv .env - source .env/bin/activate - pip install circuitpython-build-tools - -Once installed, make sure you are in the virtual environment: - -.. code-block:: shell - - source .env/bin/activate - -Then run the build: - -.. code-block:: shell - - circuitpython-build-bundles --filename_prefix adafruit-circuitpython-pyportal --library_location . - -Sphinx documentation ------------------------ - -Sphinx is used to build the documentation based on rST files and comments in the code. First, -install dependencies (feel free to reuse the virtual environment from above): - -.. code-block:: shell - - python3 -m venv .env - source .env/bin/activate - pip install Sphinx sphinx-rtd-theme - -Now, once you have the virtual environment activated: - -.. code-block:: shell - - cd docs - sphinx-build -E -W -b html . _build/html - -This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to -view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to -locally verify it will pass. From 0879104d40fcf79ebdeada97e69a62f025ebd019 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Mon, 15 Jul 2019 18:01:48 -0400 Subject: [PATCH 10/22] Add set_headers --- adafruit_pyportal.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index dbaa922..0c0614a 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -362,6 +362,13 @@ def __init__(self, *, url=None, headers=None, json_path=None, regexp_path=None, gc.collect() + def set_headers(self, headers): + """Set the headers used by fetch(). + + :param headers: The new header dictionary + """ + self._headers = headers + def set_background(self, file_or_color, position=None): """The background image to a bitmap file. From 9850a575bd836f597892c32a4e25652f8ae7346c Mon Sep 17 00:00:00 2001 From: brentru Date: Tue, 23 Jul 2019 16:46:38 -0400 Subject: [PATCH 11/22] update IO circuitpython method names --- adafruit_pyportal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index 0c0614a..6da3108 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -69,7 +69,7 @@ import rtc import supervisor -from adafruit_io.adafruit_io import RESTClient, AdafruitIO_RequestError +from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError try: from secrets import secrets From 32fd0b7b5457d0c7cc94f69bcff32b6b4e56fac5 Mon Sep 17 00:00:00 2001 From: brentru Date: Tue, 23 Jul 2019 17:25:06 -0400 Subject: [PATCH 12/22] replace restclient --- adafruit_pyportal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index 6da3108..b5f976f 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -691,7 +691,7 @@ def push_to_io(self, feed_key, data): raise KeyError("Adafruit IO secrets are kept in secrets.py, please add them there!\n\n") wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(self._esp, secrets, None) - io_client = RESTClient(aio_username, aio_key, wifi) + io_client = IO_HTTP(aio_username, aio_key, wifi) while True: try: From 6b6bbc8b89b114b56fd1667c6417e15775d31cc8 Mon Sep 17 00:00:00 2001 From: brentru Date: Wed, 24 Jul 2019 11:51:09 -0400 Subject: [PATCH 13/22] update for compat with pybadge/pygamer with cursor instead of touchscreen --- adafruit_pyportal.py | 49 +++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index b5f976f..5547397 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -50,8 +50,16 @@ import busio from digitalio import DigitalInOut import pulseio -import adafruit_touchscreen import neopixel +try: + import adafruit_touchscreen +except ImportError: + pass +try: + from adafruit_cursorcontrol.cursorcontrol import Cursor + from adafruit_cursorcontrol.cursorcontrol_cursormanager import CursorManager +except ImportError: + pass from adafruit_esp32spi import adafruit_esp32spi, adafruit_esp32spi_wifimanager import adafruit_esp32spi.adafruit_esp32spi_requests as requests @@ -164,6 +172,8 @@ def __init__(self, *, url=None, headers=None, json_path=None, regexp_path=None, self._debug = debug try: + self._backlight = pulseio.PWMOut(board.TFT_LITE) # pylint: disable=no-member + except AttributeError: self._backlight = pulseio.PWMOut(board.TFT_BACKLIGHT) # pylint: disable=no-member except ValueError: self._backlight = None @@ -224,7 +234,10 @@ def __init__(self, *, url=None, headers=None, json_path=None, regexp_path=None, self._speaker_enable = DigitalInOut(board.SPEAKER_ENABLE) self._speaker_enable.switch_to_output(False) - self.audio = audioio.AudioOut(board.AUDIO_OUT) + try: # PyPortal + self.audio = audioio.AudioOut(board.AUDIO_OUT) + except AttributeError: # PyGamer/PyBadge + self.audio = audioio.AudioOut(board.SPEAKER) try: self.play_file("pyportal_startup.wav") except OSError: @@ -347,18 +360,26 @@ def __init__(self, *, url=None, headers=None, json_path=None, regexp_path=None, self._image_position = (0, 0) # default to top corner if not self._image_resize: self._image_resize = (320, 240) # default to full screen - - if self._debug: - print("Init touchscreen") - # pylint: disable=no-member - self.touchscreen = adafruit_touchscreen.Touchscreen(board.TOUCH_XL, board.TOUCH_XR, - board.TOUCH_YD, board.TOUCH_YU, - calibration=((5200, 59000), - (5800, 57000)), - size=(320, 240)) - # pylint: enable=no-member - - self.set_backlight(1.0) # turn on backlight + if hasattr(board, 'TOUCH_XL'): + if self._debug: + print("Init touchscreen") + # pylint: disable=no-member + self.touchscreen = adafruit_touchscreen.Touchscreen(board.TOUCH_XL, board.TOUCH_XR, + board.TOUCH_YD, board.TOUCH_YU, + calibration=((5200, 59000), + (5800, 57000)), + size=(320, 240)) + # pylint: enable=no-member + + self.set_backlight(1.0) # turn on backlight + elif hasattr(board, 'BUTTON_CLOCK'): + if self._debug: + print("Init cursor") + self.mouse_cursor = Cursor(board.DISPLAY, display_group=self.splash, cursor_speed=8) + self.mouse_cursor.hide() + self.cursor = CursorManager(self.mouse_cursor) + else: + raise AttributeError('PyPortal module requires either a touchscreen or gamepad.') gc.collect() From e4aac2f83761528f82c2bfe17e6475d733e2a95f Mon Sep 17 00:00:00 2001 From: brentru Date: Wed, 24 Jul 2019 12:15:35 -0400 Subject: [PATCH 14/22] fix errors on pr per @ladyada review --- adafruit_pyportal.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index 5547397..ec2c26f 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -51,15 +51,10 @@ from digitalio import DigitalInOut import pulseio import neopixel -try: - import adafruit_touchscreen -except ImportError: - pass -try: - from adafruit_cursorcontrol.cursorcontrol import Cursor - from adafruit_cursorcontrol.cursorcontrol_cursormanager import CursorManager -except ImportError: - pass + +import adafruit_touchscreen +from adafruit_cursorcontrol.cursorcontrol import Cursor +from adafruit_cursorcontrol.cursorcontrol_cursormanager import CursorManager from adafruit_esp32spi import adafruit_esp32spi, adafruit_esp32spi_wifimanager import adafruit_esp32spi.adafruit_esp32spi_requests as requests @@ -171,11 +166,11 @@ def __init__(self, *, url=None, headers=None, json_path=None, regexp_path=None, self._debug = debug - try: - self._backlight = pulseio.PWMOut(board.TFT_LITE) # pylint: disable=no-member - except AttributeError: + if hasattr(board, 'TFT_BACKLIGHT'): self._backlight = pulseio.PWMOut(board.TFT_BACKLIGHT) # pylint: disable=no-member - except ValueError: + elif hasattr(board, 'TFT_LITE'): + self._backlight = pulseio.PWMOut(board.TFT_LITE) # pylint: disable=no-member + else: self._backlight = None self.set_backlight(1.0) # turn on backlight @@ -234,10 +229,12 @@ def __init__(self, *, url=None, headers=None, json_path=None, regexp_path=None, self._speaker_enable = DigitalInOut(board.SPEAKER_ENABLE) self._speaker_enable.switch_to_output(False) - try: # PyPortal + if hasattr(board, 'AUDIO_OUT'): self.audio = audioio.AudioOut(board.AUDIO_OUT) - except AttributeError: # PyGamer/PyBadge + elif hasattr(board, 'SPEAKER'): self.audio = audioio.AudioOut(board.SPEAKER) + else: + raise AttributeError('Board does not have a builtin speaker!') try: self.play_file("pyportal_startup.wav") except OSError: From b50095a9f3d9e47145b4c4ed8636c7b8131571f1 Mon Sep 17 00:00:00 2001 From: brentru Date: Wed, 24 Jul 2019 12:18:05 -0400 Subject: [PATCH 15/22] travis --- adafruit_pyportal.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index ec2c26f..b4f2668 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -52,12 +52,13 @@ import pulseio import neopixel +from adafruit_esp32spi import adafruit_esp32spi, adafruit_esp32spi_wifimanager +import adafruit_esp32spi.adafruit_esp32spi_requests as requests + import adafruit_touchscreen from adafruit_cursorcontrol.cursorcontrol import Cursor from adafruit_cursorcontrol.cursorcontrol_cursormanager import CursorManager -from adafruit_esp32spi import adafruit_esp32spi, adafruit_esp32spi_wifimanager -import adafruit_esp32spi.adafruit_esp32spi_requests as requests try: from adafruit_display_text.text_area import TextArea # pylint: disable=unused-import print("*** WARNING ***\nPlease update your library bundle to the latest 'adafruit_display_text' version as we've deprecated 'text_area' in favor of 'label'") # pylint: disable=line-too-long From 87a67f47a41be1399bc02d4eae71f5c5a265f348 Mon Sep 17 00:00:00 2001 From: brentru Date: Wed, 24 Jul 2019 12:20:38 -0400 Subject: [PATCH 16/22] fix docs --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 02ae91b..cd3a222 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -23,7 +23,7 @@ autodoc_mock_imports = ["rtc", "supervisor", "pulseio", "audioio", "displayio", "neopixel", "microcontroller", "adafruit_touchscreen", "adafruit_bitmap_font", "adafruit_display_text", "adafruit_esp32spi", "secrets", - "adafruit_sdcard", "storage", "adafruit_io"] + "adafruit_sdcard", "storage", "adafruit_io", "adafruit_cursorcontrol"] intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)} From dfd1cb4ed164395f3e2d242936be450a12acffec Mon Sep 17 00:00:00 2001 From: Jerry Needell Date: Sun, 28 Jul 2019 16:36:06 -0400 Subject: [PATCH 17/22] choose between touchscreen and cursor manager --- adafruit_pyportal.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index b4f2668..b9645c7 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -55,9 +55,11 @@ from adafruit_esp32spi import adafruit_esp32spi, adafruit_esp32spi_wifimanager import adafruit_esp32spi.adafruit_esp32spi_requests as requests -import adafruit_touchscreen -from adafruit_cursorcontrol.cursorcontrol import Cursor -from adafruit_cursorcontrol.cursorcontrol_cursormanager import CursorManager +if hasattr(board, 'TOUCH_XL'): + import adafruit_touchscreen +elif hasattr(board, 'BUTTON_CLOCK'): + from adafruit_cursorcontrol.cursorcontrol import Cursor + from adafruit_cursorcontrol.cursorcontrol_cursormanager import CursorManager try: from adafruit_display_text.text_area import TextArea # pylint: disable=unused-import From 3d5888011ecec637890781ca8360f7f84fd88f87 Mon Sep 17 00:00:00 2001 From: Jerry Needell Date: Sun, 28 Jul 2019 16:41:42 -0400 Subject: [PATCH 18/22] pylint - move imports --- adafruit_pyportal.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index b9645c7..4b5a069 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -51,6 +51,16 @@ from digitalio import DigitalInOut import pulseio import neopixel +from adafruit_bitmap_font import bitmap_font + +import storage +import adafruit_sdcard +import displayio +import audioio +import rtc +import supervisor + +from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError from adafruit_esp32spi import adafruit_esp32spi, adafruit_esp32spi_wifimanager import adafruit_esp32spi.adafruit_esp32spi_requests as requests @@ -66,16 +76,6 @@ print("*** WARNING ***\nPlease update your library bundle to the latest 'adafruit_display_text' version as we've deprecated 'text_area' in favor of 'label'") # pylint: disable=line-too-long except ImportError: from adafruit_display_text.Label import Label -from adafruit_bitmap_font import bitmap_font - -import storage -import adafruit_sdcard -import displayio -import audioio -import rtc -import supervisor - -from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError try: from secrets import secrets From 30b1a5366b81197c22ff1951163e19cd00f0e3c7 Mon Sep 17 00:00:00 2001 From: Jerry Needell Date: Sun, 28 Jul 2019 16:49:29 -0400 Subject: [PATCH 19/22] pylint - gotta love pylint --- adafruit_pyportal.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index 4b5a069..015615a 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -51,19 +51,18 @@ from digitalio import DigitalInOut import pulseio import neopixel -from adafruit_bitmap_font import bitmap_font - import storage -import adafruit_sdcard import displayio import audioio import rtc import supervisor - -from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError - from adafruit_esp32spi import adafruit_esp32spi, adafruit_esp32spi_wifimanager import adafruit_esp32spi.adafruit_esp32spi_requests as requests +from adafruit_bitmap_font import bitmap_font +from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError +import adafruit_sdcard + + if hasattr(board, 'TOUCH_XL'): import adafruit_touchscreen From 63bcbc1643b73158eaba1285ed86848da7920558 Mon Sep 17 00:00:00 2001 From: Jerry Needell Date: Sun, 28 Jul 2019 16:53:18 -0400 Subject: [PATCH 20/22] pylint - grr -- it passed on my pylint --- adafruit_pyportal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index 015615a..90d6b3c 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -51,13 +51,13 @@ from digitalio import DigitalInOut import pulseio import neopixel +from adafruit_esp32spi import adafruit_esp32spi, adafruit_esp32spi_wifimanager +import adafruit_esp32spi.adafruit_esp32spi_requests as requests import storage import displayio import audioio import rtc import supervisor -from adafruit_esp32spi import adafruit_esp32spi, adafruit_esp32spi_wifimanager -import adafruit_esp32spi.adafruit_esp32spi_requests as requests from adafruit_bitmap_font import bitmap_font from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError import adafruit_sdcard From e1e47183809da43b9af7390953a011f75aaf1d17 Mon Sep 17 00:00:00 2001 From: brentru Date: Mon, 29 Jul 2019 11:13:18 -0400 Subject: [PATCH 21/22] fix tft-in-use-error --- adafruit_pyportal.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index b4f2668..a541c71 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -167,11 +167,12 @@ def __init__(self, *, url=None, headers=None, json_path=None, regexp_path=None, self._debug = debug - if hasattr(board, 'TFT_BACKLIGHT'): - self._backlight = pulseio.PWMOut(board.TFT_BACKLIGHT) # pylint: disable=no-member - elif hasattr(board, 'TFT_LITE'): - self._backlight = pulseio.PWMOut(board.TFT_LITE) # pylint: disable=no-member - else: + try: + if hasattr(board, 'TFT_BACKLIGHT'): + self._backlight = pulseio.PWMOut(board.TFT_BACKLIGHT) # pylint: disable=no-member + elif hasattr(board, 'TFT_LITE'): + self._backlight = pulseio.PWMOut(board.TFT_LITE) # pylint: disable=no-member + except ValueError: self._backlight = None self.set_backlight(1.0) # turn on backlight From 23b2c76a8f278424c5f90bf7682fe21c9620e779 Mon Sep 17 00:00:00 2001 From: brentru Date: Mon, 29 Jul 2019 12:06:37 -0400 Subject: [PATCH 22/22] update to requests --- adafruit_pyportal.py | 5 +++-- docs/conf.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index 28d28c5..4985a34 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -52,7 +52,8 @@ import pulseio import neopixel from adafruit_esp32spi import adafruit_esp32spi, adafruit_esp32spi_wifimanager -import adafruit_esp32spi.adafruit_esp32spi_requests as requests +import adafruit_esp32spi.adafruit_esp32spi_socket as socket +import adafruit_requests as requests import storage import displayio import audioio @@ -273,7 +274,7 @@ def __init__(self, *, url=None, headers=None, json_path=None, regexp_path=None, self._esp.reset() else: raise RuntimeError("Was not able to find ESP32") - requests.set_interface(self._esp) + requests.set_socket(socket, self._esp) if url and not self._uselocal: self._connect_esp() diff --git a/docs/conf.py b/docs/conf.py index cd3a222..ba65728 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -23,7 +23,8 @@ autodoc_mock_imports = ["rtc", "supervisor", "pulseio", "audioio", "displayio", "neopixel", "microcontroller", "adafruit_touchscreen", "adafruit_bitmap_font", "adafruit_display_text", "adafruit_esp32spi", "secrets", - "adafruit_sdcard", "storage", "adafruit_io", "adafruit_cursorcontrol"] + "adafruit_sdcard", "storage", "adafruit_io", "adafruit_cursorcontrol", + "adafruit_requests"] intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}