Ejemplo n.º 1
0
void conserve_power(bool conserve) {
    if (conserve == g_conserve)
        return;
    g_conserve = conserve;
    if (conserve) {
        tick_timer_service_unsubscribe();
        tick_timer_service_subscribe(MINUTE_UNIT, &handle_tick);
        layer_set_hidden(second_display_layer, true);
    } else {
        tick_timer_service_unsubscribe();
        tick_timer_service_subscribe(SECOND_UNIT, &handle_tick);
        layer_set_hidden(second_display_layer, false);
    }
}
Ejemplo n.º 2
0
static void pause() {
	tick_timer_service_unsubscribe();
	
	state.running = 0;
	
	text_layer_set_text(ui.top_text, "PAUSED");
}
Ejemplo n.º 3
0
/*
  dealloc
*/
void handle_deinit( void ) {
  // Unsubscribe from services
  tick_timer_service_unsubscribe();
  battery_state_service_unsubscribe();
  bluetooth_connection_service_unsubscribe();

  // Destroy image objects
  destroy_graphics( background_image, background_layer );
  destroy_graphics( battery_image, battery_layer );
  destroy_graphics( bluetooth_image, bluetooth_layer );
  destroy_graphics( icon_bitmap, icon_layer );

  // Destroy text objects
  text_layer_destroy( text_time_layer );
  text_layer_destroy( text_ampm_layer );
  text_layer_destroy( text_secs_layer );
  text_layer_destroy( text_days_layer );
  text_layer_destroy( text_date_layer );
  text_layer_destroy( text_week_layer );
  text_layer_destroy( temp_layer );

  // Destroy inverter layer
  inverter_layer_destroy( currentDayLayer );
  
  // Destroy font objects
  fonts_unload_custom_font( font_time );
  fonts_unload_custom_font( font_days );
  fonts_unload_custom_font( font_date );

  // Clean up AppSync system
  app_sync_deinit( &app );

  // Destroy window
  window_destroy( window );
}
Ejemplo n.º 4
0
void shake_handler(AccelAxisType axis, int32_t direction){
	switch(main_settings.shakeAction){
		case SHAKE_USE_CHANGE_SWEAR_WORD:
			app_timer_cancel(animate_word_timer);
			app_timer_cancel(update_word_timer);
			animate_word_timer = app_timer_register(50, fire_animation_callback, NULL);
			update_word_timer = app_timer_register(850, update_word_callback, NULL);
			break;
		case SHAKE_USE_LAUNCH_EXTRA_SCREEN:
			if(!extra_window_is_loaded()){
				extra_window_update_settings(main_settings);
				window_stack_push(extra_window_get_window(), true);
			}
			else{
				window_stack_pop(true);
			}
			break;
		case SHAKE_USE_SIMPLICITY:
			if(simplicity_is_loaded()){
				simplicity_pop();
				tick_timer_service_subscribe(SECOND_UNIT, tick_handler);
			}
			else{
				tick_timer_service_unsubscribe();
				simplicity_push();
			}
			break;
	}
}
Ejemplo n.º 5
0
void handle_deinit(void) {
  tick_timer_service_unsubscribe();

  persist_write_string(MESSAGE_KEY_DATE_FORMAT_KEY,       PersistDateFormat);
  persist_write_int(MESSAGE_KEY_BT_VIBRATE_KEY,           PersistBTLoss);
  persist_write_int(MESSAGE_KEY_LOW_BATTERY_KEY,          PersistLow_Batt);
  
  battery_state_service_unsubscribe();
  bluetooth_connection_service_unsubscribe();
  app_focus_service_unsubscribe();

  text_layer_destroy(text_time_layer);
  text_layer_destroy(text_date_layer);
  text_layer_destroy(text_dayname_layer);
  text_layer_destroy(text_battery_layer);

  layer_destroy(BatteryLineLayer);
  layer_destroy(BTLayer);

  gbitmap_destroy(image);
  bitmap_layer_destroy(image_layer);

  fonts_unload_custom_font(fontHelvNewLight20);
  fonts_unload_custom_font(fontRobotoBoldSubset40);
  fonts_unload_custom_font(fontRobotoBoldSubset45);


  window_destroy(window);
}
Ejemplo n.º 6
0
static void deinit() {
	window_destroy(window);
	text_layer_destroy(label_layer_time);
	
	tick_timer_service_unsubscribe();
	app_message_deregister_callbacks();
}
Ejemplo n.º 7
0
static void sync_tuple_changed_callback(const uint32_t key, const Tuple* new_tuple, const Tuple* old_tuple, void* context) {
  switch (key) {
    case BLINK_KEY:
      blink = new_tuple->value->uint8;
      tick_timer_service_unsubscribe();
      if(blink) {
        tick_timer_service_subscribe(SECOND_UNIT, handle_tick);
      }
      else {
        tick_timer_service_subscribe(MINUTE_UNIT, handle_tick);
      }
	  
      break;
     case INVERT_KEY:
      invert = new_tuple->value->uint8;
      change_background(invert);
      break;
    case BLUETOOTHVIBE_KEY:
      bluetoothvibe = new_tuple->value->uint8;
      break;      
    case HOURLYVIBE_KEY:
      hourlyvibe = new_tuple->value->uint8;
      break;
  }
}
Ejemplo n.º 8
0
void psUnload(Window *window) {

  // Stop keeping track of time/chrono elapsed.
  tick_timer_service_unsubscribe();

  // Stop timers if running.
  if (resetStartTimerHandle != NULL)
  {
    app_timer_cancel(resetStartTimerHandle);
    resetStartTimerHandle = NULL;
  }
  if (resetEndTimerHandle != NULL)
  {
    app_timer_cancel(resetEndTimerHandle);
    resetEndTimerHandle = NULL;
  }

  bitmap_layer_destroy(ssIconLayer);
  text_layer_destroy(psChronoLayer);
  text_layer_destroy(psSplitsLayer);
  window_destroy(psWindow);

  //psSavePersistentData();

  chronoCloseTm = time(NULL);
}
Ejemplo n.º 9
0
void disable_seconds() {
  layer_remove_from_parent(bitmap_layer_get_layer((BitmapLayer*) white_second_layer));
  layer_remove_from_parent(bitmap_layer_get_layer((BitmapLayer*) black_second_layer));
  
  tick_timer_service_unsubscribe();
  tick_timer_service_subscribe(MINUTE_UNIT, &handle_tick);
}
Ejemplo n.º 10
0
// Clean up
void tic_tock_toe_deinit(void) {
  window_destroy(window);
  layer_destroy(boardLayer);
  layer_destroy(playersLayer);
  text_layer_destroy(timeLayer);
  tick_timer_service_unsubscribe();
}
Ejemplo n.º 11
0
void download_complete_handler(NetDownload *download) {
  printf("Loaded image with %lu bytes", download->length);
  printf("Heap free is %u bytes", heap_bytes_free());

  #ifdef PBL_PLATFORM_APLITE
  GBitmap *bmp = gbitmap_create_with_png_data(download->data, download->length);
  #else
    GBitmap *bmp = gbitmap_create_from_png_data(download->data, download->length);
  #endif
  bitmap_layer_set_bitmap(bitmap_layer, bmp);

  // Save pointer to currently shown bitmap (to free it)
  if (current_bmp) {
    gbitmap_destroy(current_bmp);
  }
  current_bmp = bmp;

  // Free the memory now
  #ifdef PBL_PLATFORM_APLITE
  // gbitmap_create_with_png_data will free download->data
  #else
    free(download->data);
  #endif
  // We null it out now to avoid a double free
  download->data = NULL;
  netdownload_destroy(download);
  
  // Change tick handler to every minute now to save some battery
  tick_timer_service_unsubscribe();
  tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
  
  time_t temp = time(NULL);
  last_check = localtime(&temp);
}
Ejemplo n.º 12
0
static void main_window_unload(Window *window) {
  // Destroy TextLayer
    text_layer_destroy(s_time_layer);
    text_layer_destroy(s_bg_layer);
    text_layer_destroy(am_layer);
    text_layer_destroy(date_layer);
    text_layer_destroy(s_battery_layer);
    text_layer_destroy(hour_layer);
    text_layer_destroy(min_layer);
    text_layer_destroy(condition_layer);
    text_layer_destroy(temp_layer);
    text_layer_destroy(city_layer);
    text_layer_destroy(battery_text_layer);
    /*text_layer_destroy(s_temperature_layer);
    bitmap_layer_destroy(s_bitmap_layer);
    bitmap_layer_destroy(s_icon_layer);
    bitmap_layer_destroy(bt_layer);*/
    fonts_unload_custom_font(s_custom_font_24);
    fonts_unload_custom_font(s_custom_font_18);
    fonts_unload_custom_font(s_custom_font_12);
    //gbitmap_destroy(blank_bitmap);
    //gbitmap_destroy(bt_bitmap);
    gbitmap_destroy(no_phone_bitmap);
    bitmap_layer_destroy(no_phone_layer);
    bluetooth_connection_service_unsubscribe();
    battery_state_service_unsubscribe();
    tick_timer_service_unsubscribe();
}
Ejemplo n.º 13
0
void handle_deinit(void) {

  fonts_unload_custom_font(mTimeFont);

  //fonts_unload_custom_font(mDateFont);
	fonts_unload_custom_font(mTemperatureFont);

	//fonts_unload_custom_font(mHighLowFont);

  layer_remove_from_parent(bitmap_layer_get_layer(mWeatherIconLayer));
  bitmap_layer_destroy(mWeatherIconLayer);
  gbitmap_destroy(mWeatherIcon);

  layer_remove_from_parent(bitmap_layer_get_layer(battery_image_layer));
  bitmap_layer_destroy(battery_image_layer);
  gbitmap_destroy(battery_image);
  battery_image = NULL;
  
  tick_timer_service_unsubscribe();
  bluetooth_connection_service_unsubscribe();
  battery_state_service_unsubscribe();
 
  text_layer_destroy(mHighLowLayer);
  text_layer_destroy(mTimeSeparatorLayer);
  text_layer_destroy(mTemperatureLayer);
  text_layer_destroy(mDateLayer);
  text_layer_destroy(mTimeMinutesLayer);
  text_layer_destroy(mTimeHourLayer);
  layer_destroy(mTimeLayer);
  layer_destroy(mBackgroundLayer);
  remove_invert_top();
  remove_invert_bottom();  
  
  window_destroy(mWindow);
}
Ejemplo n.º 14
0
void handle_deinit(void) {
	tick_timer_service_unsubscribe();
	accel_tap_service_unsubscribe();
  text_layer_destroy(time_layer);
	text_layer_destroy(date_layer);
  window_destroy(my_window);
}
Ejemplo n.º 15
0
void handle_deinit(void)
{
	tick_timer_service_unsubscribe();

	for (int i = 0; i < NUMBER_OF_IMAGES; i++)
	{
		gbitmap_destroy(images[i]);
	}

	bitmap_layer_destroy(dlayers[topbar_layer]);
	bitmap_layer_destroy(dlayers[month_tens_layer]);
	bitmap_layer_destroy(dlayers[month_ones_layer]);
	bitmap_layer_destroy(dlayers[month_seperator_layer]);
	bitmap_layer_destroy(dlayers[day_tens_layer]);
	bitmap_layer_destroy(dlayers[day_ones_layer]);
	bitmap_layer_destroy(dlayers[day_text_layer]);
	bitmap_layer_destroy(dlayers[secs_tens_layer]);
	bitmap_layer_destroy(dlayers[secs_ones_layer]);
	bitmap_layer_destroy(dlayers[ampm_layer]);
	bitmap_layer_destroy(dlayers[hours_tens_layer]);
	bitmap_layer_destroy(dlayers[hours_ones_layer]);
	bitmap_layer_destroy(dlayers[time_seperator_layer]);
	bitmap_layer_destroy(dlayers[mins_tens_layer]);
	bitmap_layer_destroy(dlayers[mins_ones_layer]);

	window_destroy(window);
}
Ejemplo n.º 16
0
void remove_callback_handler(void *data) {
    Menu *temp = data;
    menu = temp;
    tick_timer_service_unsubscribe();

    appmessage_clear_nearby_station();
}
Ejemplo n.º 17
0
void handle_battery(BatteryChargeState charge_state) {
#if DEBUG
  //strftime(debug_buffer, DEBUG_BUFFER_BYTES, "%d.%m.%Y %H:%M:%S", now);
  snprintf(debug_buffer, DEBUG_BUFFER_BYTES, "%s%d%%",  charge_state.is_charging ? "+" : "", charge_state.charge_percent);
  text_layer_set_text(debug_layer, debug_buffer);
#endif
#if SCREENSHOT
  bitmap_layer_set_bitmap(battery_layer, battery_images[1]);
  bool showSeconds = seconds_mode != SECONDS_MODE_NEVER;
  bool showBattery = battery_mode != BATTERY_MODE_NEVER;
  bool showDate = date_mode != DATE_MODE_NEVER;
#else
  bitmap_layer_set_bitmap(battery_layer, battery_images[
    (charge_state.is_charging ? 11 : 0) + min(charge_state.charge_percent / 9, 10)]); // 90% is max
  bool battery_is_low = charge_state.charge_percent <= 10;
  bool showSeconds = seconds_mode == SECONDS_MODE_ALWAYS
    || (seconds_mode == SECONDS_MODE_IFNOTLOW && (!battery_is_low || charge_state.is_charging));
  bool showBattery = battery_mode == BATTERY_MODE_ALWAYS
    || (battery_mode == BATTERY_MODE_IF_LOW && battery_is_low)
    || charge_state.is_charging;
  bool showDate = date_mode != DATE_MODE_NEVER;
#endif
  if (hide_seconds != !showSeconds) {
    hide_seconds = !showSeconds;
    tick_timer_service_unsubscribe();
    tick_timer_service_subscribe(hide_seconds ? MINUTE_UNIT : SECOND_UNIT, &handle_tick);
  }
  layer_set_hidden(bitmap_layer_get_layer(battery_layer), !showBattery);
  if (layer_get_hidden(date_layer) != !showDate) {
    layer_set_hidden(date_layer, !showDate);
    layer_set_frame(background_layer, GRect(0, showDate ? 0 : 12, 144, 144));
  }
}
Ejemplo n.º 18
0
static void do_deinit(void) {
  tick_timer_service_unsubscribe();
  text_layer_destroy(s_data.text_date_layer);
  text_layer_destroy(s_data.text_time_layer);
  layer_destroy(s_data.line_layer);
  window_destroy(s_data.window);
}
Ejemplo n.º 19
0
void handle_deinit() {
  app_message_deregister_callbacks();
  battery_state_service_unsubscribe();
  tick_timer_service_unsubscribe();
  if (has_config) {
    persist_write_int(SECONDS_MODE, seconds_mode);
    persist_write_int(BATTERY_MODE, battery_mode);
    persist_write_int(DATE_MODE, date_mode);
    persist_write_int(BLUETOOTH_MODE, bluetooth_mode);
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Wrote config");
  } else {
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Did not write config");
  }
  fonts_unload_custom_font(font);
  gpath_destroy(sec_path);
  gpath_destroy(min_path);
  gpath_destroy(hour_path);
  inverter_layer_destroy(inverter_layer);
#if DEBUG
  text_layer_destroy(debug_layer);
#endif
  layer_destroy(hands_layer);
  bitmap_layer_destroy(logo_layer);
  gbitmap_destroy(logo);
  bitmap_layer_destroy(battery_layer);
  for (int i = 0; i < 22; i++)
    gbitmap_destroy(battery_images[i]);
  bitmap_layer_destroy(bluetooth_layer);
  for (int i = 0; i < 2; i++)
    gbitmap_destroy(bluetooth_images[i]);
  layer_destroy(background_layer);
  layer_destroy(date_layer);
  window_destroy(window);
}
Ejemplo n.º 20
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
}
Ejemplo n.º 21
0
static void reset() {
	tick_timer_service_unsubscribe();
	
	state.running = 0;
	state.round = 0;

	if (!stretch_settings.program) {
		layer_set_hidden(text_layer_get_layer(ui.middle_text), true);

		Layer *image_layer = text_layer_get_layer(ui.time_text);
		GRect image_frame = layer_get_frame(image_layer);
		image_frame.origin.x = (ui.bounds.size.w / 2) - 40;
		image_frame.origin.y = (ui.bounds.size.h / 2) - 25;
		layer_set_frame(image_layer, image_frame);
	}

	if (stretch_settings.prepare == 0) {
		state.round_time = stretch_settings.time;
		state.stretch = 1;
	} else {
		state.round_time = stretch_settings.prepare;
		state.stretch = 0;
	}

	update_ui();
}
Ejemplo n.º 22
0
static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
  static char s_uptime_buffer[32];
  vibes_short_pulse();
  alert_time--;
  if(alert_time <= 0 ){
    //TODO: write notification code
    tick_timer_service_unsubscribe();
    vibes_cancel();
    text_layer_set_text(s_alert_text_layer, "Timout Reached\n:(");
    
    // Prepare dictionary
    DictionaryIterator *iterator;
    app_message_outbox_begin(&iterator);
    
    // Write data
    char buff[100];
    if(persist_exists(PERSIST_KEY_PHONE_NUMBER)){
      persist_read_string(PERSIST_KEY_PHONE_NUMBER, buff, 100);
      dict_write_cstring(iterator, PERSIST_KEY_PHONE_NUMBER, buff);
    }
    if(persist_exists(PERSIST_KEY_NAME)){
      persist_read_string(PERSIST_KEY_NAME, buff, 100);
      dict_write_cstring(iterator, PERSIST_KEY_NAME, buff);
    }
    // Send the data!
    app_message_outbox_send();
    
  } else {
    snprintf(s_uptime_buffer, sizeof(s_uptime_buffer), BANNER_TEXT "\n" CLOCK_FORMAT_STRING, 
             alert_time/60, alert_time%60);
    text_layer_set_text(s_alert_text_layer, s_uptime_buffer);
  }
}
Ejemplo n.º 23
0
void handle_deinit(void) {
  tick_timer_service_unsubscribe();
  layer_destroy(bitmap_layer_get_layer(background_image_layer));
  layer_destroy(display_layer);
  window_destroy(window);

}
Ejemplo n.º 24
0
void handle_layout() {
  BatteryChargeState charge_state = battery_state_service_peek();
  bool battery_is_low = charge_state.charge_percent <= 20;
  bool showSeconds = seconds_mode == SECONDS_MODE_ALWAYS
    || (seconds_mode == SECONDS_MODE_IFNOTLOW && (!battery_is_low || charge_state.is_plugged));
  bool showBattery = battery_mode == BATTERY_MODE_ALWAYS
    || (battery_mode == BATTERY_MODE_IF_LOW && battery_is_low)
    || charge_state.is_plugged;
  int face_top = PBL_IF_ROUND_ELSE(0, date_pos == DATE_POS_BOTTOM ? 0 : date_pos == DATE_POS_OFF ? 12 : 24);
  int date_top = date_pos == DATE_POS_TOP ? 0 : EXTENT;
  int battery_top = date_pos == DATE_POS_TOP ? 168-10-3 : 3;
  if (hide_seconds != !showSeconds) {
    hide_seconds = !showSeconds;
    tick_timer_service_unsubscribe();
    tick_timer_service_subscribe(hide_seconds ? MINUTE_UNIT : SECOND_UNIT, &handle_tick);
  }
  layer_set_hidden(date_layer, date_pos == DATE_POS_OFF);
  layer_set_hidden(battery_layer, !showBattery);
  layer_set_frame(background_layer, GRect(0, face_top, EXTENT, EXTENT));
  layer_set_frame(date_layer, GRect(0, date_top, EXTENT, 24));
  layer_set_frame(battery_layer, GRect(EXTENT-22-3, battery_top, 22, 10));
  FG_COLOR = graphics_mode == GRAPHICS_MODE_INVERT ? GColorBlack : GColorWhite;
  BG_COLOR = graphics_mode == GRAPHICS_MODE_INVERT ? GColorWhite : GColorBlack;
  window_set_background_color(window, BG_COLOR);
}
Ejemplo n.º 25
0
static void sync_tuple_changed_callback(const uint32_t key, const Tuple* new_tuple, const Tuple* old_tuple, void* context) {
  switch (key) {
    case BLINK_KEY:
      blink = new_tuple->value->uint8;
      tick_timer_service_unsubscribe();
      if(blink) {
        tick_timer_service_subscribe(SECOND_UNIT, handle_tick);
      }
      else {
        tick_timer_service_subscribe(MINUTE_UNIT, handle_tick);
      }
	  
      break;

    case BLUETOOTHVIBE_KEY:
      bluetoothvibe = new_tuple->value->uint8;
      break;      
    case HOURLYVIBE_KEY:
      hourlyvibe = new_tuple->value->uint8;
      break;
    case SHOW_24H_ICON_KEY: //n3v3r
      switch_show_24h_icon = new_tuple->value->uint8;
      break;
    case SHOW_BATT_PERCENT_KEY: //n3v3r
      switch_show_batt_percent = new_tuple->value->uint8;
      break;
  }
}
Ejemplo n.º 26
0
void handle_deinit()
{
    tick_timer_service_unsubscribe();

    animation_unschedule_all();

    property_animation_destroy(mario_animation_beg);
    property_animation_destroy(mario_animation_end);
    property_animation_destroy(block_animation_beg);
    property_animation_destroy(block_animation_end);
    property_animation_destroy(hour_animation_slide_in);
    property_animation_destroy(hour_animation_slide_away);
    property_animation_destroy(minute_animation_slide_in);
    property_animation_destroy(minute_animation_slide_away);

    gbitmap_destroy(mario_normal_bmp);
    gbitmap_destroy(mario_jump_bmp);
    gbitmap_destroy(ground_bmp);

    text_layer_destroy(date_layer);
    text_layer_destroy(text_minute_layer);
    text_layer_destroy(text_hour_layer);

    layer_destroy(ground_layer);
    layer_destroy(mario_layer);
    layer_destroy(blocks_layer);

    window_destroy(window);
}
Ejemplo n.º 27
0
static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
	
	APP_LOG(APP_LOG_LEVEL_INFO, "inbox");
	
	//seconds
	Tuple *t = dict_find(iterator, 0);
	seconds = (int)t->value->int32 == 1;
		
	tick_timer_service_unsubscribe();	
	tick_timer_service_subscribe(seconds?SECOND_UNIT:MINUTE_UNIT, (TickHandler) tick);
	
	//weekday
	t = dict_find(iterator, 1);
	weekday = (int)t->value->int32 == 1;
	
	//date
	t = dict_find(iterator, 2);
	date = (int)t->value->int32 == 1;
	
	//month
	t = dict_find(iterator, 3);
	month = (int)t->value->int32 == 1;
	
	//redraw
	layer_mark_dirty(layer);
		
}
Ejemplo n.º 28
0
static void handle_deinit() {
  app_message_deregister_callbacks();
  battery_state_service_unsubscribe();
  tick_timer_service_unsubscribe();
  fonts_unload_custom_font(font);
  fonts_unload_custom_font(font2);
  gpath_destroy(min_path);
  gpath_destroy(hour_path);
  gpath_destroy(hour_in_path);
  text_layer_destroy(battp_layer);
  text_layer_destroy(date_layer);
  text_layer_destroy(day_layer);
  text_layer_destroy(time_layer);
  layer_destroy(hands_layer);
  bitmap_layer_destroy(logo_layer);
  gbitmap_destroy(logo);
  bitmap_layer_destroy(battery_layer);
  for (int i = 0; i < 22; i++)
    gbitmap_destroy(battery_images[i]);
  bitmap_layer_destroy(bluetooth_layer);
  for (int i = 0; i < 2; i++)
    gbitmap_destroy(bluetooth_images[i]);
  layer_destroy(background_layer);
  window_destroy(window);
}
Ejemplo n.º 29
0
void deinit()
{

	tick_timer_service_unsubscribe();
	
	window_destroy(window);
}
Ejemplo n.º 30
0
static void s_sync_tuple_changed_callback(const uint32_t key, const Tuple* new_tuple, const Tuple* old_tuple, void* context) {
  //APP_LOG(APP_LOG_LEVEL_DEBUG, "sync_tuple_changed_callback, key: %lu", key);
  //APP_LOG(APP_LOG_LEVEL_DEBUG, "sync_tuple_changed_callback, new_tuple->value->cstring: %s", new_tuple->value->cstring);
  
  switch (key) {
    case DialColor_KEY:  
      strcpy(configs.dialcolor, new_tuple->value->cstring);
    
      load_background_image();
    
      break;
    case SecondHandOption_KEY:
      strcpy(configs.secondhandoption, new_tuple->value->cstring);
 
      if (strcmp(configs.secondhandoption, "quartz") == 0) {
        tick_timer_service_unsubscribe();
        tick_timer_service_subscribe(SECOND_UNIT, handle_tick);
      }
      else if (strcmp(configs.secondhandoption, "stop2go") == 0) {
        tick_timer_service_unsubscribe();
        tick_timer_service_subscribe(SECOND_UNIT, handle_tick);
      }
      else if (strcmp(configs.secondhandoption, "off") == 0) {
        tick_timer_service_unsubscribe();
        tick_timer_service_subscribe(MINUTE_UNIT, handle_tick);
      }
    
      break;
    case DateOption_KEY:
      strcpy(configs.dateoption, new_tuple->value->cstring);
    
      break;
    case HourlyVibration_KEY:
      strcpy(configs.hourlyvibration, new_tuple->value->cstring);
    
      break;
    case BluetoothStatusDetection_KEY:
      configs.bluetoothstatusdetection = new_tuple->value->uint8;
    
      break;
  }
  

  time_t now = time(NULL);
  struct tm *t = localtime(&now);
  handle_tick(t, HOUR_UNIT + MINUTE_UNIT + SECOND_UNIT);
}