avr: implement encoder and button routines