update and test with rpi zero 2
This commit is contained in:
87
RpiLedBars/backend/.build/CPackConfig.cmake
Normal file
87
RpiLedBars/backend/.build/CPackConfig.cmake
Normal file
@@ -0,0 +1,87 @@
|
||||
# This file will be configured to contain variables for CPack. These variables
|
||||
# should be set in the CMake list file of the project before CPack module is
|
||||
# included. The list of available CPACK_xxx variables and their associated
|
||||
# documentation may be obtained using
|
||||
# cpack --help-variable-list
|
||||
#
|
||||
# Some variables are common to all generators (e.g. CPACK_PACKAGE_NAME)
|
||||
# and some are specific to a generator
|
||||
# (e.g. CPACK_NSIS_EXTRA_INSTALL_COMMANDS). The generator specific variables
|
||||
# usually begin with CPACK_<GENNAME>_xxxx.
|
||||
|
||||
|
||||
set(CPACK_BINARY_7Z "")
|
||||
set(CPACK_BINARY_BUNDLE "")
|
||||
set(CPACK_BINARY_CYGWIN "")
|
||||
set(CPACK_BINARY_DEB "OFF")
|
||||
set(CPACK_BINARY_DRAGNDROP "")
|
||||
set(CPACK_BINARY_FREEBSD "OFF")
|
||||
set(CPACK_BINARY_IFW "OFF")
|
||||
set(CPACK_BINARY_NSIS "OFF")
|
||||
set(CPACK_BINARY_NUGET "")
|
||||
set(CPACK_BINARY_OSXX11 "")
|
||||
set(CPACK_BINARY_PACKAGEMAKER "")
|
||||
set(CPACK_BINARY_PRODUCTBUILD "")
|
||||
set(CPACK_BINARY_RPM "OFF")
|
||||
set(CPACK_BINARY_STGZ "ON")
|
||||
set(CPACK_BINARY_TBZ2 "OFF")
|
||||
set(CPACK_BINARY_TGZ "ON")
|
||||
set(CPACK_BINARY_TXZ "OFF")
|
||||
set(CPACK_BINARY_TZ "ON")
|
||||
set(CPACK_BINARY_WIX "")
|
||||
set(CPACK_BINARY_ZIP "")
|
||||
set(CPACK_BUILD_SOURCE_DIRS "/home/paquito/Projects/LedBars/RpiLedBars/backend;/home/paquito/Projects/LedBars/RpiLedBars/backend/.build")
|
||||
set(CPACK_CMAKE_GENERATOR "Unix Makefiles")
|
||||
set(CPACK_COMPONENTS_ALL "")
|
||||
set(CPACK_COMPONENT_UNSPECIFIED_HIDDEN "TRUE")
|
||||
set(CPACK_COMPONENT_UNSPECIFIED_REQUIRED "TRUE")
|
||||
set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE "/usr/share/cmake-3.16/Templates/CPack.GenericDescription.txt")
|
||||
set(CPACK_GENERATOR "STGZ;TGZ;TZ")
|
||||
set(CPACK_INSTALL_CMAKE_PROJECTS "/home/paquito/Projects/LedBars/RpiLedBars/backend/.build;RpiLedBars;ALL;/")
|
||||
set(CPACK_INSTALL_PREFIX "/usr/local")
|
||||
set(CPACK_MODULE_PATH "")
|
||||
set(CPACK_NSIS_DISPLAY_NAME "json-c 0.16.99")
|
||||
set(CPACK_NSIS_INSTALLER_ICON_CODE "")
|
||||
set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "")
|
||||
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
|
||||
set(CPACK_NSIS_PACKAGE_NAME "json-c 0.16.99")
|
||||
set(CPACK_OUTPUT_CONFIG_FILE "/home/paquito/Projects/LedBars/RpiLedBars/backend/.build/CPackConfig.cmake")
|
||||
set(CPACK_PACKAGE_DEFAULT_LOCATION "/")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE "/usr/share/cmake-3.16/Templates/CPack.GenericDescription.txt")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "RpiLedBars built using CMake")
|
||||
set(CPACK_PACKAGE_FILE_NAME "json-c-0.16.99-Linux")
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "json-c 0.16.99")
|
||||
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "json-c 0.16.99")
|
||||
set(CPACK_PACKAGE_NAME "json-c")
|
||||
set(CPACK_PACKAGE_RELOCATABLE "true")
|
||||
set(CPACK_PACKAGE_VENDOR "Humanity")
|
||||
set(CPACK_PACKAGE_VERSION "0.16.99")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "0")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "16")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "99")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "/usr/share/cmake-3.16/Templates/CPack.GenericLicense.txt")
|
||||
set(CPACK_RESOURCE_FILE_README "/usr/share/cmake-3.16/Templates/CPack.GenericDescription.txt")
|
||||
set(CPACK_RESOURCE_FILE_WELCOME "/usr/share/cmake-3.16/Templates/CPack.GenericWelcome.txt")
|
||||
set(CPACK_SET_DESTDIR "OFF")
|
||||
set(CPACK_SOURCE_7Z "")
|
||||
set(CPACK_SOURCE_CYGWIN "")
|
||||
set(CPACK_SOURCE_GENERATOR "TBZ2;TGZ;TXZ;TZ")
|
||||
set(CPACK_SOURCE_IGNORE_FILES "/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/build;/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/cmake-build-debug;/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/pack;/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/.idea;/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/.DS_Store;/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/.git;/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/.vscode")
|
||||
set(CPACK_SOURCE_OUTPUT_CONFIG_FILE "/home/paquito/Projects/LedBars/RpiLedBars/backend/.build/CPackSourceConfig.cmake")
|
||||
set(CPACK_SOURCE_RPM "OFF")
|
||||
set(CPACK_SOURCE_TBZ2 "ON")
|
||||
set(CPACK_SOURCE_TGZ "ON")
|
||||
set(CPACK_SOURCE_TXZ "ON")
|
||||
set(CPACK_SOURCE_TZ "ON")
|
||||
set(CPACK_SOURCE_ZIP "OFF")
|
||||
set(CPACK_SYSTEM_NAME "Linux")
|
||||
set(CPACK_TOPLEVEL_TAG "Linux")
|
||||
set(CPACK_WIX_SIZEOF_VOID_P "8")
|
||||
|
||||
if(NOT CPACK_PROPERTIES_FILE)
|
||||
set(CPACK_PROPERTIES_FILE "/home/paquito/Projects/LedBars/RpiLedBars/backend/.build/CPackProperties.cmake")
|
||||
endif()
|
||||
|
||||
if(EXISTS ${CPACK_PROPERTIES_FILE})
|
||||
include(${CPACK_PROPERTIES_FILE})
|
||||
endif()
|
94
RpiLedBars/backend/.build/CPackSourceConfig.cmake
Normal file
94
RpiLedBars/backend/.build/CPackSourceConfig.cmake
Normal file
@@ -0,0 +1,94 @@
|
||||
# This file will be configured to contain variables for CPack. These variables
|
||||
# should be set in the CMake list file of the project before CPack module is
|
||||
# included. The list of available CPACK_xxx variables and their associated
|
||||
# documentation may be obtained using
|
||||
# cpack --help-variable-list
|
||||
#
|
||||
# Some variables are common to all generators (e.g. CPACK_PACKAGE_NAME)
|
||||
# and some are specific to a generator
|
||||
# (e.g. CPACK_NSIS_EXTRA_INSTALL_COMMANDS). The generator specific variables
|
||||
# usually begin with CPACK_<GENNAME>_xxxx.
|
||||
|
||||
|
||||
set(CPACK_BINARY_7Z "")
|
||||
set(CPACK_BINARY_BUNDLE "")
|
||||
set(CPACK_BINARY_CYGWIN "")
|
||||
set(CPACK_BINARY_DEB "OFF")
|
||||
set(CPACK_BINARY_DRAGNDROP "")
|
||||
set(CPACK_BINARY_FREEBSD "OFF")
|
||||
set(CPACK_BINARY_IFW "OFF")
|
||||
set(CPACK_BINARY_NSIS "OFF")
|
||||
set(CPACK_BINARY_NUGET "")
|
||||
set(CPACK_BINARY_OSXX11 "")
|
||||
set(CPACK_BINARY_PACKAGEMAKER "")
|
||||
set(CPACK_BINARY_PRODUCTBUILD "")
|
||||
set(CPACK_BINARY_RPM "OFF")
|
||||
set(CPACK_BINARY_STGZ "ON")
|
||||
set(CPACK_BINARY_TBZ2 "OFF")
|
||||
set(CPACK_BINARY_TGZ "ON")
|
||||
set(CPACK_BINARY_TXZ "OFF")
|
||||
set(CPACK_BINARY_TZ "ON")
|
||||
set(CPACK_BINARY_WIX "")
|
||||
set(CPACK_BINARY_ZIP "")
|
||||
set(CPACK_BUILD_SOURCE_DIRS "/home/paquito/Projects/LedBars/RpiLedBars/backend;/home/paquito/Projects/LedBars/RpiLedBars/backend/.build")
|
||||
set(CPACK_CMAKE_GENERATOR "Unix Makefiles")
|
||||
set(CPACK_COMPONENTS_ALL "")
|
||||
set(CPACK_COMPONENT_UNSPECIFIED_HIDDEN "TRUE")
|
||||
set(CPACK_COMPONENT_UNSPECIFIED_REQUIRED "TRUE")
|
||||
set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE "/usr/share/cmake-3.16/Templates/CPack.GenericDescription.txt")
|
||||
set(CPACK_GENERATOR "TBZ2;TGZ;TXZ;TZ")
|
||||
set(CPACK_IGNORE_FILES "/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/build;/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/cmake-build-debug;/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/pack;/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/.idea;/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/.DS_Store;/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/.git;/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/.vscode")
|
||||
set(CPACK_INSTALLED_DIRECTORIES "/home/paquito/Projects/LedBars/RpiLedBars/backend;/")
|
||||
set(CPACK_INSTALL_CMAKE_PROJECTS "")
|
||||
set(CPACK_INSTALL_PREFIX "/usr/local")
|
||||
set(CPACK_MODULE_PATH "")
|
||||
set(CPACK_NSIS_DISPLAY_NAME "json-c 0.16.99")
|
||||
set(CPACK_NSIS_INSTALLER_ICON_CODE "")
|
||||
set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "")
|
||||
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
|
||||
set(CPACK_NSIS_PACKAGE_NAME "json-c 0.16.99")
|
||||
set(CPACK_OUTPUT_CONFIG_FILE "/home/paquito/Projects/LedBars/RpiLedBars/backend/.build/CPackConfig.cmake")
|
||||
set(CPACK_PACKAGE_DEFAULT_LOCATION "/")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE "/usr/share/cmake-3.16/Templates/CPack.GenericDescription.txt")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "RpiLedBars built using CMake")
|
||||
set(CPACK_PACKAGE_FILE_NAME "json-c-0.16.99-Source")
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "json-c 0.16.99")
|
||||
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "json-c 0.16.99")
|
||||
set(CPACK_PACKAGE_NAME "json-c")
|
||||
set(CPACK_PACKAGE_RELOCATABLE "true")
|
||||
set(CPACK_PACKAGE_VENDOR "Humanity")
|
||||
set(CPACK_PACKAGE_VERSION "0.16.99")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "0")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "16")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "99")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "/usr/share/cmake-3.16/Templates/CPack.GenericLicense.txt")
|
||||
set(CPACK_RESOURCE_FILE_README "/usr/share/cmake-3.16/Templates/CPack.GenericDescription.txt")
|
||||
set(CPACK_RESOURCE_FILE_WELCOME "/usr/share/cmake-3.16/Templates/CPack.GenericWelcome.txt")
|
||||
set(CPACK_RPM_PACKAGE_SOURCES "ON")
|
||||
set(CPACK_SET_DESTDIR "OFF")
|
||||
set(CPACK_SOURCE_7Z "")
|
||||
set(CPACK_SOURCE_CYGWIN "")
|
||||
set(CPACK_SOURCE_GENERATOR "TBZ2;TGZ;TXZ;TZ")
|
||||
set(CPACK_SOURCE_IGNORE_FILES "/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/build;/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/cmake-build-debug;/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/pack;/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/.idea;/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/.DS_Store;/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/.git;/mnt/c/Users/Paquito/Projects/LedBars/RpiLedBars/backend/.build/_deps/json-c-src/.vscode")
|
||||
set(CPACK_SOURCE_INSTALLED_DIRECTORIES "/home/paquito/Projects/LedBars/RpiLedBars/backend;/")
|
||||
set(CPACK_SOURCE_OUTPUT_CONFIG_FILE "/home/paquito/Projects/LedBars/RpiLedBars/backend/.build/CPackSourceConfig.cmake")
|
||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME "json-c-0.16.99-Source")
|
||||
set(CPACK_SOURCE_RPM "OFF")
|
||||
set(CPACK_SOURCE_TBZ2 "ON")
|
||||
set(CPACK_SOURCE_TGZ "ON")
|
||||
set(CPACK_SOURCE_TOPLEVEL_TAG "Linux-Source")
|
||||
set(CPACK_SOURCE_TXZ "ON")
|
||||
set(CPACK_SOURCE_TZ "ON")
|
||||
set(CPACK_SOURCE_ZIP "OFF")
|
||||
set(CPACK_STRIP_FILES "")
|
||||
set(CPACK_SYSTEM_NAME "Linux")
|
||||
set(CPACK_TOPLEVEL_TAG "Linux-Source")
|
||||
set(CPACK_WIX_SIZEOF_VOID_P "8")
|
||||
|
||||
if(NOT CPACK_PROPERTIES_FILE)
|
||||
set(CPACK_PROPERTIES_FILE "/home/paquito/Projects/LedBars/RpiLedBars/backend/.build/CPackProperties.cmake")
|
||||
endif()
|
||||
|
||||
if(EXISTS ${CPACK_PROPERTIES_FILE})
|
||||
include(${CPACK_PROPERTIES_FILE})
|
||||
endif()
|
24
RpiLedBars/backend/.build/src/cava_config
Normal file
24
RpiLedBars/backend/.build/src/cava_config
Normal file
@@ -0,0 +1,24 @@
|
||||
[general]
|
||||
framerate = 60
|
||||
autosens = 0
|
||||
sensitivity = 200
|
||||
bars = 128
|
||||
|
||||
[input]
|
||||
method = alsa
|
||||
source = plughw:1
|
||||
|
||||
[output]
|
||||
method = raw
|
||||
channels = mono
|
||||
mono_option = left
|
||||
data_format = ascii
|
||||
ascii_max_range=65535
|
||||
bit_format = 16bit
|
||||
|
||||
[smoothing]
|
||||
integral = 77
|
||||
monstercat = 0
|
||||
waves = 0
|
||||
gravity = 0
|
||||
|
@@ -5,8 +5,9 @@ project(RpiLedBars VERSION 0.5 LANGUAGES C)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
add_subdirectory(libs)
|
||||
|
||||
configure_file(cava_config ../ COPYONLY)
|
||||
configure_file(cava_config src/ COPYONLY)
|
||||
|
||||
add_subdirectory(src)
|
@@ -19,11 +19,18 @@ sudo pip3 install --upgrade adafruit-python-shell
|
||||
~~~
|
||||
|
||||
#### Build and install module
|
||||
OLD OS <= buster
|
||||
~~~bash
|
||||
cd /tmp
|
||||
sudo wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/i2smic.py
|
||||
sudo python3 i2smic.py
|
||||
~~~
|
||||
New os
|
||||
Edit `sudo nano /boot/firmware/config.txt` to add
|
||||
~~~
|
||||
dtoverlay=googlevoicehat-soundcard
|
||||
~~~
|
||||
|
||||
|
||||
After a kernel update this step as to be executed again (after reboot -> depends on `uname`)
|
||||
|
||||
@@ -48,14 +55,24 @@ cp res/.asoundrc ~/.asoundrc
|
||||
### Project depenencies
|
||||
|
||||
~~~bash
|
||||
sudo apt install libasound2-dev wiringpi
|
||||
sudo apt install cmake libasound2-dev
|
||||
~~~
|
||||
|
||||
#### WiringPi
|
||||
~~~bash
|
||||
(
|
||||
cd /tmp
|
||||
wget https://github.com/WiringPi/WiringPi/releases/download/3.6/wiringpi_3.6_armhf.deb
|
||||
sudo apt install /tmp/wiringpi_3.6_armhf.deb
|
||||
)
|
||||
~~~
|
||||
|
||||
#### Cava
|
||||
|
||||
~~~bash
|
||||
sudo apt install libfftw3-dev libasound2-dev libtool automake
|
||||
cd cava_
|
||||
sudo apt install libfftw3-dev libasound2-dev libtool automake git
|
||||
git clone https://github.com/karlstav/cava.git
|
||||
cd cava
|
||||
./autogen.sh
|
||||
./configure
|
||||
make
|
||||
|
3
RpiLedBars/backend/build.sh
Normal file
3
RpiLedBars/backend/build.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
cmake -B .build && cmake --build .build
|
@@ -1,5 +1,8 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
# make
|
||||
install -v -D ../build/src/RpiLedBars cava_config -t /opt/pixled/
|
||||
sudo -s install -v -D ./build/src cava_config -t /opt/pixled/
|
||||
sudo -s install -v -D ./build/src RpiLedBars -t /opt/pixled/
|
||||
# cp ./bin/pixled bin/service_pixled
|
||||
sudo -s bash -c "cp pixled.service /etc/systemd/system; systemctl daemon-reload"
|
||||
# sudo -s bash -c "systemctl enable pixled"
|
||||
|
@@ -1,6 +1,9 @@
|
||||
include(FetchContent)
|
||||
|
||||
set(FETCHCONTENT_FULLY_DISCONNECTED ON)
|
||||
#set(FETCHCONTENT_FULLY_DISCONNECTED ON)
|
||||
|
||||
# set(BUILD_SHARED_LIBS off)
|
||||
# set(ENABLE_CJSON_TEST off)
|
||||
|
||||
FetchContent_Declare(
|
||||
logc
|
||||
@@ -12,5 +15,10 @@ FetchContent_Declare(
|
||||
GIT_REPOSITORY "https://github.com/Tropicananass/wsServer.git"
|
||||
)
|
||||
|
||||
# FetchContent_Declare(
|
||||
# cjson
|
||||
# GIT_REPOSITORY "https://github.com/DaveGamble/cJSON.git"
|
||||
# )
|
||||
|
||||
# add the log.c and ws libraries
|
||||
FetchContent_MakeAvailable(logc ws)
|
||||
FetchContent_MakeAvailable(logc ws)
|
||||
|
6
RpiLedBars/backend/run.sh
Normal file
6
RpiLedBars/backend/run.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
sudo -s bash -c "systemctl stop pixled"
|
||||
cd '.build/src/' || exit 1
|
||||
chmod u+x ./RpiLedBars
|
||||
sudo ./RpiLedBars -n 60 -d 1
|
@@ -137,40 +137,48 @@ int main(int argc, char const *argv[]) {
|
||||
**************************************************************************************************/
|
||||
|
||||
void parseCommandLineArgs(int argc, char const *argv[]) {
|
||||
int args = 0;
|
||||
int argIt = 0;
|
||||
|
||||
while (argc > ++args) // Process command-line args
|
||||
while (argc > ++argIt) // Process command-line args
|
||||
{
|
||||
if (argv[args][0] == '-') {
|
||||
switch (toupper(argv[args][1])) {
|
||||
if (argv[argIt][0] == '-' && argv[argIt][2] == '\0') {
|
||||
switch (toupper(argv[argIt][1])) {
|
||||
case 'N': // -N: number of LEDs per channel
|
||||
if (args >= argc - 1) {
|
||||
if (argIt >= argc - 1) {
|
||||
log_error("no numeric value");
|
||||
exit(-EXIT_FAILURE);
|
||||
} else {
|
||||
param_access->pixled.chanLedCount = atoi(argv[++args]);
|
||||
int ledCount = atoi(argv[++argIt]);
|
||||
param_access->pixled.chanLedCount = ledCount <= CHAN_MAXLEDS ? ledCount : CHAN_MAXLEDS;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'D': // -D: debug level
|
||||
if (args >= argc - 1) {
|
||||
if (argIt >= argc - 1) {
|
||||
log_error("no debug level");
|
||||
exit(-EXIT_FAILURE);
|
||||
} else {
|
||||
logLevel = atoi(argv[++args]);
|
||||
logLevel = atoi(argv[++argIt]);
|
||||
log_set_level(logLevel);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'T': // -T: test mode
|
||||
IsTestMode = true;
|
||||
break;
|
||||
|
||||
default: // Otherwise error
|
||||
log_error("Unrecognised option '%c'\n", argv[args][1]);
|
||||
fprintf(stderr, "Options:\n"
|
||||
" -t Test mode (flash LEDs)\n"
|
||||
" -n num number of LEDs per channel\n"
|
||||
" -d lvl debug level\n");
|
||||
log_error("Unknown option '%c'\n", argv[argIt][1]);
|
||||
fprintf(stderr,
|
||||
"Options:\n"
|
||||
" -t Test mode (flash LEDs)\n"
|
||||
" -n num number of LEDs per channel (max : %d)\n"
|
||||
" -d lvl debug level\n",
|
||||
CHAN_MAXLEDS);
|
||||
exit(-EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
log_warn("Unknown option '%s'\n", argv[argIt]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,10 +296,10 @@ void execute_autonomous_mode() {
|
||||
if ((ret = cava_get_buffer(&buffer)) == 0) {
|
||||
switch (param_access->auton.pattern) {
|
||||
case 0:
|
||||
bounce_led_and_color(buffer, CAVA_BAR_NUMBER);
|
||||
bounce_led(buffer, CAVA_BAR_NUMBER);
|
||||
break;
|
||||
case 1:
|
||||
bounce_led(buffer, CAVA_BAR_NUMBER);
|
||||
bounce_led_and_color(buffer, CAVA_BAR_NUMBER);
|
||||
break;
|
||||
case 2:
|
||||
bounce_led_and_travel(buffer, CAVA_BAR_NUMBER);
|
||||
|
@@ -43,6 +43,7 @@ ledbar_param_t const dummyLedbarParam = {.sensitivity = 1.,
|
||||
**************************************************************************************************/
|
||||
|
||||
param_t param;
|
||||
param_t *param_access = NULL;
|
||||
|
||||
pthread_mutex_t paramLockMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
|
@@ -54,7 +54,10 @@ typedef struct {
|
||||
} auton_param_t;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @var ledbar_param_t::sensitivity
|
||||
* sensitivity of the led bar
|
||||
*/
|
||||
typedef struct {
|
||||
float sensitivity;
|
||||
@@ -81,7 +84,7 @@ typedef struct {
|
||||
* Global Variables
|
||||
**************************************************************************************************/
|
||||
|
||||
param_t *param_access;
|
||||
extern param_t *param_access;
|
||||
|
||||
/***************************************************************************************************
|
||||
* External Function Prototypes
|
||||
@@ -89,56 +92,92 @@ param_t *param_access;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void param_setup();
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @brief Set the mode object
|
||||
*
|
||||
* @param[in] mode
|
||||
*/
|
||||
void set_mode(unsigned int mode);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @brief Set the pattern object
|
||||
*
|
||||
* @param[in] pattern
|
||||
*/
|
||||
void set_pattern(unsigned int pattern);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @brief Set the hue auto shift object
|
||||
*
|
||||
* @param[in] HasToBeEnabled
|
||||
*/
|
||||
void set_hue_auto_shift(bool HasToBeEnabled);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @brief Set the gravity object
|
||||
*
|
||||
* @param[in] gravity8
|
||||
*/
|
||||
void set_gravity(int8_t gravity8);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @brief Set the sensitivity object
|
||||
*
|
||||
* @param[in] channel
|
||||
*
|
||||
* @param[in] sensitivity8
|
||||
*/
|
||||
void set_sensitivity(int channel, int8_t sensitivity8);
|
||||
|
||||
/**
|
||||
* @brief Set the hue base object
|
||||
*
|
||||
* @param[in] channel
|
||||
* @param[in] hueBase8
|
||||
*/
|
||||
void set_hue_base(int channel, int8_t hueBase8);
|
||||
|
||||
/**
|
||||
* @brief Set the hue interval object
|
||||
*
|
||||
* @param[in] channel
|
||||
* @param[in] hueInterval8
|
||||
*/
|
||||
void set_hue_interval(int channel, int8_t hueInterval8);
|
||||
|
||||
/**
|
||||
* @brief Set the hue auto shift interval object
|
||||
*
|
||||
* @param[in] channel
|
||||
* @param[in] hueInterval8
|
||||
*/
|
||||
void set_hue_auto_shift_interval(int channel, int8_t hueInterval8);
|
||||
|
||||
/**
|
||||
* @brief Set the hue auto shift speed object
|
||||
*
|
||||
* @param[in] channel
|
||||
* @param[in] hueSpeed8
|
||||
*/
|
||||
void set_hue_auto_shift_speed(int channel, int8_t hueSpeed8);
|
||||
|
||||
/**
|
||||
* @brief Set the luminosity object
|
||||
*
|
||||
* @param[in] channel
|
||||
* @param[in] luminosity8
|
||||
*/
|
||||
void set_luminosity(int channel, int8_t luminosity8);
|
||||
|
||||
/**
|
||||
* @brief Set the saturation object
|
||||
*
|
||||
* @param[in] channel
|
||||
* @param[in] saturation8
|
||||
*/
|
||||
void set_saturation(int channel, int8_t saturation8);
|
||||
|
||||
#endif /* __RPI_PARAM_H__ */
|
@@ -51,51 +51,64 @@ int baseLedIndexArray[LED_NCHANS];
|
||||
* Internal Function Prototypes
|
||||
**************************************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief Get the max on interval object
|
||||
*
|
||||
* @param array
|
||||
* @param length
|
||||
* @param intervalMin
|
||||
* @param intervalSize
|
||||
* @return uint16_t
|
||||
*/
|
||||
uint16_t get_max_on_interval(uint16_t *array, unsigned int length, size_t intervalMin,
|
||||
size_t intervalSize);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param value
|
||||
* @param valueIndex
|
||||
* @return uint16_t
|
||||
*/
|
||||
uint16_t apply_sensitivity(uint16_t value, unsigned int valueIndex);
|
||||
|
||||
/**
|
||||
* @brief Get the led to light count object
|
||||
*
|
||||
* @param barValue
|
||||
* @param barIndex
|
||||
* @return unsigned int
|
||||
*/
|
||||
unsigned int get_led_to_light_count(uint16_t barValue, unsigned int barIndex);
|
||||
|
||||
/**
|
||||
* @brief Get the first led to light object
|
||||
*
|
||||
* @param barIndex
|
||||
* @return unsigned int
|
||||
*/
|
||||
unsigned int get_first_led_to_light(unsigned int barIndex);
|
||||
|
||||
/**
|
||||
* @brief Get the hsv color object
|
||||
*
|
||||
* @param barIndex
|
||||
* @param shiftRatio
|
||||
* @return uint32_t
|
||||
*/
|
||||
uint32_t get_hsv_color(unsigned int barIndex, float shiftRatio);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param barIndex
|
||||
*/
|
||||
void increment_autoshift(unsigned int barIndex);
|
||||
|
||||
/***************************************************************************************************
|
||||
* External Function Definitions
|
||||
**************************************************************************************************/
|
||||
|
||||
void bounce_led_and_color(uint16_t *spectrumArray, unsigned int spectrumLength) {
|
||||
for (size_t ledBarIndex = 0; ledBarIndex < LED_NCHANS; ++ledBarIndex) {
|
||||
size_t intervalSize = spectrumLength / LED_NCHANS;
|
||||
uint16_t barMax = 0;
|
||||
unsigned int ledToLightCount = 0;
|
||||
|
||||
barMax = get_max_on_interval(spectrumArray, spectrumLength, ledBarIndex * intervalSize,
|
||||
intervalSize);
|
||||
barMax = apply_sensitivity(barMax, ledBarIndex);
|
||||
ledToLightCount = get_led_to_light_count(barMax, ledBarIndex);
|
||||
|
||||
uint32_t color = get_hsv_color(ledBarIndex, (ledToLightCount - 1) /
|
||||
(float)param_access->pixled.chanLedCount);
|
||||
|
||||
for (size_t i = 0; i < ledToLightCount; ++i) {
|
||||
rgbData[i][ledBarIndex] = color;
|
||||
rgb_txdata(rgbData[i], i);
|
||||
}
|
||||
for (size_t i = ledToLightCount; i < param_access->pixled.chanLedCount; ++i) {
|
||||
rgbData[i][ledBarIndex] = 0x000000;
|
||||
rgb_txdata(rgbData[i], i);
|
||||
}
|
||||
|
||||
increment_autoshift(ledBarIndex);
|
||||
}
|
||||
leddriver_refresh();
|
||||
}
|
||||
|
||||
void bounce_led(uint16_t *spectrumArray, unsigned int spectrumLength) {
|
||||
for (size_t ledBarIndex = 0; ledBarIndex < LED_NCHANS; ++ledBarIndex) {
|
||||
size_t intervalSize = spectrumLength / LED_NCHANS;
|
||||
@@ -124,6 +137,34 @@ void bounce_led(uint16_t *spectrumArray, unsigned int spectrumLength) {
|
||||
leddriver_refresh();
|
||||
}
|
||||
|
||||
void bounce_led_and_color(uint16_t *spectrumArray, unsigned int spectrumLength) {
|
||||
for (size_t ledBarIndex = 0; ledBarIndex < LED_NCHANS; ++ledBarIndex) {
|
||||
size_t intervalSize = spectrumLength / LED_NCHANS;
|
||||
uint16_t barMax = 0;
|
||||
unsigned int ledToLightCount = 0;
|
||||
|
||||
barMax = get_max_on_interval(spectrumArray, spectrumLength, ledBarIndex * intervalSize,
|
||||
intervalSize);
|
||||
barMax = apply_sensitivity(barMax, ledBarIndex);
|
||||
ledToLightCount = get_led_to_light_count(barMax, ledBarIndex);
|
||||
|
||||
uint32_t color = get_hsv_color(ledBarIndex, (ledToLightCount - 1) /
|
||||
(float)param_access->pixled.chanLedCount);
|
||||
|
||||
for (size_t i = 0; i < ledToLightCount; ++i) {
|
||||
rgbData[i][ledBarIndex] = color;
|
||||
rgb_txdata(rgbData[i], i);
|
||||
}
|
||||
for (size_t i = ledToLightCount; i < param_access->pixled.chanLedCount; ++i) {
|
||||
rgbData[i][ledBarIndex] = 0x000000;
|
||||
rgb_txdata(rgbData[i], i);
|
||||
}
|
||||
|
||||
increment_autoshift(ledBarIndex);
|
||||
}
|
||||
leddriver_refresh();
|
||||
}
|
||||
|
||||
void bounce_led_and_travel(uint16_t *spectrumArray, unsigned int spectrumLength) {
|
||||
for (size_t ledBarIndex = 0; ledBarIndex < LED_NCHANS; ++ledBarIndex) {
|
||||
size_t intervalSize = spectrumLength / LED_NCHANS;
|
||||
|
@@ -31,16 +31,6 @@
|
||||
* @brief
|
||||
*
|
||||
* @param[in] spectrumArray array of value from spectral analysis
|
||||
*
|
||||
* @param[in] spectrumLength length of spectrum array
|
||||
*/
|
||||
void bounce_led_and_color(uint16_t *spectrumArray, unsigned int spectrumLength);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in] spectrumArray array of value from spectral analysis
|
||||
*
|
||||
* @param[in] spectrumLength length of spectrum array
|
||||
*/
|
||||
void bounce_led(uint16_t *spectrumArray, unsigned int spectrumLength);
|
||||
@@ -49,7 +39,14 @@ void bounce_led(uint16_t *spectrumArray, unsigned int spectrumLength);
|
||||
* @brief
|
||||
*
|
||||
* @param[in] spectrumArray array of value from spectral analysis
|
||||
* @param[in] spectrumLength length of spectrum array
|
||||
*/
|
||||
void bounce_led_and_color(uint16_t *spectrumArray, unsigned int spectrumLength);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in] spectrumArray array of value from spectral analysis
|
||||
* @param[in] spectrumLength length of spectrum array
|
||||
*/
|
||||
void bounce_led_and_travel(uint16_t *spectrumArray, unsigned int spectrumLength);
|
||||
|
@@ -34,7 +34,7 @@
|
||||
|
||||
int client_fd = -1;
|
||||
|
||||
int channel = LED_NCHANS;
|
||||
int current_channel = LED_NCHANS;
|
||||
|
||||
/***************************************************************************************************
|
||||
* Internal Function Prototypes
|
||||
@@ -73,18 +73,74 @@ void onclose(int fd);
|
||||
*/
|
||||
void onmessage(int fd, const unsigned char *msg, uint64_t size, int type);
|
||||
|
||||
void mode_command_handler(char *payload);
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param payload
|
||||
*/
|
||||
void mode_command_handler(const char *payload);
|
||||
|
||||
void pattern_command_handler(char *payload);
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param payload
|
||||
*/
|
||||
void pattern_command_handler(const char *payload);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param payload
|
||||
*/
|
||||
void color_command_handler(char *payload);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param payload
|
||||
*/
|
||||
void hue_interval_command_handler(char *payload);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param payload
|
||||
*/
|
||||
void modulate_command_handler(char *payload);
|
||||
|
||||
void channel_command_handler(char *payload);
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param payload
|
||||
*/
|
||||
void modulation_interval_command_handler(char *payload);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param payload
|
||||
*/
|
||||
void modulation_speed_command_handler(char *payload);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param payload
|
||||
*/
|
||||
void channel_command_handler(const char *payload);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param payload
|
||||
*/
|
||||
void sensitivity_command_handler(char *payload);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param payload
|
||||
*/
|
||||
void gravity_command_handler(char *payload);
|
||||
|
||||
/***************************************************************************************************
|
||||
@@ -130,45 +186,65 @@ void onclose(int fd) {
|
||||
client_fd = -1;
|
||||
}
|
||||
|
||||
#define FOREACH_CMD(FNCT) \
|
||||
FNCT(mode) \
|
||||
FNCT(pattern) \
|
||||
FNCT(channel)
|
||||
|
||||
#define GENERATE_SWITCH(CASE) \
|
||||
if (!strcmp(command, #CASE)) { \
|
||||
CASE##_command_handler(payload); \
|
||||
} else
|
||||
|
||||
void onmessage(int fd, const unsigned char *msg, uint64_t size, int type) {
|
||||
char msgStr[size + 1];
|
||||
char *command, *payload;
|
||||
char *cli = ws_getaddress(fd);
|
||||
log_trace("Received message: %s (size: %" PRId64 ", type: %d), from: %s/%d", msg, size, type, cli,
|
||||
fd);
|
||||
|
||||
strcpy(msgStr, (char *)msg);
|
||||
command = strtok(msgStr, ":");
|
||||
if (command != NULL) {
|
||||
payload = strtok(NULL, ":");
|
||||
if (payload != NULL && strlen(command) == 1) {
|
||||
switch (command[0]) {
|
||||
case 'm':
|
||||
mode_command_handler(payload);
|
||||
break;
|
||||
case 'p':
|
||||
pattern_command_handler(payload);
|
||||
break;
|
||||
case 'c':
|
||||
color_command_handler(payload);
|
||||
break;
|
||||
case 's':
|
||||
modulate_command_handler(payload);
|
||||
break;
|
||||
case 'h':
|
||||
channel_command_handler(payload);
|
||||
break;
|
||||
case 'e':
|
||||
sensitivity_command_handler(payload);
|
||||
break;
|
||||
case 'g':
|
||||
gravity_command_handler(payload);
|
||||
break;
|
||||
if (payload != NULL) {
|
||||
|
||||
default:
|
||||
log_warn("Unkown command in \"%s\"", msgStr);
|
||||
break;
|
||||
}
|
||||
FOREACH_CMD(GENERATE_SWITCH) log_warn("Unkown command %s in \"%s\"", command, msg);
|
||||
// switch (command[0]) {
|
||||
// case 'm':
|
||||
// mode_command_handler(payload);
|
||||
// break;
|
||||
// case 'p':
|
||||
// pattern_command_handler(payload);
|
||||
// break;
|
||||
// case 'i':
|
||||
// hue_interval_command_handler(payload);
|
||||
// break;
|
||||
// case 'c':
|
||||
// color_command_handler(payload);
|
||||
// break;
|
||||
// case 's':
|
||||
// modulate_command_handler(payload);
|
||||
// break;
|
||||
// case 't':
|
||||
// modulation_interval_command_handler(payload);
|
||||
// break;
|
||||
// case 'u':
|
||||
// modulation_speed_command_handler(payload);
|
||||
// break;
|
||||
// case 'h':
|
||||
// channel_command_handler(payload);
|
||||
// break;
|
||||
// case 'e':
|
||||
// sensitivity_command_handler(payload);
|
||||
// break;
|
||||
// case 'g':
|
||||
// gravity_command_handler(payload);
|
||||
// break;
|
||||
|
||||
// default:
|
||||
// log_warn("Unkown command in \"%s\"", msgStr);
|
||||
// break;
|
||||
// }
|
||||
} else {
|
||||
log_warn("Empty payload in \"%s\"", msgStr);
|
||||
}
|
||||
@@ -179,7 +255,7 @@ void onmessage(int fd, const unsigned char *msg, uint64_t size, int type) {
|
||||
free(cli);
|
||||
}
|
||||
|
||||
void mode_command_handler(char *payload) {
|
||||
void mode_command_handler(const char *payload) {
|
||||
int newMode = atoi(payload);
|
||||
if (0 <= newMode && newMode <= 3) {
|
||||
set_mode(newMode);
|
||||
@@ -188,7 +264,7 @@ void mode_command_handler(char *payload) {
|
||||
}
|
||||
}
|
||||
|
||||
void pattern_command_handler(char *payload) {
|
||||
void pattern_command_handler(const char *payload) {
|
||||
int newPattern = atoi(payload);
|
||||
if (0 <= newPattern && newPattern <= 3) {
|
||||
set_pattern(newPattern);
|
||||
@@ -209,33 +285,46 @@ void color_command_handler(char *payload) {
|
||||
log_debug(" - %s", tokenArray[n]);
|
||||
}
|
||||
if (atoi(tokenArray[0]) == 0) {
|
||||
set_hue_base(channel, atoi(tokenArray[1]) * INT8_MAX / HUE_MAX);
|
||||
set_saturation(channel, atoi(tokenArray[2]) * INT8_MAX / 100);
|
||||
set_luminosity(channel, atoi(tokenArray[3]) * INT8_MAX / 100);
|
||||
} else {
|
||||
set_saturation(channel, atoi(tokenArray[2]) * INT8_MAX / 100);
|
||||
set_luminosity(channel, atoi(tokenArray[3]) * INT8_MAX / 100);
|
||||
set_hue_base(current_channel, atoi(tokenArray[1]) * INT8_MAX / HUE_MAX);
|
||||
set_saturation(current_channel, atoi(tokenArray[2]) * INT8_MAX / 100);
|
||||
set_luminosity(current_channel, atoi(tokenArray[3]) * INT8_MAX / 100);
|
||||
}
|
||||
}
|
||||
|
||||
void hue_interval_command_handler(char *payload) {
|
||||
int hueInterval = atoi(payload);
|
||||
log_debug("hueInterval: %d", hueInterval);
|
||||
set_hue_interval(current_channel, hueInterval);
|
||||
}
|
||||
|
||||
void modulate_command_handler(char *payload) {
|
||||
bool modulate;
|
||||
modulate = strcmp(payload, "true") == 0;
|
||||
log_debug("modulate :%s", modulate ? "true" : "false");
|
||||
set_hue_auto_shift(modulate);
|
||||
set_hue_auto_shift(modulate);
|
||||
}
|
||||
|
||||
void channel_command_handler(char *payload) {
|
||||
void modulation_interval_command_handler(char *payload) {
|
||||
int modulationInterval = atoi(payload);
|
||||
set_hue_auto_shift_interval(8, modulationInterval);
|
||||
}
|
||||
|
||||
void modulation_speed_command_handler(char *payload) {
|
||||
int modulationSpeed = atoi(payload);
|
||||
set_hue_auto_shift_speed(8, modulationSpeed);
|
||||
}
|
||||
|
||||
void channel_command_handler(const char *payload) {
|
||||
int newChannel = atoi(payload);
|
||||
if (0 <= newChannel && newChannel <= LED_NCHANS) {
|
||||
log_debug("Channel: %d", newChannel);
|
||||
channel = newChannel;
|
||||
current_channel = newChannel;
|
||||
}
|
||||
}
|
||||
|
||||
void sensitivity_command_handler(char *payload) {
|
||||
int newSensitivity = atoi(payload);
|
||||
set_sensitivity(channel, newSensitivity);
|
||||
set_sensitivity(current_channel, newSensitivity);
|
||||
}
|
||||
|
||||
void gravity_command_handler(char *payload) {
|
||||
|
Reference in New Issue
Block a user