예제 #1
0
/**
 * Called periodically to scan buttons
 */
INLINE void buttons__run(void) {
    uint8_t current_state = PORT_VALUE(BUTTONS) & BUTTONS_MASK;
    if ((buttons__changed = buttons__state ^ current_state)) {
        buttons__time = BUTTONS__REPEAT_DELAY;
        buttons__state = current_state;
        buttons__repeat_phase = 0;
    }
    else {
        if (buttons__time > 0) {
            --buttons__time;
        }
        else {
            buttons__time = BUTTONS__REPEAT_PERIOD;
            buttons__repeat_phase = 1;
        }
    }
}
예제 #2
0
/**
 * Read the LEDs state.
 * Every set bit (for bits 0-5) corresponds to press of the corresponding button.
 * Bits 6 and 7 will be undefined.
 */
uint8_t leds_tap__get(void) {
    return PORT_VALUE(LEDS_TAP);
}
예제 #3
0
static inline uint8_t keypad__in(void) { return PORT_VALUE(KEYPAD__IN); }