/* convert two reed contacts into two UP/DOWN clock pulses for bidirectional counters ATtiny13 @ 1.2 MHz */ #include #include #include #define F_CPU 1200000UL #define F_TIMER 2000 #define RELOAD (F_CPU / (8L*F_TIMER) - 1) #if RELOAD >255 #error RELOAD value >255 #endif #define ENCODER_PIN PINB #define PHASE_A (1< 0) { UP; } else if (enc_delta < 0) { DOWN; } else { NONE; } }