Updates from pi

This commit is contained in:
2022-07-20 16:57:01 +02:00
parent 84612aded5
commit c1fb89271c
18 changed files with 468 additions and 133 deletions

View File

@@ -106,7 +106,7 @@ void set_sensitivity(int channel, int8_t sensitivity8) {
} else {
param.ledbar[channel].sensitivity = sensitivity;
}
log_debug("Sensitivity : %f", sensitivity);
log_debug("Sensitivity[%d] : %f", channel, sensitivity);
}
void set_hue_base(int channel, int8_t hueBase8) {

View File

@@ -187,7 +187,7 @@ static int start_cava_process() {
if (cavaPid == 0) {
/* Child process*/
// int fdLogOut;
char *args[] = {"cava", "-p", "/home/pi/LedBars/RpiLedBars/cava_config", NULL};
char *args[] = {"cava", "-p", "./cava_config", NULL};
/* Close reading end of the pipe */
close(fdCavaPipe[0]);

View File

@@ -34,6 +34,8 @@
int client_fd = -1;
int channel = LED_NCHANS;
/***************************************************************************************************
* Internal Function Prototypes
**************************************************************************************************/
@@ -77,6 +79,14 @@ void pattern_command_handler(char *payload);
void color_command_handler(char *payload);
void modulate_command_handler(char *payload);
void channel_command_handler(char *payload);
void sensitivity_command_handler(char *payload);
void gravity_command_handler(char *payload);
/***************************************************************************************************
* External Function Definitions
**************************************************************************************************/
@@ -142,6 +152,18 @@ void onmessage(int fd, const unsigned char *msg, uint64_t size, int type) {
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;
default:
log_warn("Unkown command in \"%s\"", msgStr);
@@ -187,8 +209,36 @@ void color_command_handler(char *payload) {
log_debug(" - %s", tokenArray[n]);
}
if (atoi(tokenArray[0]) == 0) {
set_hue_base(LED_NCHANS, atoi(tokenArray[1]) * INT8_MAX / HUE_MAX);
set_saturation(LED_NCHANS, atoi(tokenArray[2]) * INT8_MAX / 100);
set_luminosity(LED_NCHANS, atoi(tokenArray[3]) * INT8_MAX / 100);
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);
}
}
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);
}
void channel_command_handler(char *payload) {
int newChannel = atoi(payload);
if (0 <= newChannel && newChannel <= LED_NCHANS) {
log_debug("Channel: %d", newChannel);
channel = newChannel;
}
}
void sensitivity_command_handler(char *payload) {
int newSensitivity = atoi(payload);
set_sensitivity(channel, newSensitivity);
}
void gravity_command_handler(char *payload) {
int newGravity = atoi(payload);
set_gravity(newGravity);
}