示例#1
0
void long_press_button_ontimer( struct long_press_button_state_t* state ) {
    static uint8_t button_state = BUTTON_OFF;

    uint8_t next_button_state = digitalRead( state->pin );

    if ((BUTTON_OFF == button_state) &&
            (BUTTON_ON  == next_button_state)) {
        // OFF -> ON
        TIMER_START( state->timer, state->threshold_time );
    }
    else if ((BUTTON_ON == button_state) &&
             (BUTTON_ON == next_button_state)) {
        // still pressing

        TIMER_TICK( state->timer );

        if (TIMER_FIRED( state->timer )) {
            state->callback();

            // fires again after state->threshold_time
            button_state = BUTTON_OFF;
            return;
        }
    }

    button_state = next_button_state;
}
示例#2
0
// careful, called from ISR
void GSwifi::onTimer() {
    for (int i=0; i<16; i++) {
        if ( ! cidIsRequest(i) &&
             TIMER_RUNNING(timers_[i]) ) {
            TIMER_COUNTDOWN(timers_[i]);
        }
    }

    TIMER_TICK( timeout_timer_ );
}
示例#3
0
void IR_timer (void)
{
    if (IrCtrl.state == IR_RECVING) {
        TIMER_TICK( IrCtrl.recv_timer );

        if ( TIMER_FIRED( IrCtrl.recv_timer ) ) {
            TIMER_STOP( IrCtrl.recv_timer );
            IR_state( IR_RECVED );
        }
    }

    if (IrCtrl.state == IR_XMITTING) {
        TIMER_TICK( IrCtrl.xmit_timer );

        if ( TIMER_FIRED( IrCtrl.xmit_timer ) ) {
            TIMER_STOP( IrCtrl.xmit_timer );
            IR_state( IR_IDLE );
        }
    }
}
示例#4
0
void irkit_http_on_timer() {
    TIMER_TICK(polling_timer);

    TIMER_TICK(suspend_polling_timer);
}