[{"element_type":"user_image","content":"https://cdn-learn.adafruit.com/user_assets/assets/000/000/501/original/helpers_ai_image.jpg?1701221631","metadata":{"caption":""}},{"element_type":"text","content":"\n        \u003ch2\u003eMaybe It's Just Me\u003c/h2\u003e\n\u003cp\u003eAs I work on different projects I find myself implementing similar things across projects. This has led to a lot of copy/paste work. Which in turn leads to having to update multiple projects when I find an issue or improvement.\u003c/p\u003e\n\u003cp\u003eSo I decided to start a helpers project. It is essentially a set of wrapper classes that I can use across projects.\u003c/p\u003e\n\u003ch2\u003eWhat's In The Big Pink Box?\u003c/h2\u003e\n\u003cp\u003eI've just started to build this project and have started with the ones that were in use with my current projects. I plan to add more as I move to other projects.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003etime_lord.py\n\u003cul\u003e\n\u003cli\u003eProvides a time singleton that supports RTC if desired\u003c/li\u003e\n\u003cli\u003eCurrently does not support using SPI and Network to get the time (maybe in a later release)\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003elocal_logger.py\n\u003cul\u003e\n\u003cli\u003eProvides a logging singleton that supports adding/removing different handlers and accessing files on your SD card\u003c/li\u003e\n\u003cli\u003erotating log files is currently incomplete\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003elocal_mqtt.py\n\u003cul\u003e\n\u003cli\u003eProvides an MQTT singleton that uses SSL by default\u003c/li\u003e\n\u003cli\u003eSupports publishing independently or via the MQTTHandler in adafruit_logging\u0026nbsp;\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch2\u003eAny Gotchas?\u003c/h2\u003e\n\u003cp\u003eI have done my best to keep all the helpers independent. I didn't want to force anyone to use local_logger just to use the time_lord wrapper.\u003c/p\u003e\n\u003cp\u003eThe responsibility use the helpers together falls to the program.\u003c/p\u003e\n\u003ch2\u003eHow Does it Work?\u003c/h2\u003e\n\u003cp\u003eI clone this project into the project in which I want to use the wrappers. From there I just copy the wrappers I'm using to my microcontroller.\u003c/p\u003e\n\u003cp\u003eExample code - implementing time_lord.py without using a real-time clock:\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e...\u003cbr\u003eimport socketpool\u003cbr\u003e\u003cspan\u003eimport \u003c/span\u003ewifi\u003cbr\u003e\u003cspan\u003eimport \u003c/span\u003etime_lord\u003cbr\u003e\u003cbr\u003e...\u003cbr\u003epool = socketpool.SocketPool(wifi.radio)\u003cbr\u003e\u003cbr\u003emy_time = time_lord.configure_time(pool)\u003cbr\u003e\u003cbr\u003e...\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eExample code - implementing local_logger with time_lord and a real-time clock:\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e...\u003cbr\u003eimport rtc\u003cbr\u003eimport socketpool\u003cbr\u003e\u003cspan\u003eimport \u003c/span\u003ewifi\u003cbr\u003e\u003cspan\u003eimport \u003c/span\u003etime_lord\u003cbr\u003eimport local_logger\u003cbr\u003e\u003cbr\u003e...\u003cbr\u003e\u003cbr\u003epool = socketpool.SocketPool(wifi.radio)\u003cbr\u003ertc = RTC()\u0026nbsp; # using a QTPY ESP32 Pico\u003cbr\u003e\u003cbr\u003emy_time = time_lord.configure_time(pool, rtc)\u003cbr\u003emy_log = local_logger.getLocalLogger(use_time=True)\u003cbr\u003e\u003cbr\u003e...\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eExample code - implementing local_mqtt with local_logger without time_lord:\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e...\u003cbr\u003eimport local_mqtt\u003cbr\u003eimport local_logger\u003cbr\u003e\u003cbr\u003e...\u003cbr\u003e\u003cbr\u003emy_log = local_logger.getLocalLogger()\u003cbr\u003emy_mqtt = local_mqtt.getMQTT(use_logger=True)\u003c/code\u003e\u003c/p\u003e\n\u003ch2\u003eWhere To Get the Project\u003c/h2\u003e\n\u003cp\u003eYou can find the project on \u003ca href=\"https://github.com/niccit/circuitpy_helpers/blob/main/local_mqtt.py\"\u003eGithub\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003ePlease feel free to contribute!\u003c/p\u003e\n      ","metadata":{}}]