Skip to content

Added param to disable image converter #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 8, 2020

Conversation

virgilvox
Copy link

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

Moheeb Zara added 2 commits April 27, 2020 17:14
In some cases your image may already be the correct format.
@FoamyGuy
Copy link
Contributor

@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

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look good to me. But untested.

I attempted to test them out but was unable to get a successful test in, and now my PyPortal seems to be stuck in a weird state where it will not succeed fetching any data from the network even with sample scripts unrelated to these changes.

@kattni
Copy link
Contributor

kattni commented Aug 19, 2020

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

@FoamyGuy
Copy link
Contributor

FoamyGuy commented Aug 21, 2020

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
Copy link
Contributor

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
Copy link
Contributor

FoamyGuy commented Sep 4, 2020

#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.

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to successfully test this new parameter with the latest version that uses sdcardio if it's available.

Test on PyPortal 6.0.0-alpha.3

@makermelissa makermelissa merged commit 161a881 into adafruit:master Oct 8, 2020
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Oct 13, 2020
Updating https://github.com/adafruit/Adafruit_CircuitPython_PyPortal to 3.5.0 from 3.4.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#88 from makermelissa/http-errors
  > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#87 from makermelissa/content-headers
  > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#80 from virgilvox/patch-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants