sensitivity param for auto mode

This commit is contained in:
Tropicananass 2021-08-01 10:16:28 +01:00
parent c16cc57ccd
commit c93997776d
7 changed files with 27 additions and 14 deletions

View File

@ -3,7 +3,7 @@ Description=pixled
After=network.target After=network.target
[Service] [Service]
ExecStart=pixled -n 180 -d 1 ExecStart=pixled -n 180 -d 2
Restart=always Restart=always
User=root User=root
Group=root Group=root

View File

@ -13,4 +13,6 @@ void rgb_txdata(int *rgbs, int index);
void leddriver_refresh(); void leddriver_refresh();
uint32_t ColorHSV(uint16_t hue, uint8_t sat, uint8_t val);
#endif // __RPI_LEDDRIVER_H__ #endif // __RPI_LEDDRIVER_H__

View File

@ -84,12 +84,12 @@ int main(int argc, char const *argv[]) {
signal(SIGINT, terminate); signal(SIGINT, terminate);
// struct sched_param sp; struct sched_param sp;
// sp.sched_priority = 32; sp.sched_priority = 32;
// if (pthread_setschedparam(pthread_self(), SCHED_FIFO, &sp)) { if (pthread_setschedparam(pthread_self(), SCHED_FIFO, &sp)) {
// fprintf(stderr, "WARNING: Failed to set stepper thread to real-time priority: %s\n", fprintf(stderr, "WARNING: Failed to set stepper thread to real-time priority: %s\n",
// strerror(errno)); strerror(errno));
// } }
log_set_lock(log_lock_helper, &logLockMutex); log_set_lock(log_lock_helper, &logLockMutex);
@ -278,23 +278,31 @@ void execute_artnet_mode() {
leddriver_refresh(); leddriver_refresh();
} }
uint16_t static const minHue = 120 * UINT16_MAX / 360;
uint16_t static const maxHue = 300 * UINT16_MAX / 360;
uint16_t static const hueInterval = UINT16_MAX - (maxHue - minHue);
void execute_autonomous_mode() { void execute_autonomous_mode() {
int ret; int ret;
uint16_t *buffer; uint16_t *buffer;
if ((ret = cava_get_buffer(&buffer)) == 0) { if ((ret = cava_get_buffer(&buffer)) == 0) {
for (size_t ledBarIndex = 0; ledBarIndex < 4; ++ledBarIndex) { for (size_t ledBarIndex = 0; ledBarIndex < LED_NCHANS; ++ledBarIndex) {
uint16_t barMax = 0; uint16_t barMax = 0;
for (size_t bar = 0; bar < 20 / 4; ++bar) { for (size_t cavaBar = 0; cavaBar < CAVA_BAR_NUMBER / LED_NCHANS; ++cavaBar) {
unsigned barIndex = ledBarIndex * 20 / 4 + bar; unsigned barIndex = ledBarIndex * CAVA_BAR_NUMBER / LED_NCHANS + cavaBar;
if (barMax < buffer[barIndex]) { if (barMax < buffer[barIndex]) {
barMax = buffer[barIndex]; barMax = buffer[barIndex];
} }
} }
barMax *= param_access->auton.sensitivity * param_access->ledbar[ledBarIndex].sensitivity;
unsigned ledToLight = barMax * chanLedCount / UINT16_MAX; unsigned ledToLight = barMax * chanLedCount / UINT16_MAX;
unsigned long hueShift = (long)barMax * (long)hueInterval / hueInterval;
uint16_t hue = minHue - hueShift;
uint32_t color = ColorHSV(hue, 255, 100);
for (size_t i = 0; i < ledToLight; ++i) { for (size_t i = 0; i < ledToLight; ++i) {
rgb_data[i][ledBarIndex] = 0xff0000; rgb_data[i][ledBarIndex] = color;
rgb_txdata(rgb_data[i], i); rgb_txdata(rgb_data[i], i);
} }
for (size_t i = ledToLight; i < chanLedCount; ++i) { for (size_t i = ledToLight; i < chanLedCount; ++i) {

View File

@ -182,7 +182,7 @@ void handle_in_port_events(snd_seq_event_t *ev) {
case SND_SEQ_EVENT_CONTROLLER: case SND_SEQ_EVENT_CONTROLLER:
switch (ev->data.control.param) { switch (ev->data.control.param) {
case 1: case 1:
set_sensitivity(destChannel, ev->data.control.value + 1);
break; break;
default: default:

View File

@ -57,7 +57,7 @@ typedef struct {
* Global Variables * Global Variables
**************************************************************************************************/ **************************************************************************************************/
static param_t *param_access; param_t *param_access;
/*************************************************************************************************** /***************************************************************************************************
* External Function Prototypes * External Function Prototypes

View File

@ -28,7 +28,7 @@
/** /**
* Constant for Maximum char in a line (128 number of (5 char + 1 delim) + \n ) * Constant for Maximum char in a line (128 number of (5 char + 1 delim) + \n )
*/ */
#define MAXLINECHAR 128 * (5 + 1) + 1 #define MAXLINECHAR CAVA_BAR_NUMBER * (5 + 1) + 1
/*************************************************************************************************** /***************************************************************************************************
* Type and Contant Definitions * Type and Contant Definitions

View File

@ -7,12 +7,15 @@
/*************************************************************************************************** /***************************************************************************************************
* Includes * Includes
**************************************************************************************************/ **************************************************************************************************/
#include <stdint.h> #include <stdint.h>
/*************************************************************************************************** /***************************************************************************************************
* Preprocessor Constants and Macros * Preprocessor Constants and Macros
**************************************************************************************************/ **************************************************************************************************/
#define CAVA_BAR_NUMBER 128
/*************************************************************************************************** /***************************************************************************************************
* Type and Contant Definitions * Type and Contant Definitions
**************************************************************************************************/ **************************************************************************************************/