The test is done with the following elements:
- a 64x32 Adafruit matrix panel
- a BBC micro:bit v2, having a nRF52833 MCU
- an edge adapter for the micro:bit to plug some Dupont cables
- a Adafruit RGB Matrix bonnet to convert the 3.3V micro:bit GPIO outputs to 5V
- various Dupont cables, that I made to select the size and the required male/female connectors
- there is also a 5V DC power supply which can provide up to 10 A
To deploy, you must set up the tools described in the Rust Discovery Book. Notably:
- Rust (obviously)
- Cargo Embed
- Arm GCC toolchain
- The Rust/LLVM target
thumbv7em-none-eabihf
for micro:bit v2
This project is already configured to be specifically deployed on the micro:bit v2. The memory map is notably prepared for the nrf52833 chip.
The project is current split in:
/nrf52833_rgb_led_matrix
: the main library, with some examples/icon_generator
: a utility to generate Rust code from images
The Cargo Workspace cannot directly be build, due to some issues in mixing compilation targets (the library for ARMv7, and the utility for the local computer), you must go in each directory to launch the Cargo commands.
For instance, to build the library:
$ cd nrf52833_rgb_led_matrix
$ cargo build --release
Unless you need to debug, you must use the release version. The matrix needs frequent refreshes, which will be impeded by the unoptimized code version.
Some examples are also presents in the examples/
directory. To use them:
$ cargo embed --release --example hello_world_blink
What mainly helped me is:
- Adafruit matrix panel - Wiring and working guide, aims Arduino
- hzeller GitHub - Wiring and working guide, also explain some issues if using a 3.3V logic circuits like with Cortex-M.
- Big Mess o' Wires - Basic working example, which helped understand the correct OE/Line/Latch sequence and confirmed some issues I had when not modifying the line selection.
- Adafruit matrix panel code - Give some clues on using binary code modulation for LED colors
Some additional related resources:
- Binary code modulation explanation
- Rust port of code for Rasperry Pi (this one requires an operating system)
To debug and display some metrics, the logging
feature can be enabled.
In order to display the logs using cargo embed
, you can create a
Embed.local.toml
local file, and override some elements from Embed.toml
to
enable RTT.
[default.rtt]
enabled = true
Then you can recompile and inject the code by activating the logging
feature:
$ cargo embed --release --features logging
Some git pre-commit hooks are available. You can install them using:
$ pre-commit install
- For now, code not optimized; notably, GPIO are manipulated one at a time through the HAL instead of manipulating them at once through a direct register access, and I do not really care on precise timings
- Binary Code Modulation is implemented to have more than 8 colors. For now, I only manage to use 2 BCM bit plans with the Microbit, but it should allow about 64 colors? Anyay, the screen is not refreshed quickly enough to allow more colors. No gamma correction.
- I stick to heapless development, which make it a bit hard to design something that can adapt to various LED matrix sizes
- Currrently, globally hard-coded for a 64x32 RGB LED matrix, I have some issues in designing something that can be adapted to other kind of LED Matrix (probably procedural macros are the way, or using a heap and trait objects?)
- I have issues in writting some unit tests, with the message
can't find crate for 'test'
. Possibly related to the use ofno_std
target. - Issues in using
defmt
for logging, I have tildes as output. For now, directly using rtt with some macro when featureslogging
is enabled
MIT License
Copyright (c) 2022, 2023 Vincent Hiribarren
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.