Merge branch 'max-brightness-scale' into 'main'

Limit pattern brightness based on `max_brightness` too

Closes #95

See merge request agx/feedbackd!199
This commit is contained in:
Guido Günther
2025-12-29 17:35:47 +00:00
4 changed files with 23 additions and 10 deletions
+1 -4
View File
@@ -100,10 +100,7 @@ if get_option('daemon')
endif endif
endif endif
install_data('feedbackd.sysusers', install_data('feedbackd.sysusers', rename: 'feedbackd.conf', install_dir: systemd_sysusers_dir)
rename: 'feedbackd.conf',
install_dir: systemd_sysusers_dir,
)
if get_option('media-roles') if get_option('media-roles')
install_data('media-role-nodes.conf', install_dir: wireplumberdir) install_data('media-role-nodes.conf', install_dir: wireplumberdir)
+9 -4
View File
@@ -15,6 +15,8 @@
#include <gio/gio.h> #include <gio/gio.h>
#include <math.h>
#define LED_MULTI_INDEX_ATTR "multi_index" #define LED_MULTI_INDEX_ATTR "multi_index"
#define LED_MULTI_INDEX_RED "red" #define LED_MULTI_INDEX_RED "red"
#define LED_MULTI_INDEX_GREEN "green" #define LED_MULTI_INDEX_GREEN "green"
@@ -132,11 +134,14 @@ fbd_dev_led_multicolor_set_color (FbdDevLed *led,
colors[priv->green_index] = 0; colors[priv->green_index] = 0;
colors[priv->blue_index] = max_brightness; colors[priv->blue_index] = max_brightness;
break; break;
case FBD_FEEDBACK_LED_COLOR_RGB: case FBD_FEEDBACK_LED_COLOR_RGB: {
colors[priv->red_index] = rgb->r; float scale = max_brightness / 255.0;
colors[priv->green_index] = rgb->g; /* RGB colors are 0..255 so we need to scale to 0..max_brightness */
colors[priv->blue_index] = rgb->b; colors[priv->red_index] = MIN (max_brightness, roundf (rgb->r * scale));
colors[priv->green_index] = MIN (max_brightness, roundf (rgb->g * scale));
colors[priv->blue_index] = MIN (max_brightness, roundf (rgb->b * scale));
break; break;
}
default: default:
g_warning("Unhandled color: %d\n", color); g_warning("Unhandled color: %d\n", color);
return FALSE; return FALSE;
+2 -1
View File
@@ -329,7 +329,8 @@ fbd_feedback_led_class_init (FbdFeedbackLedClass *klass)
* FbdFeedbackLed:color: * FbdFeedbackLed:color:
* *
* The color the LED should blink with. The color is given as color * The color the LED should blink with. The color is given as color
* name or `rgb()` color value. * name or `rgb()` color value. E.g. a value of "#FF0000" is equivalent
* to `red` at maximum brightness.
*/ */
props[PROP_COLOR] = props[PROP_COLOR] =
g_param_spec_string ("color", "", "", g_param_spec_string ("color", "", "",
+11 -1
View File
@@ -38,7 +38,17 @@ if get_option('daemon')
'fbd-udev.c', 'fbd-udev.c',
] ]
fbd_deps = [gio, gio_unix, glib, gmobile, gobject, gsound, gudev, json_glib] fbd_deps = [
gio,
gio_unix,
glib,
gmobile,
gobject,
gsound,
gudev,
json_glib,
cc.find_library('m', required: false),
]
fbd_inc = [include_directories('.'), libfeedback_inc, dbus_inc] fbd_inc = [include_directories('.'), libfeedback_inc, dbus_inc]