peterhinch / micropython-micro-gui

A lightweight MicroPython GUI library for display drivers based on framebuf, allows input via pushbuttons. See also micropython-touch.
MIT License
247 stars 37 forks source link

Initialize periferies out of code #1

Closed petrkr closed 2 years ago

petrkr commented 2 years ago

Is some way how to initialize SPI/I2C outside of hardware_setup?

This will cause you can not use SPI for other devices (SDCard, card reader etc...) because you can not initialize SPI class more than once. Add Adjuster widgeAdd Adjuster widget and demos. t and demos. 2 months ago

lot of internal classes rely on hardware_setup and it's "ssd" object.

I have one solution like I can do "from hardware_setup import spi" to achieve that, but do not know if that is "good" one.

I will rather initialize spi/i2c in my code and then pass it to external libraries

peterhinch commented 2 years ago

The intention is that hardware_setup.py is a file that you write. This lets you share the bus with other hardware, but you will need to take account of this mechanism to prevent bus contention.