adafruit / Adafruit_CircuitPython_PyPortal

CircuitPython driver for Adafruit PyPortal.
MIT License
46 stars 57 forks source link

Added param to disable image converter #80

Closed virgilvox closed 3 years ago

virgilvox commented 4 years ago

I'm doing image conversion in my back-end. I'd like to be able to disable the use of the AIO image converter service

FoamyGuy commented 4 years ago

@virgilvox thank you for adding this. Can you please run the black formatter on the edited code. There is a guide here showing how to install and use it: https://learn.adafruit.com/improve-your-code-with-pylint/black

kattni commented 4 years ago

@FoamyGuy Per our discussion, please try to test this PR. Let me know if you run into issues. Thanks!

FoamyGuy commented 4 years ago

I'm not sure if it's really related to the code in this PR or not to be honest but I have been unable to successfully test this.

I've been trying to test with this code with PyPortal on Circuit Python 5.3.1:

# NOTE: Make sure you've created your secrets.py file before running this example
# https://learn.adafruit.com/adafruit-pyportal/internet-connect#whats-a-secrets-file-17-2
import board
from adafruit_pyportal import PyPortal

# Set a data source URL
IMAGE_URL = "http://192.168.1.109:8000/image_compressed2.bmp"
TEXT_URL = "http://192.168.1.109:8000/test.txt"

# Create the PyPortal object
pyportal = PyPortal(
    url=TEXT_URL,
    image_url_path=IMAGE_URL,
    status_neopixel=board.NEOPIXEL,
    debug=True,
    convert_image=False
)

pyportal.set_background(0xFF00FF)
# Set display to show REPL
#board.DISPLAY.show(None)

# Go get that data
print("Fetching")
data = pyportal.fetch()

while True:
    pass

As sanity test I added a call to set the background of the screen to pink and that is working properly.

The output of the script appears to be normal as far as I can tell. And does indicate that it is setting the image onto the screen.

...
Read 153088 bytes, 650 remaining
Read 153600 bytes, 138 remaining
Read 153738 bytes, 0 remaining
Created file of 153738 bytes in 8.3 seconds
Set background to  /sd/cache.bmp

But the image is not actually shown on the screen. The screen remains pink (or black if I remove the other set_background() call).

I took the SDCard out of the pyportal and verified that the cache.bmp file is getting downloaded to there and the file appears to be fine from a PC.

Perhaps that is enough to approve this PR? The file is getting downloaded and I can see from the console outputs that it's not getting converted via adafruit.io, which is the point of this PR. But I'd definitely feel better about it if I could actually get it showing on the screen.

If I switch my PyPortal to the latest build from S3 I get the same result. File downloaded successfully but not shown on screen.

FoamyGuy commented 4 years ago

Update on this: I think something deeper is going on here preventing set_background() from working properly. I've created #3309 to document my findings because this issue is resulting in the device getting locked up.

FoamyGuy commented 4 years ago

83 resolves the issue by switching from adafruit_sdcard to sdcardio. I think once that change is merged in this PR will be able to be successfully tested.