In place modifying version of scale8() that does not clean up the R1 register on AVR.
If you are doing several "scale8()'s" in a row, use this, and then explicitly call cleanup_R1().
- Warning
- You MUST call cleanup_R1() after using this function!
- Warning
- This function always modifies its arguments in place!
- Parameters
-
i | input value to scale |
scale | scale factor, in n/256 units |
- See also
- scale8()
Definition at line 217 of file scale8.h.
218 {
219#if SCALE8_C == 1
220#if (FASTLED_SCALE8_FIXED == 1)
221 i = (((uint16_t)i) * ((uint16_t)(
scale) + 1)) >> 8;
222#else
223 i = ((int)i * (int)(
scale)) >> 8;
224#endif
225#elif SCALE8_AVRASM == 1
226 asm volatile(
227#if (FASTLED_SCALE8_FIXED == 1)
228
229 "mul %0, %1 \n\t"
230
231 "add r0, %0 \n\t"
232
233 "ldi %0, 0x00 \n\t"
234
235 "adc %0, r1 \n\t"
236#else
237
238 "mul %0, %1 \n\t"
239
240 "mov %0, r1 \n\t"
241#endif
242
243
244
245 : "+d"(i)
247 : "r0", "r1"
248 );
249#else
250#error "No implementation for nscale8_LEAVING_R1_DIRTY available."
251#endif
252}
UISlider scale("Scale", 4,.1, 4,.1)
References LIB8STATIC_ALWAYS_INLINE, and scale.