本文整理汇总了C++中persist_exists函数的典型用法代码示例。如果您正苦于以下问题:C++ persist_exists函数的具体用法?C++ persist_exists怎么用?C++ persist_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了persist_exists函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: settings_load
void settings_load(void) {
if (persist_exists(PERSIST_SETTINGS)) {
if (! persist_exists(PERSIST_SETTINGS_VERSION)) {
DEBUG("Migrating settings from 2.X to 3.X");
OldSettings old_settings;
int res = persist_read_data(PERSIST_SETTINGS, &old_settings, sizeof(old_settings));
if (res >= 0) {
migrate_settings_01(old_settings);
return;
}
}
else if (persist_read_int(PERSIST_SETTINGS_VERSION) == SETTINGS_VERSION_TINY) {
SettingsTiny settings_tiny;
int res = persist_read_data(PERSIST_SETTINGS, &settings_tiny, sizeof(settings_tiny));
if (res >= 0) {
migrate_settings_02(settings_tiny);
return;
}
}
int res = persist_read_data(PERSIST_SETTINGS, &_settings, sizeof(_settings));
if (res < 0) {
LOG("Settings load failed: %d", res);
}
}
}
开发者ID:Kfernand2,项目名称:pebble,代码行数:25,代码来源:settings.c
示例2: show_charge_log
static void show_charge_log()
{
if (!persist_exists(PERSIST_KEY_LOG_COUNT) || !persist_exists(PERSIST_KEY_LOG_INDEX)) {
return;
}
int log_count = persist_read_int(PERSIST_KEY_LOG_COUNT);
int log_index = persist_read_int(PERSIST_KEY_LOG_INDEX);
if (log_count == 0) {
return;
}
time_t now = time(NULL);
for (int i = 0; i < log_count; ++i) {
uint32_t key_log = PERSIST_KEY_LOG_BASE + (log_index + i) % MAX_LOG_COUNT;
ChargeLog charge_log;
persist_read_data(key_log, &charge_log, sizeof(charge_log));
static char buff[] = "999 4294967296 %100";
snprintf(buff, sizeof(buff), "%d %u %d%%", i, (unsigned)difftime(now, charge_log.time), charge_log.charge_state.charge_percent);
APP_LOG(APP_LOG_LEVEL_DEBUG, buff);
}
}
开发者ID:tmatz,项目名称:PebbleBatteryLog,代码行数:25,代码来源:main.c
示例3: init
/*
* A place for everything and everything it its place. This is
* mainly here because main() would be messy otherwise.
*/
static void init() {
int theme;
/*
* Read the stored configuration keys or write defaults if they
* don't exist so that the config is properly loaded.
*/
if(persist_exists(KEY_CONFIG_TEMP_UNIT)) {
persist_read_string(KEY_CONFIG_TEMP_UNIT, s_temp_unit, sizeof(s_temp_unit));
} else {
strncpy(s_temp_unit, DEFAULT_TEMP_UNIT, sizeof(s_temp_unit));
persist_write_string(KEY_CONFIG_TEMP_UNIT, s_temp_unit);
}
if(persist_exists(KEY_CONFIG_THEME)) {
theme = persist_read_int(KEY_CONFIG_THEME);
s_theme = (theme >= 0 && theme < THEME_COUNT) ? theme : DEFAULT_THEME;
} else {
s_theme = DEFAULT_THEME;
persist_write_int(KEY_CONFIG_THEME, s_theme);
}
// Build the main window and register callbacks so that the UI gets
// drawn.
//
s_main_window = window_create();
window_set_window_handlers(s_main_window, (WindowHandlers) {
.load = load_cb,
.unload = unload_cb
});
开发者ID:musl,项目名称:DataFace,代码行数:36,代码来源:main.c
示例4: pause_click_handler
static void pause_click_handler(ClickRecognizerRef recognizer, void *context) {
int calib_stored = persist_exists(CALIB_PKEY) ? persist_read_int(CALIB_PKEY) : CALIB_DEFAULT;
if (calib_stored != 0 && calibrating == 0) {
pause++;
pause = pause % 2;
if (pause == 0) {
end_time = time(NULL);
double elapsed = difftime(end_time, start_time);
result = (int)floor(sum_x/elapsed);
display(text_layer_3, "Score: %d", result);
action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_play);
int calib_stored = persist_exists(CALIB_PKEY) ? persist_read_int(CALIB_PKEY) : CALIB_DEFAULT;
display(text_layer_4, "Calib: %d", calib_stored);
text_layer_set_text(text_layer_2, "");
if (result > 2*calib_stored) {
send(0, 1);
text_layer_set_text(text_layer_1, "YOU'RE DRUNK");
dialog_message_window_push();
}
else {
send(0, 0);
text_layer_set_text(text_layer_1, "YOU'RE FINE");
}
}
else {
sum_x = 0;
text_layer_set_text(text_layer_2, "RUNNING");
text_layer_set_text(text_layer_3, "");
action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_pause);
start_time = time(NULL);
}
}
}
开发者ID:mohaiminalaoun,项目名称:Drunkness-tester,代码行数:35,代码来源:main.c
示例5: save_charge_log
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);
}
}
开发者ID:tmatz,项目名称:PebbleBatteryLog,代码行数:30,代码来源:main.c
示例6: loadPersistentValues
static void loadPersistentValues() {
backgroundBlack = persist_exists(PERSIST_KEY_BACKGROUND) ? persist_read_int(PERSIST_KEY_BACKGROUND) : DEFAULT_BACKGROUND;
showDay = persist_exists(PERSIST_KEY_SHOW_DAY) ? persist_read_int(PERSIST_KEY_SHOW_DAY) : DEFAULT_SHOWDAY;
APP_LOG(APP_LOG_LEVEL_DEBUG, "Loaded values from storage - background=%d, showDay=%d",
persist_exists(PERSIST_KEY_BACKGROUND) ? backgroundBlack : -1,
persist_exists(PERSIST_KEY_SHOW_DAY)? showDay : -1);
}
开发者ID:hhundsch,项目名称:big_time_date,代码行数:7,代码来源:big_time_date.c
示例7: history_load
static void history_load() {
if (persist_exists(MESSAGE_KEY_batches)) {
current_history_batch = persist_read_int(MESSAGE_KEY_batches);
}
if (current_history_batch < 0) {
// APP_LOG(APP_LOG_LEVEL_DEBUG, "No history in persistent storage: %d", current_history_batch);
return;
}
// APP_LOG(APP_LOG_LEVEL_DEBUG, "Reading %d history batches from persistent storage", current_history_batch+1);
int total_bytes_read = 0;
for (int i=0; i<=current_history_batch; i++) {
if (persist_exists(FIRST_HISTORY_BATCH+i)) {
// int result = persist_read_data(FIRST_HISTORY_BATCH+i, &history[i], sizeof(history[i]));
// APP_LOG(APP_LOG_LEVEL_DEBUG, "Loaded history batch %d, %d bytes, %d events, result %d", i, (int) sizeof(history[i]), history[i].last_event+1, result);
persist_read_data(FIRST_HISTORY_BATCH+i, &history[i], sizeof(history[i]));
total_bytes_read += sizeof(history[i]);
}
else {
APP_LOG(APP_LOG_LEVEL_WARNING, "No history batch %d although current_history_batch %d indicates its existence!", i, current_history_batch);
}
}
start_time = (int) history[0].event_time[0];
selected = (Selected) {current_history_batch, history[current_history_batch].last_event};
events = current_history_batch * HISTORY_BATCH_SIZE + history[current_history_batch].last_event + 1;
if (persist_exists(MESSAGE_KEY_avgMood)) {
average_mood = persist_read_int(MESSAGE_KEY_avgMood);
}
APP_LOG(APP_LOG_LEVEL_DEBUG, "Total history: %d batches, %d events, %d bytes", current_history_batch+1, events, total_bytes_read);
}
开发者ID:samuelmr,项目名称:pebble-trackmood,代码行数:29,代码来源:trackmood.c
示例8: main_init
// omain init - registers callback functions, reads persistent data, and requests most recent data from
// companion app. Sets default timer length to 10 seconds.
void main_init(void) {
s_reset_app(NULL);
// initialize app message
app_message_register_inbox_received(inbox_received_callback);
app_message_register_inbox_dropped(inbox_dropped_callback);
app_message_register_outbox_failed(outbox_failed_callback);
app_message_register_outbox_sent(outbox_sent_callback);
app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());
// send request for most recent data
DictionaryIterator *iter;
app_message_outbox_begin(&iter);
dict_write_uint8(iter, 0, 42);
app_message_outbox_send();
// gather persistent data for timer length and passcode
if (persist_exists(TIMERLEN_PERSIST_KEY)) {
s_timer_len = persist_read_int(TIMERLEN_PERSIST_KEY);
} else {
s_timer_len = 10*1000;
}
if (persist_exists(PASSCODE_PERSIST_KEY)) {
s_passcode_defined = true;
persist_read_string(PASSCODE_PERSIST_KEY, s_passcode, PASSCODE_LEN + 1);
} else {
s_passcode_defined = false;
}
}
开发者ID:Tsukinara,项目名称:DangerZone,代码行数:31,代码来源:quick_alert.c
示例9: readConfig
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);
}
开发者ID:dmitre,项目名称:Blockslide-Date_2.0_reverce-pebble,代码行数:32,代码来源:Blockslide-Date_2.0.c
示例10: window_load
static void window_load(Window *window) {
Layer *root_layer = window_get_root_layer(window);
if (persist_exists(PERSIST_KEY_ID_POMODORO)) {
persist_read_data(PERSIST_KEY_ID_POMODORO, &pomodoro, sizeof(pomodoro));
}
if (persist_exists(PERSIST_KEY_ID_POMODORO_CYCLE)) {
persist_read_data(PERSIST_KEY_ID_POMODORO_CYCLE, &pomodoro.cycle, sizeof(pomodoro.cycle));
}
if (persist_exists(PERSIST_KEY_ID_POMODORO_CYCLE_NOW)) {
persist_read_data(PERSIST_KEY_ID_POMODORO_CYCLE_NOW, &pomodoro.timer, sizeof(pomodoro.timer));
if (pomodoro.cycle <= pomodoro.timer) pomodoro.timer = -1;
}
tick_timer_service_subscribe(HOUR_UNIT | MINUTE_UNIT, tick_handler);
// LOAD RESOURCE
uint8_t resource_id = (uint8_t)RESOURCE_ID_HANNA_B;
for (uint8_t i = 0; i < bitmaps_length; ++i) {
bitmaps[i] = gbitmap_create_with_resource((uint8_t)(resource_id + i));
}
load_layers(root_layer);
}
开发者ID:soomtong,项目名称:HannaClock,代码行数:27,代码来源:main.c
示例11: tick_handler
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);
}
}
开发者ID:Herschee,项目名称:Watchdog,代码行数:33,代码来源:alert_window.c
示例12: options_init
void options_init() {
if(persist_exists(OPTION_LARGE_FONT))
large_font = persist_read_bool(OPTION_LARGE_FONT);
if(persist_exists(OPTION_TASK_ACTIONS_POSITION))
task_actions_position = persist_read_int(OPTION_TASK_ACTIONS_POSITION);
LOG("lg font? %d", large_font);
LOG("act pos? %d", task_actions_position);
}
开发者ID:Ameb,项目名称:PebbleNotes,代码行数:8,代码来源:options.c
示例13: load_config
// Load existing config from persistent storage
void load_config() {
if (persist_exists(MESSAGE_KEY_INVERT)) {
config_invert = persist_read_bool(MESSAGE_KEY_INVERT);
}
if (persist_exists(MESSAGE_KEY_DATE_FORMAT)) {
config_date_format = persist_read_int(MESSAGE_KEY_DATE_FORMAT);
}
}
开发者ID:Gia90,项目名称:PebbleSlipknotBarcode,代码行数:9,代码来源:watchface.c
示例14: read_settings_from_memory
void read_settings_from_memory() {
if (persist_exists(KEY_SCALE_CHOICE))
scale = persist_read_int(KEY_SCALE_CHOICE);
if (persist_exists(KEY_CLOCK_FORMAT))
clock_format = persist_read_int(KEY_CLOCK_FORMAT);
if (persist_exists(KEY_DATE_FORMAT))
date_format = persist_read_int(KEY_DATE_FORMAT);
}
开发者ID:lanmonster,项目名称:DozenalTime,代码行数:8,代码来源:main.c
示例15: load_persistent_data
static void load_persistent_data(){
uint32_t data_from = persist_exists(DATE_SAVE) ? (uint32_t)persist_read_int(DATE_SAVE) : get_today();
if (data_from == get_today()){
rounds_done = persist_exists(COMPLETED_COUNT) ? persist_read_int(COMPLETED_COUNT) : 0;
rounds_canceled = persist_exists(CANCELED_COUNT) ? persist_read_int(CANCELED_COUNT) : 0;
}
}
开发者ID:klassenpeter,项目名称:pebble_tomato,代码行数:8,代码来源:main.c
示例16: load_items
static void load_items(void){
int i, key;
for (i=0; i<NUM_FIRST_MENU_ITEMS; i++){
key = 2*i;
if (persist_exists(key)) persist_read_string(key, book_list[i].name, sizeof(book_list[i].name));
key++;
if (persist_exists(key)) book_list[i].page_number = persist_read_int(key);
}
}
开发者ID:cfg1,项目名称:pebble-bookmarks,代码行数:9,代码来源:main.c
示例17: LoadPersistedData
bool LoadPersistedData(void)
{
CharacterData *characterData;
int floor = 0;
bool useWorkerApp = false;
if(!persist_exists(PERSISTED_IS_DATA_SAVED) || !persist_read_bool(PERSISTED_IS_DATA_SAVED))
return false;
if(!IsPersistedDataCurrent())
{
WARNING_LOG("Persisted data does not match current version, clearing.");
ClearPersistedData();
return false;
}
ProfileLogStart("LoadPersistedData");
INFO_LOG("Loading persisted data.");
characterData = GetCharacter();
persist_read_data(PERSISTED_CHARACTER_DATA, characterData, sizeof(CharacterData));
floor = persist_read_int(PERSISTED_CURRENT_FLOOR);
SetCurrentFloor(floor);
persist_read_data(PERSISTED_ITEM_DATA, GetItemsOwned(), GetSizeOfItemsOwned());
SetStatPointsPurchased(persist_read_int(PERSISTED_STAT_POINTS_PURCHASED));
SetVibration(persist_read_bool(PERSISTED_VIBRATION));
SetFastMode(persist_read_bool(PERSISTED_FAST_MODE));
if(persist_exists(PERSISTED_USE_OLD_ASSETS))
SetUseOldAssets(persist_read_bool(PERSISTED_USE_OLD_ASSETS));
useWorkerApp = persist_read_bool(PERSISTED_WORKER_APP);
if(useWorkerApp)
{
AttemptToLaunchWorkerApp();
}
else
{
// If the user has launched the worker app outside of MiniDungeon,
// they want it on.
if(WorkerIsRunning())
SetWorkerApp(true);
}
SetWorkerCanLaunch(persist_read_bool(PERSISTED_WORKER_CAN_LAUNCH));
if(persist_read_bool(PERSISTED_IN_COMBAT))
{
int currentMonster = persist_read_int(PERSISTED_MONSTER_TYPE);
int currentMonsterHealth = persist_read_int(PERSISTED_MONSTER_HEALTH);
ResumeBattle(currentMonster, currentMonsterHealth);
}
ProfileLogStop("LoadPersistedData");
if(characterData->level == 0)
{
// Something bad happened to the data, possible due to a watch crash
ERROR_LOG("Persisted data was broken somehow, clearing");
ClearPersistedData();
return false;
}
return true;
}
开发者ID:PhatedOne,项目名称:MiniDungeon,代码行数:57,代码来源:Persistence.c
示例18: handle_init
void handle_init() {
keyIndex = (persist_exists(KEY_INDEX_KEY) ? persist_read_int(KEY_INDEX_KEY) : 0);
unsigned char offset = '0';
unsigned char rawDST = 'N';
unsigned char rawCount = '1';
resource_load_byte_range(resource_get_handle(RESOURCE_ID_GMT_OFFSET), 0, &offset, 1);
timeZoneIndex = (persist_exists(TIME_ZONE_KEY) ? persist_read_int(TIME_ZONE_KEY) : (offset - '0'));
resource_load_byte_range(resource_get_handle(RESOURCE_ID_IS_DST), 0, &rawDST, 1);
isDST = (persist_exists(IS_DST_KEY) ? persist_read_bool(IS_DST_KEY) : (rawDST == 'Y'));
resource_load_byte_range(resource_get_handle(RESOURCE_ID_SECRET_COUNT), 0, &rawCount, 1);
keyCount = rawCount - '0';
window = window_create();
window_stack_push(window, true /* Animated */);
//Great for debugging the layout.
//window_set_background_color(&window, GColorBlack);
Layer* rootLayer = window_get_root_layer(window);
GRect rootLayerRect = layer_get_bounds(rootLayer);
barLayer = layer_create(GRect(0,70,rootLayerRect.size.w,5));
layer_set_update_proc(barLayer, bar_layer_update);
layer_add_child(rootLayer, barLayer);
currentKey = text_layer_create(GRect(0,0,rootLayerRect.size.w,22));
text_layer_set_font(currentKey, fonts_get_system_font(FONT_KEY_GOTHIC_18));
text_layer_set_text_alignment(currentKey, GTextAlignmentCenter);
layer_add_child(rootLayer, text_layer_get_layer(currentKey));
currentCode = text_layer_create(GRect(0,32,rootLayerRect.size.w,36));
text_layer_set_font(currentCode, fonts_get_system_font(FONT_KEY_BITHAM_34_MEDIUM_NUMBERS));
text_layer_set_text_alignment(currentCode, GTextAlignmentCenter);
layer_add_child(rootLayer, text_layer_get_layer(currentCode));
currentTime = text_layer_create(GRect(0,rootLayerRect.size.h-(15+22),(rootLayerRect.size.w/3)*2,22));
text_layer_set_font(currentTime, fonts_get_system_font(FONT_KEY_GOTHIC_18));
text_layer_set_text_alignment(currentTime, GTextAlignmentLeft);
layer_add_child(rootLayer, text_layer_get_layer(currentTime));
currentOffset = text_layer_create(GRect((rootLayerRect.size.w/3)*2,rootLayerRect.size.h-(15+22),rootLayerRect.size.w/3,22));
text_layer_set_font(currentOffset, fonts_get_system_font(FONT_KEY_GOTHIC_18));
text_layer_set_text_alignment(currentOffset, GTextAlignmentRight);
layer_add_child(rootLayer, text_layer_get_layer(currentOffset));
// Attach our desired button functionality
window_set_click_config_provider(window, (ClickConfigProvider) click_config_provider);
reload();
}
开发者ID:Kleppten,项目名称:totpeb,代码行数:56,代码来源:pTOTP.c
示例19: init
static void init() {
s_icon_plus = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_ICON_PLUS);
s_icon_minus = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_ICON_MINUS);
// Get the count from persistent storage for use if it exists, otherwise use the default
s_player1_score = persist_exists(PLAYER1_SCORE_PKEY) ? persist_read_int(PLAYER1_SCORE_PKEY) : PLAYER_SCORE_DEFAULT;
s_player2_score = persist_exists(PLAYER2_SCORE_PKEY) ? persist_read_int(PLAYER2_SCORE_PKEY) : PLAYER_SCORE_DEFAULT;
s_main_window = window_create();
window_set_window_handlers(s_main_window, (WindowHandlers) {
.load = main_window_load,
.unload = main_window_unload,
});
开发者ID:Unpaid-Intern,项目名称:basics-score-counter,代码行数:13,代码来源:feature_persist_counter.c
示例20: 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
注:本文中的persist_exists函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论