spacecraft-design-lab-2019 / documentation

Wiki lives in here
https://github.com/spacecraft-design-lab-2019/documentation/wiki
12 stars 3 forks source link

Understanding C-modules in circuitpython #146

Open maholli opened 5 years ago

maholli commented 5 years ago

This issue co-locates a lot of resources for getting started building custom CircuitPython modules as well as specifics about handling large data arrays.

Example modules that use large matrix math

A good starting point might be looking at displayio. Displayio is a core piece of CircuitPython development used to drive complex LCD, OLED, and e-ink displays. This involves storing, manipulating, and refreshing large 2D arrays.

There's also plenty of glue-code that holds it all together and allows you to call things from CircuitPython. You'll get a feel for that by looking at:

Alternatively, good general implementation examples are the various c-modules that make up the "python" functionality.

💡 please jot down your findings as comments to this issue so others can benefit

maholli commented 4 years ago

Building CircuitPython

To build circuitpython, follow the instructions starting here: https://github.com/adafruit/circuitpython/tree/master/ports/atmel-samd#setup

Changing build configurations (like adding ulab)

When building CP, there are files that tell the compiler which aspects of MicroPython to include in the build. There are many of these files, which enable much of the modularity of CP/MP. Some of these files are:

  1. circuitpy_mpconfig.h
  2. the port-specific file (remember, CircuitPython is a port of MicroPython!) mpconfigport.h
  3. and the board-specific file, for example, the kicksat-sprite board: mpconfigboard.h

To include ulab in the CP build, follow the instructions here. Ignore the first bit about cloning MicroPython (you already did that when you cloned CircuitPython). Pay specific attention to this part: image ⭐ Make sure you can build vanilla CircuitPython before trying to add things in. If you've already successfully built CP, then make sure to skip this step for ulab as well: image