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

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

Public Typedefs

using StepType = std::conditional_t< (std::numeric_limits< UnsignedType >::max ()<=255), uint16_t, uint32_t >
 

Public Member Functions

void initialize (T begin, T end, StepType steps)
 
void step ()
 update the intermediate value for one step
 
getValue ()
 
void stop ()
 stops the interpolation.
 

Detailed Description

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

This class allows the linear ramping of one value over a number of steps.

All integer types use binary scaling through a fixed-point arithmetic, however, all other types default to floating-point arithmetic with casting between types.

Be aware that the algortihm for 8bit types is optimized for low computational costs. Therefore the steps are limited to 128 steps * value_difference, which is 32'768 steps over the full 8bit range. If you specify a more steps in this case, the ramp simply is 'steeper'. If this is a problem, consider using a 16bit type, which does not have this limitation.

Warning
This class does not know when to stop stepping. This means, that over- and underflows of the target value must be prevented externally.
Author
Niklas Hauser

Member Typedef Documentation

template<typename T = uint8_t>
using modm::ui::FastRamp< T >::StepType = std::conditional_t< (std::numeric_limits<UnsignedType>::max() <= 255), uint16_t, uint32_t >

for 8bit value types, the steps are limited to 2^15 anyway, so we do not need uint32_t for the steps, but we can use uint16_t

Member Function Documentation

template<typename T = uint8_t>
T modm::ui::FastRamp< T >::getValue ( )
inline
Returns
the intermediate value.
template<typename T = uint8_t>
void modm::ui::FastRamp< T >::initialize ( begin,
end,
StepType  steps 
)
inline

This method calculates the incline of the ramp.

Parameters
beginthe beginning of the ramp
endthe end of the ramp
stepsthe number of steps for the ramp.

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