The detect-rotation/blank/redraw block and the brightness step-up block were two stateful chunks in loop() glued by a brightness_ramp global. Fold them into handle_rotation_change() with local static state — the 'on rotation change, flash to black then ramp back' invariant lives in one place and the loop body shrinks.