• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ persist_read_int函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中persist_read_int函数的典型用法代码示例。如果您正苦于以下问题:C++ persist_read_int函数的具体用法?C++ persist_read_int怎么用?C++ persist_read_int使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了persist_read_int函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: window_load

static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  s_text_layer = text_layer_create(GRect(0, 55, bounds.size.w, 100));
  text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_LECO_38_BOLD_NUMBERS));
  text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter);
  text_layer_set_background_color(s_text_layer, GColorClear);

  if (persist_read_int(KEY_BACKGROUND_COLOR)) {
    int background_color = persist_read_int(KEY_BACKGROUND_COLOR);
    set_background_and_text_color(background_color);
  }

  if (persist_read_bool(KEY_TWENTY_FOUR_HOUR_FORMAT)) {
    twenty_four_hour_format = persist_read_bool(KEY_TWENTY_FOUR_HOUR_FORMAT);
  }

  layer_add_child(window_layer, text_layer_get_layer(s_text_layer));

  update_time();
}
开发者ID:GarrettGraham,项目名称:slate-watchface-template,代码行数:22,代码来源:main.c


示例2: game_start

static void game_start() {
	srand(time(NULL));
	
	game_wins = 0;
	if (game_is_first && persist_exists(0)) {
		game_wins = persist_read_int(0);
	}
	game_is_first = false;
	round_start();
	
	game_timer = app_timer_register(WAIT_RESTING, game_update, NULL);
	layer_mark_dirty(game_layer);
}
开发者ID:SteffanDonal,项目名称:pebble-a-micro-western,代码行数:13,代码来源:main.c


示例3: init_settings

void init_settings() {
    int font_id = 0;
    if(persist_exists(KEY_STORAGE_OK) && persist_read_int(KEY_STORAGE_OK) == KEY_STORAGE_OK) {
        APP_LOG(APP_LOG_LEVEL_DEBUG, "Reading from storage");
        storage_ok = true; //else storage empty or corrupt
        font_id = persist_read_int(KEY_FONT);
    } else {
        APP_LOG(APP_LOG_LEVEL_DEBUG, "No stored settings");
    }
    settings = (Settings) {
        .bg = persist_read_colour(KEY_BG, DEF_BG),
        .fg = persist_read_colour(KEY_FG, DEF_FG),
        //Settings
        .disco_vibrate = persist_read_bool_def(KEY_DISCO_VIBRATE, true),
        .disco_desaturate = persist_read_bool_def(KEY_DESATURATE, true),
        .show_weather = persist_read_bool_def(KEY_WEATHER, true),
        .show_date = persist_read_bool_def(KEY_DATE, true),
        .fahrenheit = persist_read_bool_def(KEY_TEMP_UNITS_F, false),
        //Fonts
        .font_main_big = fonts_load_custom_font(resource_get_handle(custom_fonts[font_id])),
        .font_big_y_offset = font_offset(font_id),
        .font_date = fonts_get_system_font(persist_read_bool_def(KEY_SIZE_DATE, false) ?
                                           FONT_KEY_GOTHIC_14 : FONT_KEY_GOTHIC_24_BOLD),
        .font_temp = fonts_get_system_font(persist_read_bool_def(KEY_SIZE_WEATHER, false) ?
                                           FONT_KEY_GOTHIC_24_BOLD : FONT_KEY_GOTHIC_14),
        .num_colours = persist_read_int_def(KEY_N_COLOURS, DEF_N_COLOURS, 3, 5)
    };
    //Ribbon Colours
    settings.colours[0] = persist_read_colour(KEY_C1, DEF_C1);
    settings.colours[1] = persist_read_colour(KEY_C2, DEF_C2);
    settings.colours[2] = persist_read_colour(KEY_C3, DEF_C3);
    settings.colours[3] = persist_read_colour(KEY_C4, DEF_C4);
    settings.colours[4] = persist_read_colour(KEY_C5, DEF_C5);
}

void destroy_settings() {
    fonts_unload_custom_font(settings.font_main_big);
}
开发者ID:bcaller,项目名称:pebble-superspinnywatch,代码行数:38,代码来源:settings.c


示例4: stats_print_status

void stats_print_status()
{
  APP_LOG(APP_LOG_LEVEL_DEBUG, "HAPPINESS:%d", (int)persist_read_int(HAPPINESS_LEVEL_KEY));
  APP_LOG(APP_LOG_LEVEL_DEBUG, "HUNGER:%d", (int)persist_read_int(HUNGER_LEVEL_KEY));
  APP_LOG(APP_LOG_LEVEL_DEBUG, "ENERGY:%d", (int)persist_read_int(ENERGY_LEVEL_KEY));
  APP_LOG(APP_LOG_LEVEL_DEBUG, "ACTIVE:%d", (int)persist_read_int(ACTIVE_LEVEL_KEY));
  APP_LOG(APP_LOG_LEVEL_DEBUG, "HYGIENE:%d", (int)persist_read_int(HYGIENE_LEVEL_KEY));
  APP_LOG(APP_LOG_LEVEL_DEBUG, "SICK:%s", persist_read_bool(SICK_STATUS_KEY) ? "true" : "false");
  APP_LOG(APP_LOG_LEVEL_DEBUG, "SLEEP:%s", persist_read_bool(SLEEP_STATUS_KEY) ? "true" : "false");
  APP_LOG(APP_LOG_LEVEL_DEBUG, "TOTAL STATS:%d", (int)persist_read_int(TOTAL_STATS_KEY));
  APP_LOG(APP_LOG_LEVEL_DEBUG, "TOTAL TICS:%d", (int)persist_read_int(TOTAL_TICS_KEY));
}
开发者ID:JefreyHildebrandt,项目名称:burabuchi,代码行数:12,代码来源:Stats.c


示例5: get_event_no_from_row_index

static int get_event_no_from_row_index(int index) {
    int i = 0;
    int past_events = 0;
    time_t now = time(0);
    while ((i - past_events) <= index && persist_exists(i*PERSIST_EVENT_FIELDCOUNT + PERSIST_EVENT_TITLE)) {
        if (persist_exists(i*PERSIST_EVENT_FIELDCOUNT + PERSIST_EVENT_END_DATE)) {
            int end_date = persist_read_int(i * PERSIST_EVENT_FIELDCOUNT + PERSIST_EVENT_END_DATE);
            if (end_date < now)
                past_events++;
        }
        i++;
    }
    return i - 1;
}
开发者ID:andrei-markeev,项目名称:pebble-outlook-events,代码行数:14,代码来源:ui_eventsmenu.c


示例6: on_window_load

// pebble event handlers
static void on_window_load(Window *window) {
  init_stroke_datas(window);
  action_bar_init(window);

  b_stroke_selected = false;
  i_current_stroke = persist_read_int(CURRENT_STROKE);

  if(b_stroke_selected) {
    init_stroke_layers();
    change_stroke(i_current_stroke);
  } else {
    init_intro_layers();
  }
}
开发者ID:cameronwilby,项目名称:swim-counter,代码行数:15,代码来源:swimcount.c


示例7: get_events_count_callback

static uint16_t get_events_count_callback(struct MenuLayer *menu_layer, uint16_t section_index, void *callback_context) {
    int i = 0;
    int past_events = 0;
    time_t now = time(0);
    while (persist_exists(i*PERSIST_EVENT_FIELDCOUNT + PERSIST_EVENT_TITLE)) {
        if (persist_exists(i*PERSIST_EVENT_FIELDCOUNT + PERSIST_EVENT_END_DATE)) {
            int end_date = persist_read_int(i * PERSIST_EVENT_FIELDCOUNT + PERSIST_EVENT_END_DATE);
            if (end_date < now)
                past_events++;
        }
        i++;
    }
    return i - past_events;
}
开发者ID:andrei-markeev,项目名称:pebble-outlook-events,代码行数:14,代码来源:ui_eventsmenu.c


示例8: DoNotDisturb

bool DoNotDisturb(int Hour, int Minutes, int DNDStart_KEY, int DNDEnd_KEY){
	//Define the variables
	bool blnNextDay = 0;

	//Read the Hourly Vibe Quiet Hours setup
	int intDNDStart = persist_read_int(DNDStart_KEY);
	int intDNDEnd = persist_read_int(DNDEnd_KEY);
	
	//Determine if the DND End is the next day
	if(intDNDStart>intDNDEnd){blnNextDay = 1;}
	
	if (blnNextDay){
	//if the DND End is next day, DND period is when the Current Hour is greater than Start Hour
		if ((Hour>=intDNDStart)||(Hour<intDNDEnd)){return true; } //DND period
		else {return false;} //Not DND period
	}
	else{
	//if the DND End is the same day, DND period is when the Current Hour is between Start and End Hours
		if ((Hour>=intDNDStart)&&(Hour<intDNDEnd)){return true;} //DND period
		else {return false;} //Not DND period
	}
	
}
开发者ID:dabdemon,项目名称:Yahoo--Weather,代码行数:23,代码来源:functions.c


示例9: main_window_load

static void main_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect window_bounds = layer_get_bounds(window_layer);

  // status layer
  status_layer = text_layer_create(GRect(0, window_bounds.size.h / 2 - (42 / 2) - 28 - 5, window_bounds.size.w, 42));
  text_layer_set_font(status_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  text_layer_set_background_color(status_layer, GColorClear);
  text_layer_set_text_alignment(status_layer, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(status_layer));
  
  // output layer
  output_layer = text_layer_create(GRect(0, window_bounds.size.h / 2 - (42 / 2) - 5, window_bounds.size.w, 42));
  text_layer_set_font(output_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
  text_layer_set_background_color(output_layer, GColorClear);
  text_layer_set_text_color(output_layer, GColorWhite);
  text_layer_set_text_alignment(output_layer, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(output_layer));
  
  // bpm layer
  bpm_layer = text_layer_create(GRect(0, window_bounds.size.h / 2 + (42 / 2) - 5, window_bounds.size.w, 42));
  text_layer_set_font(bpm_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  text_layer_set_background_color(bpm_layer, GColorClear);
  text_layer_set_text_color(bpm_layer, GColorWhite);
  text_layer_set_text_alignment(bpm_layer, GTextAlignmentCenter);
  text_layer_set_text(bpm_layer, "BPM");
  layer_add_child(window_layer, text_layer_get_layer(bpm_layer));

  // read stuff
  vibe_duration = (persist_exists(KEY_VIBE_DURATION) ? persist_read_int(KEY_VIBE_DURATION) : INITIAL_VIBE_DURATION);
  set_vibe(vibe_duration);
  set_tempo(persist_exists(KEY_TEMPO) ? persist_read_int(KEY_TEMPO) : INITIAL_TEMPO);
  
  color = get_color();
  set_state(true);
  metronome_loop();
}
开发者ID:Evan-Goode,项目名称:pebble-metronome,代码行数:37,代码来源:metronome.c


示例10: storage_load

void storage_load(){
	APP_LOG(APP_LOG_LEVEL_INFO,"storage_load()");
	
	if(!persist_exists(STORAGE_KEY_VERSION)){ 
		APP_LOG(APP_LOG_LEVEL_WARNING,"no version"); 
		return;
	}
	if(persist_read_int(STORAGE_KEY_VERSION)!=STORAGE_VERSION){
		APP_LOG(APP_LOG_LEVEL_WARNING,"wrong version");
		return;
	}
	if(!persist_exists(STORAGE_KEY_COUNT)){ 
		APP_LOG(APP_LOG_LEVEL_ERROR,"no count"); 
		return;
	}
	uint8_t storage_count=(uint8_t)persist_read_int(STORAGE_KEY_COUNT);
 	APP_LOG(APP_LOG_LEVEL_INFO,"storage count: %d",storage_count);
	Timer* timer;
	int result;
	for(uint8_t i=0;i<storage_count;i++){
		if(!persist_exists(STORAGE_KEY_DATA+i)){ 
			APP_LOG(APP_LOG_LEVEL_ERROR,"missing timer %d in storage %d",i,STORAGE_KEY_DATA+i); 
			continue;
		}
		timer=timer_create();
		result=persist_read_data(STORAGE_KEY_DATA+i,timer,sizeof(Timer));
		if(result<0){
			APP_LOG(APP_LOG_LEVEL_ERROR,"read error timer %d in storage %d",i,STORAGE_KEY_DATA+i);
			timer_destroy(timer);
			continue;
		}
		timers_add(timer);
		APP_LOG(APP_LOG_LEVEL_INFO,"loaded timer %d",i);
	}
		
	APP_LOG(APP_LOG_LEVEL_INFO,"loaded");
}
开发者ID:Stopka,项目名称:StopWatch,代码行数:37,代码来源:timers.c


示例11: ClearPersistedData

void ClearPersistedData(void)
{
	ProfileLogStart("ClearPersistedData");
	if(persist_exists(PERSISTED_IS_DATA_SAVED))
	{
		DEBUG_LOG("Clearing persisted data.");
		int maxKey = persist_read_int(PERSISTED_MAX_KEY_USED);
		int i;
		for(i = 0; i <= maxKey; ++i)
		{
			persist_delete(i);
		}
	}
	ProfileLogStop("ClearPersistedData");
}
开发者ID:BlackLamb,项目名称:MiniDungeon,代码行数:15,代码来源:Persistence.c


示例12: storage_init

// Makes sure storage is populated (by checking and, on absence, writing
// defaults) and then reading values.
void storage_init(void) {
    LOG_FUNC();

    // THIS MUST NEVER BE ENABLED */for (unsigned int i = 0; i <= MAXIMUM_EVER_USED; i++) {
    // THIS MUST NEVER BE ENABLED */    if ((i % 10000) == 0) {
    // THIS MUST NEVER BE ENABLED */        LOG_EXT(LOG_STORAGE, "storage_init(): working key %d", i);
    // THIS MUST NEVER BE ENABLED */    }
    // THIS MUST NEVER BE ENABLED */    if (persist_exists(i)) {
    // THIS MUST NEVER BE ENABLED */        LOG_EXT(LOG_STORAGE, "storage_init(): deleting key %d", i);
    // THIS MUST NEVER BE ENABLED */        persist_delete(i);
    // THIS MUST NEVER BE ENABLED */    }
    // THIS MUST NEVER BE ENABLED */}

    if (!persist_exists(SELECTED_VERSION)) {
        persist_write_string(SELECTED_VERSION, "Regular");
        LOG_EXT(LOG_STORAGE, "storage_init(): init %d with data %s", SELECTED_VERSION, "Regular");
    }
    persist_read_string(SELECTED_VERSION, storage.selectedVersion, 64);
    if (!persist_exists(BATTERY_ESTIMATE)) {
        persist_write_data(BATTERY_ESTIMATE, (void*)&battery_estimate_data_init, sizeof(battery_estimate_data));
        LOG_EXT(LOG_STORAGE, "storage_init(): init %d", BATTERY_ESTIMATE);
    }
    persist_read_data(BATTERY_ESTIMATE, (void*)&(storage.battery_estimate), sizeof(battery_estimate_data));
    if (!persist_exists(LAST_FULL_TIMESTAMP)) {
        persist_write_int(LAST_FULL_TIMESTAMP, (time_t)-1);
        LOG_EXT(LOG_STORAGE, "storage_init(): init %d with data %ld", LAST_FULL_TIMESTAMP, (time_t)-1);
    }
    storage.last_full_timestamp = persist_read_int(LAST_FULL_TIMESTAMP);
    if (!persist_exists(BATTERY_DISPLAY)) {
        persist_write_int(BATTERY_DISPLAY, 7);
        LOG_EXT(LOG_STORAGE, "storage_init(): init %d with data %d", BATTERY_DISPLAY, 1);
    }
    storage.battery_display = persist_read_int(BATTERY_DISPLAY);

    app_log_storage_log(LOG_STORAGE_SU);
}
开发者ID:astifter,项目名称:BetteryWatch,代码行数:38,代码来源:storage.c


示例13: readConfig

void readConfig() {
	if (persist_exists(CONFIG_KEY_DATEORDER)) {
		USDate = persist_read_int(CONFIG_KEY_DATEORDER);
	} else {
		APP_LOG(APP_LOG_LEVEL_DEBUG, "persist_exists(CONFIG_KEY_DATEORDER) returned false");
		USDate = 1;
	}

	if (persist_exists(CONFIG_KEY_LANG)) {
		curLang = persist_read_int(CONFIG_KEY_LANG);
	} else {
		APP_LOG(APP_LOG_LEVEL_DEBUG, "persist_exists(CONFIG_KEY_LANG) returned false");
		curLang = LANG_ENGLISH;
	}
	
	if (persist_exists(CONFIG_KEY_BACKLIGHT)) {
		backlight = persist_read_int(CONFIG_KEY_BACKLIGHT);
	} else {
		APP_LOG(APP_LOG_LEVEL_DEBUG, "persist_exists(CONFIG_KEY_BACKLIGHT) returned false");
		backlight = 0;
	}
	
	logVariables("readConfig");
}
开发者ID:linuxq,项目名称:Arc_2.0,代码行数:24,代码来源:Arc_2.0.c


示例14: init

static void init() {
    if (!persist_exists(BACKGROUND_COLOR_KEY)) {
        persist_write_int(BACKGROUND_COLOR_KEY, pcb_background.argb);
        persist_write_int(SILKSCREEN_COLOR_KEY, pcb_silkscreen.argb);
    }
    else {
        pcb_background.argb = persist_read_int(BACKGROUND_COLOR_KEY);
        pcb_silkscreen.argb = persist_read_int(SILKSCREEN_COLOR_KEY);
    }

    time_t t = time(NULL);
    struct tm *time_now = localtime(&t);
    tick_handler(time_now, MINUTE_UNIT);

    s_ocra_font = fonts_load_custom_font(
        resource_get_handle(RESOURCE_ID_FONT_OCR_A_20));
    
    s_resistor_img = gbitmap_create_with_resource(RESOURCE_ID_RESISTOR_IMG);
    
    s_main_window = window_create();
    window_set_window_handlers(s_main_window, (WindowHandlers) {
        .load = window_load,
        .unload = window_unload,
    });
开发者ID:llamahunter,项目名称:resistor-time,代码行数:24,代码来源:resistor.c


示例15: set_score

static void set_score() {
	int highScore = persist_read_int(HIGH_SCORE_KEY);

	if (state.score > highScore) {
		// Save persistent data
		persist_write_int(HIGH_SCORE_KEY, state.score);	
		highScore = state.score;
	}
	
	// Display high score
	static char buf[32];
	snprintf(buf, 32, "High Score: %u", highScore);
	text_layer_set_text(high_score_label, buf);
	
	layer_set_hidden((Layer*) high_score_label, false);
}
开发者ID:aradreed,项目名称:up-down,代码行数:16,代码来源:updown.c


示例16: tick_handler

static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
  update_time();
  // Get weather update every n minutes
  int fetch = persist_read_int(MESSAGE_KEY_Weather_Fetch);
  if(tick_time->tm_min % fetch == 0) {
    // Begin dictionary
    DictionaryIterator *iter;
    app_message_outbox_begin(&iter);
  
    // Add a key-value pair
    dict_write_uint8(iter, 0, 0);
  
    // Send the message!
    app_message_outbox_send();
  }
}
开发者ID:eisea,项目名称:SimpleTime,代码行数:16,代码来源:main.c


示例17: set_time_display

static void set_time_display() {
	// Check if our time display property exists
	if (persist_exists(KEY_TIME_DISPLAY)) {
		// If so, read it in to a variable
		TIME_DISPLAY = persist_read_int(KEY_TIME_DISPLAY);
	}
	
	// If time display == 0, hide the display, otherwise show
	bool hide = TIME_DISPLAY == 0 ? true : false;
	
	// Hide or show the layer
	layer_set_hidden(text_layer_get_layer(label_layer_time), hide);
	
	// Output log message for testing
	APP_LOG(APP_LOG_LEVEL_INFO, "SELECTED TIME DISPLAY: %d", TIME_DISPLAY);
}
开发者ID:asyba,项目名称:PebbleConfig,代码行数:16,代码来源:pconfig.c


示例18: cache_stale

//
//  Ageing logic
//
int cache_stale(){
  // get mins since epoch 
  time_t epoch = time(NULL);
  uint16_t now_mins = epoch / 60;
  
  // retrieve time cache was initialised 
  uint16_t cache_init = persist_read_int (TIME_INIT_KEY);
  
  uint16_t cache_age = now_mins-cache_init; 
  
  if (cache_age > CACHE_MAX_MINS) {
//     APP_LOG(APP_LOG_LEVEL_INFO, "         cache_stale() = 1   now= %u, cache_init = %u", (unsigned int)now_mins, (unsigned int) cache_init);
    return 1;
  }
//   APP_LOG(APP_LOG_LEVEL_INFO, "         cache_stale() = 0   now= %u, cache_init = %u", (unsigned int)now_mins, (unsigned int) cache_init);
  return 0;
}
开发者ID:obitoo,项目名称:PebbleTidesUK,代码行数:20,代码来源:cache.c


示例19: Settings_init

void Settings_init() {
  // first, check if we have any saved settings
  int settingsVersion = persist_read_int(SETTINGS_VERSION_KEY);

  // load all settings
  Settings_loadFromStorage();

  // for BW watches, reset colors to defaults
  #ifndef PBL_COLOR
    if(settingsVersion < CURRENT_SETTINGS_VERSION) {
      globalSettings.timeColor      = GColorWhite;
      globalSettings.sidebarColor   = GColorWhite;
      globalSettings.timeBgColor      = GColorBlack;
      globalSettings.sidebarTextColor = GColorBlack;
    }
  #endif
}
开发者ID:Jajunk,项目名称:TimeStylePebble,代码行数:17,代码来源:settings.c


示例20: stats_decrease_stat_value

void stats_decrease_stat_value(uint32_t key)
{
  int cur_val = persist_read_int(key);
  cur_val--;
  if(persist_read_bool(SICK_STATUS_KEY))
  {
    cur_val--;
  }
  if(cur_val <= STAT_FIELD_MIN)
  {
    persist_write_int(key, STAT_FIELD_MIN);
  }
  else
  {
    persist_write_int(key, cur_val);
  }
}
开发者ID:JefreyHildebrandt,项目名称:burabuchi,代码行数:17,代码来源:Stats.c



注:本文中的persist_read_int函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ persist_write_int函数代码示例发布时间:2022-05-30
下一篇:
C++ persist_exists函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap