@ -39,7 +39,11 @@ public:
return traits ;
return traits ;
}
}
void add_on_state_callback ( std : : function < void ( light : : LightColorValues , std : : string ) > & & callback ) {
void add_on_light_mode_callback ( std : : function < void ( std : : string ) > & & callback ) {
light_mode_callback_ . add ( std : : move ( callback ) ) ;
}
void add_on_state_callback ( std : : function < void ( light : : LightColorValues ) > & & callback ) {
state_callback_ . add ( std : : move ( callback ) ) ;
state_callback_ . add ( std : : move ( callback ) ) ;
}
}
@ -57,17 +61,15 @@ public:
GPIOOutputs * delegate ;
GPIOOutputs * delegate ;
if ( transition_handler_ - > set_light_color_values ( values ) ) {
if ( transition_handler_ - > set_light_color_values ( values ) ) {
delegate = transition_handler_ ;
delegate = transition_handler_ ;
state_callback_ . call (
transition_handler_ - > get_end_values ( ) ,
delegate - > light_mode ) ;
light_mode_callback_ . call ( delegate - > light_mode ) ;
state_callback_ . call ( transition_handler_ - > get_end_values ( ) ) ;
} else {
} else {
instant_handler_ - > set_light_color_values ( values ) ;
instant_handler_ - > set_light_color_values ( values ) ;
delegate = instant_handler_ ;
delegate = instant_handler_ ;
state_callback_ . call ( values , delegate - > light_mode ) ;
light_mode_callback_ . call ( delegate - > light_mode ) ;
state_callback_ . call ( values ) ;
}
}
light_mode_ = delegate - > light_mode ;
/ / Note : one might think that it is more logical to turn on the LED
/ / Note : one might think that it is more logical to turn on the LED
/ / circuitry master switch after setting the individual channels ,
/ / circuitry master switch after setting the individual channels ,
/ / but this is the order that was used by the original firmware . I
/ / but this is the order that was used by the original firmware . I
@ -88,16 +90,12 @@ public:
light_ - > turn_off ( ) ;
light_ - > turn_off ( ) ;
}
}
std : : string get_light_mode ( ) {
return light_mode_ ;
}
protected :
protected :
LightHAL * light_ ;
LightHAL * light_ ;
ColorTransitionHandler * transition_handler_ ;
ColorTransitionHandler * transition_handler_ ;
ColorInstantHandler * instant_handler_ = new ColorInstantHandler ( ) ;
ColorInstantHandler * instant_handler_ = new ColorInstantHandler ( ) ;
CallbackManager < void ( light : : LightColorValues , std : : string ) > stat e_callback_{ } ;
std : : string light_mode_ ;
CallbackManager < void ( std : : string ) > light_mod e_callback_{ } ;
CallbackManager < voi d( light : : LightColorValues ) > state_callback_ { } ;
friend class YeelightBS2LightState ;
friend class YeelightBS2LightState ;