Ejemplo n.º 1
0
static void stubSendAcceleration()
{
	open_radio();

    // Set SimpliciTI mode
    sRFsmpl.mode = SIMPLICITI_ACCELERATION;

    // Set SimpliciTI timeout to save battery power
    sRFsmpl.timeout2 = SIMPLICITI_TIMEOUT2;

    if (simpliciti_link())
    {

    	simpliciti_main_sync();

        setFlag(simpliciti_flag, SIMPLICITI_TRIGGER_SEND_DATA);

    	simpliciti_main_tx_only();
    }

    // Set SimpliciTI state to OFF
    sRFsmpl.mode = SIMPLICITI_OFF;

    close_radio();
}
// *************************************************************************************************
// @fn          start_simpliciti_tx_only
// @brief       Start SimpliciTI (tx only). 
// @param       simpliciti_state_t		SIMPLICITI_ACCELERATION, SIMPLICITI_BUTTONS
// @return      none
// *************************************************************************************************
void start_simpliciti_tx_only(simpliciti_mode_t mode)
{
  	

	
	
	// Turn on beeper icon to show activity
	display_symbol(LCD_ICON_BEEPER1, SEG_ON_BLINK_ON);
	

	
	// Prepare radio for RF communication
	open_radio();

	// Set SimpliciTI mode
	sRFsmpl.mode = mode;
	
	// Set SimpliciTI timeout to save battery power
	sRFsmpl.timeout = SIMPLICITI_TIMEOUT; 
		
	// Start SimpliciTI stack. Try to link to access point.
	// Exit with timeout or by a button DOWN press.
	if (simpliciti_link())
	{
		

		// Enter TX only routine. This will transfer button events and/or acceleration data to access point.
		simpliciti_main_tx_only();
	}

	// Set SimpliciTI state to OFF
	sRFsmpl.mode = SIMPLICITI_OFF;

	// Stop acceleration sensor
	as_stop();

	// Powerdown radio
	close_radio();
	
	// Clear last button events

	BUTTONS_IFG = 0x00;  
	button.all_flags = 0;
	
	// Clear icons
	display_symbol(LCD_ICON_BEEPER1, SEG_OFF_BLINK_OFF);

	
 	
	
}
// *************************************************************************************************
// @fn          start_simpliciti_tx_only
// @brief       Start SimpliciTI (tx only).
// @param       simpliciti_state_t              SIMPLICITI_ACCELERATION, SIMPLICITI_BUTTONS
// @return      none
// *************************************************************************************************
void start_simpliciti_tx_only(simpliciti_mode_t mode)
{
    // Display time in line 1
    clear_line(LINE1);
    fptr_lcd_function_line1(LINE1, DISPLAY_LINE_CLEAR);
    display_time(LINE1, DISPLAY_LINE_UPDATE_FULL);

    // Preset simpliciti_data with mode (key or mouse click) and clear other data bytes
    if (mode == SIMPLICITI_ACCELERATION)
    {
        simpliciti_data[0] = SIMPLICITI_MOUSE_EVENTS;
    }
    else
    {
        simpliciti_data[0] = SIMPLICITI_KEY_EVENTS;
    }
    simpliciti_data[1] = 0;
    simpliciti_data[2] = 0;
    simpliciti_data[3] = 0;

    // Turn on beeper icon to show activity
    display_symbol(LCD_ICON_BEEPER1, SEG_ON_BLINK_ON);
    display_symbol(LCD_ICON_BEEPER2, SEG_ON_BLINK_ON);
    display_symbol(LCD_ICON_BEEPER3, SEG_ON_BLINK_ON);

    // Debounce button event
    Timer0_A4_Delay(CONV_MS_TO_TICKS(BUTTONS_DEBOUNCE_TIME_OUT));

    // Prepare radio for RF communication
    open_radio();

    // Set SimpliciTI mode
    sRFsmpl.mode = mode;

    // Set SimpliciTI timeout to save battery power
    sRFsmpl.timeout = SIMPLICITI_TIMEOUT;

    // Start SimpliciTI stack. Try to link to access point.
    // Exit with timeout or by a button DOWN press.
    if (simpliciti_link())
    {
        if (mode == SIMPLICITI_ACCELERATION)
        {
            // Start acceleration sensor
            as_start();
        }

        // Enter TX only routine. This will transfer button events and/or acceleration data to
        // access point.
        simpliciti_main_tx_only();
    }

    // Set SimpliciTI state to OFF
    sRFsmpl.mode = SIMPLICITI_OFF;

    // Stop acceleration sensor
    as_stop();

    // Powerdown radio
    close_radio();

    // Clear last button events
    Timer0_A4_Delay(CONV_MS_TO_TICKS(BUTTONS_DEBOUNCE_TIME_OUT));
    BUTTONS_IFG = 0x00;
    button.all_flags = 0;

    // Clear icons
    display_symbol(LCD_ICON_BEEPER1, SEG_OFF_BLINK_OFF);
    display_symbol(LCD_ICON_BEEPER2, SEG_OFF_BLINK_OFF);
    display_symbol(LCD_ICON_BEEPER3, SEG_OFF_BLINK_OFF);

    // Clean up line 1
    clear_line(LINE1);
    display_time(LINE1, DISPLAY_LINE_CLEAR);

    // Force full display update
    display.flag.full_update = 1;
}