adafruit / Adafruit_CircuitPython_ESP32SPI

ESP32 as wifi with SPI interface
MIT License
103 stars 75 forks source link

Another settings.toml update, slightly different approach #182

Closed RetiredWizard closed 12 months ago

RetiredWizard commented 1 year ago

I decided to take a stab at reworking the examples in this library to work with settings.toml and didn't notice the existing pr #179.

I took a slightly different approach as I didn't actually make any functional changes to the core library. The library currently doesn't directly access the settings.py file but uses a dictionary that is passed in and I decided it was less breaking to simply modify the examples to build the passed in dictionary from settings.toml. I also left a fallback to reading the secrets.py file in the examples because I didn't know when/if any learn guides that might reference the examples would be updated.

I considered just tossing this out, once I spotted the existing PR but since the work was already done, I figured I'd throw it out there anyway. There are advantages to modifying the library to access the secrets directly from the settings.toml environment variable, particularly with regards to simplifying the usage of library and example programs, so I'm not sure my approach makes sense.

edit: I tested most of the example programs using an Arduino Nano Connect RP2040.

RetiredWizard commented 1 year ago

It has occurred to me that having a basic utility to create a secrets dictionary from the settings.toml environment parameters would ease the process of eliminating the secrets.py file. If such a function existed then moving to settings.toml would simply require the replacement of import secrets.py with an assignement similar to secrets = os.build_secrets(). Just a though....