void ledPlayPattern(mvdAppState state)
{
    if (state == AppStatePoweredOff)
    {
        if (the_app->a2dp_source == SourceAnalog && chargerIsConnected())
        {
            ledsPlay(ledStates[ state ].charging);
        }
        else
        {
            ledsPlay(ledStates[ state ].normal);
        }
    }
    else if (state == AppStateLowBattery)
    {
        if (the_app->audioAdaptorPoweredOn)
        {
            ledsPlay(ledStates[ the_app->app_state ].low_battery);
        }
    }
    else
    {
        if (the_app->audioAdaptorPoweredOn)
        {
            if (the_app->a2dp_source == SourceAnalog && chargerIsConnected())
            {
                ledsPlay(ledStates[ the_app->app_state ].charging);
            }
            else
            {
                ledsPlay(ledStates[ the_app->app_state ].normal);
            }
        }
    }
}
Beispiel #2
0
static void led_controller1( Task t, MessageId id, Message payload )
{
    PRINT(("Pattern No. %d\n", count ));
    
    ledsPlay( patterns[count] );

    count++;
    count %= NO_OF_PATTERNS;
    
    MessageSendLater( t, 0, 0, DELAY );
}
void ledPlayPattern(mvdAppState state)
{
    if (state == AppStatePoweredOff)
    {
        ledsPlay(ledStates[ state ].normal);
    }
    else if (state == AppStateLowBattery)
    {
        if (the_app->audioAdaptorPoweredOn)
        {
            ledsPlay(ledStates[ the_app->app_state ].low_battery);
        }
    }
    else
    {
        if (the_app->audioAdaptorPoweredOn)
        {
            ledsPlay(ledStates[ the_app->app_state ].normal);
        }
    }
}
Beispiel #4
0
static void hal_deactivating_state_enter(void) {
	
	DEBUG(("hal deactivating state enter...\n"));
	
	update_indication();

	ledsPlay(BEEP_TWICE);
/*    ledsPlay(MOTOR_TWICE);*/
	MessageSendLater(getHalTask(), HAL_DEACTIVATING_TIMEOUT, 0, BEEP_TWICE_DURATION + 100);
	
	/** send message to profile **/
	MessageSend(hal.profile_task, HAL_MESSAGE_SWITCHING_OFF, 0);
	MessageSend(hal.function_task, HAL_MESSAGE_SWITCHING_OFF, 0);
}
Beispiel #5
0
/* Task handler function */
void PioTaskHandler(Task task, MessageId id, Message message)
{
    switch(id)
    {
        case NewHeaterState:
            {
                ledsPlay(patterns[(int)pioApp.new_heater_state]);
                pioApp.heater_state = pioApp.new_heater_state; 
                DEBUG(("NewHeaterState state = %d\n", (int) pioApp.new_heater_state));
            }
           break;
        case RequestTemperature:
           break;
        default:
            /* An unexpected message has arrived - must handle it */
            DEBUG(("pio app - msg type  not yet handled 0x%x\n", id));
            break;
    }
}
Beispiel #6
0
static void hal_activating_state_enter(void) {
	
	DEBUG(("hal activating state enter...\n"));
	update_indication();	

	hal.beep_finished = FALSE;
	hal.power_button_released = FALSE;
	/**
	ledsPlay(ALL_LEDS_OFF);
	**/
	
	ledsPlay(BEEP_TWICE);
    /*ledsPlay(MOTOR_TWICE);*/
    
/*    
    PioSetDir(1<<9, 1<<9);
	PioSet(1<<9, 1<<9);
	*/
	MessageSendLater(getHalTask(), HAL_ACTIVATING_TIMEOUT, 0, BEEP_TWICE_DURATION + 100);
}
Beispiel #7
0
static void hal_initialising_handler(Task task, MessageId id, Message message) {
	
	switch (id) {
		
		case PIO_RAW:
			{
				DEBUG(("hal initialising state, PIO_RAW message arrived...\n"));
			
				/** update charging state, and no check, even battery low we have nothing to do **/
				pio_raw_handler(message);
				update_indication();
			}
			break;			
		
		case BATTERY_READING_MESSAGE:
			{
				DEBUG(("hal warming-up state, BATTERY_READING_MESSAGE message arrived...\n"));
				/** update battery reading and no check, even battery low we have nothing to do **/
				if (hal.voltage == K_VoltageInit) {

					BatteryInit(&hal.battery_state, getHalTask(), BATTERY_READING_SOURCE, BATTERY_POLLING_PERIOD);
				}
				battery_message_handler(message);
				update_indication();
			}
			break;		
			
		case HAL_POWER_BUTTON_HELD_SHORT:
			{
				DEBUG(("hal initialising state, POWER_BUTTON_HELD_SHORT message arrived...\n"));
			
				/** let error mananger check initialization result, and determing the control flow **/
				initialisationFinished();
				hal_set_state(ACTIVATING);
			}
			break;
			
		case POWER_BUTTON_PRESS:
			
			DEBUG(("hal initialising state, POWER_BUTTON_PRESS message arrived...\n"));

			MessageSendLater(getHalTask(), HAL_POWER_BUTTON_HELD_SHORT, 0, 2000);
			MessageSendLater(getHalTask(), HAL_POWER_BUTTON_HELD_LONG, 0, 8000);
			break;

			
		case POWER_BUTTON_RELEASE:
			
			DEBUG(("hal initialising state, POWER_BUTTON_RELEASE message arrived...\n"));
			
			MessageCancelAll(getHalTask(), HAL_POWER_BUTTON_HELD_SHORT);
			MessageCancelAll(getHalTask(), HAL_POWER_BUTTON_HELD_LONG);
			break;
            
        case FUNCTION_BUTTON_DFU:
            
            DEBUG(("hal initialising state, FUNCTION_BUTTON_DFU message arrived...\n"));
            ledsPlay(BEEP_ONCE);/*if need beep we should add a timeout message then to enter DFU mode*/
            MessageSendLater(getHalTask(), HAL_FUNCTION_BUTTON_DFU_TIMEOUT, 0, BEEP_ONCE_DURATION + 100);
            break;
            
        case HAL_FUNCTION_BUTTON_DFU_TIMEOUT:
            
            DEBUG(("hal initialising state, HAL_FUNCTION_BUTTON_DFU_TIMEOUT message arrived...\n"));
            BootSetMode(0);
            break;            
			
		default:
			break;
	}
}