Small C++17 project for controlling two Necsel lasers with configurable devices, LUT files, and brightness behavior.
.
├── CMakeLists.txt
├── Makefile
├── config.ini
├── .github/workflows/
│ ├── publish-ci-image.yml
│ └── nightly.yml
├── docker/
│ ├── Dockerfile.dev
│ └── Dockerfile.ci
├── src/
│ ├── ConfigParser.cpp
│ ├── ConfigParser.h
│ ├── main.cpp
│ ├── LaserController.cpp
│ └── LaserController.h
└── test/
├── CMakeLists.txt
├── ConfigParserTests.cpp
└── ParseFaultTests.cpp
src/main.cpp- Reads
config.inithroughConfigParser - Parses CLI arguments with CLI11
- Creates two
LaserControllerinstances and applies intensity
- Reads
src/ConfigParser.cpp/src/ConfigParser.h- INI parsing and config value conversion helpers (
asString,asInt)
- INI parsing and config value conversion helpers (
src/LaserController.cpp/src/LaserController.h- Serial communication and command handling for laser hardware
- LUT loading/interpolation for RGB current values
CMakeLists.txt- Builds
laser-controllerwith C++17 - Uses
FetchContentfor:nlohmann_jsonCLI11
- Enables testing via
add_subdirectory(test)
- Builds
test/- GoogleTest-based unit tests discovered by CTest
Prereqs:
- CMake >= 3.16
- A C++17 compiler (
g++/clang++) - Make
- Internet access on first configure (for
FetchContentdependencies)
Using Makefile:
make configure
make compile
make runRun with CLI args:
make run ARGS="--intensity 40 --low-light-threshold 15"Other useful targets:
make test # Runs all unit tests through CTest
make lint # Builds with strict warnings
make syntax-check # Syntax check for src/main.cpp
make help # Lists all targetsDirect CMake flow:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build --parallel
./build/laser-controllerBuild image:
make build-devStart a long-running dev container with repo mounted into /workspace:
make startCompile from inside container:
docker exec -it laser-controller-dev make compileOpen shell in container:
make shellStop/remove container:
make stop
make cleanThis image is a runner/base environment (it does not build the project at image build time).
Build it:
make build-ciOr build both images:
make buildIntended CI usage is to run make <target> (for example make test) against checked-out source inside this container.
-
.github/workflows/publish-ci-image.yml- Builds
docker/Dockerfile.ci - Publishes to GHCR as:
ghcr.io/<owner>/laser-controller-ci:<sha>ghcr.io/<owner>/laser-controller-ci:<branch>ghcr.io/<owner>/laser-controller-ci:latest(onmain)
- Builds
-
.github/workflows/nightly.yml- Runs every day at
02:00 UTC - Uses the GHCR-hosted container image directly as the job container
- Runs all unit tests with
make test
- Runs every day at
Config file defaults are read from config.ini, for example:
laser0Devicelaser1DevicelowLightThresholdlaser0LUTlaser1LUT
CLI options are available via:
./build/laser-controller --helpCommon options:
-c, --config--intensity--low-light-threshold--laser0-device--laser1-device--laser0-lut--laser1-lut
CLI values override config.ini values.