예제 #1
0
파일: Step.c 프로젝트: Podbod12/FSTime
inline void StartSteps()
{
  int num_samples = 1;
  accel_data_service_subscribe(num_samples, data_handler);
	
	// Choose update rate
  accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);
	
	bInForwardPart = false;
}
예제 #2
0
void accl_init(void) {
	tick_timer_service_subscribe(SECOND_UNIT, handle_second_tick);
	accel_data_service_subscribe(10, &accel_data_handler);
	accel_service_set_sampling_rate(sample_freq); //This is the place that works
	
	app_message_register_outbox_failed(accl_out_failed_handler);
	app_message_register_outbox_sent(accl_out_received_handler);

    timer = app_timer_register(timer_interval, timer_callback, NULL);
	app_comm_set_sniff_interval(SNIFF_INTERVAL_REDUCED);
}
예제 #3
0
/*
 * Initialise comms and accelerometer
 */
EXTFN void init_morpheuz() {

  open_comms();

  // Accelerometer
  accel_data_service_subscribe(25, accel_data_handler);
  accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);

  // Set the smart status
  set_smart_status();
}
예제 #4
0
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;
}
예제 #5
0
static void begin_sending_data() {
  if(s_sending)
    return;  // has already begun

  // Begin sending data
  s_sending = true;

  accel_service_set_sampling_rate(ACCEL_SAMPLING_25HZ);
  accel_data_service_subscribe(SAMPLES_PER_UPDATE, accel_data_handler);

  accel_logging_start();
}
예제 #6
0
void start_callback(int index, void *ctx) {
   APP_LOG(APP_LOG_LEVEL_DEBUG, "In Start_Callback!!");
	accel_data_service_subscribe(0, NULL);

	menu_items[0].title = "Continue Trail";
	menu_items[0].subtitle = "Ready for more?";
	layer_mark_dirty(simple_menu_layer_get_layer(pedometer_settings));

	pedometer = window_create();

	window_set_window_handlers(pedometer, (WindowHandlers ) { .load = ped_load,
					.unload = ped_unload, });
예제 #7
0
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();
}
예제 #8
0
// PRESENTATION: Callbacks in general...
void select_click_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *callback_context)
{
   //cell_index->row use this to get the value in the array exercise_names and post the name to a new window..
  // just like the other select click.
  //Get which row
  // draw row maybe?

  strcpy(selected_exercise, exercise_names[(int)cell_index->row]);
  
  if (strstr(selected_exercise, "http://wger.de/api/v2/exercise/") != NULL) {
    LIST_MESSAGE_WINDOW_NUM_ROWS  = 20; // need to reset to max

   //window_stack_pop(false);
    sendString(0,selected_exercise); // 2 is the page number.. need to figure this out.   
  }
  else {
  
    s_tracking_window = window_create();
    
    window_set_click_config_provider(s_tracking_window, (ClickConfigProvider) tracking_config_provider);
    
    
    window_set_window_handlers(s_tracking_window, (WindowHandlers) {
      .load = tracking_window_load,
      .unload = tracking_window_unload
    }); 
  
  // PRESENTATION: Push to navigation stack... back button automatically pulls from stack

    window_stack_push(s_tracking_window, false);
  
    char new_str2[strlen("Selected exercise: ")+strlen(selected_exercise)+1] ;
    
    new_str2[0] = '\0';   // ensures the memory is an empty string
    strcat(new_str2,"Selected exercise: ");
      
    strcat(new_str2,selected_exercise);
    
    text_layer_set_text(s_tracking_layer,  new_str2);
  
    int num_samples = 3;
    
  // PRESENTATION: Accelerometer setup.. pretty simple to use. Data_handler method handles accelerometer data 
  // as it comes in
    accel_data_service_subscribe(num_samples, data_handler);
  
    // Choose update rate
    accel_service_set_sampling_rate(ACCEL_SAMPLING_25HZ);
    

    
  }
/*!
 @brief putメソッド,DeviceOrientationプロファイルのメッセージを処理する.

 @param[in] received 受信したメッセージ
 @param[in] iter レスポンスを格納するイテレータ

 */
static void in_received_put_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_subscribe(PER_UPDATE, &in_event_accel_handler);//イベントハンドラと呼び出す回数の設定
        accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);//サンプリングレートの設定
        break;
    default:
        // not support
        pebble_set_error_code(ERROR_NOT_SUPPORT_ATTRIBUTE);
        break;
    }
}
예제 #10
0
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);
}
예제 #11
0
void show_go(void) {
  initialise_ui();
  tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
  accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);
  accel_data_service_subscribe(1, Accel_Data_Handler);
  accel_subscribed=true;
  app_message_register_inbox_received(inbox_recieved_callback);
  app_message_register_inbox_dropped(inbox_dropped_callback);
  app_message_register_outbox_failed(outbox_failed_callback);
  app_message_register_outbox_sent(outbox_sent_callback);
  app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());
  window_set_window_handlers(s_window, (WindowHandlers) {
    .unload = handle_window_unload,
  });
예제 #12
0
static bool init(void) {
    
    accel_data_service_subscribe(ACCEL_BATCH, &data_handler);
    accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);
    
    accel_data_log = data_logging_create(
        0x1010,
        DATA_LOGGING_BYTE_ARRAY,
        sizeof(AccelData) * ACCEL_BATCH,
        false
    );
    
    return true;
    
}
예제 #13
0
/*
 * Initialise comms and accelerometer
 */
void init_morpheuz(Window *window) {

  init_alarm();

  open_comms();

  // Accelerometer
  accel_data_service_subscribe(25, accel_data_handler);
  accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);

  // Set click provider
  window_set_click_config_provider(window, (ClickConfigProvider) click_config_provider);

  // Set the smart status
  set_smart_status();
}
//Initialization of parameters for the mobile app
void handle_init(void) {
  	//Initialize handshake flag
	IS_HANDSHAKE = 0;

    //Create a window to display content
	my_window = window_create();
    
    //Push window onto the window stack
    window_stack_push(my_window, true /* true means use default window load animation */);
    
    //Create a rendering layer for window
    Layer *window_layer = window_get_root_layer(my_window);
    
    //Get window layer dimensions/bounds
    GRect bounds = layer_get_frame(window_layer);
  
    //Create a text layer
    layer = layer_create(bounds);
  	
  	//Set rendering function for text layer
  	layer_set_update_proc(layer, update_layer_callback);
  	
  	//Add text layer to the window
  	layer_add_child(window_layer, layer);

    //Subscribe/initialize the batch accelerometer data processing with 14 samples 
    //per batch and pass to accel_data_handler for processing
    accel_data_service_subscribe(WINDOW_SIZE, &accel_data_handler);
  
    //Set accelerometer sampling rate to 10Hz (important for window size).
    //If sampling rate is increased, then batch size must be increased to 
    //capture whole handshake within the window.s
    accel_service_set_sampling_rate(SAMPLE_RATE);

    if(MODE == DTW){
	    //Initialize handshake signature
	    handshake_ref = allocAccBuf(WINDOW_SIZE);

	    //Populate reference handshake matrix pointer
	    int z;
	    for(z=0; z<WINDOW_SIZE;z++){
	    	handshake_ref[z][0] = handshake_signature[z][0];
	    	handshake_ref[z][1] = handshake_signature[z][1];
	    	handshake_ref[z][2] = handshake_signature[z][2];
	    }
  	}
}
예제 #15
0
static void main_window_load(Window *win){
  s_canvas = layer_create(GRect(0, 0, 144, 168));
  layer_set_update_proc(s_canvas, update_proc);
  layer_add_child(window_get_root_layer(win),s_canvas);
  accel_data_service_subscribe(1, accel_handler);
  
  accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);
  tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);

  //set font
  system_font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
  custom_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_TTF_24));
  
  
  //set weatfer_or_time_text
  weatfer_or_time_text = text_layer_create(GRect(0, 72, 144, 56));
  text_layer_set_background_color(weatfer_or_time_text, GColorClear);
  text_layer_set_text_color(weatfer_or_time_text, GColorWhite);
  text_layer_set_text_alignment(weatfer_or_time_text, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(win), text_layer_get_layer(weatfer_or_time_text));
  
  //set month_text
  month_text = text_layer_create(GRect(58, 122, 30, 30));
  text_layer_set_background_color(month_text, GColorClear);
  text_layer_set_text(month_text, "00:00");
  text_layer_set_font(month_text, system_font);
  text_layer_set_text_alignment(month_text, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(win), text_layer_get_layer(month_text));
  
  //set day_text
  day_text = text_layer_create(GRect(106, 122, 30, 30));
  text_layer_set_background_color(day_text, GColorClear);
  text_layer_set_text(day_text, "00:00");
  text_layer_set_font(day_text, system_font);
  text_layer_set_text_alignment(day_text, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(win), text_layer_get_layer(day_text));
  
  //set week_text
  week_text = text_layer_create(GRect(0, 121, 50, 30));
  text_layer_set_background_color(week_text, GColorClear);
  text_layer_set_text(week_text, "week");
  text_layer_set_font(week_text, system_font);
  text_layer_set_text_alignment(week_text, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(win), text_layer_get_layer(week_text));
}
예제 #16
0
void window_load(Window *window)
{
  Layer *window_layer = window_get_root_layer(window);

  text_layer_1 = text_layer_create(GRect(0, 0, 104, 30));
  text_layer_set_text_color(text_layer_1, GColorBlack);
  text_layer_set_background_color(text_layer_1, GColorWhite);
  text_layer_set_font(text_layer_1, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  layer_add_child(window_layer, text_layer_get_layer(text_layer_1));

  s_action_bar = action_bar_layer_create();
  action_bar_layer_add_to_window(s_action_bar, window);
  action_bar_layer_set_click_config_provider(s_action_bar, click_config_provider);
  action_bar_layer_set_icon(s_action_bar, BUTTON_ID_DOWN, s_icon_reset);
  action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_play);
  action_bar_layer_set_icon(s_action_bar, BUTTON_ID_UP, s_icon_calib);
  
  text_layer_2 = text_layer_create(GRect(0, 30, 104, 40));
  text_layer_set_font(text_layer_2, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  layer_add_child(window_layer, text_layer_get_layer(text_layer_2));
  
  text_layer_3 = text_layer_create(GRect(0, 70, 104, 20));
  layer_add_child(window_layer, text_layer_get_layer(text_layer_3));
  text_layer_set_overflow_mode(text_layer_3, GTextOverflowModeWordWrap);
  
  text_layer_4 = text_layer_create(GRect(0, 90, 104, 20));
  layer_add_child(window_layer, text_layer_get_layer(text_layer_4));
  int calib_stored = persist_exists(CALIB_PKEY) ? persist_read_int(CALIB_PKEY) : CALIB_DEFAULT;
  if (calib_stored != 0) {
    text_layer_set_text(text_layer_1, "HELLO,");
    text_layer_set_text(text_layer_2, "DRINK SAFE");
    text_layer_set_text(text_layer_4, "Flick to start");
    display(text_layer_3,"Calib: %d", calib_stored);
  }
  else {
    text_layer_set_text(text_layer_1, "PLEASE");
    text_layer_set_text(text_layer_2, "CALIBRATE");
    text_layer_set_text(text_layer_3, "Press UP button");
    text_layer_set_text(text_layer_4, "to calibrate.");
  }
  accel_data_service_subscribe(1, accel_handler);
  accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);

  accel_tap_service_subscribe(accel_tap_handler);
}
예제 #17
0
파일: accelData.c 프로젝트: Serjar/SkiMeter
void calibrate_accel_start() {
   periodsStatic = 0;
   periodsLift = 0;
   periodsSki = 0;
   calibrationCount = 0;

   calibrationSamples = malloc (DATAHZ * 10 * sizeof(uint32_t)); // keeps space for 10 seconds of samples

   pendingDecel = false;
   thresholdUp = STATICTHRESHOLD;
   thresholdDown = STATICTHRESHOLD;
   derivData = NULL;
   lastAccel.x = lastAccel.y = lastAccel.z = lastAccel.timestamp = 0;
   app_log(APP_LOG_LEVEL_INFO, __FILE__ , __LINE__, "Subscribe Calib");
   accel_data_service_subscribe(NUMSAMPLES, (AccelDataHandler) &calibrate_data_handler);
   accel_service_set_sampling_rate(ACCEL_SAMPLING_25HZ);
   vibes_short_pulse();
}
예제 #18
0
void handle_init(void) {
  my_window = window_create();

  text_layer = text_layer_create(GRect(0, 0, 144, 60));
  Layer *layer = window_get_root_layer(my_window);
  layer_add_child(layer, text_layer_get_layer(text_layer));
  text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
  text_layer_set_background_color(text_layer, GColorClear);
  layer_set_update_proc(layer, layer_on_update);
  
  window_stack_push(my_window, true);
  
  setInitValues();
  
  accel_data_service_subscribe(1, data_handler);
  
  light_enable(true);
}
예제 #19
0
static void handle_init(void) {
    // Migrate DB
    migrate_version();

    accel_data_service_subscribe(0, NULL);
	show_sleep_window();
    int inbox_size = app_message_inbox_size_maximum();
    int outbox_size = app_message_outbox_size_maximum();
    app_message_open(inbox_size, outbox_size);
    set_outbox_size(outbox_size);

    app_message_register_inbox_received(in_received_handler);
    app_message_register_inbox_dropped(in_dropped_handler);
    app_message_register_outbox_sent(out_sent_handler);
    app_message_register_outbox_failed(out_failed_handler);

    // Subscribe to Worker messages
    app_worker_message_subscribe(worker_message_handler);
    app_focus_service_subscribe(focus_handler);
}
예제 #20
0
파일: accelData.c 프로젝트: Serjar/SkiMeter
void accel_init() {
   periodsStatic = 0;
   periodsLift = 0;
   periodsSki = 0;

   pendingDecel = false;
   if (persist_get_size	(THUPKEY) == E_DOES_NOT_EXIST) {	
       thresholdUp = MOVINGTHRESHOLD;
       thresholdDown = STATICTHRESHOLD;
   }
   else {
       thresholdUp = persist_read_int (THUPKEY);
       thresholdDown = persist_read_int (THDOWNKEY);
   }

   derivData = NULL;
   lastAccel.x = lastAccel.y = lastAccel.z = lastAccel.timestamp = 0;
   app_log(APP_LOG_LEVEL_INFO, __FILE__ , __LINE__, "Subscribe");
   accel_data_service_subscribe(NUMSAMPLES, (AccelDataHandler) &accel_data_handler);
   accel_service_set_sampling_rate(ACCEL_SAMPLING_25HZ);
}   
예제 #21
0
파일: main.c 프로젝트: Dreitser/no-sleep
static void init() {
  // Register with TickTimerService
  tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
  // Subscribe to the accelerometer data service
  int num_samples = 3;
    accel_data_service_subscribe(num_samples, accel_handler);

    // Choose update rate
    accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);
// Create main Window element and assign to pointer
  s_main_window = window_create();
  
  #ifdef PBL_SDK_2
    window_set_fullscreen(s_main_window, true);
  #endif
    
  // Set handlers to manage the elements inside the Window
  window_set_window_handlers(s_main_window, (WindowHandlers) {
    .load = main_window_load,
    .unload = main_window_unload
  });
예제 #22
0
void window_load(Window *window){     
     //setup text layer for time
     text_layer = text_layer_create(GRect(0, 120, 132, 168));
     text_layer_set_background_color(text_layer, GColorClear);
     text_layer_set_text_color(text_layer, GColorBlack);
     text_layer_set_text_alignment(text_layer, GTextAlignmentCenter);
     text_layer_set_font(text_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_POKEMON_GB_24)));
     layer_add_child(window_get_root_layer(window), (Layer*) text_layer);
     
     //Setup Battery Layer
     batt_layer = text_layer_create(GRect(5, 5, 144, 30));
     text_layer_set_font(batt_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_POKEMON_GB_8)));
     layer_add_child(window_get_root_layer(window), text_layer_get_layer(batt_layer));
 
     //Get info, copy to long-lived buffer and display
     BatteryChargeState state = battery_state_service_peek();
     static char buffer[] = "HP: 100/100";
     snprintf(buffer, sizeof("HP: 100/100"), "HP: %d/100", state.charge_percent);
     text_layer_set_text(batt_layer, buffer);
     
     //Subscribe to AccelerometerService (uncomment one to choose)
     //accel_tap_service_subscribe(accel_tap_handler);
     accel_data_service_subscribe(1, accel_raw_handler);
     
     //Setup Accel Layer
     accel_layer = text_layer_create(GRect(5, 15, 144, 30));
     text_layer_set_font(accel_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_POKEMON_GB_8)));
     text_layer_set_text(accel_layer, "Accel tap: N/A");
     layer_add_child(window_get_root_layer(window), text_layer_get_layer(accel_layer));

     //Get a time structure so that the face doesn't start blank
     struct tm *t;
     time_t temp;
     temp = time(NULL);
     t = localtime(&temp);   
     //Manually call the tick handler when the window is loading
     tick_handler(t, MINUTE_UNIT);
}
예제 #23
0
void init_motion_control() {
  accel_data_service_subscribe(10, accel_data_handler);
  accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);
}
예제 #24
0
void register_pedometer(){
	accel_data_service_subscribe(0, NULL);
	timer = app_timer_register(475, timer_callback, NULL);
}
예제 #25
0
파일: run.c 프로젝트: manelto/steps
void inicio(void)
{
  // Create our app's base window
  window = window_create();
  window_stack_push(window, true);
  window_set_background_color(window, GColorBlack);

  Layer *root_layer = window_get_root_layer(window);
  GRect frame = layer_get_frame(root_layer);
  
  
  //parte accelerometer

  text_layer_1 = text_layer_create(GRect(0, 0, frame.size.w, 22));
  text_layer_2 = text_layer_create(GRect(0, 22, frame.size.w, 18));
  text_layer_set_text_color(text_layer_1, GColorWhite);
  text_layer_set_background_color(text_layer_1, GColorClear);
  text_layer_set_text_color(text_layer_2, GColorWhite);
  text_layer_set_background_color(text_layer_2, GColorClear);
  layer_add_child(root_layer, text_layer_get_layer(text_layer_1));
  layer_add_child(root_layer, text_layer_get_layer(text_layer_2));
 
  accel_data_service_subscribe(1, accel_handler);
  accel_service_set_sampling_rate(ACCEL_SAMPLING_25HZ);
 
  accel_tap_service_subscribe(tap_handler);
  //----------------------
  

  // Init the text layer used to show the time
  time_layer = text_layer_create(GRect(0, 40, frame.size.w /* width */, 35/* height */));
  text_layer_set_text_color(time_layer, GColorWhite);
  text_layer_set_background_color(time_layer, GColorClear);
  text_layer_set_font(time_layer, fonts_get_system_font(FONT_KEY_BITHAM_34_MEDIUM_NUMBERS));
  text_layer_set_text_alignment(time_layer, GTextAlignmentCenter);
  
  day_layer = text_layer_create(GRect(0, 75, frame.size.w /* width */, 30/* height */));
  text_layer_set_text_color(day_layer, GColorWhite);
  text_layer_set_background_color(day_layer, GColorClear);
  text_layer_set_font(day_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
  text_layer_set_text_alignment(day_layer, GTextAlignmentCenter);

  connection_layer = text_layer_create(GRect(0, 98, /* width */ frame.size.w, 24 /* height */));
  text_layer_set_text_color(connection_layer, GColorWhite);
  text_layer_set_background_color(connection_layer, GColorClear);
  text_layer_set_font(connection_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  text_layer_set_text_alignment(connection_layer, GTextAlignmentCenter);
  handle_bluetooth(bluetooth_connection_service_peek());

  battery_layer = text_layer_create(GRect(0, 120, /* width */ frame.size.w, 34 /* height */));
  text_layer_set_text_color(battery_layer, GColorWhite);
  text_layer_set_background_color(battery_layer, GColorClear);
  text_layer_set_font(battery_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  text_layer_set_text_alignment(battery_layer, GTextAlignmentCenter);
  text_layer_set_text(battery_layer, "100% cargado");

  // Ensures time is displayed immediately (will break if NULL tick event accessed).
  // (This is why it's a good idea to have a separate routine to do the update itself.)
  time_t now = time(NULL);
  struct tm *current_time = localtime(&now);
  handle_second_tick(current_time, SECOND_UNIT);

  tick_timer_service_subscribe(SECOND_UNIT, &handle_second_tick);
  battery_state_service_subscribe(&handle_battery);
  bluetooth_connection_service_subscribe(&handle_bluetooth);

  layer_add_child(root_layer, text_layer_get_layer(time_layer));
  layer_add_child(root_layer, text_layer_get_layer(day_layer));
  layer_add_child(root_layer, text_layer_get_layer(connection_layer));
  layer_add_child(root_layer, text_layer_get_layer(battery_layer));
}
예제 #26
0
//Hippo Command, I put my pants on backwards!
void handle_init(void) {
    APP_LOG(APP_LOG_LEVEL_DEBUG, "INIT MEMORY: %u bytes used, %u bytes free", (unsigned) heap_bytes_used(), (unsigned) heap_bytes_free());
    
    // TODO: restore this once done profiling
#ifndef LOCK_SHIP
    srand(time(NULL));
    load_holomesh(rand() % c_craft_info_count);
#else
    load_holomesh(LOCK_SHIP);
#endif
    
    APP_LOG(APP_LOG_LEVEL_DEBUG, "UI MEMORY: %u bytes used, %u bytes free", (unsigned) heap_bytes_used(), (unsigned) heap_bytes_free());

    my_window = window_create();
    window_set_background_color(my_window, GColorBlack);

    GRect logoRect = GRect(0, 12, c_viewportWidth, c_viewportWidth);
    logoLayer = bitmap_layer_create(logoRect);
    bitmap_layer_set_bitmap(logoLayer, logoBitmap);
    layer_add_child(window_get_root_layer(my_window), bitmap_layer_get_layer(logoLayer));

    // Fonts    
    g_font_sw = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_14));
    g_font_sw_symbol = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SYMBOL_14));
    g_font_time = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);
    g_font_info = fonts_get_system_font(FONT_KEY_GOTHIC_14);
    
    // Paint layer
    frameBufferLayer = bitmap_layer_create(GRect(0, 0, c_viewportWidth, c_viewportHeight));
    layer_add_child(window_get_root_layer(my_window), bitmap_layer_get_layer(frameBufferLayer));
    
    frameBufferBitmap = gbitmap_create_blank_with_palette(
        GSize(c_viewportWidth, c_viewportHeight),
        GBitmapFormat2BitPalette,
        c_palette,
        false);
    bitmap_layer_set_bitmap(frameBufferLayer, frameBufferBitmap);
    bitmap_layer_set_compositing_mode(frameBufferLayer, GCompOpSet);
    
    paint();

    GRect layerSize = GRect(0, 0, c_viewportWidth, c_viewportHeight);

    // Two small text layers
    textLayer = text_layer_create(layerSize);
    text_layer_set_background_color(textLayer, GColorClear);
    text_layer_set_text_color(textLayer, GColorYellow);
    text_layer_set_font(textLayer, g_font_sw);
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(textLayer));

    //Jet Force Push-up, you silly-billy.   
    textLayerSym = text_layer_create(layerSize);
    text_layer_set_background_color(textLayerSym, GColorClear);
    text_layer_set_text_color(textLayerSym, GColorYellow);
    text_layer_set_font(textLayerSym, g_font_sw_symbol);
    layer_set_hidden(text_layer_get_layer(textLayerSym), true);
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(textLayerSym));

    //Hippo Command, I also put my watch on backwards!

    // Info text layer
    infoTextLayer = text_layer_create(layerSize);
    text_layer_set_background_color(infoTextLayer, GColorClear);
    text_layer_set_text_color(infoTextLayer, GColorYellow);
    text_layer_set_font(infoTextLayer, g_font_info);
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(infoTextLayer));
    
    // Time
    GSize timeSize = graphics_text_layout_get_content_size(
        "00:00 AM",
        g_font_time,
        layerSize,
        0,
        GTextAlignmentLeft);
    GRect timeRect = { GPoint(DT_EDGE_PAD, c_viewportHeight - timeSize.h), GSize(c_viewportWidth, timeSize.h) };
    timeLayer = text_layer_create(timeRect);
    text_layer_set_background_color(timeLayer, GColorClear);
    text_layer_set_text_color(timeLayer, GColorYellow);
    text_layer_set_font(timeLayer, g_font_time);
    //text_layer_set_text(timeLayer, "23:45 AM");
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(timeLayer));
    
    // Date
    dateLayer = text_layer_create(layerSize);
    text_layer_set_background_color(dateLayer, GColorClear);
    text_layer_set_text_color(dateLayer, GColorYellow);
    text_layer_set_font(dateLayer, g_font_info);
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(dateLayer));
    


    time_t t = time(NULL);
    update_time_display(localtime(&t));
    update_date_display(localtime(&t));
    update_title_and_info();
    
    APP_LOG(APP_LOG_LEVEL_DEBUG, "FINAL MEMORY: %u bytes used, %u bytes free", (unsigned) heap_bytes_used(), (unsigned) heap_bytes_free());
    
    window_stack_push(my_window, true);
    tick_timer_service_subscribe(SECOND_UNIT | MINUTE_UNIT, tick_handler);
    
    g_timer = app_timer_register(c_refreshTimer, animation_timer_trigger, NULL);
    
    accel_data_service_subscribe(c_accelSampleCount, accel_data_handler);
    accel_service_set_sampling_rate(ACCEL_SAMPLING_25HZ);
}
예제 #27
0
파일: home_page.c 프로젝트: iN0bu/ICare
static void handle_window_load()
{            
    accel_data_service_subscribe(SAMPLE_BUF, accel_data_handler);
    accel_service_set_sampling_rate(ACCEL_SAMPLING_100HZ);
}
예제 #28
0
static void init() {
  s_step_count = 0;
  
  accel_data_service_subscribe(1, accel_raw_handler);
  accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);
}
예제 #29
0
void begin_logging(void) {
  logit("Begin accel")
  accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);
  accel_data_service_subscribe(10, accel_data_handler);
  
}
예제 #30
0
void enable_tilt_scroll() {
  // Subscribe to the accelerometer service
  scrollEnabled = true;
  accel_data_service_subscribe(1, &accel_data_handler);
  accel_service_set_sampling_rate(ACCEL_SAMPLING_100HZ);
}