~toykeeper/flashlight-firmware/fsm

« back to all changes in this revision

Viewing changes to ToyKeeper/spaghetti-monster/fsm-ramping.c

  • Committer: Selene ToyKeeper
  • Date: 2023-04-25 07:07:15 UTC
  • mto: (483.1.175 anduril2)
  • mto: This revision was merged to the branch mainline in revision 491.
  • Revision ID: bzr@toykeeper.net-20230425070715-yi80xgfowxmbfl6n
updated D4Sv2-tintramp -> Emisar 2-channel build target ...
... and reworked how gradual_tick() works
... and updated LT1S Pro to use new method

Show diffs side-by-side

added added

removed removed

Lines of Context:
398
398
 
399
399
// call this every frame or every few frames to change brightness very smoothly
400
400
void gradual_tick() {
 
401
    uint8_t gt = gradual_target;
 
402
    if (gt < actual_level) gt = actual_level - 1;
 
403
    else if (gt > actual_level) gt = actual_level + 1;
 
404
    gt --;
 
405
 
401
406
    // call the relevant hardware-specific function
402
407
    GradualTickFuncPtr gradual_tick_func = gradual_tick_modes[CH_MODE];
403
 
    gradual_tick_func();
 
408
    bool done = gradual_tick_func(gt);
 
409
 
 
410
    if (done) {
 
411
        uint8_t orig = gradual_target;
 
412
        set_level(gt + 1);
 
413
        gradual_target = orig;
 
414
    }
404
415
}
405
416
 
406
417