|
@@ -17,6 +17,18 @@
|
17
|
17
|
|
18
|
18
|
/* Static helper functions for this file only, prefix with _ */
|
19
|
19
|
|
|
20
|
+// Changes brightness smoothly from start value to end value
|
|
21
|
+static void _fade_value(light_device_target_t *target, uint64_t start_value, uint64_t end_value)
|
|
22
|
+{
|
|
23
|
+ int steps = 20;
|
|
24
|
+ uint64_t step_size = (uint64_t) ( ((float)end_value - (float)start_value) / (float)steps );
|
|
25
|
+
|
|
26
|
+ for(int i=1; i<steps-1; i++)
|
|
27
|
+ {
|
|
28
|
+ target->set_value(target, start_value + i * step_size);
|
|
29
|
+ usleep(10000);
|
|
30
|
+ }
|
|
31
|
+}
|
20
|
32
|
|
21
|
33
|
static void _light_add_enumerator_device(light_device_enumerator_t *enumerator, light_device_t *new_device)
|
22
|
34
|
{
|
|
@@ -721,13 +733,16 @@ bool light_cmd_set_brightness(light_context_t *ctx)
|
721
|
733
|
return false;
|
722
|
734
|
}
|
723
|
735
|
|
724
|
|
-
|
725
|
736
|
uint64_t mincap = _light_get_min_cap(ctx);
|
726
|
737
|
uint64_t value = ctx->run_params.value;
|
727
|
738
|
if(mincap > value)
|
728
|
739
|
{
|
729
|
740
|
value = mincap;
|
730
|
741
|
}
|
|
742
|
+
|
|
743
|
+ uint64_t start_value;
|
|
744
|
+ target->get_value(target, &start_value);
|
|
745
|
+ _fade_value(target, start_value, value);
|
731
|
746
|
|
732
|
747
|
if(!target->set_value(target, value))
|
733
|
748
|
{
|
|
@@ -899,6 +914,10 @@ bool light_cmd_add_brightness(light_context_t *ctx)
|
899
|
914
|
value = max_value;
|
900
|
915
|
}
|
901
|
916
|
|
|
917
|
+ uint64_t start_value;
|
|
918
|
+ target->get_value(target, &start_value);
|
|
919
|
+ _fade_value(target, start_value, value);
|
|
920
|
+
|
902
|
921
|
if(!target->set_value(target, value))
|
903
|
922
|
{
|
904
|
923
|
LIGHT_ERR("failed to write to target");
|
|
@@ -939,6 +958,10 @@ bool light_cmd_sub_brightness(light_context_t *ctx)
|
939
|
958
|
value = mincap;
|
940
|
959
|
}
|
941
|
960
|
|
|
961
|
+ uint64_t start_value;
|
|
962
|
+ target->get_value(target, &start_value);
|
|
963
|
+ _fade_value(target, start_value, value);
|
|
964
|
+
|
942
|
965
|
if(!target->set_value(target, value))
|
943
|
966
|
{
|
944
|
967
|
LIGHT_ERR("failed to write to target");
|
|
@@ -994,6 +1017,10 @@ bool light_cmd_mul_brightness(light_context_t *ctx)
|
994
|
1017
|
value = max_value;
|
995
|
1018
|
}
|
996
|
1019
|
|
|
1020
|
+ uint64_t start_value;
|
|
1021
|
+ target->get_value(target, &start_value);
|
|
1022
|
+ _fade_value(target, start_value, value);
|
|
1023
|
+
|
997
|
1024
|
if(!target->set_value(target, value))
|
998
|
1025
|
{
|
999
|
1026
|
LIGHT_ERR("failed to write to target");
|