void show_timestamps_callback(int idx, void *ctx) {
  
  // If no entries, just say so in the subtitle of the main_menu item.
  if (!available_entries()) {
    menu_item->subtitle = no_entries_text;
    SimpleMenuLayer *smenu_layer = *((SimpleMenuLayer**) ctx);
    layer_mark_dirty((Layer *) smenu_layer);
    app_timer_register(MSG_DELAY, show_timestamps_callback_end, ctx);
    menu_item->callback = NULL;
    return;
  }
  
  show_show_timestamps();
}
static void loading_retry_timer(void* data)
{
	if (!loadingMode)
		return;

    if (!connection_service_peek_pebble_app_connection())
    {
        show_disconnected_error();
        return;
    }

	send_initial_packet();
	app_timer_register(3000, loading_retry_timer, NULL);
}
Esempio n. 3
0
void handle_init() {
  int i;

  srand(time(NULL));
  initColors();

  readConfig();
  swapDigitShapes();
  app_message_init();

  initSplash();

  window = window_create();
  if (invertStatus) {
    window_set_background_color(window, GColorWhite);
  } else {
    window_set_background_color(window, GColorBlack);
  }
  window_stack_push(window, true);

  rootLayer = window_get_root_layer(window);
  mainLayer = layer_create(layer_get_bounds(rootLayer));
  layer_add_child(rootLayer, mainLayer);
  layer_set_update_proc(mainLayer, updateMainLayer);

  for (i=0; i<NUMSLOTS; i++) {
    initSlot(i, mainLayer);
  }

  initDigitCorners();

  animImpl.setup = NULL;
  animImpl.update = animateDigits;
#ifdef PBL_PLATFORM_APLITE
  animImpl.teardown = destroyAnim;
#else
  animImpl.teardown = NULL;
#endif
  createAnim();

  timer = app_timer_register(STARTDELAY, handle_timer, NULL);

  tick_timer_service_subscribe(MINUTE_UNIT, handle_tick);

  accel_tap_service_subscribe(handle_tap);

  lastBluetoothStatus = bluetooth_connection_service_peek();
  bluetooth_connection_service_subscribe(handle_bluetooth);
}
Esempio n. 4
0
// splash window
static void splash_window_load(Window *window)
{
  app_timer_register(1000, (AppTimerCallback) timer_callback, NULL);
  splash_layer = text_layer_create(GRect(0, 55, 144, 50));
  text_layer_set_background_color(splash_layer, GColorClear);
  text_layer_set_text_color(splash_layer, GColorBlack);
  text_layer_set_text(splash_layer, "News");
  
  // Improve the layout to be more like a watchface
  text_layer_set_font(splash_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
  text_layer_set_text_alignment(splash_layer, GTextAlignmentCenter);
  
  // Add it as a child layer to the Window's root layer
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(splash_layer));
}
Esempio n. 5
0
static void handle_bluetooth_disconnected () {
  window_stack_remove(bluetooth_connected_splash_window, true);
  window_stack_push(bluetooth_disconnected_splash_window, true);
      
  uint32_t vibes_pluse_segments[] = { 200, 100, 200, 100, 200, 100, 200, 100, 200 };
  VibePattern vibes_pluse_pattern = {
    .durations = vibes_pluse_segments,
    .num_segments = ARRAY_LENGTH(vibes_pluse_segments),
  };

  vibes_enqueue_custom_pattern(vibes_pluse_pattern);
  light_enable_interaction();
  // Hide splash screen
  app_timer_register(5000, (void*)hide_bluetooth_disconnected_splash_window, NULL);
}
Esempio n. 6
0
static void count_timer_handler(void *data) {
  if(s_is_running) {
    if (s_wakeup_timestamp == 0) {
      // get the wakeup timestamp for showing a countdown
      wakeup_query(s_wakeup_id, &s_wakeup_timestamp);
    }
  
    int countdown = s_wakeup_timestamp - time(NULL);
    static char s_left_time_buf[16];
    snprintf(s_left_time_buf, sizeof(s_left_time_buf), "%02d:%02d", countdown/60, countdown%60);
    text_layer_set_text(s_left_time_label, s_left_time_buf);
  }
  layer_mark_dirty(text_layer_get_layer(s_left_time_label));
  app_timer_register(1000, count_timer_handler, data);
}
Esempio n. 7
0
void handle_init() {
  uint32_t seed = 4;
  tinymt32_init(&rndstate, seed);

  window = window_create();
  window_set_fullscreen(window, true);
  window_stack_push(window, true /* Animated */);
  window_set_background_color(window, GColorBlack);

  // resource_init_current_app(&APP_RESOURCES);

  // Init the layer for the minute display
  // layer_init(&layer, window.layer.frame);
  // layer.update_proc = &layer_update_callback;
  // layer_add_child(&window.layer, &layer);

  init_particles();

  // setup debugging text layer
  GRect window_bounds = layer_get_bounds(window_get_root_layer(window));
  text_header_layer = text_layer_create(window_bounds);
  text_layer_set_text_color(text_header_layer, GColorWhite);
  text_layer_set_background_color(text_header_layer, GColorClear);
  text_layer_set_font(text_header_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_header_layer));
 
  particle_layer = layer_create(window_bounds);
  layer_set_update_proc(particle_layer, update_particles_layer);
  layer_add_child(window_get_root_layer(window), particle_layer);

  app_timer_register(50, handle_animation_timer, NULL);
  app_timer_register(random_in_range(5000, 15000), handle_swarm_timer, NULL);

  tick_timer_service_subscribe(MINUTE_UNIT, handle_tick);
  accel_tap_service_subscribe(handle_tap);
}
Esempio n. 8
0
static void thread_scroll_timer_callback(void *data)
{
	if(thread_offset_reset)
	{
		thread_offset_reset = false;
		thread_offset = 0;
	}
	else
	{
		thread_offset += 4;
	}

	if(text_size.w - thread_offset < window_frame.size.w)
	{
		thread_offset_reset = true;
		init_timer(app_timer_register(1000, thread_scroll_timer_callback, NULL));
	}
	else
	{
		init_timer(app_timer_register(thread_offset == 0 ? 1000 : TITLE_SCROLL_SPEED, thread_scroll_timer_callback, NULL));
	}

	layer_mark_dirty(thread_title_layer);
}
Esempio n. 9
0
static void load_sequence() {
  if(s_sequence) {
    gbitmap_sequence_destroy(s_sequence);
    s_sequence = NULL;
  }
  if(s_bitmap) {
    gbitmap_destroy(s_bitmap);
    s_bitmap = NULL;
  }

  s_sequence = gbitmap_sequence_create_with_resource(RESOURCE_ID_ANIMATION);
  s_bitmap = gbitmap_create_blank(gbitmap_sequence_get_bitmap_size(s_sequence), GBitmapFormat8Bit);

  app_timer_register(1, timer_handler, NULL);
}
Esempio n. 10
0
static void timer_handler(void *context) {
  uint32_t next_delay;

  // Advance to the next APNG frame
  if(gbitmap_sequence_update_bitmap_next_frame(s_sequence, s_bitmap, &next_delay)) {
    bitmap_layer_set_bitmap(s_bitmap_layer, s_bitmap);
    layer_mark_dirty(bitmap_layer_get_layer(s_bitmap_layer));

    // Timer for that delay
    app_timer_register(next_delay, timer_handler, NULL);
  } else {
    // Start again
    gbitmap_sequence_restart(s_sequence);
  }
}
Esempio n. 11
0
void feature_timer_init(){
  window = window_create();
  window_stack_push(window, true /* Animated */);

  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  text_layer = text_layer_create(bounds);
  text_layer_set_text(text_layer, "Waiting for timer...");
  text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  text_layer_set_text_alignment(text_layer, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(text_layer));

  timer = app_timer_register(1500 /* milliseconds */, timer_callback, NULL);
  // A timer can be canceled with `app_timer_cancel()`
}
Esempio n. 12
0
void init_comm(void (*callback)(DictionaryIterator *received)) {
  data_callback = callback;
  app_message_register_inbox_received(in_received_handler);
  app_message_register_inbox_dropped(in_dropped_handler);
  app_message_register_outbox_failed(out_failed_handler);

  const uint32_t inbound_size = CONTENT_SIZE;
  const uint32_t outbound_size = 64;

  // We expect the JS to initiate sending data first.
  update_in_progress = true;
  timeout_timer = app_timer_register(timeout_length(), timeout_handler, NULL);

  app_message_open(inbound_size, outbound_size);
}
Esempio n. 13
0
static void app_timer_battery(void* data) {
    if(battTimer != NULL){
        if(app_timer_reschedule(battTimer, 5000)) {
            app_timer_cancel(battTimer);
        }
        battTimer = NULL;
    }

    char buffer[25];
    memset(buffer, 0, sizeof(buffer));
    snprintf(buffer, sizeof(buffer) - 1, "STRAP_API_BATTERY/%d", battery_state_service_peek().charge_percent);

    strap_log_action(buffer);
    
    battTimer = app_timer_register(curFreq * 5 * 60 * 1000, app_timer_battery,NULL);
}
Esempio n. 14
0
// AppTimer callback
static void prv_app_timer_callback(void *data) {
  // check if timer is complete
  timer_check_elapsed();
  // refresh
  drawing_update();
  layer_mark_dirty(main_data.layer);
  // schedule next call
  main_data.app_timer = NULL;
  if (main_data.control_mode == ControlModeCounting) {
    uint32_t duration = timer_get_value_ms() % MSEC_IN_SEC;
    if (timer_is_chrono()) {
      duration = MSEC_IN_SEC - duration;
    }
    main_data.app_timer = app_timer_register(duration + 5, prv_app_timer_callback, NULL);
  }
}
Esempio n. 15
0
static void user_death_select(ClickRecognizerRef recognizer, void *context) {
  user_level = DEFAULT_USER_LEVEL;
  user_experience = DEFAULT_USER_EXPERIENCE;
  user_experience_to_level_up = DEFAULT_MAX_EXPERIENCE;
  user_health = MAX_HEALTH;
  monster_health = MAX_HEALTH;
  int delay = rand() % user_level;
   if (delay == 0) {
    delay = delay + 1;
  }
  delay = delay * 3000;
  //app_timer_cancel(event_timer);
  //app_timer_reschedule(event_timer, delay);
  window_stack_pop(false);
  app_timer_register(delay, user_death_time_up, user_death_timer_data);
}
Esempio n. 16
0
void handle_bluetooth_update(bool connected)
{
	APP_LOG(APP_LOG_LEVEL_DEBUG, "%s %s", __FUNCTION__, (connected? "true": "false"));

	if (connected) {
		draw_bluetooth_warning(bluetooth_connection_service_peek());
	}
	else {
		// Don't show/buzz right away, wait for a few seconds.
		// I'm not being smart here and cancelling any in-flight
		// timers in the case we're flapping the connect/disconnect.
		app_timer_register(BLUETOOTH_TIMEOUT_MS,
				   bluetooth_timer_callback,
				   NULL);
	}
}
Esempio n. 17
0
static void app_focus_handler(bool focus) {
  if (!focus) {
    pauseFromFocus = true;
    paused = true;
    Layer *window_layer = window_get_root_layer(window);
    layer_add_child(window_layer, text_layer_get_layer(paused_label_layer));
  }
  else {
    if (pauseFromFocus) {
      paused = false;
      s_timer = app_timer_register(tick_time, game_tick, NULL);
      layer_remove_from_parent(text_layer_get_layer(paused_label_layer));
    }
    pauseFromFocus = false;
  }
}
Esempio n. 18
0
File: window.c Progetto: a2/pandozer
static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
  clock_copy_time_string(time_buffer, sizeof(time_buffer)/sizeof(*time_buffer));
  text_layer_set_text(s_text_time, time_buffer);
  
  layer_set_hidden((Layer *)s_bitmap_panda_eye, true);

  uint32_t timeout = 600;
  bool hidden = false;
  for (int i = 0; i < 5; i++) {
    AppTimerCallback callback = (hidden ? app_timer_callback_open_panda_eye : app_timer_callback_close_panda_eye);
    app_timer_register(timeout, callback, NULL);
    
    hidden = !hidden;
    timeout += 150;
  }
}
/**
* Helper function for try_resending_message
*/
static void jsReadyTimer_callback(void *data){
    LOG("Trying to send message, phone isn't ready yet!");

    //Wait until JS is ready
    if (jsReady) {
      MessageData* message_data = (MessageData *)(data);
      int type = message_data->type;
      char* message = message_data->message;
      free(message_data);
      message_helper_send_message(type,message);
    }
  else { //Wait 1/10 seconds
    jsReadyTimer = app_timer_register(100, jsReadyTimer_callback, data);
  }

}
Esempio n. 20
0
void start_notification_service() {
    
    char *stop_id = details_list[0];
    char *service_no = details_list[1];
    
    request_for_notification(stop_id, service_no);

    AppTimer *timer = notification_store_get(stop_id, service_no);

    if (!timer) {

        char *notification_callback_context = get_notification_message(stop_id, service_no);
        AppTimer *new_timer = app_timer_register(NOTIFICATION_POLL_INTERVAL, notification_list_callback, notification_callback_context);
        notification_store_add(stop_id, service_no, new_timer);
    }
}
static void main_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);

  s_instruction_text = text_layer_create(GRect(0, 0, 144, 73));
  layer_add_child(window_layer, text_layer_get_layer(s_instruction_text));
  text_layer_set_text(s_instruction_text, "[UP] increase speed\n[SEL] reset\n[DN] decrease speed");

  s_progress_bar = progress_bar_layer_create();
  layer_add_child(window_layer, s_progress_bar);

  s_done_text = text_layer_create(GRect(50, 74, 94, 20));
  layer_add_child(window_layer, text_layer_get_layer(s_done_text));

  // Start the progress timer
  s_progress_timer = app_timer_register(s_current_speed, progress_timer_callback, NULL);
}
Esempio n. 22
0
void topbar_toggle_bluetooth_icon(bool connected) {
  layer_set_hidden(bitmap_layer_get_layer(s_data.topbar_layer.bluetooth_layer), !connected);
  if (connected) {
    //vibes_short_pulse();
    if (disconnect_timer) {
      app_timer_cancel(disconnect_timer);
    }
  } else {
    if (s_data.debug) {
      vibes_short_pulse();
    } else {
      // schedule a timer to viber in X milliseconds
      disconnect_timer = app_timer_register(5000, disconnect_timer_callback, NULL);
    }
  }
}
Esempio n. 23
0
//for each tick of the timer, walk through the flag list of the animation class
//a false flag will show the original layers, while a true flag will show the blank layer
//do not do anything if the flag has not changed from the last iteration
//at the end of the flag list, stop the animation
//    if the animation is for the splash screen,
//        force a redraw of the the main screen since the minute tick may still be a while
static void handle_timer(void *data)
{
	if(animation.index >= (int) sizeof(animation.flags)) 
	{
		if(animation.current_flag == true) 
		{
			for (int i = 0; i < LAYER_COUNT; i++) 
			{
				layer_set_hidden(text_layer_get_layer(layers[i].layer), false);
			}
		}
		
		animation.is_animating = false;
		app_timer_cancel(timer);
		
		if(is_splash_showing == true) is_splash_showing = false;
		
		//blink animation has just ended
		//so draw the main watch face even if the minute did not tick yet
		//this is to clear the previous screen and show the time immediately
		now = get_time_value();
		
		for (int i = 0; i < LAYER_COUNT; i++) 
		{
			bool has_changed = check_text(&layers[i], false);
			if (has_changed == true) 
			{
				if (animation.is_animating == false) layer_update(&layers[i]);
			}
		}
		
		return;
	}
	
	if(animation.current_flag != animation.flags[animation.index])
	{
		animation.current_flag = animation.flags[animation.index];
		
		for (int i = 0; i < LAYER_COUNT; i++) 
		{
			layer_set_hidden(text_layer_get_layer(layers[i].layer), animation.current_flag);
		}
	}
	
	animation.index++;
	timer = app_timer_register(animation.duration, handle_timer, NULL);
}
Esempio n. 24
0
static void cb_in_received_handler(DictionaryIterator *iter, void *context) {
  autoconfig_in_received_handler(iter, context);

  Tuple *code_tuple = dict_find(iter, WEATHERCODE_KEY);
  if(code_tuple){
    int32_t weather_code = code_tuple->value->int32;
    APP_LOG(APP_LOG_LEVEL_DEBUG, "code:%ld", weather_code);
    
    if(weather_code != 3200){
        Tuple *temp_tuple = dict_find(iter, TEMPERATURE_KEY);
        if (temp_tuple) {
            int32_t temperature = temp_tuple->value->int32;
            // temperature = -99;
            snprintf(temp_text, sizeof(temp_text), "%ld°", temperature);
            layer_mark_dirty(text_layer_get_layer(text_temp_layer));
        }
        Tuple *city_tuple = dict_find(iter, CITYNAME_KEY);
        if (city_tuple) {
            snprintf(city_text, sizeof(city_text), "%s", city_tuple->value->cstring);
            layer_mark_dirty(text_layer_get_layer(text_city_layer));
        }
        // weather_code = 28;
        if(weather_code > 47){
          weather_code = 0;
        }
    }
    else {
      weather_code = 0;
    }
    if(weather_image){
      gbitmap_destroy(weather_image);
    }
    weather_image = gbitmap_create_with_resource(WEATHER_IMAGE_RESOURCE[weather_code]);
    bitmap_layer_set_bitmap(weather_layer,  weather_image);
  }

  if(dict_find(iter, INTERVAL_PKEY)){
    app_timer_cancel(weather_timer);
    weather_timer = app_timer_register(getInterval() * 1000 /* milliseconds */, timer_callback, NULL);
  }

  if(dict_find(iter, LANGUAGE_PKEY)){
    time_t now = time(NULL);
    struct tm *tick_time = localtime(&now);
    handle_minute_tick(tick_time, MINUTE_UNIT);
  }
}
Esempio n. 25
0
static void window_load(Window *window) {
    Layer *window_layer = window_get_root_layer(window);
    
    datetime_layer = text_layer_create(GRect(0, 100, 144, 22));
    text_layer_set_text_color(datetime_layer, GColorBlack);
    text_layer_set_background_color(datetime_layer, GColorWhite);
    text_layer_set_font(datetime_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
    text_layer_set_text_alignment(datetime_layer, GTextAlignmentCenter);
    layer_add_child(window_layer, text_layer_get_layer(datetime_layer));
    
    icon_layer = bitmap_layer_create(GRect(84, 0, 60, 60));
    layer_add_child(window_layer, bitmap_layer_get_layer(icon_layer));
    
    bg_layer = text_layer_create(GRect(0, 5, 83, 68));
    text_layer_set_text_color(bg_layer, GColorWhite);
    text_layer_set_background_color(bg_layer, GColorClear);
    text_layer_set_font(bg_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_MEDIUM_NUMBERS));
    text_layer_set_text_alignment(bg_layer, GTextAlignmentCenter);
    layer_add_child(window_layer, text_layer_get_layer(bg_layer));
    
    readtime_layer = text_layer_create(GRect(0, 48, 144, 115));
    text_layer_set_text_color(readtime_layer, GColorWhite);
    text_layer_set_background_color(readtime_layer, GColorClear);
    text_layer_set_font(readtime_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_LIGHT));
    text_layer_set_text_alignment(readtime_layer, GTextAlignmentCenter);
    layer_add_child(window_layer, text_layer_get_layer(readtime_layer));
    
    message_layer = text_layer_create(GRect(0, 124, 144, 68));
    text_layer_set_text_color(message_layer, GColorBlack);
    text_layer_set_background_color(message_layer, GColorWhite);
    text_layer_set_font(message_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
    text_layer_set_text_alignment(message_layer, GTextAlignmentCenter);
    layer_add_child(window_layer, text_layer_get_layer(message_layer));
    
    Tuplet initial_values[] = {
        TupletInteger(CGM_ICON_KEY, (uint8_t) 4),
        TupletCString(CGM_BG_KEY, ""),
        TupletCString(CGM_READTIME_KEY, ""),
        TupletInteger(CGM_ALERT_KEY, 0),
        TupletCString(CGM_TIME_NOW, "loading..."),
        TupletCString(CGM_DELTA_KEY, " ")
    };

    app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values, ARRAY_LENGTH(initial_values),sync_tuple_changed_callback, sync_error_callback, NULL);

    timer = app_timer_register(100, timer_callback, NULL);
}
Esempio n. 26
0
static void initialise_ui(void) {
  s_window = window_create();
#ifndef PBL_SDK_3
  window_set_fullscreen(s_window, true);
#endif
  
  s_res_bitham_42_bold = fonts_get_system_font(FONT_KEY_ROBOTO_BOLD_SUBSET_49);
  s_res_gothic_18_bold = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);

  // s_textlayer_title
  s_textlayer_title = text_layer_create(GRect(0, 0, 144, 20));
  text_layer_set_text(s_textlayer_title, s_Destination);
  text_layer_set_text_alignment(s_textlayer_title, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_title);
  
  // s_textlayer_subtitle
  s_textlayer_subtitle = text_layer_create(GRect(0, 20, 144, 20));
  text_layer_set_text(s_textlayer_subtitle, s_DayOfWeek);
  text_layer_set_text_alignment(s_textlayer_subtitle, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_subtitle);
  
  // s_textlayer_destination
  s_textlayer_destination = text_layer_create(GRect(0, 135, 144, 30));
  text_layer_set_text(s_textlayer_destination,s_Station);
  text_layer_set_text_alignment(s_textlayer_destination, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_destination);
  
  s_hilite = layer_create(GRect(34, 63, 100, 39));
  layer_set_update_proc(s_hilite, hilite_update);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_hilite);
  
  // s_textlayer_time
  s_textlayer_time = text_layer_create(GRect(34, 51, 100, 51));
  text_layer_set_text(s_textlayer_time, s_time);
  text_layer_set_background_color(s_textlayer_time, GColorClear);
  text_layer_set_text_alignment(s_textlayer_time, GTextAlignmentRight);
  text_layer_set_font(s_textlayer_time, s_res_bitham_42_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_time);
  
  // s_textlayer_desc
  s_textlayer_desc = text_layer_create(GRect(5, 112, 138, 27));
  text_layer_set_text(s_textlayer_desc, "Travel Time to");
  text_layer_set_text_alignment(s_textlayer_desc, GTextAlignmentCenter);
  text_layer_set_font(s_textlayer_desc, s_res_gothic_18_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_desc);
  s_AppTimer = app_timer_register(500, AppTimerProc, NULL);
}
Esempio n. 27
0
File: main.c Progetto: SeaPea/HomeP
// Callback for when device details have been fetched
void device_details_fetched(int device_id, char *location, char *name, DeviceType device_type) {
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Details fetched - ID: %d, Location: %s, Name: %s, DeviceType: %d", 
          device_id, location, name, device_type);
  reset_inactivity_timer();
  
  if (g_device_id_list[g_device_selected] == device_id) {
    show_device_details(location, name, device_type);
    s_device_type = device_type;
    s_device_status = DSUpdating;
    show_device_status(DSUpdating, "");
    // Fetch device status after a brief delay to avoid busy comms error
    if (status_fetch_delay_timer == NULL)
      status_fetch_delay_timer = app_timer_register(100, status_fetch_delayed, NULL);
    else
      app_timer_reschedule(status_fetch_delay_timer, 100);
  }
}
Esempio n. 28
0
// handles long mid hold release
void select_long_click_release_handler(ClickRecognizerRef recognizer, void *context) {
  
  // define short vibration pulse
  static const uint32_t segments[] = { 75 };
  VibePattern pat = {
    .durations = segments,
    .num_segments = ARRAY_LENGTH(segments),
  };
  vibes_enqueue_custom_pattern(pat);
  
  if (s_curr_state == 1) {
    // queue countdown for police calling
    call_timer = app_timer_register(s_timer_len, s_call_police, NULL);
    s_timer_curr = s_timer_len;
    s_curr_state ++;
  }
}
static void timer_schedule(void* context) {
    // Largest translation string
    static char buffer[sizeof("chargement") + 3];
    static uint8_t dots = 0;

    strcpy(buffer, _("loading"));
    size_t size = strlen(buffer);
    // Add dots at the end of the buffer.
    memset(&buffer[size], '.', dots);
    // Add space character to avoid undesirable string movement due to the string centered effect.
    memset(&buffer[size + dots], ' ', 3 - dots);
    dots = (dots + 1) % 4;

    statium_watchface_layer_set_text(application.layer, buffer);

    application.timer = app_timer_register(TIMER_LOAD_VALUE, timer_schedule, NULL);
}
Esempio n. 30
0
bool loadStopDetail(char *number) {
	show_log(APP_LOG_LEVEL_DEBUG, "loadStopDetail");

	DictionaryIterator *iter;

	if (is_message_in_progess()) {
		message_queue[message_queue_position].iterator = &iter;
		message_queue[message_queue_position].key =
				TUSSAM_KEY_FETCH_STOP_DETAIL;
		message_queue[message_queue_position].valueChar = number;
		update_message_queue_position(true);
		timer_load_in_progress = app_timer_register(WAIT_EMPTY_QUEUE,
				wait_message_queue, NULL);
		APP_LOG(APP_LOG_LEVEL_INFO, "Reshedule message: %dms",
				WAIT_EMPTY_QUEUE);
		return true;
	} else {
		message_in_progess = MESSAGE_KEY_fetchStopDetail;
		set_load_in_progress(MESSAGE_KEY_fetchStopDetail);
		AppMessageResult res = app_message_outbox_begin(&iter);
		bool result = true;

		if (res != APP_MSG_OK) {
			// Error establishing the connection
			APP_LOG(APP_LOG_LEVEL_ERROR, "Error establishing the connection: %d", (int )res);
			result = false;
		}
		if (dict_write_cstring(iter, MESSAGE_KEY_fetchStopDetail, number) != DICT_OK && result) {
			// Error writing data petition
			//return;
			result = false;
		}
		if (result) {
			res = app_message_outbox_send();
		}
		if (res != APP_MSG_OK) {
			APP_LOG(APP_LOG_LEVEL_ERROR, "Error sending the data: %d", (int )res);
			//return;
			result = false;
		} else {
			APP_LOG(APP_LOG_LEVEL_INFO, "Message succesful sent! (code:%lu)", (unsigned long) MESSAGE_KEY_fetchStopDetail);
			result = true;
		}
		return result;
	}
}