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 223 of file scale8.h.
224 {
225#if SCALE8_C == 1
226#if (FASTLED_SCALE8_FIXED == 1)
227 i = (((uint16_t)i) * ((uint16_t)(
scale) + 1)) >> 8;
228#else
229 i = ((int)i * (int)(
scale)) >> 8;
230#endif
231#elif SCALE8_AVRASM == 1
232 asm volatile(
233#if (FASTLED_SCALE8_FIXED == 1)
234
235 "mul %0, %1 \n\t"
236
237 "add r0, %0 \n\t"
238
239 "ldi %0, 0x00 \n\t"
240
241 "adc %0, r1 \n\t"
242#else
243
244 "mul %0, %1 \n\t"
245
246 "mov %0, r1 \n\t"
247#endif
248
249
250
251 : "+d"(i)
253 : "r0", "r1"
254 );
255#else
256#error "No implementation for nscale8_LEAVING_R1_DIRTY available."
257#endif
258}
UISlider scale("Scale", 1.0f, 0.0f, 1.0f, 0.01f)
References LIB8STATIC_ALWAYS_INLINE, and scale.