20 #include <util/atomic.h>
41 volatile T current_value;
61 ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
63 current_value += step_size;
79 ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
92 void set(T targetvalue, T num_steps)
97 numerator = targetvalue-current_value;
100 T step = numerator/num_steps;
118 void set(T startvalue, T targetvalue, T num_steps)
121 set(targetvalue, num_steps);
131 volatile unsigned char current_value;
151 ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
153 current_value += step_size;
155 return current_value;
166 void set(
unsigned char value)
168 ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
181 void set(
unsigned char targetvalue,
unsigned char num_steps)
183 step_size=(char)((((
float)targetvalue-current_value)/num_steps));
192 void set(
unsigned char startvalue,
unsigned char targetvalue,
unsigned char num_steps)
195 set(targetvalue, num_steps);
206 volatile unsigned int current_value;
226 ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
228 current_value += step_size;
230 return current_value;
241 void set(
unsigned int value)
243 ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
256 void set(
unsigned int targetvalue,
unsigned int num_steps)
258 step_size=(int)((((
float)targetvalue-current_value)/num_steps));
268 void set(
unsigned int startvalue,
unsigned int targetvalue,
unsigned int num_steps)
271 set(targetvalue, num_steps);
284 volatile unsigned long current_value;
304 ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
306 current_value += step_size;
308 return current_value;
319 void set(
unsigned long value)
321 ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
334 void set(
unsigned long targetvalue,
unsigned long num_steps)
336 step_size=(long)((((
float)targetvalue-current_value)/num_steps));
345 void set(
unsigned long startvalue,
unsigned long targetvalue,
unsigned long num_steps)
348 set(targetvalue, num_steps);
void set(T value)
Set the current value of the line.
void set(unsigned int targetvalue, unsigned int num_steps)
Given a target value and the number of steps to take on the way, this calculates the step size needed...
void set(unsigned long value)
Set the current value of the line.
void set(unsigned long targetvalue, unsigned long num_steps)
Given a target value and the number of steps to take on the way, this calculates the step size needed...
unsigned char next()
Increments one step along the line.
void set(unsigned int value)
Set the current value of the line.
void set(unsigned char value)
Set the current value of the line.
void set(T startvalue, T targetvalue, T num_steps)
Given a new starting value, target value and the number of steps to take on the way, this sets the step size needed to get there.
For linear changes with a minimum of calculation at each step.
void set(unsigned char startvalue, unsigned char targetvalue, unsigned char num_steps)
Given a new starting value, target value and the number of steps to take on the way, this sets the step size needed to get there.
void set(T targetvalue, T num_steps)
Given a target value and the number of steps to take on the way, this calculates the step size needed...
void set(unsigned long startvalue, unsigned long targetvalue, unsigned long num_steps)
Given a new starting value, target value and the number of steps to take on the way, this sets the step size needed to get there.
void set(unsigned int startvalue, unsigned int targetvalue, unsigned int num_steps)
Given a new starting value, target value and the number of steps to take on the way, this sets the step size needed to get there.
unsigned long next()
Increments one step along the line.
unsigned int next()
Increments one step along the line.
void set(unsigned char targetvalue, unsigned char num_steps)
Given a target value and the number of steps to take on the way, this calculates the step size needed...
T next()
Increments one step along the line.