本文整理汇总了C++中persist_read_int函数的典型用法代码示例。如果您正苦于以下问题:C++ persist_read_int函数的具体用法?C++ persist_read_int怎么用?C++ persist_read_int使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了persist_read_int函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
}
示例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);
}
示例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));
}
示例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;
}
示例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();
}
}
示例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;
}
示例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
}
}
示例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();
}
示例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");
}
示例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");
}
示例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);
}
示例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");
}
示例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,
});
示例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);
}