### Build hueplusplus Examples with CMake Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Build.md Configures and builds the example programs for the hueplusplus library using CMake. This option is enabled by setting 'hueplusplus_EXAMPLES=ON', and the 'hueplusplus_examples' target compiles all examples into the 'build/examples' directory. ```bash mkdir build cd build cmake .. -Dhueplusplus_EXAMPLES=ON make hueplusplus_examples ``` -------------------------------- ### Control Hue Lights Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Getting_Started.md This C++ snippet provides an example of controlling Hue lights. It assumes a Hue object has already been created and authenticated. You can modify properties of individual lights or use transactions for batch updates. Specific commands depend on the Hue API capabilities. ```cpp #include int main() { // Assuming 'hue' is an authenticated hueplusplus::Hue object // hueplusplus::Hue hue = ...; // Example: Get lights std::vector lights = hue.getLights(); if (!lights.empty()) { // Example: Change the color of the first light hueplusplus::RgbColor color; color.r = 255; color.g = 0; color.b = 0; hue.setLightColor(lights[0].id, color); } return 0; } ``` -------------------------------- ### CMake Project Setup and Options Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/CMakeLists.txt Initializes the CMake project, sets the version, and defines boolean options for building tests, examples, and controlling external library usage. These options influence which subdirectories are included and how dependencies are handled. ```cmake cmake_minimum_required(VERSION 3.10.2...3.28) # Add cmake dir to module path, so Find*.cmake can be found set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) project(hueplusplus VERSION 1.2.0 LANGUAGES CXX) # options to set option(hueplusplus_TESTS "Build tests" OFF) option(hueplusplus_EXAMPLES "Build examples" OFF) option(hueplusplus_NO_EXTERNAL_LIBRARIES "Do not try to use external libraries" OFF) ``` -------------------------------- ### Control Hue Groups Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Getting_Started.md This C++ snippet shows how to control groups of Hue lights. Similar to controlling individual lights, it requires an authenticated Hue object. You can modify properties for entire groups at once, simplifying control over multiple devices simultaneously. ```cpp #include int main() { // Assuming 'hue' is an authenticated hueplusplus::Hue object // hueplusplus::Hue hue = ...; // Example: Get groups std::vector groups = hue.getGroups(); if (!groups.empty()) { // Example: Change the brightness of the first group hue.setGroupBrightness(groups[0].id, 128); // Set brightness to 50% } return 0; } ``` -------------------------------- ### Authenticate Hue Bridge (New User) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Getting_Started.md This C++ snippet shows how to authenticate a Hue bridge and obtain a new username. It requires a found bridge object and the BridgeFinder. Authentication requires the user to press the link button on the bridge. The getBridge function returns a Hue object that can be used for further control. ```cpp #include int main() { // Assuming 'bridges' is a vector of hueplusplus::Bridge obtained from findBridges() // hueplusplus::LinHttpHandler handler; // hueplusplus::BridgeFinder finder(handler); // std::vector bridges = finder.findBridges(); if (!bridges.empty()) { // Authenticate the first found bridge hueplusplus::Hue hue = finder.getBridge(bridges[0]); // Now 'hue' object can be used to control lights and groups } return 0; } ``` -------------------------------- ### Install and Uninstall hueplusplus Library Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Build.md Installs or uninstalls the hueplusplus library using make targets after the library has been built. These commands typically copy the compiled library and header files to system-wide locations. ```shell ~/hueplusplus/build $ make install ~/hueplusplus/build $ make uninstall ``` -------------------------------- ### Create Hue Object Manually Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Getting_Started.md This C++ snippet illustrates how to manually create a Hue object when the IP address and username are already known, avoiding the BridgeFinder. It requires the IP address, port, username, and an HttpHandler. This is useful for direct connection without searching. ```cpp #include int main() { // hueplusplus::LinHttpHandler handler; std::string bridgeIp = "YOUR_BRIDGE_IP"; int bridgePort = 80; std::string username = "YOUR_USERNAME"; hueplusplus::Hue hue(bridgeIp, bridgePort, username, handler); // The 'hue' object is now ready for use. return 0; } ``` -------------------------------- ### Search for Hue Bridges Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Getting_Started.md This C++ snippet demonstrates how to search for Hue bridges on the local network. It requires an IHttpHandler implementation (like WinHttpHandler or LinHttpHandler) and the BridgeFinder class. The function returns a vector of found bridges, including their IP and MAC addresses. ```cpp #include int main() { // Choose your HttpHandler // hueplusplus::WinHttpHandler handler; hueplusplus::LinHttpHandler handler; // Create a BridgeFinder with the handler hueplusplus::BridgeFinder finder(handler); // Find bridges std::vector bridges = finder.findBridges(); // Process found bridges (e.g., print their details) for (const auto& bridge : bridges) { std::cout << "Found Bridge: IP=" << bridge.ip << ", MAC=" << bridge.mac << std::endl; } return 0; } ``` -------------------------------- ### Clone hueplusplus Library from GitHub Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Build.md Clones the latest stable version of the hueplusplus library from its GitHub repository. This command fetches all source files into a new directory named 'hueplusplus'. ```shell ~ $ git clone https://github.com/enwi/hueplusplus.git ``` -------------------------------- ### Build hueplusplus with Tests Enabled Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Build.md Configures and builds the hueplusplus library with testing support enabled using CMake. This automatically downloads and includes Google Test and Google Mock if they are not already present. The 'unittest' target compiles and runs all tests. ```bash mkdir build cd build cmake .. -Dhueplusplus_TESTS=ON make unittest ``` -------------------------------- ### Compile and Install hueplusplus Library (Bash) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Mainpage.md This bash script outlines the steps to build and install the hueplusplus library using CMake. It includes creating a build directory, running CMake to configure the build, compiling the code with make (optionally using parallel compilation with -j), and finally installing or uninstalling the library. ```bash mkdir build cd buildcmake .. make make install ``` ```bash make -j4 ``` ```bash make uninstall ``` -------------------------------- ### Authenticate Hue Bridge (Existing User) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Getting_Started.md This C++ snippet demonstrates how to authenticate a Hue bridge when you already have a username. It requires the bridge's IP address, port, and your existing username, along with an HttpHandler. This method bypasses the need for the BridgeFinder and the link button press. ```cpp #include int main() { // hueplusplus::LinHttpHandler handler; std::string bridgeIp = "YOUR_BRIDGE_IP"; int bridgePort = 80; std::string username = "YOUR_USERNAME"; hueplusplus::Hue hue(bridgeIp, bridgePort, username, handler); // Now 'hue' object can be used to control lights and groups return 0; } ``` -------------------------------- ### Run hueplusplus Coverage Tests Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Build.md Executes coverage tests for the hueplusplus library. This requires gcov and lcov to be installed on the system. The 'coveragetest' make target generates a code coverage report. ```bash make coveragetest ``` -------------------------------- ### Install hueplusplus Libraries and Headers (CMake) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/src/CMakeLists.txt This CMake snippet handles the installation of the compiled hueplusplus shared and static libraries to the system's library directory. It also installs the header files from the 'include' directory to the system's include directory. The installation targets are defined using standard CMake installation variables. ```cmake install(TARGETS hueplusplusshared DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(TARGETS hueplusplusstatic DESTINATION ${CMAKE_INSTALL_LIBDIR}) target_include_directories(hueplusplusstatic PUBLIC $ $) install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) ``` -------------------------------- ### Find hueplusplus Library in CMake Project (Installed) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Build.md Integrates the hueplusplus library into an existing CMake project by finding the installed package. This is the preferred method if the library has been successfully installed on the system. ```cmake find_package(hueplusplus REQUIRED) ``` -------------------------------- ### Compile OpenRGB on Linux Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/Documentation/Compiling.md This snippet details the commands to compile OpenRGB on Debian/Ubuntu and Fedora systems. It includes installing dependencies, cloning the repository, configuring the build with qmake, and finally compiling with make. The resulting executable can be run directly or installed system-wide. ```bash sudo apt install git build-essential qtcreator qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libusb-1.0-0-dev libhidapi-dev pkgconf libmbedtls-dev qttools5-dev-tools git clone https://gitlab.com/CalcProgrammer1/OpenRGB cd OpenRGB mkdir build cd build qmake ../OpenRGB.pro make -j$(nproc) ``` ```bash sudo dnf install automake gcc-c++ git hidapi-devel libusbx-devel mbedtls-devel pkgconf qt5-qtbase-devel qt5-linguist git clone https://gitlab.com/CalcProgrammer1/OpenRGB cd OpenRGB mkdir build cd build qmake ../OpenRGB.pro make -j$(nproc) ``` -------------------------------- ### Install and Uninstall hueplusplus Library (Bash) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/README.md These bash commands are used to install and uninstall the hueplusplus library after it has been compiled. 'make install' copies the library files to the system, and 'make uninstall' removes them. ```bash make install make uninstall ``` -------------------------------- ### Find and Build hueplusplus Library in CMake Project (Not Installed) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Build.md Integrates hueplusplus into a CMake project by first attempting to find it and, if not found, adding its source directory to the build. This allows the library to be built as part of the main project, useful when the library is not pre-installed or is included as a submodule. ```cmake find_package(hueplusplus QUIET) if(NOT hueplusplus_FOUND) message(STATUS "-- hueplusplus not found, building it") add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}//hueplusplus" "${CMAKE_CURRENT_BINARY_DIR}/hueplusplus") endif() ``` -------------------------------- ### Compile OpenRGB on Windows Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/Documentation/Compiling.md This snippet shows the command to initiate the OpenRGB build process on Windows using a provided batch script. It requires prior installation of Git and the OpenRGB-Qt-Packages repository. The command takes arguments for the Qt version, MSVC version, and build architecture (32/64-bit). ```batch .\scripts\build-windows.bat 5.15.0 2019 64 ``` -------------------------------- ### Main Source and Optional Subdirectories (CMake) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/CMakeLists.txt Adds the main 'src' subdirectory to the build. Conditionally adds 'test' and 'examples' subdirectories based on the 'hueplusplus_TESTS' and 'hueplusplus_EXAMPLES' options respectively. ```cmake add_subdirectory(src) # if the user decided to use tests add the subdirectory if(hueplusplus_TESTS) add_subdirectory("test") endif() if(hueplusplus_EXAMPLES) add_subdirectory("examples") endif() ``` -------------------------------- ### Build hueplusplus Library with CMake Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Build.md Builds the hueplusplus library using CMake. This involves creating a separate build directory, configuring the build with CMake, and then compiling the library using make. It requires CMake version 3.10 or higher. ```shell ~/hueplusplus $ mkdir build ~/hueplusplus $ cd build ~/hueplusplus/build $ cmake .. ~/hueplusplus/build $ make ``` -------------------------------- ### Linux Kernel Parameter for ACPI Conflict Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/Documentation/SMBusAccess.md Example of how to add the 'acpi_enforce_resources=lax' kernel parameter to the Linux kernel command line to bypass ACPI conflicts with SMBus controllers on some motherboards. ```bash acpi_enforce_resources=lax ``` -------------------------------- ### Link hueplusplus Static Library in CMake Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Build.md Links the hueplusplus library as a static library to an executable target within a CMake project. This ensures that the library's code is directly included in the final executable. ```cmake target_link_libraries( PUBLIC hueplusplusstatic) ``` -------------------------------- ### Build Debian/Ubuntu Package for OpenRGB Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/Documentation/Compiling.md Instructions for creating a Debian package (.deb) for OpenRGB on Debian-based systems. This process involves installing build tools, navigating to the source directory, running a script to prepare package files, and then using dpkg-buildpackage to create the .deb file. ```bash sudo apt install debhelper cd ~/OpenRGB scripts/build-package-files.sh debian/changelog dpkg-buildpackage -us -B ``` -------------------------------- ### CMake: Find and Link hueplusplus Library Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Mainpage.md Demonstrates how to use CMake's find_package() to locate the hueplusplus library and link against its static version. This method assumes the library is already installed on the system. ```cmake find_package(hueplusplus REQUIRED) target_link_libraries( PUBLIC hueplusplusstatic) ``` -------------------------------- ### Build Type and Installation Directory Configuration (CMake) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/CMakeLists.txt Sets the default build type to 'Release' if none is specified and configures the installation directory for CMake files, adapting the path based on the operating system (Windows vs. others). ```cmake # Set default build type if none was specified set(default_build_type "Release") if(hueplusplus_master_project AND (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)) message(STATUS "Setting build type to '${default_build_type}' as none was specified") set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) # Set possible values for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() # get the correct installation directory for add_library() to work if(WIN32 AND NOT CYGWIN) set(DEF_INSTALL_CMAKE_DIR cmake) else() set(DEF_INSTALL_CMAKE_DIR lib/cmake/hueplusplus) endif() set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files") ``` -------------------------------- ### Get and Control a Specific Light (C++) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/README.md This snippet demonstrates how to get a reference to a specific light by its ID and then call various functions to control its properties like power, brightness, color, and effects. It also shows how to check for supported features. ```C++ hueplusplus::Light light1 = bridge.lights().get(1); light1.on(); light1.setBrightness(120); light1.alertHueSaturation(25500, 255); light1.setColorLoop(true); light1.setColorRGB(255, 128, 0); lights[1].off(); lights.at(1).setColorHue(4562); hueplusplus::ColorType type1 = light1.getColorType(); light1.hasBrightnessControl(); light1.hasTemperatureControl(); light1.hasColorControl(); ``` -------------------------------- ### Update hueplusplus Library with Git Rebase Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Build.md Updates the local hueplusplus library to the latest version available in the remote repository using 'git pull' with the '--rebase' option. This ensures a cleaner commit history by replaying local changes on top of the fetched updates. ```shell ~/hueplusplus $ git pull --rebase ``` -------------------------------- ### Build Fedora RPM Package for OpenRGB Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/Documentation/Compiling.md This snippet outlines the steps to build an RPM package for OpenRGB on Fedora. It includes installing RPM development tools, setting up the RPM build environment, preparing the source tarball, configuring the spec file, and finally building the RPM package using rpmbuild. ```bash sudo dnf install rpmdevtools dnf-plugins-core cd ~/ rpmdev-setuptree tar -cf rpmbuild/SOURCES/OpenRGB.tar.gz OpenRGB/ cd OpenRGB ./scripts/build-package-files.sh fedora/OpenRGB.spec cd ~/ cp OpenRGB/fedora/OpenRGB.spec rpmbuild/SPECS/ sudo dnf builddep rpmbuild/SPECS/OpenRGB.spec -y cd rpmbuild/SOURCES tar -xf OpenRGB.tar.gz cd ~/ rpmbuild -ba rpmbuild/SPECS/OpenRGB.spec ``` -------------------------------- ### Compile OpenRGB on macOS Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/Documentation/Compiling.md This snippet details the process for compiling OpenRGB on macOS. It involves installing dependencies via Homebrew, cloning the repository, configuring with qmake, building with make, and finally using macdeployqt for application bundling and code signing. ```bash brew install git qt5 hidapi libusb mbedtls@2 brew link qt5 git clone https://gitlab.com/CalcProgrammer1/OpenRGB cd OpenRGB qmake OpenRGB.pro make -j8 macdeployqt OpenRGB.app -codesign=OpenRGB ``` -------------------------------- ### Link hueplusplus Static Library in CMake (CMake) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/README.md This CMake snippet shows how to find the installed hueplusplus library and link its static version to an executable. It assumes the library has been installed system-wide. ```cmake find_package(hueplusplus REQUIRED) target_link_libraries( PUBLIC hueplusplusstatic) ``` -------------------------------- ### Linux Automatic SMBus Module Loading Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/Documentation/SMBusAccess.md Instructions to configure Linux to automatically load SMBus/I2C kernel modules at boot. This involves creating a configuration file and adding the desired module names. ```bash sudo touch /etc/modules-load.d/i2c.conf sudo sh -c 'echo "i2c-dev" >> /etc/modules-load.d/i2c.conf' sudo sh -c 'echo "i2c-i801" >> /etc/modules-load.d/i2c.conf' sudo sh -c 'echo "i2c-piix4" >> /etc/modules-load.d/i2c.conf' ``` -------------------------------- ### Linux SMBus Controller Detection and User Access Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/Documentation/SMBusAccess.md Commands to list SMBus controllers on Linux and grant user access to them. This is necessary if OpenRGB is not run as root. ```bash sudo i2cdetect -l ``` -------------------------------- ### Control Hue Lights (C++) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Mainpage.md This C++ code demonstrates how to control Philips Hue lights using the hueplusplus library. It shows how to get a specific light by its ID, retrieve all lights associated with a bridge, and then call functions to control the light's properties. It also includes methods to check the light's color type and the availability of specific functions. ```cpp auto light = bridge.lights().get(0); light.setBrightness(128); ``` ```cpp auto allLights = bridge.lights().getAll(); ``` ```cpp light.setColorName("blue"); ``` ```cpp auto colorType = light.getColorType(); ``` ```cpp auto hasColor = light.hasColor(); ``` -------------------------------- ### Linux SMBus Module Loading Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/Documentation/SMBusAccess.md Commands to load SMBus/I2C kernel modules on Linux, including i2c-dev, i2c-i801 (Intel), i2c-piix4 (AMD), and i2c-nct6793 (Nuvoton). These are essential for OpenRGB to communicate with hardware. ```bash sudo modprobe i2c-dev sudo modprobe i2c-i801 sudo modprobe i2c-piix4 sudo modprobe i2c-nct6793 ``` -------------------------------- ### Get All Lights and Control (C++) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/README.md This C++ snippet shows how to retrieve a vector of all lights controlled by the bridge and access individual lights by their index to control them. If no lights are found, the vector will be empty. ```C++ std::vector lights = bridge.lights().getAll(); lights[1].off(); lights.at(1).setColorHue(4562); ``` -------------------------------- ### Define hueplusplus Shared and Static Libraries (CMake) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/src/CMakeLists.txt This snippet defines both a shared and a static library for hueplusplus using the collected source files. It specifies dependencies on MbedTLS and nlohmann_json, sets the C++ standard to C++14, and configures include directories for both build and installation targets. It also handles platform-specific output names for the libraries. ```cmake # hueplusplus shared library add_library(hueplusplusshared SHARED ${hueplusplus_SOURCES}) target_link_libraries(hueplusplusshared PRIVATE MbedTLS::mbedtls) target_link_libraries(hueplusplusshared PUBLIC nlohmann_json::nlohmann_json) target_compile_features(hueplusplusshared PUBLIC cxx_std_14) target_include_directories(hueplusplusshared PUBLIC $ $) # hueplusplus static library add_library(hueplusplusstatic STATIC ${hueplusplus_SOURCES}) target_link_libraries(hueplusplusstatic PRIVATE MbedTLS::mbedtls) target_link_libraries(hueplusplusstatic PUBLIC nlohmann_json::nlohmann_json) target_compile_features(hueplusplusstatic PUBLIC cxx_std_14) if(NOT WIN32) # On windows, a shared library will also generate a .lib import library, making different names necessary. # On other platforms the file endings are different, so the names can be the same. set_target_properties(hueplusplusshared PROPERTIES OUTPUT_NAME hueplusplus SOVERSION 1) set_target_properties(hueplusplusstatic PROPERTIES OUTPUT_NAME hueplusplus) endif() ``` -------------------------------- ### Export hueplusplus Package and Generate Config File (CMake) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/src/CMakeLists.txt This CMake code exports the hueplusplus package for use in other projects and generates a configuration file ('hueplusplus-config.cmake.in'). The generated configuration file is then installed, allowing downstream projects to easily find and use the hueplusplus library. ```cmake # Export the package for use from the build-tree # (this registers the build-tree with a global CMake-registry) export(PACKAGE hueplusplus) # Create the hueplusplus-config.cmake configure_file ("${PROJECT_SOURCE_DIR}/cmake/hueplusplus-config.cmake.in" "${hueplusplus_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hueplusplus-config.cmake" @ONLY) # Install hueplusplus-config.cmake install(FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hueplusplus-config.cmake" DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev) ``` -------------------------------- ### Uninstall Target Configuration (CMake) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/CMakeLists.txt Creates a custom 'uninstall' target by generating a CMake script from a template and executing it. This allows users to cleanly remove installed files. ```cmake # target for uninstall if(NOT TARGET uninstall) configure_file( "${PROJECT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" "${PROJECT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) endif() ``` -------------------------------- ### Shared State Refresh Example (C++) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Shared_State.md Illustrates the hierarchical refresh process in shared state caching for the OpenRGB library. When shared state is enabled, refreshes are performed based on the last update time and refresh duration of different cache levels. This example shows how calling a non-const method like `isOn()` on a light can trigger updates at various levels, from the specific light to the entire bridge, depending on the state's staleness. ```cpp auto lights = bridge.lights(); auto light = lights[0]; // If light's state is outdated (default 30 seconds), it refreshes light and bridge.lights() light.isOn(); // If bridge state is outdated (default 60 seconds), isOn() refreshes the entire bridge // This assumes the bridge state was not updated by the previous light.isOn() call or other means. ``` -------------------------------- ### Authenticate and Get Hue Bridge Object (C++) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/README.md This C++ code illustrates how to authenticate with a Philips Hue bridge and obtain a Bridge object using the hueplusplus library. It shows two methods: obtaining a new username by calling getBridge() with an index from the found bridges, or adding an existing username using addUsername(). It also demonstrates creating a Bridge object directly if the IP address, port, username, and HttpHandler are known. ```C++ hueplusplus::Bridge bridge = finder.getBridge(bridges[0]); ``` ```C++ finder.addUsername(bridges[0].mac, ""); hueplusplus::Bridge bridge = finder.getBridge(bridges[0]); ``` ```C++ std::shared_ptr handler; // For windows use std::make_shared(); handler = std::make_shared(); hueplusplus::Bridge bridge("192.168.2.102", 80, "", handler); ``` -------------------------------- ### Basic hueplusplus Library Build (Bash) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/README.md These bash commands outline the basic steps to build the hueplusplus library using CMake. It involves creating a build directory, navigating into it, running CMake to configure the build, and then compiling the code using make. ```bash mkdir build cd build cmake .. make ``` -------------------------------- ### CMake: Download and Build GoogleTest and GoogleMock Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/test/CMakeLists.txt This snippet demonstrates how to conditionally download and build GoogleTest and GoogleMock if they are not found. It includes processes for configuring and building the test libraries, setting specific compiler flags, and adding them as subdirectories to the main build. This ensures testing capabilities are available even without pre-installed libraries. ```cmake if(NOT hueplusplus_NO_EXTERNAL_LIBRARIES) find_package(GTest) find_package(GMock) endif() if(NOT GTest_FOUND OR NOT GMock_FOUND) # Download and unpack googletest at configure time configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) execute_process(COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR} . RESULT_VARIABLE result WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/googletest-download" ) if(result) message(FATAL_ERROR "CMake step for googletest failed: ${result}") endif() execute_process(COMMAND "${CMAKE_COMMAND}" --build . RESULT_VARIABLE result WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/googletest-download" ) if(result) message(FATAL_ERROR "Build step for googletest failed: ${result}") endif() # Prevent overriding the parent project's compiler/linker # settings on Windows set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) # Add googletest directly to our build. This defines # the gtest and gtest_main targets. add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src EXCLUDE_FROM_ALL ${CMAKE_CURRENT_BINARY_DIR}/googletest-build EXCLUDE_FROM_ALL ) target_compile_features(gmock PUBLIC cxx_std_14) target_compile_features(gtest PUBLIC cxx_std_14) endif() ``` -------------------------------- ### Creating Sensor Conditions (C++) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Sensors.md Shows how to create conditions for rules based on sensor states using C++. It covers using `makeCondition()` for specific sensor types and manually constructing `hueplusplus::Condition` objects for generic sensors. Relies on the `hueplusplus` library. ```cpp #include #include #include #include // Example usage for creating conditions // Assume 'bridge' is an initialized hueplusplus::Bridge object and 'sensor' is a hueplusplus::Sensor object // For a specific sensor type (e.g., a ZLL Light sensor with a state) // hueplusplus::ZLLLightSensor zll_light_sensor = bridge.getKnownSensor(sensor_id); // auto condition = zll_light_sensor.makeCondition(hueplusplus::Condition::Operator::Is, "on", true); // For a generic sensor, creating a condition manually hueplusplus::Condition manual_condition( "/sensors/1/state/temperature", // Address to the sensor state attribute hueplusplus::Condition::Operator::Is, 25.0 // Value to compare against ); // Adding the condition to a rule // hueplusplus::Rule rule = bridge.createRule(...); // rule.addCondition(condition); ``` -------------------------------- ### MM712 Protocol Initialization Commands Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/Controllers/CoolerMasterController/CMMM712Controller/MM712protocol.txt These commands initialize the device into either a normal or direct state. The normal state allows for commands with responses, while the direct state allows for commands without responses. The initialization command structure involves specific byte sequences, and the response bytes often relate to the command bytes. ```Hexadecimal C: 0x00 0x44 0x81 0x02 R: 0x45 0x81 0x02 0x02 0x01 C: 0x00 0x5a 0x81 0x02 R: 0x5b 0x81 0x02 ``` -------------------------------- ### Authenticate Hue Bridge (C++) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Mainpage.md These C++ snippets show how to authenticate with a Philips Hue bridge using the hueplusplus library. The first snippet obtains a new username by pressing the link button on the bridge. The second snippet demonstrates adding a bridge with an existing username. The third snippet shows how to create a Bridge object directly if the IP and username are known. ```cpp auto bridge = bridgeFinder.getBridge(bridges[0]); ``` ```cpp auto bridge = hueplusplus::Bridge("127.0.0.1", "0815"); ``` ```cpp auto bridge = hueplusplus::Bridge("127.0.0.1", 80, "0815", hueplusplus::LinHttpHandler()); ``` -------------------------------- ### Working with Known Sensors (C++) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Sensors.md Demonstrates how to work with known sensor types in C++. It shows how to access specific sensor types and retrieve all sensors of a particular type using `getAllByType()`. Assumes the `hueplusplus` library is included. ```cpp #include #include #include #include // Example usage for known sensor types // Assume 'bridge' is an initialized hueplusplus::Bridge object // Accessing a specific known sensor type (e.g., a switch) hueplusplus::Switch sensor_switch = bridge.getKnownSensor(sensor_id); // Getting all sensors of a specific type (e.g., temperature sensors) std::vector temp_sensors = bridge.getAllByType(); ``` -------------------------------- ### Linux SPD5118 Driver Unload Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/Documentation/SMBusAccess.md Command to unload the spd5118 kernel driver on Linux. This is a solution if the driver claims I2C addresses needed by other modules, such as for Kingston Fury DDR5 memory. ```bash rmmod spd5118 ``` -------------------------------- ### Parallel Compilation with make (Bash) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/README.md This bash command demonstrates how to compile the hueplusplus library using make with parallel processing enabled. The '-j4' option specifies that 4 files should be compiled simultaneously, which can speed up the build process on multi-core processors. ```bash make -j4 ``` -------------------------------- ### Mode Management API Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/Documentation/RGBControllerAPI.md Manage and query the different lighting modes available on RGB devices. ```APIDOC ## Mode Management API ### Description Allows for querying and setting the active lighting mode of an RGB device, as well as retrieving information about available modes. ### Modes Structure Modes represent internal effects and have a `name` field that describes the effect. The mode's index in the vector is its ID. A mode contains the following fields: * `Mode Name` (string) * `Mode Value` (implementation-defined) * `Mode Flags` (bitfield) * `Minimum Speed` (numeric) * `Maximum Speed` (numeric) * `Minimum number of colors` (integer) * `Maximum number of colors` (integer) * `Speed Value` (numeric) * `Direction` (enum/integer) * `Color Mode` (enum/integer) * `Colors Vector` (array of RGBColor) ### Mode Flags | Bit | Description | | --- | ------------------------------- | | 0 | Mode has speed parameter | | 1 | Mode has left/right direction | | 2 | Mode has up/down direction | | 3 | Mode has horizontal/vertical dir| | 4 | Mode has brightness parameter | | 5 | Mode has per-LED color settings | | 6 | Mode has mode-specific settings | | 7 | Mode has random color option | ### Color Modes | Value | Description | | ----- | ----------------------------------------------------------------------------------------- | | 0 | None - this mode does not have configurable colors | | 1 | Per-LED - uses the RGBController's colors vector to set each LED to its specified color | | 2 | Mode Specific - has configurable colors, but not individual LED control | | 3 | Random - can be switched to a random or cycling color palette | ### Functions #### `std::string GetModeName(int mode)` - **Description**: Returns the `name` string of the given mode. - **Parameters**: - `mode` (int) - The index of the mode in the `modes` vector. - **Method**: GET - **Endpoint**: N/A (Function call) #### `int GetMode()` - **Description**: Returns the active mode index of the device. - **Method**: GET - **Endpoint**: N/A (Function call) #### `void SetMode(int mode)` - **Description**: Sets the active mode index of the device. - **Parameters**: - `mode` (int) - The index in the `modes` vector of the mode to set. - **Method**: POST - **Endpoint**: N/A (Function call) ``` -------------------------------- ### Use Transaction for Lights - C++ Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Transactions.md Demonstrates how to use a StateTransaction to change multiple properties of a light at once, such as brightness and color. The transaction optimizes requests by only including changed variables based on the current light state. Avoid refreshing the light state between transaction creation and commit to prevent invalidating internal references. ```cpp #include // Assuming 'light' is a valid openrgb::Light object // and 'client' is a valid openrgb::Client object openrgb::StateTransaction transaction(client, light); transaction.setBrightness(50.0); transaction.setColor(openrgb::Color(255, 0, 0)); // Red color transaction.commit(); ``` -------------------------------- ### Working with Unknown Sensors (C++) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/doc/markdown/Sensors.md Illustrates how to handle unknown sensor types using the generic `hueplusplus::Sensor` class in C++. It emphasizes checking for attribute existence using `hasXXX` methods before accessing them and converting to a specific type if necessary. Requires the `hueplusplus` library. ```cpp #include #include // Example usage for unknown sensor types // Assume 'bridge' is an initialized hueplusplus::Bridge object and 'sensor_id' is known hueplusplus::Sensor generic_sensor = bridge.getSensor(sensor_id); // Check for specific attributes before accessing if (generic_sensor.hasAttribute("temperature")) { // Access the attribute safely // Note: This is a conceptual example; actual attribute access might differ. } // Comparing type string and converting if (generic_sensor.typeStr() == "CLIPGenericStatus") { hueplusplus::CLIPGenericStatus clip_sensor = static_cast(generic_sensor); // Use CLIPGenericStatus specific methods } ``` -------------------------------- ### Packet IDs Overview Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/Documentation/OpenRGBSDK.md This section provides an overview of the packet IDs used in the OpenRGB SDK, including their values, names, descriptions, and supported protocol versions. ```APIDOC ## Packet IDs Overview The following IDs represent different SDK commands. Each ID packet has a certain format of data associated with it, which will be explained under each ID's section of this document. Gaps have been left in the ID values to allow for future expansion. The same ID values are often used for both request and response packets. | Value | Name | Description | | ----- | -------------------------------------------- | ----------------------------------------------- | | 0 | NET_PACKET_ID_REQUEST_CONTROLLER_COUNT | Request RGBController device count from server | | 1 | NET_PACKET_ID_REQUEST_CONTROLLER_DATA | Request RGBController data block | | 40 | NET_PACKET_ID_REQUEST_PROTOCOL_VERSION | Request OpenRGB SDK protocol version from server| | 50 | NET_PACKET_ID_SET_CLIENT_NAME | Send client name string to server | | 100 | NET_PACKET_ID_DEVICE_LIST_UPDATED | Indicate to clients that device list has updated| | 140 | NET_PACKET_ID_REQUEST_RESCAN_DEVICES | Request server to rescan devices | | 150 | NET_PACKET_ID_REQUEST_PROFILE_LIST | Request profile list | | 151 | NET_PACKET_ID_REQUEST_SAVE_PROFILE | Save current configuration in a new profile | | 152 | NET_PACKET_ID_REQUEST_LOAD_PROFILE | Load a given profile | | 153 | NET_PACKET_ID_REQUEST_DELETE_PROFILE | Delete a given profile | | 200 | NET_PACKET_ID_REQUEST_PLUGIN_LIST | Request plugin list | | 201 | NET_PACKET_ID_PLUGIN_SPECIFIC | Plugin specific | | 1000 | NET_PACKET_ID_RGBCONTROLLER_RESIZEZONE | RGBController::ResizeZone() | | 1001 | NET_PACKET_ID_RGBCONTROLLER_CLEARSEGMENTS | RGBController::ClearSegments() | | 1002 | NET_PACKET_ID_RGBCONTROLLER_ADDSEGMENT | RGBController::AddSegment() | | 1050 | NET_PACKET_ID_RGBCONTROLLER_UPDATELEDS | RGBController::UpdateLEDs() | | 1051 | NET_PACKET_ID_RGBCONTROLLER_UPDATEZONELEDS | RGBController::UpdateZoneLEDs() | | 1052 | NET_PACKET_ID_RGBCONTROLLER_UPDATESINGLELED | RGBController::UpdateSingleLED() | | 1100 | NET_PACKET_ID_RGBCONTROLLER_SETCUSTOMMODE | RGBController::SetCustomMode() | | 1101 | NET_PACKET_ID_RGBCONTROLLER_UPDATEMODE | RGBController::UpdateMode() | | 1102 | NET_PACKET_ID_RGBCONTROLLER_SAVEMODE | RGBController::SaveMode() | * The NET_PACKET_ID_REQUEST_PROTOCOL_VERSION packet was not present in protocol version 0, but clients supporting protocol versions 1+ should always send this packet. If no response is received, it should be assumed that the server is using protocol 0. ``` -------------------------------- ### Define hueplusplus Sources and Platform-Specific Handlers (CMake) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/src/CMakeLists.txt This snippet defines the primary source files for the hueplusplus library. It conditionally appends platform-specific HTTP handler source files based on whether the build is for Windows (WinHttpHandler) or Unix/ESP platforms (LinHttpHandler). The sources are then prefixed with the current source directory. ```cmake set(hueplusplus_SOURCES Action.cpp APICache.cpp BaseDevice.cpp BaseHttpHandler.cpp Bridge.cpp BridgeConfig.cpp CLIPSensors.cpp ColorUnits.cpp EntertainmentMode.cpp ExtendedColorHueStrategy.cpp ExtendedColorTemperatureStrategy.cpp Group.cpp HueCommandAPI.cpp HueDeviceTypes.cpp HueException.cpp Light.cpp ModelPictures.cpp NewDeviceList.cpp Rule.cpp Scene.cpp Schedule.cpp Sensor.cpp SimpleBrightnessStrategy.cpp SimpleColorHueStrategy.cpp SimpleColorTemperatureStrategy.cpp StateTransaction.cpp TimePattern.cpp UPnP.cpp Utils.cpp ZLLSensors.cpp) # on windows we want to compile the WinHttpHandler if(WIN32) set(hueplusplus_SOURCES ${hueplusplus_SOURCES} WinHttpHandler.cpp ) endif() # whereas on linux we want the LinHttpHandler if(UNIX) set(hueplusplus_SOURCES ${hueplusplus_SOURCES} LinHttpHandler.cpp ) endif() if(ESP_PLATFORM) set(hueplusplus_SOURCES ${hueplusplus_SOURCES} LinHttpHandler.cpp ) endif() # append current source dir before files foreach(src ${hueplusplus_SOURCES}) list(APPEND _srcList "${CMAKE_CURRENT_SOURCE_DIR}/${src}") endforeach() set(hueplusplus_SOURCES ${_srcList} PARENT_SCOPE) ``` -------------------------------- ### Include and Build hueplusplus in CMake (CMake) Source: https://gitlab.com/calcprogrammer1/openrgb/-/blob/master/dependencies/hueplusplus-1.2.0/README.md This CMake script provides a method to include the hueplusplus library directly within your project's build process if it's not found via find_package. This is useful when hueplusplus is a submodule or its path is known. ```cmake find_package(hueplusplus QUIET) if(NOT hueplusplus_FOUND) message(STATUS "-- hueplusplus not found, building it") add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}//hueplusplus" "${CMAKE_CURRENT_BINARY_DIR}/hueplusplus") endif() target_link_libraries( PUBLIC hueplusplusstatic) ```