modm API documentation
modm::ui::Animation< T > Class Template Reference

#include <modm/ui/animation/base.hpp>

Inheritance diagram for modm::ui::Animation< T >:
modm::ui::AnimationBase< T >

Public Typedefs

using TimeType = typename FastRamp< T >::StepType
 
using Handler = void (*)(T)
 

Public Member Functions

 Animation (T &value, Handler handler=nullptr)
 
void attachCallback (Handler handler)
 
virtual void setValue (T value) override
 stop any running animation and set a value.
 
getValue () const
 
virtual bool isAnimating () const override
 
virtual void stop () override
 stops any running animation.
 
virtual bool animateTo (T value, uint32_t time) override
 
virtual bool update () override
 

Detailed Description

template<typename T = uint8_t>
class modm::ui::Animation< T >

This class allows the linear animation of one value over time.

Be aware that the algorithm for 8-bit types is optimized for low computational costs, developed for fast LED fading (

See also
modm::ui::Led). Therefore the animation length is limited to 128ms * value_difference, which is about 32s over the full 8-bit range. If you specify a longer time in this case, the animation simply finishes before. If this is a problem, consider using a 16-bit type, which does not have this limitation.
Author
Niklas Hauser

Constructor & Destructor Documentation

template<typename T = uint8_t>
modm::ui::Animation< T >::Animation ( T &  value,
Handler  handler = nullptr 
)
Parameters
valuea reference to the value to be animated
handlerthis function will be called whenever the value has been changed

Member Function Documentation

template<typename T = uint8_t>
virtual bool modm::ui::Animation< T >::animateTo ( value,
uint32_t  time 
)
overridevirtual

Animate from the current value to a new value in the specified ms.

Returns
true if animation started, false if otherwise

Implements modm::ui::AnimationBase< T >.

template<typename T = uint8_t>
void modm::ui::Animation< T >::attachCallback ( Handler  handler)
Parameters
handlerthis function will be called whenever the value has been changed
template<typename T = uint8_t>
T modm::ui::Animation< T >::getValue ( ) const
Returns
the current value
template<typename T = uint8_t>
virtual bool modm::ui::Animation< T >::isAnimating ( ) const
overridevirtual
Returns
true if animation is currently running, false if otherwise

Implements modm::ui::AnimationBase< T >.

template<typename T = uint8_t>
virtual bool modm::ui::Animation< T >::update ( )
overridevirtual

Can be called at an interval of 1ms or less. If you do not need 1ms response time, you may call this at intervals < 250ms.

Returns
true if the value has been changed, false otherwise

Reimplemented from modm::ui::AnimationBase< T >.


The documentation for this class was generated from the following file: