Skip to content

Commit 31432df

Browse files
committed
Re-added SDL support as a default instead of X11 (faster)
- LINUX_RENDERER_SDL is default since it's much faster for full frame rendering and includes scaling on bigger screens. - Detect Arm vs Intel to turn on local X rendering vs RGBPanel rendering - Re-added delay loop in main.cpp for FastLED rendering
1 parent a304d92 commit 31432df

6 files changed

Lines changed: 30 additions & 4 deletions

File tree

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@
1919
[submodule "rpi-rgb-led-matrix"]
2020
path = rpi-rgb-led-matrix
2121
url = https://github.com/hzeller/rpi-rgb-led-matrix/
22+
[submodule "libraries/FastLED_NeoMatrix"]
23+
path = libraries/FastLED_NeoMatrix
24+
url = https://github.com/marcmerlin/FastLED_NeoMatrix
-874 KB
Binary file not shown.

examples/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
CUSTOM_LIBS := libraries
22

3+
# Use SDL instead of X11. It is faster but requires SDL.
4+
LINUX_RENDERER_SDL = yes
5+
# SDL is even too fast compared to regular neopixels, so we introduce
6+
# a configurable delay here
7+
LINUX_RENDERER_SDL_MAIN_DELAY = 10
8+
39
ARDUINO_LIBS += SPI
410
ARDUINO_LIBS += FastLED
511
ARDUINO_LIBS += Framebuffer_GFX
12+
# LINUX_RENDERER_SDL uses FastLED_NeoMatrix and FastLED
13+
ARDUINO_LIBS += FastLED_NeoMatrix
614
# Comment this out unless you are building for X11 rendering
715
ARDUINO_LIBS += FastLED_TFTWrapper_GFX
816
# Comment this out unless you are building for RGBPanels on rPi

libraries/FastLED_NeoMatrix

Submodule FastLED_NeoMatrix added at 0daa5c3

makeNativeArduino.mk

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,27 @@ CFLAGS += -DARDUINO=101 -DSKETCH_FILE=\"$(SKETCH)\"
1717
CFLAGS += -std=gnu11
1818
CFLAGS += -lm
1919
CFLAGS += -DARDUINOONPC
20-
#CFLAGS += -DFASTLED_SDL $(shell sdl2-config --cflags)
2120

2221
CXXFLAGS += -Wall -Wextra -Wno-unused-parameter
2322
CXXFLAGS += -DARDUINO=101 -DSKETCH_FILE=\"$(SKETCH)\"
2423
CXXFLAGS += -Wno-class-memaccess # FastLED does some naughty things
2524
CXXFLAGS += -std=gnu++11
2625
CXXFLAGS += -DARDUINOONPC
27-
#CXXFLAGS += -DFASTLED_SDL $(shell sdl2-config --cflags)
2826

2927
LDFLAGS += -Wl,--gc-sections
3028
LDFLAGS += -L/usr/X11R6/lib -lX11 # include X11 library
3129
LDFLAGS += -pthread # include linux thread library
3230
# comment this out if you arne't using https://github.com/hzeller/rpi-rgb-led-matrix/
31+
32+
ifneq ($(shell uname -m),x86_64)
33+
#pragma message "ARDUINOONPC building on ARM (guessing rPi), will link against rgbmatrix"
3334
LDFLAGS += -L$(NATIVE_ROOT)/rpi-rgb-led-matrix/lib -lrgbmatrix -lrt
34-
#LDFLAGS += $(shell sdl2-config --libs)
35+
else
36+
ifeq ($(LINUX_RENDERER_SDL),yes)
37+
CXXFLAGS += -DFASTLED_SDL $(shell sdl2-config --cflags) -DLINUX_RENDERER_SDL -DLINUX_RENDERER_SDL_MAIN_DELAY=$(LINUX_RENDERER_SDL_MAIN_DELAY)
38+
LDFLAGS += $(shell sdl2-config --libs)
39+
endif
40+
endif
3541

3642
DEPDIR := $(BUILD_ROOT)
3743
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
@@ -77,6 +83,7 @@ clean:
7783
rm $(TARGET)
7884

7985
print:
86+
@echo "LINUX_RENDERER_SDL:\t $(LINUX_RENDERER_SDL)"
8087
@echo "BUILD_ROOT:\t $(BUILD_ROOT)"
8188
@echo "INCLUDES:\t $(INCLUDES)"
8289
@echo "OBJECTS:\t $(OBJECTS)"
@@ -86,7 +93,9 @@ print:
8693
@echo "SRC_C :\t $(SRC_C)"
8794
@echo "SRC_CXX :\t $(SRC_CXX)"
8895
@echo "SRC_USER:\t $(SRC_USER)"
89-
@echo ":\t $(INC_USER_FOLDERS)"
96+
@echo "INC_USER_FOLDERS:\t $(INC_USER_FOLDERS)"
97+
@echo "CXXFLAGS :\t $(CXXFLAGS)"
98+
@echo "LDFLAGS:\t $(LDFLAGS)"
9099

91100

92101
$(BUILD_ROOT)/%.o : %.c $(DEPDIR)/%.d

src/main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ int main()
4444
{
4545
loop();
4646
delayMicroseconds(10); // leave a little bit calculation time to other applications
47+
#ifdef LINUX_RENDERER_SDL
48+
// SDL rendering is much faster than FastLED pixel pushing, so we add a delay to emulate
49+
// the delay you'd get from real LEDs like WS2812B
50+
delay(LINUX_RENDERER_SDL_MAIN_DELAY);
51+
#endif
4752
}
4853

4954
//closeScreen();

0 commit comments

Comments
 (0)