This is a demo CircuitPython host application on the M5Stack CardPuter for the Signaloid C0-microSD Calculator Demo.
cardputer.demo.mp4
This demo application supports the following arithmetic operations of two uniform distributions:
- Addition
- Subtraction
- Multiplication
- Division
Folder src contains the CircuitPython source code that runs on the CardPuter. The CardPuter acts as the host that communicates with a Signaloid C0-microSD through its integrated microSD card slot.
Folder submodules/C0-microSD-utilities/ contains the interface.py library, which is symlinked to the src folder, that defines the interface between the host and the Signaloid C0-microSD.
Folder submodules/signaloid-python/ contains the distributional.py and plot_histogram_dirac_deltas.py libraries, which are symlinked to the src folder, that define the parsing and plotting of the distributional information from the Signaloid C0-microSD results.
The correct way to clone this repository is:
git clone --recursive https://github.com/signaloid/Signaloid-C0-microSD-CardPuter-DemoIf you forgot to clone with --recursive, and end up with empty submodule directories, you can remedy this with
git submodule update --init --recursiveTo build and flash the C0-microSD application, follow the instructions in the Signaloid C0-microSD Calculator Demo. This is mandatory before running the host application, so that the Signaloid C0-microSD is initialized with the correct firmware, and able to communicate with the host.
To prepare the CardPuter for the CircuitPython application, you have to flash it with the CircuitPython firmware following the instructions in the CircuitPython M5Stack CardPuter documentation.
Important
Please use the 9.1.0 version of the CircuitPython firmware, as the latest, at the time of writing, 9.2.5 version causes random crashes when running the host application.
Download the 9.1.0 version from here, or use the Browse S3 button from the CircuitPython M5Stack CardPuter documentation and locate the adafruit-circuitpython-m5stack_cardputer-en_US-9.1.0.uf2 file.
Note
- The guide needs to be run on the Google Chrome browser, it most likely won't work on other browsers (even Chromium-based ones).
- Switch the CardPuter to its bootloader mode: Press and hold the
Btn G0button, which is to the left of theOn/Offswitch, and then plug in the USB type-C cable to connect the CardPuter to your computer. Once connected, you can let theBtn G0. You will not see any reaction from the CardPuter (black screen, no LEDs). However, you should now be able to locate a new serial port device, typicallyttyACM0on Linux, orCOM1on Windows, or similar. - Click the
Open installerbutton on the latest stable CircuitPython release section of the CircuitPython M5Stack CardPuter documentation. - Choose the
Install Bootloader onlyoption, and click next. - Click the
Connectbutton, and choose your new serial port device. ClickContinue, wait until the flashing finishes, and then clickClose. This will erase everything on the CardPuter, and flash the latest bootloader. If no serial port selection window appears, make sure you are using the Chrome browser. - Reboot the CardPuter by pressing the
Btn Rstbutton, at the back of the CardPuter. - You should now be able to see a new
FTHRS3BOOTremovable storage device. If you are using Linux, you have to mount it. - You may now close the installer.
- Locate the
adafruit-circuitpython-m5stack_cardputer-en_US-9.1.0.uf2file you previously downloaded, and copy it to theFTHRS3BOOTdevice. It should now reboot to the CircuitPython firmware. - You should now be able to see a
Hello World!greeting on the CardPuter, and aCIRCUITPYremovable storage device on your computer. If not, try to reboot the CardPuter by pressing theBtn Rstbutton.
To run the Python host application you first need to bundle all library dependencies. To do that run this command from the root folder:
makeThis command will do the following:
- Initialize & update all submodules.
- Apply the necessary patches to the Signaloid Python library, so that it can be used with the CardPuter using CircuitPython.
- Create the
CircuitPythonLibs/folder, where the Adafruit CircuitPython bundle and the Community CircuitPython bundle libraries are downloaded and extracted. - Create the
src/lib/folder, where the CircuitPython libraries are symlinked to.
To copy the CircuitPython application to the CardPuter, run this command from the root folder:
make syncThis command will hard copy all the files and folders from the src folder to the CardPuter. Make sure that you have mounted your CardPuter to your computer, and that the mount path is correctly specified at the DEVICE variable in the Makefile (default is /run/media/<user>/CIRCUITPY).
To live sync the CircuitPython application to the CardPuter, while you are developing or making changes, run this command from the root folder:
make live-syncThis command will first sync all the files and folders from the src folder to the CardPuter, then watch for any changes in the src folder, and live sync them to the CardPuter. Make sure that you have mounted your CardPuter to your computer, and that the mount path is correctly specified at the DEVICE variable in the Makefile (default is /run/media/<user>/CIRCUITPY).
To clean the project, run this command from the root folder:
make cleanThis command will delete the CircuitPythonLibs/, and the src/lib/ folders.
To clean the CardPuter, run this command from the root folder:
make clean-deviceThis command will delete all files and folders from the CardPuter, and will create a new "Hello World" code.py file. Make sure that you have mounted your CardPuter to your computer and that the mount path is correctly specified at the DEVICE variable in the Makefile (default is /run/media/<user>/CIRCUITPY).
The host application is designed to parse two input arguments. Each argument specifies a uniform distribution, represented in the the concise form of uncertainty
notation, i.e., X.Y(Z). The application supports addition, subtraction, multiplication, and division of the input arguments.
usage: {add,sub,mul,div} uniform_distribution1 uniform_distribution2
Host application for C0-microSD calculator application
positional arguments:
{add,sub,mul,div}
Commands
add Add two uniformly distributed random variables
sub Subtract two uniformly distributed random variables
mul Multiply two uniformly distributed random variables
div Divide two uniformly distributed random variables
uniform_distribution1 uniform_distribution2
Two uniform distributions
For example, you can multiply the value 2.0 with a tolerance of +- 0.5 and the value 5.0 with a tolerance of +- 0.3 by running:
mul 2.0(5) 5.0(3)