minor refactoring to create a more general loop counter
silly bugfix introduced by refactoring
up_n_down: add some smoothing to brightness adjustments