Skip to content

gotbordom/laser-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laser Controller

Small C++17 project for controlling two Necsel lasers with configurable devices, LUT files, and brightness behavior.

Project Layout

.
├── 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

How The Code Is Set Up

  • src/main.cpp
    • Reads config.ini through ConfigParser
    • Parses CLI arguments with CLI11
    • Creates two LaserController instances and applies intensity
  • src/ConfigParser.cpp / src/ConfigParser.h
    • INI parsing and config value conversion helpers (asString, asInt)
  • 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-controller with C++17
    • Uses FetchContent for:
      • nlohmann_json
      • CLI11
    • Enables testing via add_subdirectory(test)
  • test/
    • GoogleTest-based unit tests discovered by CTest

Build Locally

Prereqs:

  • CMake >= 3.16
  • A C++17 compiler (g++/clang++)
  • Make
  • Internet access on first configure (for FetchContent dependencies)

Using Makefile:

make configure
make compile
make run

Run 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 targets

Direct CMake flow:

cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build --parallel
./build/laser-controller

Build and Run In Docker

Dev image (docker/Dockerfile.dev)

Build image:

make build-dev

Start a long-running dev container with repo mounted into /workspace:

make start

Compile from inside container:

docker exec -it laser-controller-dev make compile

Open shell in container:

make shell

Stop/remove container:

make stop
make clean

CI runner image (docker/Dockerfile.ci)

This image is a runner/base environment (it does not build the project at image build time).

Build it:

make build-ci

Or build both images:

make build

Intended CI usage is to run make <target> (for example make test) against checked-out source inside this container.

GitHub Actions

  • .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 (on main)
  • .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

Runtime Config and CLI

Config file defaults are read from config.ini, for example:

  • laser0Device
  • laser1Device
  • lowLightThreshold
  • laser0LUT
  • laser1LUT

CLI options are available via:

./build/laser-controller --help

Common options:

  • -c, --config
  • --intensity
  • --low-light-threshold
  • --laser0-device
  • --laser1-device
  • --laser0-lut
  • --laser1-lut

CLI values override config.ini values.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors