Example #1
0
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
  
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Inbox called!");
  // Color Scheme?
  Tuple *color_red_t = dict_find(iter, KEY_COLOR_RED);
  Tuple *color_green_t = dict_find(iter, KEY_COLOR_GREEN);
  Tuple *color_blue_t = dict_find(iter, KEY_COLOR_BLUE);
  if(color_red_t && color_green_t && color_blue_t) {
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Got new Background RGB values!");
  // Apply the color, if available
  #if defined(PBL_BW)
    window_set_background_color(s_main_window, GColorWhite);
  #elif defined(PBL_COLOR)
    int red = color_red_t->value->int32;
    int green = color_green_t->value->int32;
    int blue = color_blue_t->value->int32;
  
    // Persist values
    persist_write_int(KEY_COLOR_RED, red);
    persist_write_int(KEY_COLOR_GREEN, green);
    persist_write_int(KEY_COLOR_BLUE, blue);
  
    GColor bg_color = GColorFromRGB(red, green, blue);
    window_set_background_color(s_main_window, bg_color);
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Set new background color!");
  #endif
  }  
}
Example #2
0
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
  APP_LOG(APP_LOG_LEVEL_INFO, "Tuple read");
  Tuple *invert_face_t = dict_find(iter, KEY_INVERT_FACE);
  Tuple *bluetooth_vibration_t = dict_find(iter, KEY_BLUETOOTH_VIBRATION);
  Tuple *show_date_t = dict_find(iter, KEY_SHOW_DATE);
  
  if(invert_face_t){
    invert_face = invert_face_t->value->int8;
    persist_write_int(KEY_INVERT_FACE, invert_face);
    APP_LOG(APP_LOG_LEVEL_INFO, "Recevied invert info");
  }
  
  if(bluetooth_vibration_t){
    bluetooth_vibration = bluetooth_vibration_t->value->int8;
    persist_write_int(KEY_BLUETOOTH_VIBRATION, bluetooth_vibration);
    APP_LOG(APP_LOG_LEVEL_INFO, "Recevied bluetooth info");
  }
  
  if(show_date_t){
    show_date = show_date_t->value->int8;
    persist_write_int(KEY_SHOW_DATE, show_date);
    APP_LOG(APP_LOG_LEVEL_INFO, "Recevied date info");
  }

  update_layers();
}
void readConfig() {
	if (persist_exists(CONFIG_KEY_DATEORDER)) {
		USDate = persist_read_int(CONFIG_KEY_DATEORDER);
	} else {
		USDate = 1;
		persist_write_int(CONFIG_KEY_DATEORDER, USDate);
	}
	
	if (persist_exists(CONFIG_KEY_WEEKDAY)) {
		showWeekday = persist_read_int(CONFIG_KEY_WEEKDAY);
	} else {
		showWeekday = 0;
		persist_write_int(CONFIG_KEY_WEEKDAY, showWeekday);
	}
	
	if (persist_exists(CONFIG_KEY_LANG)) {
		curLang = persist_read_int(CONFIG_KEY_LANG);
	} else {
		curLang = LANG_ENGLISH;
		persist_write_int(CONFIG_KEY_LANG, curLang);
	}
	
	if (persist_exists(CONFIG_KEY_STRIPES)) {
		stripedDigits = persist_read_int(CONFIG_KEY_STRIPES);
	} else {
		stripedDigits = 1;
		persist_write_int(CONFIG_KEY_STRIPES, stripedDigits);
	}
	
	APP_LOG(APP_LOG_LEVEL_DEBUG, "Stored config (dateorder=%d, weekday=%d, lang=%d, stripedDigits=%d)",
			USDate, showWeekday, curLang, stripedDigits);
}
Example #4
0
void save_charge_log(ChargeLog* charge_log)
{
  int32_t log_count = 0;
  int32_t log_index = 0;
  
  if (persist_exists(PERSIST_KEY_LOG_COUNT)) {
    log_count = persist_read_int(PERSIST_KEY_LOG_COUNT);
  }
      
  if (persist_exists(PERSIST_KEY_LOG_INDEX)) {
    log_index = persist_read_int(PERSIST_KEY_LOG_INDEX);
  }
  
  log_count++;
  
  uint32_t key_log = PERSIST_KEY_LOG_BASE + (log_index + log_count - 1) % MAX_LOG_COUNT;
  
  if (log_count > MAX_LOG_COUNT) {
    log_count--;
    log_index++;
  }
  
  persist_write_int(PERSIST_KEY_LOG_COUNT, log_count);
  persist_write_int(PERSIST_KEY_LOG_INDEX, log_index);
  persist_write_data(key_log, charge_log, sizeof(*charge_log));
  
  if (launch_reason() != APP_LAUNCH_WAKEUP) {
    layer_mark_dirty(s_graph_layer);
  }
}
Example #5
0
static void write_blk_buf_to_persist(){
  /* the persist_read_int(I_BLK_PERSIST_KEY) is NOT a count, it is the current index
  * but 1-indexced, so 1 is the first block and zero is the empty state */

  if(persist_read_int(I_BLK_PERSIST_KEY) < N_BLK_PERSIST){
    // set the index of the current block
    persist_write_int(I_BLK_PERSIST_KEY,persist_read_int(I_BLK_PERSIST_KEY)+1);
    persist_write_data(persist_read_int(I_BLK_PERSIST_KEY),
                       blk_buf,((SIZE_SUMM*N_SUMM_BLK)+SIZE_BLK_HEAD));
  }

  if(bluetooth_connection_service_peek()){
    persist_write_int(WORKER_START_FORE_APP_REASON_PERSIST_KEY,
      WFAWR_PUSH_ALL_DATA_TO_SERVER);
      summ_since_trans_server = 0; // once try to go to server, reset
      worker_launch_app();
  } else if(persist_read_int(I_BLK_PERSIST_KEY) >= (N_BLK_PERSIST-1) ){
    // if the I_BLK_PERSIST_KEY is greater than 90% of storage, then prompt
    // that need to connect the phone
    persist_write_int(WORKER_START_FORE_APP_REASON_PERSIST_KEY,
      WFAWR_MEMORY_LOW_REMINDER);
    worker_launch_app();
  }
  // else if(){
  //   // reset the counter for consecutive summaries
  //   persist_write_int(WORKER_START_FORE_APP_REASON_PERSIST_KEY,
  //     WFAWR_WEAR_REMINDER);
  //   worker_launch_app();
  // }

}
Example #6
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);
}
Example #7
0
static void init(void) {
	if(!persist_exists(CONFIG_WORK)){
		persist_write_int(CONFIG_WORK,25);
		persist_write_int(CONFIG_REST,5);
	}
	show_mainwindow();
}
Example #8
0
static void in_received_handler(DictionaryIterator *received, void *context) {
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Received config");
  Tuple *tuple = dict_find(received, MSG_START_TIME);
  if (tuple) {
    start_time = tuple->value->int32;
    persist_write_int(MSG_START_TIME, start_time);
  }
  tuple = dict_find(received, MSG_END_TIME);
  if (tuple) {
    end_time = tuple->value->int32;
    persist_write_int(MSG_END_TIME, end_time);
  }
  tuple = dict_find(received, MSG_TEXT_OTSLUJIL);
  if (tuple) {
    strcpy(text_otslujul, tuple->value->cstring);
    persist_write_string(MSG_TEXT_OTSLUJIL, text_otslujul);
  }
  tuple = dict_find(received, MSG_TEXT_OSTALOS);
  if (tuple) {
    strcpy(text_ostalos, tuple->value->cstring);
    persist_write_string(MSG_TEXT_OSTALOS, text_ostalos);
  }
  tuple = dict_find(received, MSG_TEXT_UJE);
  if (tuple) {
    strcpy(text_uje, tuple->value->cstring);
    persist_write_string(MSG_TEXT_UJE, text_uje);
  }
  time_t now = time(NULL);
  handle_tick(localtime(&now), 0);
}
Example #9
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);
}
Example #10
0
static void sync_changed_handler(const uint32_t key,
                                 const Tuple *new_tuple,
                                 const Tuple *old_tuple,
                                 void *context) {
    bool dirty = false;
    APP_LOG(APP_LOG_LEVEL_DEBUG, "sync_changed: key %" PRIu32, key);
    switch (key) {
        case BACKGROUND_COLOR_KEY:
            if (pcb_background.argb != new_tuple->value->uint8) {
                pcb_background.argb = new_tuple->value->uint8;
                persist_write_int(BACKGROUND_COLOR_KEY, pcb_background.argb);
                dirty = true;
            }
            break;

        case SILKSCREEN_COLOR_KEY:
            if (pcb_silkscreen.argb != new_tuple->value->uint8) {
                pcb_silkscreen.argb = new_tuple->value->uint8;
                persist_write_int(SILKSCREEN_COLOR_KEY, pcb_silkscreen.argb);
                dirty = true;
            }
            break;

        default:
            // ignore unknown keys
            break;
    }
    if (dirty && s_canvas_layer) {
        layer_mark_dirty(s_canvas_layer);
    }
}
Example #11
0
static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
  APP_LOG(APP_LOG_LEVEL_INFO, "Message received!");
  Tuple *t = dict_read_first(iterator);

  // Process all pairs present
  while(t != NULL) {
    // Process this pair's key
    switch (t->key) {
      case KEY_PHONE:
        persist_write_string(PERSIST_KEY_PHONE_NUMBER, t->value->cstring);
        break;
      case KEY_NAME:
        persist_write_string(PERSIST_KEY_NAME, t->value->cstring);
        break;
      case KEY_TIMER:
        persist_write_int(PERSIST_KEY_INTERVAL_TIME, t->value->int32);
        break;
      case KEY_VIBRATE:
        persist_write_int(PERSIST_KEY_BUZZ_TIME, t->value->int32);
        break;
    }

    // Get next pair, if any
    t = dict_read_next(iterator);
  }
}
Example #12
0
static void in_recv_handler(DictionaryIterator *iterator, void *context)
{
  //Get Tuple
  Tuple *t = dict_read_first(iterator);
  while (t)
  {
    switch(t->key) {
    case KEY_INVERT:
      //It's the KEY_INVERT key
      inverted = (strcmp(t->value->cstring, "si") == 0);
      layer_set_hidden((Layer *)ILFondo, inverted);
 	  persist_write_bool(KEY_INVERT, inverted);
      break;
	  
	case KEY_IDIOMA:
      //It's the KEY_INVERT key
      if(strcmp(t->value->cstring, "1")==0)
      {
        //Set and save as inverted
		idioma=1;  
        persist_write_int(KEY_IDIOMA, 1);
      }
      else if(strcmp(t->value->cstring, "0")==0)
      {
        //Set and save as not inverted
		idioma = 0;
        persist_write_int(KEY_IDIOMA, 0);
      }
      break;
    }
	t = dict_read_next(iterator);
  }
}
Example #13
0
static void save_persistent_data() {
    uint32_t today = get_today();
    persist_write_int(DATE_SAVE, today);
    persist_write_int(CANCELED_COUNT, rounds_canceled);
    persist_write_int(COMPLETED_COUNT, rounds_done);
    
}
Example #14
0
void storage_store(){
	APP_LOG(APP_LOG_LEVEL_INFO,"storage_store()");
	APP_LOG(APP_LOG_LEVEL_INFO,"max_cell_size: %d timer_size: %d laps_size: %d clock_size: %d",PERSIST_DATA_MAX_LENGTH,sizeof(Timer),sizeof(Laps),sizeof(Clock));
	
	int result;
	uint8_t c=timers_count();
	
	result=persist_write_int(STORAGE_KEY_VERSION,STORAGE_VERSION);
	if(result<0){
		APP_LOG(APP_LOG_LEVEL_ERROR,"write error count %d in storage %d #%d",c,STORAGE_KEY_COUNT,result);  
		return;
	}
	
	result=persist_write_int(STORAGE_KEY_COUNT,c);
	if(result<0){
		APP_LOG(APP_LOG_LEVEL_ERROR,"write error count %d in storage %d #%d",count_total(count),STORAGE_KEY_COUNT,result); 
		return;
	}
	APP_LOG(APP_LOG_LEVEL_INFO,"timer count %d",count_total(count));
	
	Timer* timer;
	for(uint8_t i=0;i<c;i++){
		timer=timers_get(i);
		result=persist_write_data(STORAGE_KEY_DATA+i,timer,sizeof(Timer));
		if(result<0){
			APP_LOG(APP_LOG_LEVEL_ERROR,"write error timer %d in storage %d #%d",i,STORAGE_KEY_DATA+i,result); 
			continue;
		}
		APP_LOG(APP_LOG_LEVEL_INFO,"stored timer %d",i);
	}
	APP_LOG(APP_LOG_LEVEL_INFO,"stored");
}
Example #15
0
void data_deinit() {
  // Store current values
  for(int i = 0; i < DataNumBoolKeys; i++) {
    persist_write_bool(i, s_bool_settings[i]);
  }
  persist_write_int(DataKeyForegroundColor, s_foreground.argb);
  persist_write_int(DataKeyBackgroundColor, s_background.argb);
}
Example #16
0
// Write back values.
void storage_persist(void) {
    LOG_FUNC();

    persist_write_string(SELECTED_VERSION, storage.selectedVersion);
    persist_write_data(BATTERY_ESTIMATE, (void*)&(storage.battery_estimate), sizeof(battery_estimate_data));
    persist_write_int(LAST_FULL_TIMESTAMP, storage.last_full_timestamp);
    persist_write_int(BATTERY_DISPLAY, storage.battery_display);

    app_log_storage_log(LOG_STORAGE);
}
Example #17
0
//-----------------------------------------------------------------------------------------------------------------------
void in_received_handler(DictionaryIterator *received, void *ctx)
{
	app_log(APP_LOG_LEVEL_DEBUG, __FILE__, __LINE__, "enter in_received_handler");
    
	Tuple *akt_tuple = dict_read_first(received);
    while (akt_tuple)
    {
        app_log(APP_LOG_LEVEL_DEBUG,
                __FILE__,
                __LINE__,
                "KEY %d=%s", (int16_t)akt_tuple->key,
                akt_tuple->value->cstring);

		if (akt_tuple->key == CONFIG_KEY_THEME)
			persist_write_int(CONFIG_KEY_THEME, 
				strcmp(akt_tuple->value->cstring, "circle") == 0 ? 0 : 1);
	
		if (akt_tuple->key == CONFIG_KEY_FSM)
			persist_write_bool(CONFIG_KEY_FSM, strcmp(akt_tuple->value->cstring, "yes") == 0);
		
		if (akt_tuple->key == CONFIG_KEY_INV)
			persist_write_bool(CONFIG_KEY_INV, strcmp(akt_tuple->value->cstring, "yes") == 0);
		
		if (akt_tuple->key == CONFIG_KEY_ANIM)
			persist_write_bool(CONFIG_KEY_ANIM, strcmp(akt_tuple->value->cstring, "yes") == 0);
		
		if (akt_tuple->key == CONFIG_KEY_SEP)
			persist_write_bool(CONFIG_KEY_SEP, strcmp(akt_tuple->value->cstring, "yes") == 0);
		
		if (akt_tuple->key == CONFIG_KEY_DATEFMT)
			persist_write_int(CONFIG_KEY_DATEFMT, 
				strcmp(akt_tuple->value->cstring, "fra") == 0 ? 1 : 
				strcmp(akt_tuple->value->cstring, "eng") == 0 ? 2 : 
				strcmp(akt_tuple->value->cstring, "usa") == 0 ? 3 : 
				strcmp(akt_tuple->value->cstring, "iso") == 0 ? 4 :  
				strcmp(akt_tuple->value->cstring, "gers") == 0 ? 5 : 
				strcmp(akt_tuple->value->cstring, "fras") == 0 ? 6 : 
				strcmp(akt_tuple->value->cstring, "engs") == 0 ? 7 : 
				strcmp(akt_tuple->value->cstring, "usas") == 0 ? 8 : 
				strcmp(akt_tuple->value->cstring, "isos") == 0 ? 9 : 
				strcmp(akt_tuple->value->cstring, "cus1") == 0 ? 10 : 
				strcmp(akt_tuple->value->cstring, "cus2") == 0 ? 11 : 0);
		
		if (akt_tuple->key == CONFIG_KEY_SMART)
			persist_write_bool(CONFIG_KEY_SMART, strcmp(akt_tuple->value->cstring, "yes") == 0);
		
		if (akt_tuple->key == CONFIG_KEY_VIBR)
			persist_write_bool(CONFIG_KEY_VIBR, strcmp(akt_tuple->value->cstring, "yes") == 0);
		
		akt_tuple = dict_read_next(received);
	}
	
    update_configuration();
}
Example #18
0
void select_long_click_handler(ClickRecognizerRef recognizer, void *context)
{
  persist_write_int(FAV5_PKEY, persist_read_int(FAV4_PKEY));
  persist_write_int(FAV4_PKEY, persist_read_int(FAV3_PKEY));
  persist_write_int(FAV3_PKEY, persist_read_int(FAV2_PKEY));
  persist_write_int(FAV2_PKEY, persist_read_int(FAV1_PKEY));
  persist_write_int(FAV1_PKEY, (numero1*100) + (numero2*10) + (numero3));

  text_layer_set_text(mensaje_layer, "Parada agregada a favoritos.");

}
Example #19
0
static void history_save() {
  persist_write_int(MESSAGE_KEY_batches, current_history_batch);
  persist_write_int(MESSAGE_KEY_avgMood, average_mood);
  // APP_LOG(APP_LOG_LEVEL_DEBUG, "Writing %d history batches to persistent storage", current_history_batch+1);
  for (int i=0; i<=current_history_batch; i++) {
    // int result = persist_write_data(FIRST_HISTORY_BATCH+i, &history[i], sizeof(history[i]));
    // APP_LOG(APP_LOG_LEVEL_DEBUG, "Persisted history batch %d, %d bytes, result %d", i, (int) sizeof(history[i]), result);
    persist_write_data(FIRST_HISTORY_BATCH+i, &history[i], sizeof(history[i]));
  }
  selected = (Selected) {current_history_batch, history[current_history_batch].last_event};
}
Example #20
0
static void inbox_received_callback(DictionaryIterator *iterator, void *context)
{
    Tuple* t = dict_read_first(iterator);
    while (t != NULL)
    {
        switch(t->key)
        {
        case KEY_INVERT:
            if (strcmp(t->value->cstring, "off") == 0)
            {
                mInvertColors = false;
            }
            if (strcmp(t->value->cstring, "on") == 0)
            {
                mInvertColors = true;
            }
            persist_write_bool(KEY_INVERT, mInvertColors);
            break;

        case KEY_STAR_SPEED:
            if (strcmp(t->value->cstring, "slow") == 0)
            {
                mStarSpeed = STAR_SPEED_SLOW;
            }
            else if (strcmp(t->value->cstring, "medium") == 0)
            {
                mStarSpeed = STAR_SPEED_MEDIUM;
            }
            else if (strcmp(t->value->cstring, "fast") == 0)
            {
                mStarSpeed = STAR_SPEED_FAST;
            }
            
            persist_write_int(KEY_STAR_SPEED, mStarSpeed);
        break;

        case KEY_FRAMERATE:
            if (strcmp(t->value->cstring, "power") == 0)
            {
                mFramerate = FRAMERATE_POWER;
            }
            else if (strcmp(t->value->cstring, "smooth") == 0)
            {
                mFramerate = FRAMERATE_SMOOTH;
            }
            
            persist_write_int(KEY_FRAMERATE, mFramerate);
        break;
        }
        
        t = dict_read_next(iterator);
    }
}
Example #21
0
void app_message_received(DictionaryIterator *iter, void *context) {
	// Tuple *jeep_model_t = dict_find(iter, KEY_JEEP_MODEL);

	Tuple *display_type_t = dict_find(iter, MESSAGE_KEY_type);
	if(display_type_t) {
		// display_type = display_type_t->value->int32;
		switch(display_type_t->value->cstring[0]) {
			case 'b':
				display_type = 0;
				break;
			case 'd':
				display_type = 1;
				break;
			// case 'm':
			default:
				display_type = 2;
				break;
		}
				
		persist_write_int(MESSAGE_KEY_type, display_type);
	}

	Tuple *show_seconds_t = dict_find(iter, MESSAGE_KEY_seconds);
	if(show_seconds_t) {
		APP_LOG(APP_LOG_LEVEL_DEBUG, "Seconds setting received as: %d", show_seconds_t->value->int32);
		show_seconds = show_seconds_t->value->int32 == 1;
		persist_write_bool(MESSAGE_KEY_seconds,show_seconds);
	}

	Tuple *jeep_color_t = dict_find(iter, MESSAGE_KEY_jeepColor);
	if(jeep_color_t) {
		int jeep_color_i = jeep_color_t->value->int32;
		persist_write_int(MESSAGE_KEY_jeepColor, jeep_color_i);
		jeep_color = GColorFromHEX(jeep_color_i);
	}

	Tuple *time_color_t = dict_find(iter, MESSAGE_KEY_timeColor);
	if(time_color_t) {
		int time_color_i = time_color_t->value->int32;
		persist_write_int(MESSAGE_KEY_timeColor, time_color_i);
		time_color = GColorFromHEX(time_color_i);
	}

	Tuple *background_color_t = dict_find(iter, MESSAGE_KEY_bgColor);
	if(background_color_t) {
		int background_color_i = background_color_t->value->int32;
		persist_write_int(MESSAGE_KEY_bgColor, background_color_i);
		background_color = GColorFromHEX(background_color_i);
	    window_set_background_color(main_window,background_color);
	}
	watchface_load(main_window);
}
Example #22
0
static void start_pomodoro_rest() {
  persist_write_int(PERSIST_POMODORO_MODE, MODE_CONCENTRATION);
  vibes_double_pulse();
  
  time_t wakeup_time = time(NULL) + REST_TIME;
  s_wakeup_id = wakeup_schedule(wakeup_time, WAKEUP_REASON_REST_END, true);
  if (s_wakeup_id <= 0) {
    APP_LOG(APP_LOG_LEVEL_ERROR, "FAILED to scheduling");
  }
  persist_write_int(PERSIST_WAKEUP, s_wakeup_id);
  
  text_layer_set_text_color(s_left_time_label, REST_COLOR);
}
Example #23
0
void Settings_saveToStorage() {
  // ensure that the weather disabled setting is accurate before saving it
  Settings_updateDynamicSettings();

  // save settings to persistent storage
  persist_write_data(SETTING_TIME_COLOR_KEY,            &globalSettings.timeColor,        sizeof(GColor));
  persist_write_data(SETTING_TIME_BG_COLOR_KEY,         &globalSettings.timeBgColor,      sizeof(GColor));
  persist_write_data(SETTING_SIDEBAR_COLOR_KEY,         &globalSettings.sidebarColor,     sizeof(GColor));
  persist_write_data(SETTING_SIDEBAR_TEXT_COLOR_KEY,    &globalSettings.sidebarTextColor, sizeof(GColor));
  persist_write_bool(SETTING_USE_METRIC_KEY,            globalSettings.useMetric);
  persist_write_bool(SETTING_SIDEBAR_LEFT_KEY,          globalSettings.sidebarOnLeft);
  persist_write_bool(SETTING_BT_VIBE_KEY,               globalSettings.btVibe);
  persist_write_int( SETTING_LANGUAGE_ID_KEY,           globalSettings.languageId);
  persist_write_int( SETTING_LEADING_ZERO_KEY,          globalSettings.showLeadingZero);
  persist_write_bool(SETTING_SHOW_BATTERY_PCT_KEY,      globalSettings.showBatteryPct);
  persist_write_bool(SETTING_DISABLE_WEATHER_KEY,       globalSettings.disableWeather);
  persist_write_bool(SETTING_CLOCK_FONT_ID_KEY,         globalSettings.clockFontId);
  persist_write_int( SETTING_HOURLY_VIBE_KEY,           globalSettings.hourlyVibe);
  persist_write_bool(SETTING_BATTERY_ONLY_WHEN_LOW_KEY, globalSettings.onlyShowBatteryWhenLow);
  persist_write_bool(SETTING_USE_LARGE_FONTS_KEY,       globalSettings.useLargeFonts);
  persist_write_int(SETTING_SIDEBAR_WIDGET0_KEY,        globalSettings.widgets[0]);
  persist_write_int(SETTING_SIDEBAR_WIDGET1_KEY,        globalSettings.widgets[1]);
  persist_write_int(SETTING_SIDEBAR_WIDGET2_KEY,        globalSettings.widgets[2]);
  persist_write_string(SETTING_ALTCLOCK_NAME_KEY,       globalSettings.altclockName);
  persist_write_int(SETTING_ALTCLOCK_OFFSET_KEY,        globalSettings.altclockOffset);

  persist_write_int(SETTINGS_VERSION_KEY,               CURRENT_SETTINGS_VERSION);
}
Example #24
0
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
  	Tuple *start_time_t = dict_find(iter, START_TIME_IN);
  	Tuple *end_time_t = dict_find(iter, END_TIME_IN);
	//dict_find(received, KEY_A)->value->uint32

	//APP_LOG(APP_LOG_LEVEL_DEBUG, "input_Start after message received = %d", input_Start);
	input_Start = start_time_t->value->int32;
	//APP_LOG(APP_LOG_LEVEL_DEBUG, "input_Start after storage = %d", input_Start);
    input_End = end_time_t->value->int32;
	
	persist_write_int(START_TIME_IN, input_Start);
	persist_write_int(END_TIME_IN, input_End);
	
}
Example #25
0
bool SavePersistedData(void)
{
	CharacterData *characterData;

	if(!IsPersistedDataCurrent())
	{
		WARNING_LOG("Persisted data does not match current version, clearing.");
		ClearPersistedData();
	}
	
	if(sizeof(CharacterData) > PERSIST_DATA_MAX_LENGTH )
	{
		ERROR_LOG("CharacterData is too big to save (%d).", sizeof(CharacterData));
		return false;
	}

	INFO_LOG("Saving persisted data.");
	persist_write_bool(PERSISTED_IS_DATA_SAVED, true);
	persist_write_int(PERSISTED_CURRENT_DATA_VERSION, CURRENT_DATA_VERSION);
	persist_write_int(PERSISTED_MAX_KEY_USED, MAX_PERSISTED_KEY);
	
	characterData = GetCharacter();
	persist_write_data(PERSISTED_CHARACTER_DATA, characterData, sizeof(CharacterData));
	
	persist_write_int(PERSISTED_CURRENT_FLOOR, GetCurrentFloor());
	
	uint8_t * itemsOwned = malloc(sizeof(uint8_t) * ITEM_TYPE_COUNT);
	GetItemsOwned(itemsOwned);
	persist_write_data(PERSISTED_ITEM_DATA, itemsOwned, sizeof(itemsOwned));
	free(itemsOwned);
	
	persist_write_int(PERSISTED_STAT_POINTS_PURCHASED, GetStatPointsPurchased());

	persist_write_bool(PERSISTED_VIBRATION, GetVibration());
	persist_write_bool(PERSISTED_FAST_MODE, GetFastMode());
	persist_write_bool(PERSISTED_EASY_MODE, GetEasyMode());

	persist_write_bool(PERSISTED_IN_COMBAT, ClosingWhileInBattle());
	
	persist_write_data(PERSISTED_MONSTER_TYPE, GetCurMonster(), sizeof(MonsterInfo));
	
	CardSave saves[NB_TYPE_CARDS];
	GetCardSaves(saves);
	persist_write_data(PERSISTED_CARD_DECK, saves, sizeof(saves));
	
	persist_write_int(PERSISTED_ENTRIES_SIZE, GetEntriesSize());
	
	return true;
}
Example #26
0
void main_save_data() {
  data_loaded_from_watch = true;
  persist_write_int(STORAGE_KEY_VERSION, CURRENT_STORAGE_VERSION);
  data_timestamp=time(NULL);
  persist_write_int(STORAGE_KEY_TIMESTAMP, data_timestamp);
  if (timer.Active) {
    persist_write_data(STORAGE_KEY_TIMER, &timer, sizeof(Timer));
  } else {
    persist_delete(STORAGE_KEY_TIMER);
  }
  persist_write_data(STORAGE_KEY_SETTINGS, &settings, sizeof(Settings));
  jobs_list_save(STORAGE_KEY_FIRST_JOB); 
  send_settings_to_phone();
  settings_menu_hide();
}
Example #27
0
static void weight_select_click_handler(ClickRecognizerRef recognize, void *context) {
  ftoa(weight_buff, m_weight_d, 3);
  text_layer_set_text(s_text_layer2, weight_buff);
  persist_write_int(((exercise_int + 3)+(unit_system*7)), m_weight_d*10);
  init_sets_window();
  window_stack_push(s_sets_window, false);
}
Example #28
0
void handle_deinit(void) {
	//Deletes the bitmaps
	gbitmap_destroy(def);
	gbitmap_destroy(staged);
	gbitmap_destroy(bulb1);
	gbitmap_destroy(bulb2);
	gbitmap_destroy(bulb3);
	gbitmap_destroy(green);
	
	//Deletes the bitmap layers
	bitmap_layer_destroy(def_layer);
	bitmap_layer_destroy(staged_layer);
	bitmap_layer_destroy(bulb1_layer);
	bitmap_layer_destroy(bulb2_layer);
	bitmap_layer_destroy(bulb3_layer);
	bitmap_layer_destroy(green_layer);

	//Deletes the window
	window_destroy(my_window);
	
	//Deletes the text boxes
	text_layer_destroy(text);
	
	//Writes the current value to the persistent storage value so the app remembers it
	persist_write_int(ROLLOUT_KEY, rollout);
}
Example #29
0
void timers_save(void) {
  if (timers_count() == 0) {
    persist_delete(PERSIST_TIMER_START);
    return;
  }
  TimerBlock* block = NULL;
  uint8_t block_count = 0;
  for (uint8_t b = 0; b < timers_count(); b += 1) {
    if (NULL == block) {
      block = malloc(sizeof(TimerBlock));
      block->total_timers = timers_count();
      block->save_time = time(NULL);
    }

    uint8_t timer_block_pos = b % TIMER_BLOCK_SIZE;
    block->timers[timer_block_pos] = *timers_get(b);

    bool is_last_timer_in_block = timer_block_pos == (TIMER_BLOCK_SIZE - 1);
    if (is_last_timer_in_block) {
      persist_write_data(PERSIST_TIMER_START + block_count, block, sizeof(TimerBlock));
      block_count += 1;
      free(block);
      block = NULL;
    }
  }
  if (block) {
    persist_write_data(PERSIST_TIMER_START + block_count, block, sizeof(TimerBlock));
  }
  persist_write_int(PERSIST_TIMERS_VERSION, TIMERS_VERSION_CURRENT);
}
Example #30
0
void Settings_saveToStorage() {
  // ensure that the weather disabled setting is accurate before saving it
  Settings_updateDynamicSettings();

  // save settings to compressed structure and to persistent storage
  StoredSettings storedSettings;
  // if previous version settings are used than only first part of settings would be overwrited
  // all the other fields will left filled with zeroes
  storedSettings.timeColor = globalSettings.timeColor;
  storedSettings.timeBgColor = globalSettings.timeBgColor;
  storedSettings.sidebarColor = globalSettings.sidebarColor;
  storedSettings.sidebarTextColor = globalSettings.sidebarTextColor;
  storedSettings.languageId = globalSettings.languageId;
  storedSettings.showLeadingZero = globalSettings.showLeadingZero;
  storedSettings.clockFontId = globalSettings.clockFontId;
  storedSettings.btVibe = globalSettings.btVibe;
  storedSettings.hourlyVibe = globalSettings.hourlyVibe;
  storedSettings.widgets[0] = globalSettings.widgets[0];
  storedSettings.widgets[1] = globalSettings.widgets[1];
  storedSettings.widgets[2] = globalSettings.widgets[2];
  storedSettings.sidebarOnLeft = globalSettings.sidebarOnLeft;
  storedSettings.useLargeFonts = globalSettings.useLargeFonts;
  storedSettings.useMetric = globalSettings.useMetric;
  storedSettings.showBatteryPct = globalSettings.showBatteryPct;
  storedSettings.disableAutobattery = globalSettings.disableAutobattery;
  storedSettings.healthUseDistance = globalSettings.healthUseDistance;
  storedSettings.healthUseRestfulSleep = globalSettings.healthUseRestfulSleep;
  storedSettings.decimalSeparator = globalSettings.decimalSeparator;
  memcpy(storedSettings.altclockName, globalSettings.altclockName, 8);
  storedSettings.altclockOffset = globalSettings.altclockOffset;
  storedSettings.activateDisconnectIcon = globalSettings.activateDisconnectIcon;

  persist_write_data(SETTING_VERSION6_AND_HIGHER, &storedSettings, sizeof(StoredSettings));
  persist_write_int(SETTINGS_VERSION_KEY, CURRENT_SETTINGS_VERSION);
}