Allow constant lighting of notification LED through the setting of frequency in theme.json to zero.
This commit is contained in:
committed by
Guido Günther
parent
b181c942ad
commit
0e88863a3d
+16
-10
@@ -115,25 +115,31 @@ fbd_dev_led_start_periodic_default (FbdDevLed *led,
|
|||||||
guint freq)
|
guint freq)
|
||||||
{
|
{
|
||||||
FbdDevLedPrivate *priv;
|
FbdDevLedPrivate *priv;
|
||||||
g_autoptr (GError) err = NULL;
|
|
||||||
g_autofree gchar *str = NULL;
|
|
||||||
gboolean success = FALSE;
|
gboolean success = FALSE;
|
||||||
gdouble max;
|
gdouble max;
|
||||||
gdouble t;
|
|
||||||
|
|
||||||
g_return_val_if_fail (FBD_IS_DEV_LED (led), FALSE);
|
g_return_val_if_fail (FBD_IS_DEV_LED (led), FALSE);
|
||||||
g_return_val_if_fail (max_brightness_percentage <= 100, FALSE);
|
g_return_val_if_fail (max_brightness_percentage <= 100, FALSE);
|
||||||
priv = fbd_dev_led_get_instance_private (led);
|
priv = fbd_dev_led_get_instance_private (led);
|
||||||
|
|
||||||
max = priv->max_brightness * (max_brightness_percentage / 100.0);
|
max = priv->max_brightness * (max_brightness_percentage / 100.0);
|
||||||
/* ms mHz T/2 */
|
if (freq) {
|
||||||
t = 1000.0 * 1000.0 / freq / 2.0;
|
g_autofree gchar *str = NULL;
|
||||||
str = g_strdup_printf ("0 %d %d %d\n", (gint)t, (gint)max, (gint)t);
|
g_autoptr (GError) err = NULL;
|
||||||
g_debug ("Freq %d mHz, Brightness: %d%%, Blink pattern: %s", freq, max_brightness_percentage, str);
|
gdouble t;
|
||||||
|
|
||||||
success = fbd_udev_set_sysfs_path_attr_as_string (priv->dev, LED_PATTERN_ATTR, str, &err);
|
/* ms mHz T/2 */
|
||||||
if (!success)
|
t = 1000.0 * 1000.0 / freq / 2.0;
|
||||||
g_warning ("Failed to set led pattern: %s", err->message);
|
str = g_strdup_printf ("0 %d %d %d\n", (gint)t, (gint)max, (gint)t);
|
||||||
|
g_debug ("Freq %d mHz, Brightness: %d%%, Blink pattern: %s", freq, max_brightness_percentage,
|
||||||
|
str);
|
||||||
|
success = fbd_udev_set_sysfs_path_attr_as_string (priv->dev, LED_PATTERN_ATTR, str, &err);
|
||||||
|
if (!success)
|
||||||
|
g_warning ("Failed to set led pattern: %s", err->message);
|
||||||
|
} else {
|
||||||
|
g_debug ("Constant light, Brightness: %d%%", max_brightness_percentage);
|
||||||
|
success = fbd_dev_led_set_brightness (led, (gint)max);
|
||||||
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ test_fbd_dev_led_flash (FbdUmockdevFixture *fixture, gconstpointer unused)
|
|||||||
g_assert_cmpint (fbd_dev_led_get_max_brightness (led), ==, 255);
|
g_assert_cmpint (fbd_dev_led_get_max_brightness (led), ==, 255);
|
||||||
g_assert_true (fbd_dev_led_supports_color (led, FBD_FEEDBACK_LED_COLOR_FLASH));
|
g_assert_true (fbd_dev_led_supports_color (led, FBD_FEEDBACK_LED_COLOR_FLASH));
|
||||||
g_assert_true (fbd_dev_led_start_periodic (led, 50, 50));
|
g_assert_true (fbd_dev_led_start_periodic (led, 50, 50));
|
||||||
|
g_assert_true (fbd_dev_led_start_periodic (led, 50, 0));
|
||||||
|
|
||||||
g_assert_finalize_object (led);
|
g_assert_finalize_object (led);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user