Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ftdi led device #1595

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/ci_install.sh
Expand Up @@ -35,6 +35,6 @@ function installAndUpgrade()
if [[ $CI_NAME == 'osx' || $CI_NAME == 'darwin' ]]; then
echo "Install dependencies"
brew update
dependencies=("qt5" "python" "libusb" "cmake" "doxygen")
dependencies=("qt5" "python" "libusb" "cmake" "doxygen", "libftdi")
installAndUpgrade "${dependencies[@]}"
fi
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Expand Up @@ -32,7 +32,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@v2
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Expand Up @@ -88,6 +88,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 @@ -117,6 +118,7 @@ IF ( ${CMAKE_SYSTEM} MATCHES "Linux" )
ELSEIF ( WIN32 )
SET ( DEFAULT_DX ON )
SET ( DEFAULT_MF ON )
SET ( DEFAULT_DEV_FTDI OFF )
ELSE()
SET ( DEFAULT_FB OFF )
SET ( DEFAULT_V4L2 OFF )
Expand Down Expand Up @@ -341,6 +343,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
5 changes: 4 additions & 1 deletion HyperionConfig.h.in
Expand Up @@ -61,9 +61,12 @@
// Define to enable the Serial devices
#cmakedefine ENABLE_DEV_SERIAL

// Define to enable the SPI devices
// Define to enable the SPI spidev devices
#cmakedefine ENABLE_DEV_SPI

// Define to enable the SPI ftdi devices
#cmakedefine ENABLE_DEV_FTDI

// Define to enable the Tinkerforge devices
#cmakedefine ENABLE_DEV_TINKERFORGE

Expand Down
7 changes: 6 additions & 1 deletion assets/webconfig/i18n/en.json
Expand Up @@ -153,7 +153,7 @@
"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_RPiSPI": "SPI",
"conf_leds_optgroup_debug": "Debug",
"conf_leds_optgroup_network": "Network",
"conf_leds_optgroup_other": "Other",
Expand Down Expand Up @@ -567,6 +567,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
16 changes: 12 additions & 4 deletions assets/webconfig/js/content_leds.js
Expand Up @@ -18,7 +18,7 @@ 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 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 @@ -1139,7 +1139,15 @@ $(document).ready(function () {
});

hwLedCountDefault = 1;
colorOrderDefault = "rgb";

switch (ledType) {
case "sk6812spi":
colorOrderDefault = "grb";
break;
default:
colorOrderDefault = "rgb";
}

break;

case "philipshue":
Expand Down Expand Up @@ -1647,7 +1655,7 @@ $(document).ready(function () {
optArr[5] = [];

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 Down Expand Up @@ -1899,7 +1907,7 @@ var updateOutputSelectList = function (ledType, discoveryInfo) {
ledTypeGroup = "devNET";
} else if ($.inArray(ledType, devSerial) != -1) {
ledTypeGroup = "devSerial";
} else if ($.inArray(ledType, devRPiSPI) != -1) {
} else if ($.inArray(ledType, devSPI) != -1) {
ledTypeGroup = "devRPiSPI";
} else if ($.inArray(ledType, devRPiGPIO) != -1) {
ledTypeGroup = "devRPiGPIO";
Expand Down
8 changes: 4 additions & 4 deletions doc/development/CompileHowto.md
Expand Up @@ -87,14 +87,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 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 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 @@ -136,7 +136,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 @@ -145,7 +145,7 @@ To install on OS X you either need Homebrew or Macport but Homebrew is the recom

First you need to install the dependencies:
```console
brew install qt5 python3 cmake libusb doxygen
brew install qt5 python3 cmake libusb doxygen libftdi
```

## Windows
Expand Down
7 changes: 6 additions & 1 deletion include/utils/RgbToRgbw.h
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
22 changes: 21 additions & 1 deletion libsrc/leddevice/CMakeLists.txt
Expand Up @@ -42,8 +42,20 @@ if ( ENABLE_DEV_SERIAL )
FILE ( GLOB Leddevice_SERIAL_SOURCES "${CURRENT_SOURCE_DIR}/dev_serial/*.h" "${CURRENT_SOURCE_DIR}/dev_serial/*.cpp")
endif()

if ( ENABLE_DEV_SPI )
if ( ENABLE_DEV_SPI OR ENABLE_DEV_FTDI )
FILE ( GLOB Leddevice_SPI_SOURCES "${CURRENT_SOURCE_DIR}/dev_spi/*.h" "${CURRENT_SOURCE_DIR}/dev_spi/*.cpp")

FILE ( GLOB Leddevice_SPI_PROVIDERS_SOURCES "${CURRENT_SOURCE_DIR}/dev_spi/providers/BaseProvider.*")

if ( ENABLE_DEV_FTDI )
file (GLOB FTDI_PROVIDER_SOURCES "${CURRENT_SOURCE_DIR}/dev_spi/providers/ProviderFtdi.*")
list (APPEND Leddevice_SPI_PROVIDERS_SOURCES ${FTDI_PROVIDER_SOURCES})
endif()

if ( ENABLE_DEV_SPI )
file (GLOB SPIDEV_PROVIDER_SOURCES "${CURRENT_SOURCE_DIR}/dev_spi/providers/ProviderSpidev.*")
list (APPEND Leddevice_SPI_PROVIDERS_SOURCES ${SPIDEV_PROVIDER_SOURCES})
endif()
endif()

if ( ENABLE_DEV_TINKERFORGE )
Expand Down Expand Up @@ -73,6 +85,7 @@ SET( Leddevice_SOURCES
${Leddevice_PWM_SOURCES}
${Leddevice_SERIAL_SOURCES}
${Leddevice_SPI_SOURCES}
${Leddevice_SPI_PROVIDERS_SOURCES}
${Leddevice_TINKER_SOURCES}
${Leddevice_USB_HID_SOURCES}
)
Expand Down Expand Up @@ -164,3 +177,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()

4 changes: 2 additions & 2 deletions libsrc/leddevice/dev_spi/LedDeviceAPA104.cpp
Expand Up @@ -55,14 +55,14 @@

bool LedDeviceAPA104::init(const QJsonObject &deviceConfig)
{
_baudRate_Hz = 2235000;
// _baudRate_Hz = 2235000;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

bool isInitOK = false;

// Initialise sub-class
if ( ProviderSpi::init(deviceConfig) )
{
WarningIf(( _baudRate_Hz < 2000000 || _baudRate_Hz > 2470000 ), _log, "SPI rate %d outside recommended range (2000000 -> 2470000)", _baudRate_Hz);
// WarningIf(( _baudRate_Hz < 2000000 || _baudRate_Hz > 2470000 ), _log, "SPI rate %d outside recommended range (2000000 -> 2470000)", _baudRate_Hz);

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

_ledBuffer.resize(_ledRGBCount * SPI_BYTES_PER_COLOUR + SPI_FRAME_END_LATCH_BYTES, 0x00);

Expand Down
4 changes: 2 additions & 2 deletions libsrc/leddevice/dev_spi/LedDeviceSk6812SPI.cpp
Expand Up @@ -20,7 +20,7 @@

bool LedDeviceSk6812SPI::init(const QJsonObject &deviceConfig)
{
_baudRate_Hz = 3000000;
// _baudRate_Hz = 3000000;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

bool isInitOK = false;

Expand All @@ -40,7 +40,7 @@
{
Debug( _log, "whiteAlgorithm : %s", QSTRING_CSTR(whiteAlgorithm));

WarningIf(( _baudRate_Hz < 2050000 || _baudRate_Hz > 4000000 ), _log, "SPI rate %d outside recommended range (2050000 -> 4000000)", _baudRate_Hz);
// WarningIf(( _baudRate_Hz < 2050000 || _baudRate_Hz > 4000000 ), _log, "SPI rate %d outside recommended range (2050000 -> 4000000)", _baudRate_Hz);

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

const int SPI_FRAME_END_LATCH_BYTES = 3;
_ledBuffer.resize(_ledRGBWCount * SPI_BYTES_PER_COLOUR + SPI_FRAME_END_LATCH_BYTES, 0x00);
Expand Down
4 changes: 2 additions & 2 deletions libsrc/leddevice/dev_spi/LedDeviceSk6822SPI.cpp
Expand Up @@ -57,14 +57,14 @@

bool LedDeviceSk6822SPI::init(const QJsonObject &deviceConfig)
{
_baudRate_Hz = 2230000;
// _baudRate_Hz = 2230000;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

bool isInitOK = false;

// Initialise sub-class
if ( ProviderSpi::init(deviceConfig) )
{
WarningIf(( _baudRate_Hz < 2000000 || _baudRate_Hz > 2460000 ), _log, "SPI rate %d outside recommended range (2000000 -> 2460000)", _baudRate_Hz);
// WarningIf(( _baudRate_Hz < 2000000 || _baudRate_Hz > 2460000 ), _log, "SPI rate %d outside recommended range (2000000 -> 2460000)", _baudRate_Hz);

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

_ledBuffer.resize( (_ledRGBCount * SPI_BYTES_PER_COLOUR) + (_ledCount * SPI_BYTES_WAIT_TIME ) + SPI_FRAME_END_LATCH_BYTES, 0x00);
isInitOK = true;
Expand Down
4 changes: 2 additions & 2 deletions libsrc/leddevice/dev_spi/LedDeviceWs2812SPI.cpp
Expand Up @@ -54,14 +54,14 @@

bool LedDeviceWs2812SPI::init(const QJsonObject &deviceConfig)
{
_baudRate_Hz = 2600000;
// _baudRate_Hz = 2600000;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

bool isInitOK = false;

// Initialise sub-class
if ( ProviderSpi::init(deviceConfig) )
{
WarningIf(( _baudRate_Hz < 2106000 || _baudRate_Hz > 3075000 ), _log, "SPI rate %d outside recommended range (2106000 -> 3075000)", _baudRate_Hz);
// WarningIf(( _baudRate_Hz < 2106000 || _baudRate_Hz > 3075000 ), _log, "SPI rate %d outside recommended range (2106000 -> 3075000)", _baudRate_Hz);

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

_ledBuffer.resize(_ledRGBCount * SPI_BYTES_PER_COLOUR + SPI_FRAME_END_LATCH_BYTES, 0x00);

Expand Down