I typically learn new things by alternating between hands-on time and reading study time. After reading through (though not necessarily understand all of) several Python Enhancement Proposals ending with PEP 492 Coroutines with async and await syntax I'm ready to switch back to playing in a code editor. My CircuitPython practice project is to interface with a control panel I salvaged from a Canon MX340 multi-function inkjet. I've successfully accomplished that with a few rough test programs, but I didn't understand what I did, thus the study session.

Now that I understand a bit more of Python generally and CircuitPython in particular, I want to aim higher for my project. Instead of a bunch of test code written on the fly whenever the next idea occurs to me, I should go in and organize things sensibly. I want to learn from Adafruit's collection of CircuitPython libraries to interface with hardware peripherals, following their lead to reorganize my MX340 jumble into a self-contained piece of reusable code. I believe the primary reference would be Adafruit's CircuitPython design guide for community-contributed libraries. I don't understand all of it yet, but I expect to learn by doing and learn from my failures to conform to the design guide. I do not realistically expect my MX340 CircuitPython library to be used by many others. The point of the exercise is to learn how to build such a library, so that a future library I write may actually be useful to others.

Here are my updated goals:

  1. A class to handle serial communication with the NEC K13988 chip on board the control panel, with three functional areas:

    • Buttons: Event queue of button activity, following precedence of Adafruit's keypad class.
    • LEDs: Two boolean properties with get/set to manipulate LEDs under K13988 control.
    • LCD screen: following precedence of Adafruit's rgbmatrix class, either create a byte array for raw frame buffer or use a caller-allocated byte array. Implement a refresh() method which will initiate sending frame buffer data to K13988 for display.

  2. An optional class to wrap the above LCD raw byte array into a MicroPython-style FrameBuffer class. Implemented as adafruit_framebuf with a custom frame buffer manipulation class. This is optional and not part of #1 because the caller may wish to manipulate the byte buffer directly.
  3. Some example code utilizing the above.
  4. After writing example code, decide if it's useful to add one more: An optional class as single point of contact for the entire control panel. Exposing a single event queue integrating direct-control buttons ("Power" and "Stop") with K13988-scanned buttons, and properties for direct-control LEDs ("Power" and "Alarm") peer of K13988-controlled LEDs ("WiFi" and "In Use/Memory")

That seems like a set of achievable goals to guide me as I got started with code reorganizing.