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(); }
void reopen_radio() { if (!attempt_reopen) return; if (open_radio() != -1) { start_mute_timer(); radio_setfreq(radio_getfreq()); set_text_freq(radio_getfreq()); onoff_state = 1; /* on */ } set_onoff_button(onoff_state); }
// ************************************************************************************************* // @fn start_simpliciti_sync // @brief Start SimpliciTI (sync mode). // @param none // @return none // ************************************************************************************************* void start_simpliciti_sync(void) { // Clear LINE1 clear_line(LINE1); fptr_lcd_function_line1(LINE1, DISPLAY_LINE_CLEAR); // Stop data logging and close session stop_datalog(); // 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); // Prepare radio for RF communication open_radio(); // Set SimpliciTI mode sRFsmpl.mode = SIMPLICITI_SYNC; // 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 DOWN button press. if (simpliciti_link()) { // Enter sync routine. This will send ready-to-receive packets at regular intervals to the // access point. // The access point always replies a command (NOP if no other command is set) simpliciti_main_sync(); } // Set SimpliciTI state to OFF sRFsmpl.mode = SIMPLICITI_OFF; // 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); // Force full display update display.flag.full_update = 1; }
// ************************************************************************************************* // @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); }
void gkrellm_radio_turn_onoff(void) { if (!onoff_state) { if (open_radio() == -1) { gkrellm_message_window("GKrellM radio plugin", _("Couldn't open /dev/radio"), NULL); } else { /* radio was opened */ onoff_state = 1; /* on */ start_mute_timer(); radio_setfreq(radio_getfreq()); set_text_freq(radio_getfreq()); set_onoff_button(onoff_state); } } else { onoff_state = 0; /* off */ set_onoff_button(onoff_state); close_radio(); } }
// ************************************************************************************************* // @fn start_simpliciti_sync // @brief Start SimpliciTI (sync mode). // @param none // @return none // ************************************************************************************************* void start_simpliciti_sync(void) { display_symbol(LCD_ICON_BEEPER1, 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 = SIMPLICITI_SYNC; // 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 sync routine. This will send ready-to-receive packets at regular intervals to the access point. // The access point replies with a command (NOP if no other command is set) simpliciti_main_sync(); } // Set SimpliciTI state to OFF sRFsmpl.mode = SIMPLICITI_OFF; // Powerdown radio close_radio(); BUTTONS_IFG = 0x00; button.all_flags = 0; // Clear icons display_symbol(LCD_ICON_BEEPER1, SEG_OFF_BLINK_OFF); }
void sx_gate (u8 line) { u16 i; if (button.flag.down) { display_symbol (LCD_ICON_BEEPER1, SEG_ON); open_radio(); gate_init(); for(i=0;i<50;i++) { GATE_Transmit(open, GATE_SETTING_PKTLEN); Timer0_A4_Delay(CONV_MS_TO_TICKS(11)); } close_radio(); display_symbol (LCD_ICON_BEEPER1, SEG_OFF); } else { } }
// ************************************************************************************************* // @fn sx_bluerobin // @brief BlueRobin direct function. Button UP connects/disconnects with sender unit. // @param u8 line LINE1 // @return none // ************************************************************************************************* void sx_bluerobin(u8 line) { u8 stop = 0; // Exit if battery voltage is too low for radio operation if (sys.flag.low_battery) return; // Exit if SimpliciTI stack is active if (is_rf()) return; // UP: connect / disconnect transmitter if(button.flag.up) { if (sBlueRobin.state == BLUEROBIN_OFF) { // Init BlueRobin timer and radio open_radio(); // Initialize BR library BRRX_Init_v(); // Set BR data transmission properties BRRX_SetPowerdownDelay_v(10); // Power down channel after 10 consecutive lost data packets (~9 seconds) BRRX_SetSearchTimeout_v(8); // Stop searching after 8 seconds // Sensitivity in learn mode reduced --> connect only to close transmitters // Skip this part if chest strap id was set in a previous learn mode run #if REMEMBER_TX_ID == TRUE if (sBlueRobin.cs_id == 0) BRRX_SetSignalLevelReduction_v(5); #else // Forget previously learned transmitter ID and connect to next close transmitter sBlueRobin.cs_id = 0; BRRX_SetSignalLevelReduction_v(5); #endif // Apply frequency offset compensation to radio register FSCTRL0 // If calibration memory was erased, rf_frequoffset defaults to 0x00 and has no effect WriteSingleReg(FSCTRL0, rf_frequoffset); // New state is SEARCH sBlueRobin.state = BLUEROBIN_SEARCHING; // Blink RF icon to show searching 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); // Turn on radio and establish connection if channel not already started if (BRRX_GetState_t(HR_CHANNEL) == TX_OFF) { // Start in learn mode (connect to closest heart rate transmitter) BRRX_SetID_v(HR_CHANNEL, sBlueRobin.cs_id); BRRX_Start_v(HR_CHANNEL); // Wait until learning phase is over while (BRRX_GetState_t(HR_CHANNEL)==TX_SEARCH) { Timer0_A4_Delay(CONV_MS_TO_TICKS(200)); } } // Check if connection attempt was successful if (BRRX_GetState_t(HR_CHANNEL)==TX_ACTIVE) { // Successfully connected to transmitter sBlueRobin.state = BLUEROBIN_CONNECTED; // When in learn mode, copy chest strap ID if (sBlueRobin.cs_id == 0) { sBlueRobin.cs_id = BRRX_GetID_u32(HR_CHANNEL); } // Show steady RF icon to indicate established connection display_symbol(LCD_ICON_BEEPER1, SEG_ON_BLINK_OFF); display_symbol(LCD_ICON_BEEPER2, SEG_ON_BLINK_OFF); display_symbol(LCD_ICON_BEEPER3, SEG_ON_BLINK_OFF); // Show blinking icon display_symbol(LCD_ICON_HEART, SEG_ON_BLINK_ON); } else // Error -> Shutdown connection { stop = 1; } } else if (sBlueRobin.state == BLUEROBIN_CONNECTED) { // Shutdown connection stop = 1; } } // Shutdown connection if (stop) { stop_bluerobin(); } }
// ************************************************************************************************* // @fn start_bluerobin // @brief Start BlueRobin stack and search for a transmitter. // @param none // @return 0 = no transmitter found, 1 = connected to a transmitter // ************************************************************************************************* u8 start_bluerobin(void) { u8 timeout, i; // Init BlueRobin timer and radio // Enable high current mode open_radio(); // Initialize BR library BRRX_Init_v(); // Set BR data transmission properties BRRX_SetPowerdownDelay_v(10); // Power down channel after 10 consecutive lost data packets (~9 // seconds) BRRX_SetSearchTimeout_v(6); // Stop searching after 8 seconds // Sensitivity in learn mode reduced --> connect only to close transmitters // Skip this part if chest strap id was set in a previous learn mode run #if REMEMBER_TX_ID == TRUE if (sBlueRobin.cs_id == 0) BRRX_SetSignalLevelReduction_v(5); #else // Forget previously learned transmitter ID and connect to next close transmitter sBlueRobin.cs_id = 0; BRRX_SetSignalLevelReduction_v(5); #endif // Apply frequency offset compensation to radio register FSCTRL0 // If calibration memory was erased, rf_frequoffset defaults to 0x00 and has no effect WriteSingleReg(FSCTRL0, rf_frequoffset); // New state is SEARCH sBlueRobin.state = BLUEROBIN_SEARCHING; // Blink RF icon to show searching 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); // Turn on radio and establish connection if channel not already started if (BRRX_GetState_t(HR_CHANNEL) == TX_OFF) { // Start in learn mode (connect to closest heart rate transmitter) BRRX_SetID_v(HR_CHANNEL, sBlueRobin.cs_id); BRRX_Start_v(HR_CHANNEL); // Wait until learning phase is over, additional timeout prevents race condition if hardware // works incorrect timeout = 40; while ((BRRX_GetState_t(HR_CHANNEL) == TX_SEARCH) && (timeout-- > 0)) { Timer0_A4_Delay(CONV_MS_TO_TICKS(200)); } // Timeout? if (timeout == 0) { display_chars(LCD_SEG_L1_3_0, (u8 *) "FAIL", SEG_ON); for (i = 0; i < 4; i++) Timer0_A4_Delay(CONV_MS_TO_TICKS(500)); } } // Check if connection attempt was successful if (BRRX_GetState_t(HR_CHANNEL) == TX_ACTIVE) { // Successfully connected to transmitter sBlueRobin.state = BLUEROBIN_CONNECTED; // When in learn mode, copy chest strap ID if (sBlueRobin.cs_id == 0) sBlueRobin.cs_id = BRRX_GetID_u32(HR_CHANNEL); // Show steady RF icon to indicate established connection display_symbol(LCD_ICON_BEEPER1, SEG_ON_BLINK_OFF); display_symbol(LCD_ICON_BEEPER2, SEG_ON_BLINK_OFF); display_symbol(LCD_ICON_BEEPER3, SEG_ON_BLINK_OFF); // Show blinking icon display_symbol(LCD_ICON_HEART, SEG_ON_BLINK_ON); return (1); } else // Error -> Shutdown connection { // Clear RF icon 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); return (0); } }
// ************************************************************************************************* // @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; }