pimoroni / pimoroni-pico

Libraries and examples to support Pimoroni Pico add-ons in C++ and MicroPython.
https://shop.pimoroni.com/collections/pico
MIT License
1.33k stars 499 forks source link

Using image.py with pico inky pack #575

Open adamwest9 opened 2 years ago

adamwest9 commented 2 years ago

I can use this to display an image on the inky pack but I want to adjust the buttons to work with the inky buttons I can't find out how to change the configuration.

helgibbons commented 2 years ago

There's some example code for setting up and reading the buttons on Inky Pack here, does that help?

https://github.com/pimoroni/pimoroni-pico/blob/main/micropython/examples/pico_inky/button_test.py

adamwest9 commented 2 years ago

I wanted to use .bin files to save space. Maybe I should be asking how to display .bin files with mircopyrhon over on the inky pack section. I want to use the handy total_images count number of bin files that they used on badger image.py. I did try to reasign the pin number to make it work but that didn't work.

helgibbons commented 2 years ago

Ah, I see what you mean - as far as I can tell there's no display.image function in PicoGraphics that can be used to display images from raw data, like there is in the Badger 2040 module.

Is displaying 1-bit images/icons from a bytearray using PicoGraphics something that can be done @Gadgetoid ? This would come in handy for GFX Pack too!

adamwest9 commented 2 years ago

I established a few things, one is the the buttons on the inky pack are "machine.Pin.PULL_UP" pins and not DOWN pins. so I can get the button.py for the badger 2040 to read the buttons on the inky pack but I can't figure out how to adjust those pins inside of the image.py file.

adamwest9 commented 2 years ago

So now I figured out enough to know that "display.pressed(badger2040.BUTTON_A):" is always reading press, I assume it is because the inky pin is a PULL_UP and the Badger is a PULL_DOWN. If I could only figure out how to switch display.pressed to read press the other way around then everything would work (I think). If tell it to look only for: if display.pressed(badger2040.BUTTON_A): if state["current_image"] < TOTAL_IMAGES - 1: state["current_image"] += 1 changed = True then it will flip through the .bin files until it gets to the end so it is always thinking the button is pressed. Any help would be great.