sensitivity param for auto mode
This commit is contained in:
parent
c16cc57ccd
commit
c93997776d
@ -3,7 +3,7 @@ Description=pixled
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=pixled -n 180 -d 1
|
||||
ExecStart=pixled -n 180 -d 2
|
||||
Restart=always
|
||||
User=root
|
||||
Group=root
|
||||
|
@ -13,4 +13,6 @@ void rgb_txdata(int *rgbs, int index);
|
||||
|
||||
void leddriver_refresh();
|
||||
|
||||
uint32_t ColorHSV(uint16_t hue, uint8_t sat, uint8_t val);
|
||||
|
||||
#endif // __RPI_LEDDRIVER_H__
|
@ -84,12 +84,12 @@ int main(int argc, char const *argv[]) {
|
||||
|
||||
signal(SIGINT, terminate);
|
||||
|
||||
// struct sched_param sp;
|
||||
// sp.sched_priority = 32;
|
||||
// if (pthread_setschedparam(pthread_self(), SCHED_FIFO, &sp)) {
|
||||
// fprintf(stderr, "WARNING: Failed to set stepper thread to real-time priority: %s\n",
|
||||
// strerror(errno));
|
||||
// }
|
||||
struct sched_param sp;
|
||||
sp.sched_priority = 32;
|
||||
if (pthread_setschedparam(pthread_self(), SCHED_FIFO, &sp)) {
|
||||
fprintf(stderr, "WARNING: Failed to set stepper thread to real-time priority: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
log_set_lock(log_lock_helper, &logLockMutex);
|
||||
|
||||
@ -278,23 +278,31 @@ void execute_artnet_mode() {
|
||||
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() {
|
||||
int ret;
|
||||
uint16_t *buffer;
|
||||
|
||||
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;
|
||||
for (size_t bar = 0; bar < 20 / 4; ++bar) {
|
||||
unsigned barIndex = ledBarIndex * 20 / 4 + bar;
|
||||
for (size_t cavaBar = 0; cavaBar < CAVA_BAR_NUMBER / LED_NCHANS; ++cavaBar) {
|
||||
unsigned barIndex = ledBarIndex * CAVA_BAR_NUMBER / LED_NCHANS + cavaBar;
|
||||
if (barMax < buffer[barIndex]) {
|
||||
barMax = buffer[barIndex];
|
||||
}
|
||||
}
|
||||
barMax *= param_access->auton.sensitivity * param_access->ledbar[ledBarIndex].sensitivity;
|
||||
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) {
|
||||
rgb_data[i][ledBarIndex] = 0xff0000;
|
||||
rgb_data[i][ledBarIndex] = color;
|
||||
rgb_txdata(rgb_data[i], i);
|
||||
}
|
||||
for (size_t i = ledToLight; i < chanLedCount; ++i) {
|
||||
|
@ -182,7 +182,7 @@ void handle_in_port_events(snd_seq_event_t *ev) {
|
||||
case SND_SEQ_EVENT_CONTROLLER:
|
||||
switch (ev->data.control.param) {
|
||||
case 1:
|
||||
|
||||
set_sensitivity(destChannel, ev->data.control.value + 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -57,7 +57,7 @@ typedef struct {
|
||||
* Global Variables
|
||||
**************************************************************************************************/
|
||||
|
||||
static param_t *param_access;
|
||||
param_t *param_access;
|
||||
|
||||
/***************************************************************************************************
|
||||
* External Function Prototypes
|
||||
|
@ -28,7 +28,7 @@
|
||||
/**
|
||||
* 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
|
||||
|
@ -7,12 +7,15 @@
|
||||
/***************************************************************************************************
|
||||
* Includes
|
||||
**************************************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/***************************************************************************************************
|
||||
* Preprocessor Constants and Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
#define CAVA_BAR_NUMBER 128
|
||||
|
||||
/***************************************************************************************************
|
||||
* Type and Contant Definitions
|
||||
**************************************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user