Ejemplo n.º 1
0
/*..........................................................................*/
QState Bomb4_timing(Bomb4 *me, QEvent const *e) {
    switch (e->sig) {
        case Q_ENTRY_SIG: {
            me->code = 0;                          /* clear the defuse code */
            return Q_HANDLED();
        }
        case UP_SIG: {
            me->code <<= 1;
            me->code |= 1;
            return Q_HANDLED();
        }
        case DOWN_SIG: {
            me->code <<= 1;
            return Q_HANDLED();
        }
        case ARM_SIG: {
            if (me->code == me->defuse) {
                return Q_TRAN(&Bomb4_setting);
            }
            return Q_HANDLED();
        }
        case TICK_SIG: {
            if (((TickEvt const *)e)->fine_time == 0) {
                --me->timeout;
                BSP_display(me->timeout);
                if (me->timeout == 0) {
                    BSP_boom();                         /* destroy the bomb */
                }
            }
            return Q_HANDLED();
        }
    }
    return Q_IGNORED();
}
Ejemplo n.º 2
0
/*..........................................................................*/
void Bomb2_timing_TICK(Bomb2 *me, Event const *e) {
    if (((TickEvt const *)e)->fine_time == 0) {
        --me->timeout;
        BSP_display(me->timeout);
        if (me->timeout == 0) {
            BSP_boom();                                 /* destroy the bomb */
        }
    }
}
Ejemplo n.º 3
0
void TimingState::onTICK(Bomb3 *context, uint8_t fine_time) const {
    if (fine_time == 0) {
        --context->m_timeout;
        BSP_display(context->m_timeout);
        if (context->m_timeout == 0) {
            BSP_boom();                                    // destroy the bomb
        }
    }
}