Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
src/lv_conf.h
build/
bin
scene*.json
114 changes: 114 additions & 0 deletions dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SRC_DIR="${ROOT_DIR}/src"
BIN="${ROOT_DIR}/bin/x32ctrl"

usage() {
cat <<'EOF'
Usage: ./dev.sh [--clean] [--skip-submodules] [--] [x32ctrl args...]
Builds the SDL2 desktop development simulator, then starts it in bodyless
development mode.
Options:
--clean Remove the simulator build output before compiling.
--skip-submodules Do not run git submodule update --init --recursive.
-h, --help Show this help text.
Any remaining arguments are forwarded to x32ctrl after --bodyless.
EOF
}

clean=0
update_submodules=1
app_args=()

while [[ $# -gt 0 ]]; do
case "$1" in
--clean)
clean=1
shift
;;
--skip-submodules)
update_submodules=0
shift
;;
-h|--help)
usage
exit 0
;;
--)
shift
app_args+=("$@")
break
;;
*)
app_args+=("$1")
shift
;;
esac
done

jobs_count() {
if command -v nproc >/dev/null 2>&1; then
nproc 2>/dev/null || echo 4
elif command -v sysctl >/dev/null 2>&1; then
sysctl -n hw.ncpu 2>/dev/null || echo 4
else
echo 4
fi
}

sdl_cflags=""
sdl_libs=""

if command -v sdl2-config >/dev/null 2>&1; then
sdl_cflags="$(sdl2-config --cflags)"
sdl_libs="$(sdl2-config --libs)"
elif command -v pkg-config >/dev/null 2>&1 && pkg-config --exists sdl2; then
sdl_cflags="$(pkg-config --cflags sdl2)"
sdl_libs="$(pkg-config --libs sdl2)"
else
cat >&2 <<'EOF'
SDL2 development files were not found.
Install SDL2, then run this script again:
macOS: brew install sdl2
Debian/Ubuntu: sudo apt install libsdl2-dev
Fedora: sudo dnf install SDL2-devel
EOF
exit 1
fi

case "$(uname -s)" in
Linux)
platform_ldflags="-lrt"
;;
Darwin)
platform_ldflags=""
;;
*)
platform_ldflags=""
;;
esac

if [[ "${update_submodules}" -eq 1 ]]; then
git -C "${ROOT_DIR}" submodule update --init --recursive
fi

if [[ "${clean}" -eq 1 ]]; then
make -C "${SRC_DIR}" -f Makefile_x64_SDL2 clean
fi

common_flags="-g -I../lib -I../lib/libartnet -I../lib/lv_port_linux -I../lib/glaze/include ${sdl_cflags} -MMD -MP -DBODYLESS_SDL2"

make -C "${SRC_DIR}" -f Makefile_x64_SDL2 -j"$(jobs_count)" \
CC="${CC:-cc}" \
CXX="${CXX:-c++}" \
CFLAGS="${CFLAGS:-${common_flags}}" \
CXXFLAGS="${CXXFLAGS:-"-std=c++23 ${common_flags}"}" \
LDFLAGS="${LDFLAGS:-"${sdl_libs} -lm -lpthread ${platform_ldflags}"}"

exec "${BIN}" --bodyless "${app_args[@]}"
4 changes: 4 additions & 0 deletions files/lv_conf_SDL2.h
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,11 @@
#endif

/** Driver for /dev/fb */
#ifdef __APPLE__
#define LV_USE_LINUX_FBDEV 0
#else
#define LV_USE_LINUX_FBDEV 1
#endif
#if LV_USE_LINUX_FBDEV
#define LV_LINUX_FBDEV_BSD 0
#define LV_LINUX_FBDEV_RENDER_MODE LV_DISPLAY_RENDER_MODE_PARTIAL
Expand Down
73 changes: 46 additions & 27 deletions src/Makefile_x64_SDL2
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,34 @@
#LD = arm-linux-gnueabi-ld

LVGL_DIR_NAME ?= lvgl
LVGL_DIR ?= ./lv_port_linux
LVGL_DIR ?= ../lib/lv_port_linux
LVGL_PATH = demosAreDisabledByThisHack
GLAZE_PATH = ./lib
LIB_DIR = ../lib
GLAZE_PATH = ../lib/glaze/include

WARNINGS := -Wall -Wshadow -Wundef -Wextra -Wno-unused-function -Wno-error=strict-prototypes -Wpointer-arith \
-fno-strict-aliasing -Wno-error=cpp -Wuninitialized -Wmaybe-uninitialized -Wno-unused-parameter -Wno-missing-field-initializers -Wtype-limits \
-fno-strict-aliasing -Wno-error=cpp -Wuninitialized -Wno-unused-parameter -Wno-missing-field-initializers -Wtype-limits \
-Wsizeof-pointer-memaccess -Wno-format-nonliteral -Wno-cast-qual -Wunreachable-code -Wno-switch-default -Wreturn-type -Wmultichar -Wformat-security \
-Wno-ignored-qualifiers -Wno-error=pedantic -Wno-sign-compare -Wno-error=missing-prototypes -Wdouble-promotion -Wclobbered -Wdeprecated -Wempty-body \
-Wshift-negative-value -Wstack-usage=2048 -Wno-unused-value
-Wno-ignored-qualifiers -Wno-error=pedantic -Wno-sign-compare -Wno-error=missing-prototypes -Wdouble-promotion -Wdeprecated -Wempty-body \
-Wshift-negative-value -Wno-unused-value

DEPFLAGS = -MMD -MP -D=BODYLESS_SDL2
DEPFLAGS = -MMD -MP -DBODYLESS_SDL2

# normal build
#CFLAGS ?= -O3 -g0 -I$(LVGL_DIR)/ -I $(GLAZE_PATH)/ $(WARNINGS) $(DEPFLAGS)
#CXXFLAGS ?= -std=c++23 -O3 -g0 -I$(LVGL_DIR)/ -I$(GLAZE_PATH)/ $(WARNINGS) $(DEPFLAGS)
#CFLAGS ?= -O3 -g0 -I$(LIB_DIR) -I$(LIB_DIR)/libartnet -I$(LVGL_DIR)/ -I $(GLAZE_PATH)/ $(WARNINGS) $(DEPFLAGS)
#CXXFLAGS ?= -std=c++23 -O3 -g0 -I$(LIB_DIR) -I$(LIB_DIR)/libartnet -I$(LVGL_DIR)/ -I$(GLAZE_PATH)/ $(WARNINGS) $(DEPFLAGS)

# debug build
CFLAGS ?= -g -I$(LVGL_DIR)/ -I$(GLAZE_PATH)/ $(WARNINGS) $(DEPFLAGS)
CXXFLAGS ?= -std=c++23 -g -I$(LVGL_DIR)/ -I$(GLAZE_PATH)/ $(WARNINGS) $(DEPFLAGS)
CFLAGS ?= -g -I$(LIB_DIR) -I$(LIB_DIR)/libartnet -I$(LVGL_DIR)/ -I$(GLAZE_PATH)/ $(WARNINGS) $(DEPFLAGS)
CXXFLAGS ?= -std=c++23 -g -I$(LIB_DIR) -I$(LIB_DIR)/libartnet -I$(LVGL_DIR)/ -I$(GLAZE_PATH)/ $(WARNINGS) $(DEPFLAGS)

LDFLAGS ?= -lSDL2 -lm -lrt -lpthread #-lartnet
LDFLAGS ?= -lSDL2 -lm -lpthread

UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
LDFLAGS += -lrt
WARNINGS += -Wmaybe-uninitialized -Wclobbered -Wstack-usage=2048
endif

BIN = x32ctrl
BUILD_DIR = ../bin
Expand All @@ -38,19 +45,24 @@ BUILD_BIN_DIR = $(BUILD_DIR)
prefix ?= /usr
bindir ?= $(prefix)/bin

# Collect source files recursively
CSRCS := $(shell find \
-path './lv_port_linux/example' -prune -o \
-path './lv_port_linux/lvgl/demos' -prune -o \
-path './lv_port_linux/lvgl/examples' -prune -o \
-path './lv_port_linux/lvgl/tests' -prune -o \
-type f -name '*.c' -not -path './lv_port_linux/src/main.c' -print)
CXXSRCS := $(shell find \
-path './lv_port_linux/example' -prune -o \
-path './lv_port_linux/lvgl/demos' -prune -o \
-path './lv_port_linux/lvgl/examples' -prune -o \
-path './lv_port_linux/lvgl/tests' -prune -o \
-type f -name '*.cpp' -not -path './lv_port_linux/src/main.c' -print)
# Collect source files recursively (macOS and Linux compatible find)
CSRCS := $(shell find . -type f -name '*.c' -print) \
$(shell find ../lib \
-path '../lib/lv_port_linux/example' -prune -o \
-path '../lib/lv_port_linux/lvgl/demos' -prune -o \
-path '../lib/lv_port_linux/lvgl/examples' -prune -o \
-path '../lib/lv_port_linux/lvgl/tests' -prune -o \
-path '../lib/glaze' -prune -o \
-type f -name '*.c' -not -path '../lib/lv_port_linux/src/main.c' -print)

CXXSRCS := $(shell find . -type f -name '*.cpp' -print) \
$(shell find ../lib \
-path '../lib/lv_port_linux/example' -prune -o \
-path '../lib/lv_port_linux/lvgl/demos' -prune -o \
-path '../lib/lv_port_linux/lvgl/examples' -prune -o \
-path '../lib/lv_port_linux/lvgl/tests' -prune -o \
-path '../lib/glaze' -prune -o \
-type f -name '*.cpp' -not -path '../lib/lv_port_linux/src/main.c' -print)

all: copy default

Expand Down Expand Up @@ -84,9 +96,16 @@ $(BUILD_OBJ_DIR)/%.o: %.S lv_conf.h
@echo "AS $<"

copy:
@if ! diff -q lv_conf_SDL2.h lv_port_linux/lv_conf.h >/dev/null 2>&1; then \
cp lv_conf_SDL2.h lv_port_linux/lv_conf.h; \
echo "Update lv_port_linux/lv_conf.h (changed content)"; \
@if ! diff -q ../files/lv_conf_SDL2.h $(LVGL_DIR)/lv_conf.h >/dev/null 2>&1; then \
cp ../files/lv_conf_SDL2.h $(LVGL_DIR)/lv_conf.h; \
echo "Update $(LVGL_DIR)/lv_conf.h (changed content)"; \
else \
echo "lv_conf.h is up to date."; \
fi

@if ! diff -q ../files/lv_conf_SDL2.h lv_conf.h >/dev/null 2>&1; then \
cp ../files/lv_conf_SDL2.h lv_conf.h; \
echo "Update lv_conf.h (changed content)"; \
else \
echo "lv_conf.h is up to date."; \
fi
Expand Down
3 changes: 1 addition & 2 deletions src/artnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
#include "base.h"

using namespace std;
using enum MP_ID;

#if ENABLE_ARTNET

#include "../libartnet/artnet/artnet.h"

class Artnet : public X32Base
{
using enum MP_ID;
public:
Artnet(X32BaseParameter* basepar);
void Init();
Expand Down
2 changes: 2 additions & 0 deletions src/external.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#include <stdarg.h>
#include <unistd.h>
#include <math.h>
#ifndef __APPLE__
#include <linux/input.h>
#endif
#include <set>
#include <map>

Expand Down
1 change: 1 addition & 0 deletions src/lcd-menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ using namespace std;

class LcdMenu : public X32Base {
private:
using enum MP_ID;
Mixer* mixer;
Surface* surface;
bool initDone = false;
Expand Down
10 changes: 10 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ static lv_indev_t *mouse_wheel;
static lv_indev_t *keyboard;
#endif

#ifndef __APPLE__
timer_t timerid_10ms;
struct sigevent sev_10ms;
struct itimerspec trigger_10ms;
#endif
uint8_t vtimercounter = 0;

void timer100msCallbackLvgl(_lv_timer_t* lv_timer) {
Expand All @@ -77,6 +79,8 @@ void timer50msCallbackLvgl(_lv_timer_t* lv_timer) {
void timer10msCallbackLvgl(_lv_timer_t* lv_timer) {
ui_tick(); ctrl->Tick10ms();
}

#ifndef __APPLE__
void timer10msCallbackLinux(int timer) {

ctrl->Tick10ms();
Expand Down Expand Up @@ -122,8 +126,10 @@ void init10msTimer_NonGUI(void) {
perror("timer_settime");
}
}
#endif

void guiInit(X32Config* config) {
using enum MP_ID;

lv_init();

Expand Down Expand Up @@ -389,7 +395,11 @@ int main(int argc, char* argv[]) {
if (config->IsModelX32Core()){
// only necessary if LVGL is not used
helper->Log("Starting Timers...\n");
#ifndef __APPLE__
init10msTimer_NonGUI();
#else
helper->Log("Timers not supported on macOS.\n");
#endif

helper->Log("Press Ctrl+C to terminate program.\n");
while (1) {
Expand Down
3 changes: 1 addition & 2 deletions src/mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
#include "card.h"

using namespace std;
using enum MP_ID;

class Mixer : public X32Base
{
using enum MP_ID;
private:

// solo is (somewhere) activated
Expand Down
11 changes: 7 additions & 4 deletions src/mixerparameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include "defines.h"
#include "enum.h"

#include <stdexcept>
#include <typeinfo>

using namespace std;
using namespace WString;

Expand Down Expand Up @@ -83,7 +86,7 @@ class Mixerparameter
{
if (index >= instances)
{
__throw_out_of_range((String("The index ") + String(index) + String(" is bigger than the specified instances of ") + String(instances) + String(" (zero based!) of the Mixerparameter ") + GetName() + String(".")).c_str());
throw std::out_of_range((String("The index ") + String(index) + String(" is bigger than the specified instances of ") + String(instances) + String(" (zero based!) of the Mixerparameter ") + GetName() + String(".")).c_str());
}
}

Expand All @@ -94,7 +97,7 @@ class Mixerparameter
{
if (mp_value_type != value_type)
{
__throw_bad_typeid();
throw std::bad_typeid();
}
}

Expand All @@ -104,7 +107,7 @@ class Mixerparameter
{
if (readonly)
{
__throw_logic_error((String("The Mixerparameter ") + GetName() + String(" can not be changed, it is readonly.")).c_str());
throw std::logic_error((String("The Mixerparameter ") + GetName() + String(" can not be changed, it is readonly.")).c_str());
}
}

Expand Down Expand Up @@ -884,7 +887,7 @@ class Mixerparameter

if (stepsize == 0)
{
__throw_logic_error((String("Stepsize of Mixerparameter ") + GetName() + String(" is 0, so no change can happen!")).c_str());
throw std::logic_error((String("Stepsize of Mixerparameter ") + GetName() + String(" is 0, so no change can happen!")).c_str());
}

float newValue;
Expand Down
3 changes: 1 addition & 2 deletions src/page-meters.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
#include "page.h"

using namespace std;
using enum MP_ID;

class PageMeters : public Page
{
using enum MP_ID;
private:

lv_obj_t* meterBlocks[9];
Expand Down
2 changes: 2 additions & 0 deletions src/page-routing-channels.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ using namespace std;

class PageRoutingChannels: public Page
{
#ifndef __clang__
using enum MP_ID;
#endif

private:

Expand Down
Loading