Skip to content

Commit

Permalink
Implement ftdi led device - 2 (#1746)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lord-Grey authored May 31, 2024
1 parent 897e4aa commit 76fff98
Show file tree
Hide file tree
Showing 24 changed files with 1,037 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
if: ${{ matrix.language == 'cpp' }}
run: |
sudo apt-get update
sudo apt-get install --yes git cmake build-essential qtbase5-dev libqt5serialport5-dev libqt5sql5-sqlite libqt5svg5-dev libqt5x11extras5-dev libusb-1.0-0-dev python3-dev libcec-dev libxcb-image0-dev libxcb-util0-dev libxcb-shm0-dev libxcb-render0-dev libxcb-randr0-dev libxrandr-dev libxrender-dev libavahi-core-dev libavahi-compat-libdnssd-dev libasound2-dev libturbojpeg0-dev libjpeg-dev libssl-dev
sudo apt-get install --yes git cmake build-essential qtbase5-dev libqt5serialport5-dev libqt5sql5-sqlite libqt5svg5-dev libqt5x11extras5-dev libusb-1.0-0-dev python3-dev libcec-dev libxcb-image0-dev libxcb-util0-dev libxcb-shm0-dev libxcb-render0-dev libxcb-randr0-dev libxrandr-dev libxrender-dev libavahi-core-dev libavahi-compat-libdnssd-dev libasound2-dev libturbojpeg0-dev libjpeg-dev libssl-dev libftdi1-dev
- name: 🔁 Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qt5_6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
echo '::group::Update/Install dependencies'
brew untap --force homebrew/core homebrew/cask
brew update || true
brew install qt@${{ inputs.qt_version }} vulkan-headers ninja || true
brew install qt@${{ inputs.qt_version }} vulkan-headers ninja libftdi || true
echo '::endgroup::'
- name: 👷 Build
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Support for ftdi chip based LED-devices with ws2812, sk6812 apa102 LED types (Many thanks to @nurikk) (#1746)
- Support gaps on Matrix Layout (#1696)
- Windows: Added a new grabber that uses the DXGI DDA (Desktop Duplication API). This has much better performance than the DX grabber as it does more of its work on the GPU.

Expand Down
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ set(DEFAULT_DEV_SPI OFF)
set(DEFAULT_DEV_TINKERFORGE OFF)
set(DEFAULT_DEV_USB_HID OFF)
set(DEFAULT_DEV_WS281XPWM OFF)
set(DEFAULT_DEV_FTDI ON )

# Services
set(DEFAULT_EFFECTENGINE ON )
Expand Down Expand Up @@ -121,9 +122,10 @@ if(${CMAKE_SYSTEM} MATCHES "Linux")
set(DEFAULT_DEV_USB_HID ON)
set(DEFAULT_CEC ON)
elseif (WIN32)
set(DEFAULT_DX ON)
set(DEFAULT_DDA ON)
set(DEFAULT_MF ON)
set(DEFAULT_DX ON )
set(DEFAULT_DDA ON )
set(DEFAULT_MF ON )
set(DEFAULT_DEV_FTDI OFF)
else()
set(DEFAULT_FB OFF)
set(DEFAULT_V4L2 OFF)
Expand Down Expand Up @@ -353,6 +355,9 @@ message(STATUS "ENABLE_DEV_USB_HID = ${ENABLE_DEV_USB_HID}")
option(ENABLE_DEV_WS281XPWM "Enable the WS281x-PWM device" ${DEFAULT_DEV_WS281XPWM})
message(STATUS "ENABLE_DEV_WS281XPWM = ${ENABLE_DEV_WS281XPWM}")

option(ENABLE_DEV_FTDI "Enable the FTDI devices" ${DEFAULT_DEV_FTDI} )
message(STATUS "ENABLE_DEV_FTDI = ${ENABLE_DEV_FTDI}")

removeIndent()

message(STATUS "Services options:")
Expand Down
8 changes: 7 additions & 1 deletion assets/webconfig/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,12 @@
"conf_leds_note_layout_overwrite": "Note: Overwrite creates a default layout for {{plural:$1| one LED| all $1 LEDs}} given by the hardware LED count",
"conf_leds_optgroup_RPiGPIO": "RPi GPIO",
"conf_leds_optgroup_RPiPWM": "RPi PWM",
"conf_leds_optgroup_RPiSPI": "RPi SPI",
"conf_leds_optgroup_SPI": "SPI",
"conf_leds_optgroup_debug": "Debug",
"conf_leds_optgroup_network": "Network",
"conf_leds_optgroup_other": "Other",
"conf_leds_optgroup_usb": "USB/Serial",
"conf_leds_optgroup_ftdi": "USB/Ftdi",
"conf_logging_btn_autoscroll": "Auto scrolling",
"conf_logging_btn_clipboard": "Copy Log to Clipboard",
"conf_logging_btn_pbupload": "Upload a report for support requests",
Expand Down Expand Up @@ -619,6 +620,11 @@
"edt_dev_enum_sub_min_cool_adjust": "Subtract cool white",
"edt_dev_enum_sub_min_warm_adjust": "Subtract warm white",
"edt_dev_enum_subtract_minimum": "Subtract minimum",
"edt_dev_enum_cold_white": "Cold white",
"edt_dev_enum_neutral_white": "Neutral white",
"edt_dev_enum_auto": "Auto",
"edt_dev_enum_auto_max": "Auto max",
"edt_dev_enum_auto_accurate": "Auto accurate",
"edt_dev_enum_white_off": "White off",
"edt_dev_general_autostart_title": "Autostart",
"edt_dev_general_autostart_title_info": "The LED device is switched-on during startup or not",
Expand Down
93 changes: 85 additions & 8 deletions assets/webconfig/js/content_leds.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ var bottomRight2bottomLeft = null;
var bottomLeft2topLeft = null;
var toggleKeystoneCorrectionArea = false;

var devRPiSPI = ['apa102', 'apa104', 'ws2801', 'lpd6803', 'lpd8806', 'p9813', 'sk6812spi', 'sk6822spi', 'sk9822', 'ws2812spi'];
var devSPI = ['apa102', 'apa104', 'ws2801', 'lpd6803', 'lpd8806', 'p9813', 'sk6812spi', 'sk6822spi', 'sk9822', 'ws2812spi'];
var devFTDI = ['apa102_ftdi', 'sk6812_ftdi', 'ws2812_ftdi'];
var devRPiPWM = ['ws281x'];
var devRPiGPIO = ['piblaster'];
var devNET = ['atmoorb', 'cololight', 'fadecandy', 'philipshue', 'nanoleaf', 'razer', 'tinkerforge', 'tpm2net', 'udpe131', 'udpartnet', 'udpddp', 'udph801', 'udpraw', 'wled', 'yeelight'];
Expand Down Expand Up @@ -1121,6 +1122,12 @@ $(document).ready(function () {
case "karate":
case "sedu":
case "tpm2":

//FTDI devices
case "apa102_ftdi":
case "sk6812_ftdi":
case "ws2812_ftdi":

if (storedAccess === 'expert') {
filter.discoverAll = true;
}
Expand All @@ -1139,6 +1146,7 @@ $(document).ready(function () {
.catch(error => {
showNotification('danger', "Device discovery for " + ledType + " failed with error:" + error);
});

break;

case "philipshue": {
Expand Down Expand Up @@ -1441,6 +1449,9 @@ $(document).ready(function () {
case "sk9822":
case "ws2812spi":
case "piblaster":
case "apa102_ftdi":
case "sk6812_ftdi":
case "ws2812_ftdi":
default:
}

Expand Down Expand Up @@ -1657,9 +1668,10 @@ $(document).ready(function () {
optArr[3] = [];
optArr[4] = [];
optArr[5] = [];
optArr[6] = [];

for (var idx = 0; idx < ledDevices.length; idx++) {
if ($.inArray(ledDevices[idx], devRPiSPI) != -1)
if ($.inArray(ledDevices[idx], devSPI) != -1)
optArr[0].push(ledDevices[idx]);
else if ($.inArray(ledDevices[idx], devRPiPWM) != -1)
optArr[1].push(ledDevices[idx]);
Expand All @@ -1671,18 +1683,23 @@ $(document).ready(function () {
optArr[4].push(ledDevices[idx]);
else if ($.inArray(ledDevices[idx], devHID) != -1)
optArr[4].push(ledDevices[idx]);
else if (ledDevices[idx].endsWith("_ftdi")) {
var title = ledDevices[idx].replace('_ftdi','');
optArr[5].push(ledDevices[idx] + ":" + title);
}
else
optArr[5].push(ledDevices[idx]);
optArr[6].push(ledDevices[idx]);
}

$("#leddevices").append(createSel(optArr[0], $.i18n('conf_leds_optgroup_RPiSPI')));
$("#leddevices").append(createSel(optArr[1], $.i18n('conf_leds_optgroup_RPiPWM')));
$("#leddevices").append(createSel(optArr[2], $.i18n('conf_leds_optgroup_RPiGPIO')));
$("#leddevices").append(createSel(optArr[3], $.i18n('conf_leds_optgroup_network')));
$("#leddevices").append(createSel(optArr[4], $.i18n('conf_leds_optgroup_usb')));
$("#leddevices").append(createSel(optArr[5], $.i18n('conf_leds_optgroup_ftdi'), true));

if (storedAccess === 'expert' || window.serverConfig.device.type === "file") {
$("#leddevices").append(createSel(optArr[5], $.i18n('conf_leds_optgroup_other')));
$("#leddevices").append(createSel(optArr[6], $.i18n('conf_leds_optgroup_other')));
}

$("#leddevices").val(window.serverConfig.device.type);
Expand Down Expand Up @@ -1886,6 +1903,9 @@ function saveLedConfig(genDefLayout = false) {
case "sk9822":
case "ws2812spi":
case "piblaster":
case "apa102_ftdi":
case "sk6812_ftdi":
case "ws2812_ftdi":
default:
if (genDefLayout === true) {
ledConfig = {
Expand Down Expand Up @@ -1938,8 +1958,10 @@ var updateOutputSelectList = function (ledType, discoveryInfo) {
ledTypeGroup = "devNET";
} else if ($.inArray(ledType, devSerial) != -1) {
ledTypeGroup = "devSerial";
} else if ($.inArray(ledType, devRPiSPI) != -1) {
ledTypeGroup = "devRPiSPI";
} else if ($.inArray(ledType, devSPI) != -1) {
ledTypeGroup = "devSPI";
} else if ($.inArray(ledType, devFTDI) != -1) {
ledTypeGroup = "devFTDI";
} else if ($.inArray(ledType, devRPiGPIO) != -1) {
ledTypeGroup = "devRPiGPIO";
} else if ($.inArray(ledType, devRPiPWM) != -1) {
Expand Down Expand Up @@ -2062,7 +2084,63 @@ var updateOutputSelectList = function (ledType, discoveryInfo) {
}
}
break;
case "devRPiSPI":

case "devFTDI":
key = "output";

if (discoveryInfo.devices.length == 0) {
enumVals.push("NONE");
enumTitleVals.push($.i18n('edt_dev_spec_devices_discovered_none'));
$('#btn_submit_controller').prop('disabled', true);
showAllDeviceInputOptions(key, false);
}
else {
switch (ledType) {
case "ws2812_ftdi":
case "sk6812_ftdi":
case "apa102_ftdi":
for (const device of discoveryInfo.devices) {
enumVals.push(device.ftdiOpenString);

var title = "FTDI";
if (device.manufacturer) {
title = device.manufacturer;
}

if (device.serialNumber) {
title += " - " + device.serialNumber;
}
title += " (" + device.vendorIdentifier + "|" + device.productIdentifier + ")";

if (device.description) {
title += " " + device.description;
}

enumTitleVals.push(title);
}

// Select configured device
var configuredDeviceType = window.serverConfig.device.type;
var configuredOutput = window.serverConfig.device.output;
if (ledType === configuredDeviceType) {
if ($.inArray(configuredOutput, enumVals) != -1) {
enumDefaultVal = configuredOutput;
} else {
enumVals.push(window.serverConfig.device.output);
enumDefaultVal = configuredOutput;
}
}
else {
addSelect = true;
}

break;
default:
}
}
break;

case "devSPI":
case "devRPiGPIO":
key = "output";

Expand Down Expand Up @@ -2128,7 +2206,6 @@ var updateOutputSelectList = function (ledType, discoveryInfo) {
async function discover_device(ledType, params) {

const result = await requestLedDeviceDiscovery(ledType, params);

var discoveryResult = {};
if (result) {
if (result.error) {
Expand Down
8 changes: 4 additions & 4 deletions doc/development/CompileHowto.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ cd $HYPERION_HOME

```console
sudo apt-get update
sudo apt-get install git cmake build-essential qtbase5-dev libqt5serialport5-dev libqt5sql5-sqlite libqt5svg5-dev libqt5x11extras5-dev libusb-1.0-0-dev python3-dev libasound2-dev libturbojpeg0-dev libjpeg-dev libssl-dev
sudo apt-get install git cmake build-essential qtbase5-dev libqt5serialport5-dev libqt5sql5-sqlite libqt5svg5-dev libqt5x11extras5-dev libusb-1.0-0-dev python3-dev libasound2-dev libturbojpeg0-dev libjpeg-dev libssl-dev libftdi1-dev
```

**Ubuntu (22.04+) - Qt6 based**

```console
sudo apt-get update
sudo apt-get install git cmake build-essential qt6-base-dev libqt6serialport6-dev libxkbcommon-dev libvulkan-dev libgl1-mesa-dev libusb-1.0-0-dev python3-dev libasound2-dev libturbojpeg0-dev libjpeg-dev libssl-dev pkg-config
sudo apt-get install git cmake build-essential qt6-base-dev libqt6serialport6-dev libxkbcommon-dev libvulkan-dev libgl1-mesa-dev libusb-1.0-0-dev python3-dev libasound2-dev libturbojpeg0-dev libjpeg-dev libssl-dev pkg-config libftdi1-dev
```

**For Linux X11/XCB grabber support**
Expand Down Expand Up @@ -110,7 +110,7 @@ See [AUR](https://aur.archlinux.org/packages/?O=0&SeB=nd&K=hyperion&outdated=&SB
The following dependencies are needed to build hyperion.ng on fedora.
```console
sudo dnf -y groupinstall "Development Tools"
sudo dnf install python3-devel qt-devel qt5-qtbase-devel qt5-qtserialport-devel xrandr xcb-util-image-devel qt5-qtx11extras-devel alsa-lib-devel turbojpeg-devel libusb-devel xcb-util-devel dbus-devel openssl-devel fedora-packager rpmdevtools gcc libcec-devel
sudo dnf install python3-devel qt-devel qt5-qtbase-devel qt5-qtserialport-devel xrandr xcb-util-image-devel qt5-qtx11extras-devel alsa-lib-devel turbojpeg-devel libusb-devel xcb-util-devel dbus-devel openssl-devel fedora-packager rpmdevtools gcc libcec-devel libftdi1-dev
```
After installing the dependencies, you can continue with the compile instructions later on this page (the more detailed way..).

Expand All @@ -119,7 +119,7 @@ To install on OS X you either need [Homebrew](https://brew.sh/) or [Macport](htt

First you need to install the dependencies:
```console
brew install git qt@5 python3 cmake libusb [email protected]
brew install git qt@5 python3 cmake libusb [email protected] libftdi
```

## Windows
Expand Down
7 changes: 6 additions & 1 deletion include/utils/RgbToRgbw.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ namespace RGBW {
SUBTRACT_MINIMUM,
SUB_MIN_WARM_ADJUST,
SUB_MIN_COOL_ADJUST,
WHITE_OFF
WHITE_OFF,
COLD_WHITE,
NEUTRAL_WHITE,
AUTO,
AUTO_MAX,
AUTO_ACCURATE
};

WhiteAlgorithm stringToWhiteAlgorithm(const QString& str);
Expand Down
15 changes: 14 additions & 1 deletion libsrc/leddevice/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ include_directories(
dev_spi
dev_rpi_pwm
dev_tinker
dev_ftdi
)

file (GLOB Leddevice_SOURCES
Expand Down Expand Up @@ -63,7 +64,11 @@ if(ENABLE_DEV_WS281XPWM)
file (GLOB Leddevice_PWM_SOURCES "${CURRENT_SOURCE_DIR}/dev_rpi_pwm/*.h" "${CURRENT_SOURCE_DIR}/dev_rpi_pwm/*.cpp")
endif()

set(LedDevice_RESOURCES ${CURRENT_SOURCE_DIR}/LedDeviceSchemas.qrc)
if (ENABLE_DEV_FTDI)
FILE ( GLOB Leddevice_FTDI_SOURCES "${CURRENT_SOURCE_DIR}/dev_ftdi/*.h" "${CURRENT_SOURCE_DIR}/dev_ftdi/*.cpp")
endif()

set(LedDevice_RESOURCES ${CURRENT_SOURCE_DIR}/LedDeviceSchemas.qrc )

set(Leddevice_SOURCES
${Leddevice_SOURCES}
Expand All @@ -74,6 +79,7 @@ set(Leddevice_SOURCES
${Leddevice_SPI_SOURCES}
${Leddevice_TINKER_SOURCES}
${Leddevice_USB_HID_SOURCES}
${Leddevice_FTDI_SOURCES}
)

# auto generate header file that include all available leddevice headers
Expand Down Expand Up @@ -165,3 +171,10 @@ if(ENABLE_MDNS)
target_link_libraries(leddevice mdns)
endif()

if( ENABLE_DEV_FTDI )
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIB_FTDI REQUIRED IMPORTED_TARGET libftdi1 )
target_include_directories(leddevice PRIVATE PkgConfig::LIB_FTDI)
target_link_libraries(leddevice PkgConfig::LIB_FTDI)
endif()

3 changes: 3 additions & 0 deletions libsrc/leddevice/LedDeviceSchemas.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@
<file alias="schema-yeelight">schemas/schema-yeelight.json</file>
<file alias="schema-razer">schemas/schema-razer.json</file>
<file alias="schema-cololight">schemas/schema-cololight.json</file>
<file alias="schema-ws2812_ftdi">schemas/schema-ws2812_ftdi.json</file>
<file alias="schema-apa102_ftdi">schemas/schema-apa102_ftdi.json</file>
<file alias="schema-sk6812_ftdi">schemas/schema-sk6812_ftdi.json</file>
</qresource>
</RCC>
Loading

0 comments on commit 76fff98

Please sign in to comment.