Modmata - A new way to program the Arduino on your LattePanda
Over the course of this past year, I've been working on a senior capstone project for my CS degree. In this project, my group and I were tasked with creating a software environment to simplify programming on the LattePanda using Linux/C. The result is the Modmata library.
What is Modmata?
Modmata is a practical combination of the Firmata library, and the Modbus protocol. Using this new library, you can program and communicate with an Arduino Leonardo using C programs in Linux. This library greatly simplifies Arduino programming for LattePanda users that run Linux.
Our client for the project had bought a LattePanda, and planned to create some Linux programs that used the GPIO of the onboard Arduino Leonardo. Unfortunately, after looking through the LattePanda documentation, he found that most of the documented methods for physical programming on LattePanda require you to run Windows and use a Firmata library in either C# or Python.
If you want to run Linux and program the Arduino in C, there are a few ways to go about doing this, but none are very well supported or specific to the LattePanda setup. In addition, our client was concerned about the speed and reliability of the MIDI protocol, which Firmata is based on.
Modmata solves both of these problems. The library was designed specifically for use on the LattePanda, and it only requires one installer to get started. You don't even need Arduino IDE to set it up!
In addition, since Modmata is built on top of the Modbus protocol, it has error-checking built in and can run faster than Firmata. The speed in which you use it is customizable, but in testing we have been using it at 115,200 baud, rather than the standard 9,600 for Firmata.
How do I get started?
The simplest way to begin programming with Modmata is to use our Linux installer. You can download it as a tarball, and install it using the Makefile. This will upload the code that your Arduino needs to understand Modmata requests, and it will also install our library for C programming, ModmataC.
Once this is all installed, your LattePanda board should blink to indicate that the install is complete. From there, everything should be ready to go! You can write Arduino programs in C using the ModmataC.h library. The library supports programming for digital I/O, analog I/O, servos, I2C, and SPI. You can take a look at the library functions here, and get started with some example programs here.
What else can I do with Modmata?
Modmata is easy to modify, and you can even implement your own custom Modmata functions if you wish. For example, if you install our Modmata Arduino library, you can add functions from other Arduino libraries to the protocol using the Modmata library's attach() function. For example, you can take a look at our Arduino and C programs for adding functions from the Arduino LiquidCrystal library to Modmata.
Modmata Installer: https://github.com/shutch42/Modmata-Complete-Install/releases/tag/v1.1
ModmataC Library: https://github.com/shutch42/ModmataC
Modmata Arduino Library: https://github.com/shutch42/modmata
ModmataC Documentation: https://shutch42.github.io/ModmataC/
Modmata Arduino Library Documentation: https://shutch42.github.io/modmata/html/index.html