From 3cb54ae0a20f45b7681a23c7984592bd3a5aa863 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Wed, 23 Jul 2025 13:48:48 +0300 Subject: feat: Implement freeform LED video wall --- src/LEDVideoWall.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/LEDVideoWall.h | 20 ++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 src/LEDVideoWall.cpp create mode 100644 src/LEDVideoWall.h (limited to 'src') diff --git a/src/LEDVideoWall.cpp b/src/LEDVideoWall.cpp new file mode 100644 index 0000000..b86afb0 --- /dev/null +++ b/src/LEDVideoWall.cpp @@ -0,0 +1,58 @@ +#include "LEDVideoWall.h" +#include "cli.hpp" +#include + +LEDVideoWall::~LEDVideoWall() { } + +LEDVideoWall* LEDVideoWall::Freeform(mm panel_width, mm panel_height, mm wall_max_width, mm wall_max_height) { + return new LEDVideoWall( + (wall_max_width / panel_width) * panel_width, + (wall_max_height / panel_height) * panel_height); +} + +LEDVideoWall::LEDVideoWall(mm width, mm height) : Screen(width, height) { } + +enum class LEDVideoWallType { + Freeform = 0 +}; + +LEDVideoWall* LEDVideoWall::fromCommandLine() { + mm ipanel_width = 0; + cli::readUserInput( + ipanel_width, + "Enter width for a single panel (in mm): ", + "Invalid panel width, try again!"); + + mm ipanel_height = 0; + cli::readUserInput( + ipanel_height, + "Enter height for a single panel (in mm): ", + "Invalid panel height, try again!"); + + unsigned int itype = 1; + cli::readUserInputMax( + itype, + (unsigned int)1, + "Select an LED video wall type [0 for Freeform]: ", + "Invalid type, try again!"); + + LEDVideoWallType type = static_cast(itype); + switch (type) { + case LEDVideoWallType::Freeform: { + mm iwall_max_width = 0; + cli::readUserInput( + iwall_max_width, + "Enter width for a single wall_max (in mm): ", + "Invalid wall_max width, try again!"); + + mm iwall_max_height = 0; + cli::readUserInput( + iwall_max_height, + "Enter height for a single wall_max (in mm): ", + "Invalid wall_max height, try again!"); + + return LEDVideoWall::Freeform(ipanel_width, ipanel_height, iwall_max_width, iwall_max_height); + }; + } + throw std::logic_error("Implementation error: didn't handle all types of LED video walls!"); +} diff --git a/src/LEDVideoWall.h b/src/LEDVideoWall.h new file mode 100644 index 0000000..043aaed --- /dev/null +++ b/src/LEDVideoWall.h @@ -0,0 +1,20 @@ +#ifndef SG_LEDVIDEOWALL +#define SG_LEDVIDEOWALL + +#include "Screen.h" + +class LEDVideoWall : public Screen { +public: + virtual ~LEDVideoWall(); + + // Named constructor idiom https://isocpp.org/wiki/faq/ctors#named-ctor-idiom + + static LEDVideoWall* Freeform(mm panel_width, mm panel_height, mm wall_max_width, mm wall_max_height); + + static LEDVideoWall* fromCommandLine(); + +private: + LEDVideoWall(mm width, mm height); +}; + +#endif /* SG_LEDVIDEOWALL */ -- cgit v1.3.1-26-gb76a