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);
unsigned char next()
Increments one step along the line.
For linear changes with a minimum of calculation at each step.
unsigned long next()
Increments one step along the line.
unsigned int next()
Increments one step along the line.
T next()
Increments one step along the line.