예제 #1
0
파일: ui.c 프로젝트: russells/hc2
static QState uiMenuSettimeHoursFlash(struct UI *me)
{
	switch (Q_SIG(me)) {
	case Q_ENTRY_SIG:
		display_set_time(me, FALSE, TRUE);
		QActive_armX((QActive*)me, 1, 8);
		return Q_HANDLED();
	case Q_TIMEOUT1_SIG:
		display_set_time(me, TRUE, TRUE);
		return Q_TRAN(uiMenuSettimeHours);
	case BUTTON_UP_PRESS_SIGNAL:
	case BUTTON_UP_LONG_PRESS_SIGNAL:
	case BUTTON_UP_REPEAT_SIGNAL:
	case BUTTON_DOWN_PRESS_SIGNAL:
	case BUTTON_DOWN_LONG_PRESS_SIGNAL:
	case BUTTON_DOWN_REPEAT_SIGNAL:
		/** @see the comment in uiMenuSettimeMinutesFlash() */
		display_set_time(me, TRUE, TRUE);
		break;
	case Q_EXIT_SIG:
		QActive_armX((QActive*)me, 1, 17);
		return Q_HANDLED();
	}
	return Q_SUPER(uiMenuSettimeHours);
}
예제 #2
0
파일: ui.c 프로젝트: russells/hc2
static QState uiMenu(struct UI *me)
{
	switch (Q_SIG(me)) {
	case Q_ENTRY_SIG:
		ACTION();
		BSP_fast_timer_1(TRUE);
		BSP_fast_timer_2(TRUE);
		return Q_HANDLED();
	case UI_ACTION_SIGNAL:
		SERIALSTR("U");
		me->timeoutcounter = 4;
		lcd_timeouts(me->timeoutcounter);
		QActive_armX((QActive*)(me), 2,
			     3 * BSP_TICKS_PER_SECOND_TIMER2);
		return Q_HANDLED();
	case Q_TIMEOUT2_SIG:
		me->timeoutcounter --;
		lcd_timeouts(me->timeoutcounter);
		if (me->timeoutcounter) {
			QActive_armX((QActive*)(me), 2,
				     3 * BSP_TICKS_PER_SECOND_TIMER2);
			return Q_HANDLED();
		} else {
			return Q_TRAN(uiRun);
		}
	case BUTTON_CANCEL_PRESS_SIGNAL:
		return Q_TRAN(uiRun);
	case Q_EXIT_SIG:
		BSP_fast_timer_1(FALSE);
		BSP_fast_timer_2(FALSE);
		lcd_timeouts(0);
		return Q_HANDLED();
	}
	return Q_SUPER(uiTop);
}
예제 #3
0
파일: ui.c 프로젝트: russells/hc2
static QState uiMenuSettimeMinutesFlash(struct UI *me)
{
	switch (Q_SIG(me)) {
	case Q_ENTRY_SIG:
		display_set_time(me, TRUE, FALSE);
		QActive_armX((QActive*)me, 1, 8);
		return Q_HANDLED();
	case Q_TIMEOUT1_SIG:
		display_set_time(me, TRUE, TRUE);
		return Q_TRAN(uiMenuSettimeMinutes);
	case BUTTON_UP_PRESS_SIGNAL:
	case BUTTON_UP_LONG_PRESS_SIGNAL:
	case BUTTON_UP_REPEAT_SIGNAL:
	case BUTTON_DOWN_PRESS_SIGNAL:
	case BUTTON_DOWN_LONG_PRESS_SIGNAL:
	case BUTTON_DOWN_REPEAT_SIGNAL:
		/**
		 * React to the event by re-displaying the time (without the
		 * minutes hidden), but don't handle it.  This makes the time
		 * appear on the display as the button is pressed, which is
		 * move obvious to the user.
		 */
		display_set_time(me, TRUE, TRUE);
		break;
	case Q_EXIT_SIG:
		QActive_armX((QActive*)me, 1, 17);
		return Q_HANDLED();
	}
	return Q_SUPER(uiMenuSettimeMinutes);
}
예제 #4
0
파일: ui.c 프로젝트: russells/hc2
static QState uiMenuSettimeHours(struct UI *me)
{
	switch (Q_SIG(me)) {
	case Q_ENTRY_SIG:
		lcd_buttons(LCD_BUTTONS_ALL);
		me->settime_YmdHM = 'H';
		display_set_time(me, TRUE, TRUE);
		QActive_armX((QActive*)me, 1, 17);
		return Q_HANDLED();
	case Q_TIMEOUT1_SIG:
		return Q_TRAN(uiMenuSettimeHoursFlash);
	case BUTTON_ENTER_PRESS_SIGNAL:
		ACTION();
		return Q_TRAN(uiMenuSettimeMinutes);
	case BUTTON_UP_PRESS_SIGNAL:
	case BUTTON_UP_LONG_PRESS_SIGNAL:
	case BUTTON_UP_REPEAT_SIGNAL:
		ACTION();
		inc_hour(&me->settime);
		display_set_time(me, TRUE, TRUE);
		QActive_armX((QActive*)me, 1, 17);
		return Q_HANDLED();
	case BUTTON_DOWN_PRESS_SIGNAL:
	case BUTTON_DOWN_LONG_PRESS_SIGNAL:
	case BUTTON_DOWN_REPEAT_SIGNAL:
		ACTION();
		dec_hour(&me->settime);
		display_set_time(me, TRUE, TRUE);
		QActive_armX((QActive*)me, 1, 17);
		return Q_HANDLED();
	}
	return Q_SUPER(uiMenu);
}
예제 #5
0
static QState Ped_wait(Ped * const me) {
    QState status_;
    switch (Q_SIG(me)) {
        /* @(/1/1/1/1/0) */
        case Q_TIMEOUT_SIG: {
            --me->retryCtr;
            /* @(/1/1/1/1/0/0) */
            if (me->retryCtr != 0U) {
                QActive_armX((QActive *)me, 0U, WAIT_TOUT);
                QACTIVE_POST((QActive *)&AO_Pelican, PEDS_WAITING_SIG);
                status_ = QM_HANDLED();
            }
            /* @(/1/1/1/1/0/1) */
            else {
                static QActionHandler const act_[] = {
                    Q_ACTION_CAST(&Ped_off_e),
                    Q_ACTION_CAST(0)
                };
                status_ = QM_TRAN(&Ped_off_s, &act_[0]);
            }
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
예제 #6
0
파일: ui.c 프로젝트: russells/hc2
static QState uiMenuCalibrateTemperatureStarted(struct UI *me)
{
	switch (Q_SIG(me)) {
	case Q_ENTRY_SIG:
		QActive_armX(&me->super, 1, 1);
		return Q_HANDLED();
	case Q_TIMEOUT1_SIG:
		return Q_TRAN(uiMenuCalibrateGetTemperature);
	}
	return Q_SUPER(uiMenuCalibrateDeferExit);
}
예제 #7
0
파일: blinky.c 프로젝트: QuantumLeaps/qpn
/*${AOs::Blinky::SM} .......................................................*/
static QState Blinky_initial(Blinky * const me) {
    /*${AOs::Blinky::SM::initial} */
    /* arm the private time event for tick rate 0
    * to expire in 1/2s and periodically every 1/2 second
    */
    QActive_armX(&me->super,
                 0U,
                 BSP_TICKS_PER_SEC/2U,
                 BSP_TICKS_PER_SEC/2U);
    return Q_TRAN(&Blinky_off);
}
예제 #8
0
파일: comp.c 프로젝트: QuantumLeaps/qpn
/*..........................................................................*/
QState AlarmClock_timekeeping(AlarmClock * const me) {
    QState status;
    switch (Q_SIG(me)) {
        case Q_ENTRY_SIG: {
            /* timeout in one second and every second */
            QActive_armX(&me->super, 0U,
                         BSP_TICKS_PER_SEC, BSP_TICKS_PER_SEC);
            status = Q_HANDLED();
            break;
        }
        case Q_EXIT_SIG: {
            QActive_disarmX(&me->super, 0U);
            status = Q_HANDLED();
            break;
        }
        case Q_INIT_SIG: {
            status = Q_TRAN(&AlarmClock_mode24hr);
            break;
        }
        case CLOCK_12H_SIG: {
            status = Q_TRAN(&AlarmClock_mode12hr);
            break;
        }
        case CLOCK_24H_SIG: {
            status = Q_TRAN(&AlarmClock_mode24hr);
            break;
        }
        case ALARM_SIG: {
            printf("Wake up!!!\n");
            status = Q_HANDLED();
            break;
        }
        case ALARM_SET_SIG:
        case ALARM_ON_SIG:
        case ALARM_OFF_SIG: {
            /* synchronously dispatch to the orthogonal component */
            Q_SIG(&me->alarm) = Q_SIG(me);
            Q_PAR(&me->alarm) = Q_PAR(me);
            QHSM_DISPATCH(&me->alarm.super);
            status = Q_HANDLED();
            break;
        }
        case TERMINATE_SIG: {
            status = Q_TRAN(&AlarmClock_final);
            break;
        }
        default: {
            status = Q_SUPER(&QHsm_top);
            break;
        }
    }
    return status;
}
예제 #9
0
파일: ble.c 프로젝트: henrychoi/realtime
static QState Ble_ancs_setup_wait(Ble* const me) {
    uint32_t err_code;
	switch(Q_SIG(me)) {
	case Q_ENTRY_SIG:
	    QActive_armX(&me->super, 0U, /* 10 ms delay */1, /* periodic = */0);
	    return Q_HANDLED();

	case Q_TIMEOUT_SIG:
	    return Q_TRAN(&Ble_ancs_enabled);

	default:
		return Q_SUPER(&QHsm_top);
	}
}
예제 #10
0
파일: ui.c 프로젝트: russells/hc2
static QState uiMenuCalibrateTemperatureStart(struct UI *me)
{
	switch (Q_SIG(me)) {
	case Q_ENTRY_SIG:
		QActive_armX(&me->super, 1, 1);
		return Q_HANDLED();
	case Q_TIMEOUT1_SIG:
		if (start_cal(me)) {
			return Q_TRAN(uiMenuCalibrateTemperatureStarted);
		} else {
			me->temperatureWaits ++;
			Q_ASSERT( me->temperatureWaits < 10 );
			return Q_TRAN(uiMenuCalibrateTemperatureStart);
		}
	}
	return Q_SUPER(uiMenuCalibrateDeferExit);
}
예제 #11
0
static void LEDSEQ_Run(LedSeq * const me)
{
    ledAction *step;
    bool leave = false;

    if (-1 != me->activeSeq)
    {
        while(false == leave)
        {
            step = &sequences[me->activeSeq][me->state[me->activeSeq]];
            me->state[me->activeSeq]++;

            switch(step->action)
            {
                case LEDSEQ_LOOP:
                    me->state[me->activeSeq] = 0;
                    break;

                case LEDSEQ_STOP:
                    me->state[me->activeSeq] = LEDSEQ_STOP;
                    LEDSEQ_UpdateActive(me);
                    break;

                default: //The step is a LED action and a time
                    if (step->value)
                    {
                        BSP_IO_On(me->led);
                    }
                    else
                    {
                        BSP_IO_Off(me->led);
                    }

                    if (step->action == 0)
                        break;

                    QActive_armX((QActive *)me, 0U, step->action, 0);
                    leave = true;
                    break;
            }
        }
    }
}
예제 #12
0
파일: ui.c 프로젝트: russells/hc2
static QState scrollText(struct UI *me)
{
	switch (Q_SIG(me)) {
	case Q_ENTRY_SIG:
		strncpy(me->scrolltext, me->scrollstring+me->scrollindex, 7);
		me->scrolltext[7] = '\0';
		lcd_showstring(me->scrolltext);
		QActive_armX((QActive*)me, 1, 15);
		return Q_HANDLED();
	case Q_TIMEOUT1_SIG:
		me->scrollindex ++;
		if (me->scrollstring[me->scrollindex]) {
			return Q_TRAN(scrollText);
		} else {
			return Q_TRAN(uiRun);
		}
	}
	return Q_SUPER(scroll);
}
예제 #13
0
파일: ui.c 프로젝트: russells/hc2
static QState uiMenuCalibratePause(struct UI *me)
{
	switch (Q_SIG(me)) {
	case Q_ENTRY_SIG:
		/* Process any event that will cause an exit out of calibration
		   mode that we got while we were away doing the ADC
		   processing. */
		recall(me);
		/* Read the temperature fairly often.  We only wait for 5/32
		   seconds here.  We must wait for more than one tick so that
		   the recorder, which has a lower priority, gets a chance to
		   process its own ticks before ours and hence get the ADC when
		   required. */
		QActive_armX((QActive*)me, 1, 5);
		return Q_HANDLED();
	case Q_TIMEOUT1_SIG:
		me->temperatureWaits = 0;
		return Q_TRAN(uiMenuCalibrateTemperatureStart);
	}
	return Q_SUPER(uiMenuCalibrate);
}
예제 #14
0
파일: ui.c 프로젝트: russells/hc2
static QState uiMenuCalibrateGetTemperature(struct UI *me)
{
	switch (Q_SIG(me)) {
	case Q_ENTRY_SIG:
		BSP_get_temperature();
		/* Only need one tick to get the temperature, since we're
		   guaranteed to be arriving here very near the start of a tick
		   period.  But take two anyway, to be sure. */
		QActive_armX((QActive*)me, 1, 2);
		return Q_HANDLED();
	case TEMPERATURE_SIGNAL:
		SERIALSTR("<okok>");
		me->ti = Q_PAR(me);
		show_temperature_cal(me);
		return Q_TRAN(uiMenuCalibratePause);
	case Q_TIMEOUT1_SIG:
		/* Nothing has happened - give up. */
		SERIALSTR("<BLAH>");
		return Q_TRAN(uiMenuCalibratePause);
	}
	return Q_SUPER(uiMenuCalibrateDeferExit);
}
예제 #15
0
static QState Pelican_offline(Pelican * const me) {
    QState status_;
    switch (Q_SIG(me)) {
        /* @(/1/0/1/2/0) */
        case Q_TIMEOUT_SIG: {
            QActive_armX(&me->super, 0U, OFF_FLASH_TOUT);
            me->flashCtr ^= 1U;
            /* @(/1/0/1/2/0/0) */
            if ((me->flashCtr & 1U) == 0U) {
                BSP_signalCars(CARS_RED);
                BSP_signalPeds(PEDS_DONT_WALK);
                status_ = QM_HANDLED();
            }
            /* @(/1/0/1/2/0/1) */
            else {
                BSP_signalCars(CARS_BLANK);
                BSP_signalPeds(PEDS_BLANK);
                status_ = QM_HANDLED();
            }
            break;
        }
        /* @(/1/0/1/2/1) */
        case ON_SIG: {
            static QActionHandler const act_[] = {
                Q_ACTION_CAST(&Pelican_operational_e),
                Q_ACTION_CAST(&Pelican_operational_i),
                Q_ACTION_CAST(0)
            };
            status_ = QM_TRAN(&Pelican_operational_s, &act_[0]);
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
예제 #16
0
static QState Pelican_pedsFlash(Pelican * const me) {
    QState status_;
    switch (Q_SIG(me)) {
        /* @(/1/0/1/1/3/2/0) */
        case Q_TIMEOUT_SIG: {
            /* @(/1/0/1/1/3/2/0/0) */
            if (me->flashCtr != 0U) {
                --me->flashCtr;
                QActive_armX(&me->super, 0U, PEDS_FLASH_TOUT);
                /* @(/1/0/1/1/3/2/0/0/0) */
                if ((me->flashCtr & 1U) == 0U) {
                    BSP_signalPeds(PEDS_DONT_WALK);
                    status_ = QM_HANDLED();
                }
                /* @(/1/0/1/1/3/2/0/0/1) */
                else {
                    BSP_signalPeds(PEDS_BLANK);
                    status_ = QM_HANDLED();
                }
            }
            /* @(/1/0/1/1/3/2/0/1) */
            else {
                static QActionHandler const act_[] = {
                    Q_ACTION_CAST(&Pelican_pedsEnabled_x),
                    Q_ACTION_CAST(&Pelican_carsEnabled_i),
                    Q_ACTION_CAST(0)
                };
                status_ = QM_TRAN(&Pelican_carsEnabled_s, &act_[0]);
            }
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
예제 #17
0
/* @(/1/1/1/2) .............................................................*/
static QState Ped_off_e(Ped * const me) {
    QActive_armX(&me->super, 0U, OFF_TOUT);
    QACTIVE_POST((QActive *)&AO_Pelican, OFF_SIG);
    return QM_ENTRY(&Ped_off_s);
}
예제 #18
0
/* @(/1/1/1/1) .............................................................*/
static QState Ped_wait_e(Ped * const me) {
    me->retryCtr = N_ATTEMPTS;
    QActive_armX(&me->super, 0U, WAIT_TOUT);
    return QM_ENTRY(&Ped_wait_s);
}
예제 #19
0
파일: ui.c 프로젝트: russells/hc2
static QState uiShowMin(struct UI *me)
{
	QTimeEvtCtr timeout = showmaxmintimeout;
	int16_t ti;

	switch (Q_SIG(me)) {
	case Q_ENTRY_SIG:
		me->showmaxmincounter ++;
		switch (me->showmaxmincounter) {
		case 1:
			lcd_showstring("MIN T  ");
			timeout = showmaxmintimeout;
			break;
		case 2:
			lcd_showstring("SINCE  ");
			timeout = showmaxmintimeout;
			break;
		case 3:
			lcd_showstring("9 AM   ");
			timeout = showmaxmintimeout;
			break;
		case 4:
			ti = get_min_today()->ti;
			if (INVALIDTI == ti)
				me->showmaxmincounter ++;
			show_temperature(ti);
			timeout = 3 * showmaxmintimeout;
			break;
		case 5:
			show_at(&(get_min_today()->time));
			timeout = 3 * showmaxmintimeout;
			break;
		case 6:
			lcd_showstring("MIN T  ");
			timeout = showmaxmintimeout;
			break;
		case 7:
			lcd_showstring("TO LAST");
			timeout = showmaxmintimeout;
			break;
		case 8:
			lcd_showstring("9 AM   ");
			timeout = showmaxmintimeout;
			break;
		case 9:
			ti = get_min_yesterday()->ti;
			if (INVALIDTI == ti)
				me->showmaxmincounter ++;
			show_temperature(ti);
			timeout = 3 * showmaxmintimeout;
			break;
		case 10:
			show_at(&(get_min_yesterday()->time));
			timeout = 3 * showmaxmintimeout;
			break;
		default:
			Q_ASSERT( 0 );
			break;
		}
		QActive_armX(&me->super, 1, timeout);
		return Q_HANDLED();
	case Q_TIMEOUT1_SIG:
	case BUTTON_DOWN_PRESS_SIGNAL:
		if (10 == me->showmaxmincounter)
			return Q_TRAN(uiRun);
		else
			return Q_TRAN(uiShowMin);
	}
	return Q_SUPER(uiShowMinTop);
}
예제 #20
0
파일: light.c 프로젝트: ahsparrow/qpnlight
QState s_light_initial(ao_light_t * const me)
{
    QActive_armX((QActive *)me, 0U, BSP_TICKS_PER_SEC, BSP_TICKS_PER_SEC);
    return Q_TRAN(&s_light_off);
}
예제 #21
0
/* @(/1/0/1/1/2/1) .........................................................*/
static QState Pelican_carsGreen_e(Pelican * const me) {
    BSP_signalCars(CARS_GREEN);
    QActive_armX(&me->super, 0U, CARS_GREEN_MIN_TOUT);
    return QM_ENTRY(&Pelican_carsGreen_s);
}
예제 #22
0
/* @(/1/0/1/1/2/2) .........................................................*/
static QState Pelican_carsYellow_e(Pelican * const me) {
    BSP_showState(me->super.prio, "carsYellow");
    BSP_signalCars(CARS_YELLOW);
    QActive_armX(&me->super, 0U, CARS_YELLOW_TOUT);
    return QM_ENTRY(&Pelican_carsYellow_s);
}
예제 #23
0
/* @(/1/0/1/1/3/1) .........................................................*/
static QState Pelican_pedsWalk_e(Pelican * const me) {
    BSP_showState(me->super.prio, "pedsWalk");
    BSP_signalPeds(PEDS_WALK);
    QActive_armX(&me->super, 0U, PEDS_WALK_TOUT);
    return QM_ENTRY(&Pelican_pedsWalk_s);
}
예제 #24
0
/* @(/1/0/0/3) .............................................................*/
static QState Philo_eating_e(Philo * const me) {
    QActive_armX(&me->super, 0U, EAT_TIME);
    return QM_ENTRY(&Philo_eating_s);
}
예제 #25
0
/* @(/1/0/0/1) .............................................................*/
static QState Philo_thinking_e(Philo * const me) {
    QActive_armX(&me->super, 0U, THINK_TIME);
    return QM_ENTRY(&Philo_thinking_s);
}
예제 #26
0
/* @(/1/0/1/1/3/2) .........................................................*/
static QState Pelican_pedsFlash_e(Pelican * const me) {
    BSP_showState(me->super.prio, "pedsFlash");
    QActive_armX(&me->super, 0U, PEDS_FLASH_TOUT);
    me->flashCtr = (PEDS_FLASH_NUM * 2U) + 1U;
    return QM_ENTRY(&Pelican_pedsFlash_s);
}
예제 #27
0
/* @(/1/0/1/2) .............................................................*/
static QState Pelican_offline_e(Pelican * const me) {
    BSP_showState(me->super.prio, "offline");
    QActive_armX(&me->super, 0U, OFF_FLASH_TOUT);
    me->flashCtr = 0U;
    return QM_ENTRY(&Pelican_offline_s);
}