static void main_window_unload(Window *window) { // Destroy TextLayer text_layer_destroy(s_spin_time_layer); // Unsubscribe to acc. data service accel_data_service_unsubscribe(); }
void calibrate_accel_end( bool keepData) { int tries = 0; vibes_short_pulse(); accel_data_service_unsubscribe(); if (keepData) { thresholdUp -= (thresholdUp>>2); // threshold set to 75% of max value: x - x/4, down = x'/2 while ((periodsSki != 3) && (tries < MAXCALIBTRY)) { tries++; // threshold set to 75% of max value: x - x/4, down = x'/2 // thresholdDown = thresholdUp>>1; periodsLift = calibrationCount; periodsSki = strokesDetected( calibrationSamples, calibrationCount); periodsStatic = thresholdUp; lastAccel.timestamp = 0; app_log(APP_LOG_LEVEL_INFO, __FILE__ , __LINE__, "Calib detected: %i", (int)periodsSki); if (periodsSki > 3) thresholdUp += thresholdUp>>3; if (periodsSki < 3) thresholdUp -= thresholdUp>>3; } if (periodsSki != 3) { thresholdUp = MOVINGTHRESHOLD; thresholdDown = STATICTHRESHOLD; } persist_write_int(THUPKEY, thresholdUp); persist_write_int(THDOWNKEY, thresholdUp>>1); } else
/*----------------------------------------------------------------------------*/ 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; } }
static void worker_message_handler(uint16_t type, AppWorkerMessage *data) { static AppWorkerMessage msg_data; switch(type) { case WORKER_MSG_ECHO: #if !ECHO_CMDS // Construct a data packet msg_data.data0 = data->data0; // Send the data to the foreground app app_worker_send_message(WORKER_MSG_ECHO, &msg_data); #endif break; case WORKER_MSG_ACCEL_START: accel_data_service_subscribe(data->data0, worker_accel_data_handler); accel_service_set_sampling_rate(data->data1); worker_accel_enabled = true; break; case WORKER_MSG_ACCEL_STOP: accel_data_service_unsubscribe(); worker_accel_enabled = false; break; case WORKER_MSG_ACCEL_MODIFY: accel_service_set_samples_per_update(data->data0); accel_service_set_sampling_rate(data->data1); break; case WORKER_MSG_TICK_START: if ( data->data0 != 0 ) tickRate = data->data0; // how often do we want updates. tick_timer_service_subscribe(SECOND_UNIT, worker_tick_handler); worker_tick_enabled = true; break; case WORKER_MSG_TICK_STOP: tick_timer_service_unsubscribe(); worker_tick_enabled = false; break; case WORKER_MSG_LOGGING_START: datalog_ref = data_logging_create(SLEEP_DATA_LOG_TAG, DATA_LOGGING_BYTE_ARRAY, sizeof(struct AccelData), true); worker_logging_enabled = true; break; case WORKER_MSG_LOGGING_STOP: data_logging_finish(datalog_ref); worker_logging_enabled = false; break; case WORKER_MSG_STATUS_RQST: worker_send_status_resp(); break; } #if ECHO_CMDS msg_data.data0 = type; app_worker_send_message(WORKER_MSG_ECHO,&msg_data); #endif }
static void tracking_window_unload(Window *window) { // Destroy output TextLayer text_layer_destroy(s_tracking_layer); text_layer_destroy(s_reps_layer); window_destroy(window); accel_data_service_unsubscribe(); }
// Handle the start-up of the app static void init(void) { // Create window window = window_create(); window_stack_push(window, true); // Load images bg_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BG); empty_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_EMPTY); full_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_FULL); // Create bg layer bg_layer = bitmap_layer_create(GRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); bitmap_layer_set_bitmap(bg_layer, bg_image); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(bg_layer)); // Create status layers for (int i = 0; i < NUMBER_OF_STATUS_BARS; i++) { status_layer[i] = bitmap_layer_create(GRect(STATUS_BAR_X_ORIGIN + STATUS_BAR_X_OFFSET * i, STATUS_BAR_Y_ORIGIN, STATUS_BAR_WIDTH, STATUS_BAR_HEIGHT)); bitmap_layer_set_bitmap(status_layer[i], empty_image); layer_add_child(bitmap_layer_get_layer(bg_layer), bitmap_layer_get_layer(status_layer[i])); } // Subscribe minute handler //tick_timer_service_subscribe(SECOND_UNIT, &handle_tick); // Setup accelerator handling old_accel = (AccelData) { .x = 0, .y = 0, .z = 0 }; accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ); accel_service_set_samples_per_update(0); accel_data_service_subscribe(0, handle_accel); timer = app_timer_register(100 /* milliseconds */, handle_timer, NULL); } // Handle the shutdown of the app static void deinit(void) { // Disable accelerator handling accel_data_service_unsubscribe(); // Destroy status layers for (int i = 0; i < NUMBER_OF_STATUS_BARS; i++) { bitmap_layer_destroy(status_layer[i]); } // Destroy bg layer bitmap_layer_destroy(bg_layer); // Unload images gbitmap_destroy(bg_image); gbitmap_destroy(empty_image); gbitmap_destroy(full_image); // Destroy window window_destroy(window); }
void checkTiltMode() { s_tiltMode = getTiltStatus(); if (s_tiltMode > 0) { accel_data_service_subscribe(1, dataHandler); accel_service_set_sampling_rate(ACCEL_SAMPLING_25HZ); } else{ accel_data_service_unsubscribe(); } }
/*----------------------------------------------------------------------------*/ int main(void) { APP_LOG(APP_LOG_LEVEL_INFO, "main: entry: %s %s", __TIME__, __DATE__); /* * Commission App */ window = window_create(); WindowHandlers handlers = {.load = window_load, .unload = window_unload }; window_set_window_handlers(window, handlers); const bool animated = true; window_stack_push(window, animated); Layer * window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); /* Display the simple splash screen to indicate PebblePointer is running. */ image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_PEBBLEPOINTER); image_layer = bitmap_layer_create(bounds); bitmap_layer_set_bitmap(image_layer, image); bitmap_layer_set_alignment(image_layer, GAlignCenter); layer_add_child(window_layer, bitmap_layer_get_layer(image_layer)); /* Basic accelerometer initialization. Enable Tap-Tap functionality. */ accel_service_set_sampling_rate( SAMPLING_RATE ); accel_tap_service_subscribe( (AccelTapHandler) accel_tap_callback ); app_message_open(SYNC_BUFFER_SIZE, SYNC_BUFFER_SIZE); /* Request notfication on Bluetooth connectivity changes. */ bluetooth_connection_service_subscribe( bluetooth_connection_callback ); isConnected = bluetooth_connection_service_peek(); APP_LOG(APP_LOG_LEVEL_INFO, "initially %sonnected", (isConnected) ? "c" : "disc"); /* * Event Processing */ app_event_loop(); /* * Decommission App */ if (tapSwitchState == true) { accel_data_service_unsubscribe(); } /* Remove the Tap-Tap callback */ accel_tap_service_unsubscribe(); /* Release splash-screen resources */ gbitmap_destroy(image); bitmap_layer_destroy(image_layer); window_destroy(window); APP_LOG(APP_LOG_LEVEL_INFO, "main: exit"); }
static void deinit() { accel_data_service_unsubscribe(); tick_timer_service_unsubscribe(); /* free the malloc'ed x,y,z arrays and work array */ for(int16_t axis = 0; axis < N_AXIS; axis++){ free(pt_ary[axis]); } free(work_ary); }
static void check_complete_stop(){ if(stoppedR && stoppedL){ accel_data_service_unsubscribe(); accel_subscribed=false; } else if(!accel_subscribed){ accel_subscribed=true; accel_data_service_subscribe(1, Accel_Data_Handler); } }
static void deinit(void) { accel_tap_service_unsubscribe(); accel_data_service_unsubscribe(); if (timer != NULL) app_timer_cancel(timer); tick_timer_service_unsubscribe(); layer_destroy(layer); fonts_unload_custom_font(fontHour); fonts_unload_custom_font(fontDate); window_destroy(window); }
static void windows_kodi_unload(Window *window){ action_bar_layer_destroy(action_bar); text_layer_destroy(s_title_info_layer); text_layer_destroy(s_album_info_layer); if (TAP_NOT_DATA) { accel_tap_service_unsubscribe(); } else { accel_data_service_unsubscribe(); } }
static void main_window_unload(Window *win){ APP_LOG(APP_LOG_LEVEL_DEBUG, "Unloading window"); fonts_unload_custom_font(custom_font); text_layer_destroy(weatfer_or_time_text); text_layer_destroy(month_text); text_layer_destroy(day_text); text_layer_destroy(week_text); layer_destroy(s_canvas); accel_data_service_unsubscribe(); tick_timer_service_unsubscribe(); }
static void stop_sending_data() { if(!s_sending) return; // does not send currently // Stop sending data s_sending = false; accel_data_service_unsubscribe(); accel_logging_stop(); }
void autorotate_disable(bool rotate_to_normal) { if (timer_orientation_check) { app_timer_cancel(timer_orientation_check); timer_orientation_check = NULL; accel_data_service_unsubscribe(); if (rotate_to_normal) { score_layer_set_orientation_all(ScoreLayerOrientationNormal); } } }
static void main_window_unload(Window *window) { text_layer_destroy(s_time_layer); text_layer_destroy(s_stat_layer); text_layer_destroy(s_twitter_layer); text_layer_destroy(s_battery_layer); text_layer_destroy(s_quote_layer); battery_state_service_unsubscribe(); accel_data_service_unsubscribe(); }
// De-Initialise UI static void deinit(void) { accel_data_service_unsubscribe(); app_timer_cancel(show_time); app_timer_cancel(inverter_timer); app_timer_cancel(time_timer); bitmap_layer_destroy(static_1_bitmap); text_layer_destroy(time_layer); inverter_layer_destroy(static_inverter_layer); gbitmap_destroy(s_res_static_1_image); window_stack_remove(window, false); window_destroy(window); }
static void toggle_accelerometer(){ running = !running; if (running){ accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ); accel_data_service_subscribe(0, handle_accel); } else{ accel_data_service_unsubscribe(); } set_timer(); }
void simply_accel_set_data_subscribe(SimplyAccel *self, bool subscribe) { if (self->data_subscribed == subscribe) { return; } if (subscribe) { accel_data_service_subscribe(self->num_samples, handle_accel_data); accel_service_set_sampling_rate(self->rate); } else { accel_data_service_unsubscribe(); } self->data_subscribed = subscribe; }
void mainWindowUnload() { if (s_gameState == kGameOver) endGame(); else saveGame(); layer_destroy(s_boardLayer); layer_destroy(s_mainBackgroundLayer); layer_destroy(s_mainForegroundLayer); status_bar_layer_destroy(s_statusBar); s_boardLayer = NULL; s_mainBackgroundLayer = NULL; s_mainForegroundLayer = NULL; s_statusBar = NULL; stopGameTick(); accel_data_service_unsubscribe(); }
static void accel_tap_handler(AccelAxisType axis, int32_t direction) { accel_data_service_unsubscribe(); vibes_short_pulse(); psleep(2000); accel_data_service_subscribe(1, accel_handler); accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ); pause = 1; accel_tap_service_unsubscribe(); text_layer_set_text(text_layer_2, "RUNNING"); text_layer_set_text(text_layer_3, ""); action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_pause); start_time = time(NULL); app_timer_register(10000, endtrial_callback, (void*)start_time); }
/*! @brief deleteメソッド,DeviceOrientationプロファイルのメッセージを処理する. @param[in] received 受信したメッセージ @param[in] iter レスポンスを格納するイテレータ */ static void in_received_delete_device_orientation_handler(DictionaryIterator *received) { Tuple *attributeTuple = dict_find(received, KEY_ATTRIBUTE); switch (attributeTuple->value->uint8) { case DEVICE_ORIENTATION_ATTRIBUTE_ON_DEVICE_ORIENTATION: accel_data_service_unsubscribe(); pebble_sniff_interval_reduced(); break; default: // not support entry_log( "not support", "orientation" ) ; pebble_set_error_code(ERROR_NOT_SUPPORT_ATTRIBUTE); break; } }
void window_unload(Window *window) { // Call this before destroying text_layer, because it can change the text // and this must only happen while the layer exists. accel_data_service_unsubscribe(); accel_tap_service_unsubscribe(); text_layer_destroy(text_layer_2); text_layer_destroy(text_layer_1); text_layer_destroy(text_layer_3); text_layer_destroy(text_layer_4); gbitmap_destroy(s_icon_reset); gbitmap_destroy(s_icon_play); gbitmap_destroy(s_icon_pause); gbitmap_destroy(s_icon_calib); }
static void handle_deinit(void) { accel_data_service_unsubscribe(); hide_sleep_window(); // We are already in background capturing the sleep // if (get_config()->status == STATUS_ACTIVE) { // set_config_status(STATUS_NOTACTIVE); // notify_status_update(get_config()->status); // } // No more worker updates app_worker_message_unsubscribe(); freeLogic(); }
/*! * Destroys elements when app goes out of scope, and unsubscribes from * the accelerometer. * * \param window the app's main window */ void window_unload(Window *window) { // Call this before destroying text_layer, because it can change the text // and this must only happen while the layer exists. accel_data_service_unsubscribe(); gbitmap_destroy(bitmap); for (int i = 0; i < 8; i++) { gbitmap_destroy(notes[i]); } app_timer_cancel(accel_timer); app_timer_cancel(phone_timer); bitmap_layer_destroy(image_layer); bitmap_layer_destroy(note_layer); }
void cierre(void) { //parte accelerometer accel_data_service_unsubscribe(); accel_tap_service_unsubscribe(); text_layer_destroy(text_layer_2); text_layer_destroy(text_layer_1); //--------------------- tick_timer_service_unsubscribe(); battery_state_service_unsubscribe(); bluetooth_connection_service_unsubscribe(); text_layer_destroy(time_layer); text_layer_destroy(connection_layer); text_layer_destroy(battery_layer); window_destroy(window); }
static void handle_tick(struct tm *tick_time, TimeUnits units_changed) { APP_LOG(APP_LOG_LEVEL_ERROR, "checking for handshake..."); if (data_handshake == true && tap_handshake == true) { vibes_double_pulse(); text_layer_set_text(phone_layer, ""); text_layer_set_text(name_layer, ""); APP_LOG(APP_LOG_LEVEL_ERROR, "handshake detected!"); showPopup(); //send_cmd(); data_handshake = false; tap_handshake = false; accel_data_service_unsubscribe(); accel_tap_service_unsubscribe(); } }
void deregister_pedometer(){ accel_data_service_unsubscribe(); app_timer_cancel(timer); }
void deinit_motion_control() { accel_data_service_unsubscribe(); }
static void deinit() { accel_data_service_unsubscribe(); }