Skip to content

marcmerlin/ArduinoOnPc-FastLED-GFX-LEDMatrix

 
 

Repository files navigation

ArduinoOnPc FastLED::GFX LEDMatrix Fork

Blog posts with details:

What?

With this software you can run an Arduino Sketch on your PC using eiher SDL or X11 on linux. It is specifically designed to test code written for any of:

If you have run code that runs on any of those 2D backends, then it will run on this linux X11/SDL backend too:

I also modified the upstream ArduinoOnPC to display on an rPi using RGBPanels thanks to this driver: https://github.com/marcmerlin/FastLED_RPIRGBPanel_GFX ArduinoOnPC is used here to run Arduino code on Raspberry Pis to take advantage of the extra CPU power, extra RAM, etc... In my specific case, it also allows displaying arduino code on the faster and more capable rpi-rgb-led-matrix RGBPanel driver.

After you run git submodules init, you will find my suite of demos from https://github.com/marcmerlin/FastLED_NeoMatrix_SmartMatrix_LEDMatrix_GFX_Demos

How?

Three display drivers: SDL (default on linux/intel), X11 (non default, slow, linux/intel), RGBPanel (linux/rPi)

For development/Debugging, you can also run on PC using the (slow) X11 output or faster SDL output. https://github.com/marcmerlin/ArduinoOnPc-FastLED-GFX-LEDMatrix/blob/master/examples/Makefile
is used to select X11 vs SDL rendering on linux/intel. rPi is auto detected in

ifneq ($(shell uname -m |grep arm),)

In turn this affects https://github.com/marcmerlin/FastLED_NeoMatrix_SmartMatrix_LEDMatrix_GFX_Demos/blob/4436f8b5a71ceea4ef480f75f83b811b037c2cf6/neomatrix_config.h#L39 which will use one of the 3 available rendering backend for ArduinoOnPc.

SDL Driver

The bundled modified FastLED library in git submodules adds an SDL driver which is then used by FastLED NeoMatrix

Please see this code to see how to use the driver:

Because the SDL driver is much faster than talking to real FastLED, the code for linux introduces a slowdown delay (LINUX_RENDERER_SDL_MAIN_DELAY) defined here:

LINUX_RENDERER_SDL_MAIN_DELAY = 10

102_demo_snaps 103_demo_snaps

X11 Driver

git submodules should retrieve the driver for you: https://github.com/marcmerlin/FastLED_TFTWrapper_GFX/

Please see this code to see how to use the driver. It is slower than SDL and left because it was the original option available with this code. If SDL works for you, you should use it instead:

Rpi RGBPanel Driver

git submodules should retrieve the driver for you: https://github.com/marcmerlin/FastLED_RPIRGBPanel_GFX

Please see this code to see how to use the driver (this is for rPi with rpi-rgb-panel):

image

Original "What?" (when this project was only meant to be run on PCs for debugging):

With this software you can run an Arduino Sketch on your PC. You don't need an Arduino hardware. The focus here is mainly on TFTs connected to an Arduino.

This software is made for Linux using the X11 window manager. If you want to use it on windows the only current option is a virtual machine.

Original "Why?" (also when this project was only meant to be run on PCs for debugging):

Some Arduino boards do not have a debugging possibility. To find the errors in your sketches it might be usefull to be able to use a debugger. Using this tool you can debug your program locally, and develop without having to tinker with any additional hardware.

As a reminder this fork is also meant to run Arduino code on rPi.

Installation / Requirements

You need gcc and make installed.

The project uses git submodules to include some Arduino libraries. To get them, you have to run

git submodule init
git submodule update

after checking out the repository.

List of libraries imported (git submodule list)

APIs:

  • libraries/FastLED
  • libraries/LEDMatrix
  • libraries/Framebuffer_GFX: holds a CRGB framebuffer and bridges to Adafruit GFX APIs

Drivers:

  • libraries/FastLED_TFTWrapper_GFX: Small wrapper I wrote to display a Framebuffer_GFX framebuffer in ArduinoOnPC's X11 renderer
  • libraries/FastLED_RPIRGBPanel_GFX: Glue driver that feeds a Framebuffer_GFX framebuffer to rpi-rgb-led-matrix to display on RGB Panels on Raspberry Pi (not needed on a PC)
  • rpi-rgb-led-matrix: Henner Zeller's indispensable library to display on RGBPanels on rPi.

Demo code I gathered/ported/sorted by the API they use (FastLED, FastLED::NeoMatrix/Adafruit::GFX, or LEDMatrix):

  • examples/FastLED_NeoMatrix_SmartMatrix_LEDMatrix_GFX_Demos

If you use FastLED_RPIRGBPanel_GFX, make sure you first build rpi-rgb-led-matrix:

cd rpi-rgb-led-matrix; make

X11

If you don't use my special rPI RGBPanel driver ( https://github.com/marcmerlin/FastLED_RPIRGBPanel_GFX ), or SDL output (better than X11 support), then this project then uses X11. Therefore you have to install X11 support, something like:

sudo apt-get install libx11-dev electric-fence
sudo pacman -Sy libx11 electric-fence
yum install libx11 electric-fence

electric-fence is optional, but recommended since it helps find buffer overruns (actually ASAN is better now, see 
https://github.com/marcmerlin/ArduinoOnPc-FastLED-GFX-LEDMatrix/blob/7e248c4b5db717534a46cb57b45689a3ad847665/makeNativeArduino.mk#L1

BUG: Even if you use the RGB Panel output, compilation will likely needlessly require X11 even if the end binary will not require it.

Compilation

Makefile

# GFX examples that use either SDL (default on intel), X11, or RGBPanel (Default on rPi) output:
cd examples/GFX_Sublime_Demos/
examples/GFX_Sublime_Demos$ make
examples/GFX_Sublime_Demos$ ./Sublime_Demo
# Use numeric keypad + to make brighter or n/p to select demo
# Original examples that only compile with the slow X11 backend (not prefixed by GFX_):
cd examples/Adafruit_touchpaint

# Compile the code
make

# Execute
./Adafruit_touchpaint

Debugging with GCC address sanitizer (ASAN)

A big plus of this code compiling and debugging your code on linux, is that you can compile with gcc ASAN, which will allow you do find memory errors easily. Read this for details: https://github.com/marcmerlin/ArduinoOnPc-FastLED-GFX-LEDMatrix/blob/master/makeNativeArduino.mk#L1

About

Run code for SmartMatrix, Adafruit-GFX-Library, FastLED (2D), and LEDMatrix on linux/Raspberry Pi with X11, SDL, or on top of RGBPanels

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 86.3%
  • C++ 13.3%
  • Makefile 0.4%