/*----------------------------------------------------------------------------*/ void accel_tap_callback(AccelAxisType axis, uint32_t direction) { /* * If currently not connected to remote side, then force switch state OFF. */ if (isConnected == false) { tapSwitchState = false; } else { tapSwitchState = (tapSwitchState) ? false : true; } if (tapSwitchState == true) { APP_LOG(APP_LOG_LEVEL_INFO, "start sampling"); vibes_long_pulse(); app_comm_set_sniff_interval(SNIFF_INTERVAL_REDUCED); accel_data_service_subscribe( SAMPLING_RATE, (AccelDataHandler) accel_data_callback ); } else { app_comm_set_sniff_interval(SNIFF_INTERVAL_NORMAL); accel_data_service_unsubscribe(); vibes_long_pulse(); APP_LOG(APP_LOG_LEVEL_INFO, "stop sampling"); APP_LOG(APP_LOG_LEVEL_INFO, "stats: sync_set: %lu", (unsigned long)syncStats.sync_set); APP_LOG(APP_LOG_LEVEL_INFO, "stats: sync_vib: %lu", (unsigned long)syncStats.sync_vib); APP_LOG(APP_LOG_LEVEL_INFO, "stats: sync_missed: %lu", (unsigned long)syncStats.sync_missed); syncStats.sync_set = 0; syncStats.sync_vib = 0; syncStats.sync_missed = 0; } }
void updateDisplay() { int elapsed = 0; int countdown = 0; elapsed = s_currentTimer/2; countdown = s_selectedDuration - elapsed; if(s_currentTimer%2 == 0) { static char bUp[10]; static char bDown[4]; //static char bDuration[10]; //static char bDuration[5]; //static int elapsed = 0; //static int countdown = 0; //elapsed = s_currentTimer/2; //countdown = s_selectedDuration - elapsed; if(countdown > 0) { //printInt(s_countup, elapsed, bUp); printInt(s_countdown, countdown, bDown); //printInt(s_duration, s_selectedDuration, bDuration); snprintf(bUp, 10, "%d / %d", elapsed, s_selectedDuration); text_layer_set_text(s_countup, bUp); } else { printInt(s_countup, elapsed - s_selectedDuration, bUp); //text_layer_set_text(s_duration, ""); } if(countdown == 10) { vibes_double_pulse(); } else if(countdown == 3) { vibes_long_pulse(); } else if(countdown == 2 || countdown == 1) { vibes_short_pulse(); } else if(countdown == 0) { window_set_background_color(s_window, GColorWhite); vibes_long_pulse(); s_timerActive = false; updateMenu(s_selectedDuration); text_layer_set_text(s_countdown, ""); text_layer_set_text(s_countup, ""); updateSets(); } } if(s_timerActive) { if(countdown <= 10) { window_set_background_color(s_window, GColorRed); } else if (s_currentTimer < s_selectedDuration) { window_set_background_color(s_window, GColorGreen); } else { window_set_background_color(s_window, GColorOrange); if(s_currentTimer == s_selectedDuration) { // halfway point vibes_double_pulse(); } } } }
void in_received_handler(DictionaryIterator *iter, void *context) { #ifdef ENABLE_LOGS APP_LOG(APP_LOG_LEVEL_DEBUG, "Watch: Message received"); #endif int x = 0; //processing usernames for (x=0;x<MAX_NUM_USERS;x++){ Tuple *tuple = dict_find(iter, CONST_FRIEND1+x); if (tuple){ set_username_for_friend_at_index(tuple->value->cstring,x); } } //processing ids for (x=0;x<MAX_NUM_USERS;x++){ Tuple *tuple = dict_find(iter, CONST_FRIEND1+x+100); if (tuple){ set_id_for_friend_at_index(tuple->value->cstring,x); } } //processing number of friends received, this message should be the last one done in JS Tuple *tuple = dict_find(iter, CONST_FRIENDS_COUNT); if (tuple){ set_num_friends(tuple->value->int32); save_cache(); } //Confirmation of Sending Message Tuple *tuple2 = dict_find(iter, CONST_STATUS); if (tuple2){ int error = tuple2->value->int32; if (error == STYLE_ERROR) { vibes_long_pulse(); show_message_window(_("Message|Failed"),STYLE_ERROR); } else { vibes_short_pulse(); show_message_window(_("Message|Sent"),STYLE_SUCCESS); } } //Confirmation of Sending Message Tuple *tuple3 = dict_find(iter, CONST_ERROR_UPDATING_TOKEN); if (tuple3){ int error = tuple3->value->int32; if (error == STYLE_ERROR) { vibes_long_pulse(); show_message_window(_("Failed|to Sync"),STYLE_ERROR); } else { vibes_short_pulse(); show_message_window(_("Sync|Succeed"),STYLE_SUCCESS); } } }
// Bluetooth Event Handler static void handle_bluetooth(bool connected) { if (connected) { conn_state = true; bitmap_layer_set_bitmap(icon_layer, cond_img); vibes_long_pulse(); } else { conn_state = false; bitmap_layer_set_bitmap(icon_layer, gbitmap_create_with_resource(RESOURCE_ID_NO_BT)); vibes_long_pulse(); } }
static void tick(struct tm *tick_time, TimeUnits units_changed) { if (s_second_rate < 2) { layer_mark_dirty(s_date_layer); layer_mark_dirty(s_time_layer); } if (tick_time->tm_min == 0 && tick_time->tm_sec == 0 && s_vibe_hourly != SETTING_VIBE_DISABLED) { switch (s_vibe_hourly) { case SETTING_VIBE_LONG: vibes_long_pulse(); break; case SETTING_VIBE_SHORT: vibes_short_pulse(); break; case SETTING_VIBE_DOUBLE: vibes_double_pulse(); break; } } // Get weather update every 2 hours if (s_weather_icon == -1 || s_weather_temp == -100 || tick_time->tm_mday*100+tick_time->tm_hour > s_last_update_time + 1) { request_weather(); } if(tick_time->tm_hour % 2 == 0 && tick_time->tm_min == 0 && tick_time->tm_sec == 0) { request_weather(); } }
void bluetoothHandler(bool connected) { APP_LOG(DebugLevel, "bluetoothHandler: start connected :%s:",connected ? "true" : "false"); bool prevConnected=false; if(persist_exists(BT_STATUS)){ prevConnected = persist_read_bool(BT_STATUS); APP_LOG(DebugLevel, "bluetoothHandler: initial key"); } APP_LOG(DebugLevel, "bluetoothHandler: prevConnected :%s:",prevConnected ? "true" : "false"); if(connected && prevConnected) { bitmap_layer_set_bitmap(GET_LAYER(BLUETOOTH_LAYER), bluetoothImageOn); APP_LOG(DebugLevel, "bluetoothHandler: both true turned on connection"); } if(!connected && !prevConnected) { bitmap_layer_set_bitmap(GET_LAYER(BLUETOOTH_LAYER), bluetoothImageOff); APP_LOG(DebugLevel, "bluetoothHandler: both false turned off connection"); } if(connected && !prevConnected) { bitmap_layer_set_bitmap(GET_LAYER(BLUETOOTH_LAYER), bluetoothImageOn); APP_LOG(DebugLevel, "bluetoothHandler: turned on connection"); vibes_short_pulse(); } if(!connected && prevConnected) { bitmap_layer_set_bitmap(GET_LAYER(BLUETOOTH_LAYER), bluetoothImageOff); APP_LOG(DebugLevel, "bluetoothHandler: turned off connection"); vibes_long_pulse(); btBuzzerTimer = app_timer_register(BUZZER_INTERVAL, buzzer2,NULL); } persist_write_bool(BT_STATUS, connected); APP_LOG(DebugLevel, "bluetoothHandler: done saved :%s:",connected ? "true" : "false"); } // bluetoothHandler
static void handle_tap(AccelAxisType axis, int32_t direction) { persist_write_bool(STYLE_KEY, !persist_read_bool(STYLE_KEY)); set_style(); force_update(); vibes_long_pulse(); accel_tap_service_unsubscribe(); }
static void handle_tick(struct tm *t, TimeUnits units_changed) { if (strcmp(configs.secondhandoption, "stop2go") == 0) { for (int i=0; i<STOP2GO_TICK_RESOLUTION; i++) { app_timer_register(1000 / STOP2GO_TICK_RESOLUTION * i, (void*)layer_mark_dirty, window_get_root_layer(s_window)); } } else { layer_mark_dirty(window_get_root_layer(s_window)); } // Hourly vibration if (t->tm_min == 0 && t->tm_sec == 0) { if (strcmp(configs.hourlyvibration, "short") == 0) { vibes_short_pulse(); } else if (strcmp(configs.hourlyvibration, "long") == 0) { vibes_long_pulse(); } else if (strcmp(configs.hourlyvibration, "double") == 0) { vibes_double_pulse(); } } }
void bluetooth_connection_callback (bool connected) { if (!connected) { //&& settings.BluetoothVibe) { // vibe! vibes_long_pulse(); } }
void handle_battery(BatteryChargeState charge_state) { batterychargepct = charge_state.charge_percent; if (charge_state.is_charging) { batterycharging = 1; } else { batterycharging = 0; } // Reset if Battery > 20% ******************************** if (batterychargepct > 20) { if (BatteryVibesDone == 1) { //OK Reset to normal BatteryVibesDone = 0; } } // if (batterychargepct < 30) { if (BatteryVibesDone == 0) { // Do Once BatteryVibesDone = 1; vibes_long_pulse(); } } layer_mark_dirty(LineLayer); }
void tick_handler(struct tm *tick_time, TimeUnits units_changed){ if (m_timeout != 0) { time_t now = time(NULL) - m_timeout; struct tm *t = localtime(&now); strftime(m_over, sizeof(m_over), "%M:%S", t); // hack because I couldn't work out how to get single // character minutes if (m_over[0] == '0') { for (int i = 0; i < 4; ++i) { m_over[i] = m_over[i+1]; } m_over[4] = '\0'; } text_layer_set_text(s_textlayer_over, m_over); return; } m_timer--; if (m_timer == 0) { vibes_long_pulse(); text_layer_set_text(s_textlayer_count, "0"); m_timeout = time(NULL); layer_set_hidden(text_layer_get_layer(s_textlayer_over), false); // tick_timer_service_unsubscribe(); return; } snprintf(m_counter, sizeof(m_counter), "%d", m_timer); text_layer_set_text(s_textlayer_count, m_counter); }
void vibrate_quarterly() { // load settings ElCidSettings *settings = settings_load(); // don't vibrate if not set if(!settings->QuarterHourlyVibrate) { return; } // get hour from local time time_t temp = time(NULL); struct tm *tick_time = localtime(&temp); // create pattern for vibration int minutes = tick_time->tm_min; // abort if not on the quarter hour if(minutes == 0 || minutes % 15 != 0) { return; } // get settings value after we know we need it u_short vibration_type = settings->QuarterHourVibrationType; // do pattern as configured if(1 == vibration_type) { vibes_short_pulse(); } else if(2 == vibration_type) { vibes_long_pulse(); } else if(3 == vibration_type) { vibes_double_pulse(); } else if(4 == vibration_type) { vibrate_quarterly_pattern(minutes); } }
static void timer_callback(struct tm *tick_time, TimeUnits units_changed) { if (state.round_time == 0) { if (state.stretch && stretch_settings.prepare != 0) { state.round++; state.round_time = stretch_settings.prepare; vibes_long_pulse(); text_layer_set_text(ui.top_text, "Prepare"); state.stretch = 0; } else { if (stretch_settings.prepare == 0) { state.round++; } state.round_time = stretch_settings.time; vibes_short_pulse(); text_layer_set_text(ui.top_text, "Stretch"); state.stretch = 1; } update_ui(); } if (state.running) { update_time_ui(); } }
static void toggle_bluetooth_icon(bool connected) { if(appStarted && !connected && bluetoothvibe) { //vibe! vibes_long_pulse(); } layer_set_hidden(bitmap_layer_get_layer(bluetooth_layer), connected); }
static void app_connection_handler(bool connected) { layer_mark_dirty(window_get_root_layer(window)); if (!connected){ vibes_long_pulse(); } APP_LOG(APP_LOG_LEVEL_INFO, "Pebble app %sconnected", connected ? "" : "dis"); }
// Record Bluetooth connection state static void bluetooth_callback(bool connected) { if (bt_toggle == 1) { APP_LOG(APP_LOG_LEVEL_INFO, "Hide Bluetooth connection symbol"); if (!connected) {bitmap_layer_set_bitmap(s_bt_icon_layer, gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BT_0));} else {bitmap_layer_set_bitmap(s_bt_icon_layer,gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BLANK));} } else { APP_LOG(APP_LOG_LEVEL_INFO, "Show Bluetooth connection symbol"); if (!connected) {bitmap_layer_set_bitmap(s_bt_icon_layer, gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BT_0));} else {bitmap_layer_set_bitmap(s_bt_icon_layer,gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BT_1));} } // set vibrations if (!connected) { if (vibe_on_disconnect == 1) { APP_LOG(APP_LOG_LEVEL_INFO, "Vibrate on Bluetooth disconnect"); vibes_long_pulse(); } } else { if (vibe_on_connect == 1) { APP_LOG(APP_LOG_LEVEL_INFO, "Vibrate on Bluetooth reconnection"); vibes_double_pulse(); } } }
// Handles tick of the system clock. static void handle_tick(struct tm *tick_time, TimeUnits units_changed) { if(units_changed & SECOND_UNIT) { // Update control block. control_block_tick(); // Redraw the timer. draw_timer(); // Update UI. if (control_block_is_program_over()){ // Vibrate with different pattern at the end of the program. vibes_double_pulse(); // And update the screen with a final message. layer_set_hidden((Layer *)tw_tl_time, true); layer_set_hidden((Layer *)tw_tl_interval, true); text_layer_set_text(tw_tl_type, "Done!"); layer_mark_dirty((Layer *)tw_tl_type); return; } else if (control_block_is_interval_over()){ vibes_long_pulse(); } } }
void check_vibration(char *mode) { if (strcmp(mode, MODE_LONG) == 0) { vibes_long_pulse(); } else if (strcmp(mode, MODE_SHORT) == 0) { vibes_short_pulse(); } }
void Update_Connection(bool Connected){ if (Settings.Vibe_BT) vibes_long_pulse(); gbitmap_destroy(s_res_bt_picture); s_res_bt_picture = gbitmap_create_with_resource(BT_Icons[Connected]); bitmap_layer_set_bitmap(BT_Layer, s_res_bt_picture); }
void handle_bluetooth(bool connected) { if (connected) { bitmap_layer_set_bitmap(layer_conn_img, bt_connect_img); } else { bitmap_layer_set_bitmap(layer_conn_img, bt_disconnect_img); vibes_long_pulse(); } }
static void bt_handler(bool connected) { // Show current connection state if (connected) { vibes_long_pulse(); // vibrate long pulse when connection is back } else { vibes_double_pulse(); // vibrate two short pulses when connection is lost } }
static void handle_vibe_packet(Simply *simply, Packet *data) { VibePacket *packet = (VibePacket*) data; switch (packet->type) { case VibeShort: vibes_short_pulse(); break; case VibeLong: vibes_long_pulse(); break; case VibeDouble: vibes_double_pulse(); break; } }
void handle_bluetooth(bool connected) { int i; if (lastBluetoothStatus == connected) { return; } else { lastBluetoothStatus = connected; if (splashEnded && !animRunning) { if (animation_is_scheduled(anim)) { animation_unschedule(anim); } animRunning = true; for (i=0; i<NUMSLOTS; i++) { slot[i].prevDigit = slot[i].curDigit; } slot[0].curDigit = 'B' - '0'; slot[1].curDigit = 'T' - '0'; if (connected) { slot[2].curDigit = 'O' - '0'; slot[3].curDigit = 'K' - '0'; slot[4].curDigit = SPACE_D; slot[5].curDigit = SPACE_D; slot[6].curDigit = SPACE_D; slot[7].curDigit = SPACE_D; slot[8].curDigit = SPACE_D; slot[9].curDigit = SPACE_D; slot[10].curDigit = SPACE_D; slot[11].curDigit = SPACE_D; vibes_double_pulse(); } else { slot[2].curDigit = SPACE_L; slot[3].curDigit = SPACE_R; slot[4].curDigit = SPACE_D; slot[5].curDigit = 'F' - '0'; slot[6].curDigit = 'A' - '0'; slot[7].curDigit = 'I' - '0'; slot[8].curDigit = 'L' - '0'; slot[9].curDigit = 'E' - '0'; slot[10].curDigit = 'D' - '0'; slot[11].curDigit = SPACE_D; vibes_long_pulse(); } animation_schedule(anim); app_timer_register(BATTERYDELAY, handle_timer, NULL); } } }
static void bluetooth_callback(bool connected) { // Muestra el icono cuando esta desconectado layer_set_hidden(bitmap_layer_get_layer(s_layer_bt), connected); if(!connected) { // Vibracion larga vibes_long_pulse(); } }
static void handle_bluetooth_connected () { window_stack_remove(bluetooth_disconnected_splash_window, true); window_stack_push(bluetooth_connected_splash_window, true); vibes_long_pulse(); // Hide splash screen app_timer_register(2000, (void*)hide_bluetooth_connected_splash_window, NULL); light_enable_interaction(); //s_bluetooth_disconnection_dismissal_attempt = 0; }
void notify(const char *message, GBitmap *icon) { bitmap_layer_set_bitmap(warn_layer, (icon == 0 ? tick : icon)); text_layer_set_text(warn_text_layer, message); layer_set_hidden(bitmap_layer_get_layer(warn_layer), false); vibes_long_pulse(); light_enable(true); app_timer_register(WARNING_TIMEOUT, clear_warning, 0); }
//bluetooth monitoring void bt_handler(bool connected) { if (connected && gUseBluetooth == 1) { layer_set_hidden((Layer *)s_textlayer_1, false); layer_set_hidden((Layer *)s_bitmaplayer_bluetooth_connected, false); } else if (!connected && gUseBluetooth == 1){ layer_set_hidden((Layer *)s_textlayer_1, true); layer_set_hidden((Layer *)s_bitmaplayer_bluetooth_connected, true); vibes_long_pulse(); } }
void handle_battery(BatteryChargeState charge_state) { static char BatteryPctTxt[] = "+100%"; batterychargepct = charge_state.charge_percent; if (charge_state.is_charging) { batterycharging = 1; text_layer_set_background_color(text_battery_layer, GColorDukeBlue); text_layer_set_text_color(text_battery_layer, GColorWhite); } else { batterycharging = 0; } // Reset if Battery > 20% ******************************** if ((batterychargepct > 20) && (batterycharging == 0)){ BatteryVibesDone = 0; text_layer_set_background_color(text_battery_layer, GColorDukeBlue); text_layer_set_text_color(text_battery_layer, GColorWhite); } // if ((batterychargepct < 30) && (batterycharging == 0)) { #ifdef PBL_COLOR text_layer_set_text_color(text_battery_layer, GColorRed); #else text_layer_set_text_color(text_battery_layer, GColorBlack); #endif text_layer_set_background_color(text_battery_layer, GColorWhite); if ((BatteryVibesDone == 0) && (PersistLow_Batt == 1)) { // Do Once BatteryVibesDone = 1; APP_LOG(APP_LOG_LEVEL_WARNING, "Battery Vibes Sent"); vibes_long_pulse(); #ifdef PBL_COLOR text_layer_set_text_color(text_battery_layer, GColorRed); #else text_layer_set_text_color(text_battery_layer, GColorBlack); #endif text_layer_set_background_color(text_battery_layer, GColorWhite); } } if (charge_state.is_charging) { strcpy(BatteryPctTxt, "Chrg"); } else { snprintf(BatteryPctTxt, 5, "%d%%", charge_state.charge_percent); } text_layer_set_text(text_battery_layer, BatteryPctTxt); layer_mark_dirty(BatteryLineLayer); }
static void handle_bluetooth_connection(bool connected) { if (connected) { vibes_long_pulse(); } else { for (int i = 0; i<6; i++) { vibes_short_pulse(); }; }; }
void do_vibrate(void) { if(s_vibration_pattern) { s_pwmPat.durations[1] = (s_vibe_counter/s_vibration_pattern)+1; s_vibe_counter++; vibes_enqueue_custom_pwm_pattern(&s_pwmPat); } else vibes_long_pulse(); vibe_timer = app_timer_register(1000,vibe_timer_callback,NULL); }