347
// reduce repetition with macros
348
// common code at the beginning of every gradual tick handler
349
#define GRADUAL_TICK_SETUP() \
350
uint8_t gt = gradual_target; \
351
if (gt < actual_level) gt = actual_level - 1; \
352
else if (gt > actual_level) gt = actual_level + 1; \
356
// tick the top layer of the stack
357
#define GRADUAL_ADJUST_1CH(TABLE,PWM) \
358
target = PWM_GET(TABLE, gt); \
359
if (PWM < target) PWM ++; \
360
else if (PWM > target) PWM --;
362
// tick a base level of the stack
363
// (with support for special DD FET behavior
364
// like "low=0, high=255" --> "low=255, high=254")
365
#define GRADUAL_ADJUST(TABLE,PWM,TOP) \
366
target = PWM_GET(TABLE, gt); \
367
if ((gt < actual_level) \
369
&& (target == TOP)) PWM = TOP; \
371
if (PWM < target) PWM ++; \
372
else if (PWM > target) PWM --;
374
// do this when output exactly matches a ramp level
375
#define GRADUAL_IS_ACTUAL() \
376
uint8_t orig = gradual_target; \
378
gradual_target = orig;
380
347
#ifdef USE_GRADUAL_TICK_1CH
381
348
void gradual_tick_1ch() {
382
349
GRADUAL_TICK_SETUP();