示例#1
0
void create_chrono_objects() {
  app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "create_chrono_objects");
  hand_cache_init(&chrono_minute_cache);
  hand_cache_init(&chrono_second_cache);
  hand_cache_init(&chrono_tenth_cache);

  update_chrono_laps_time();
}
示例#2
0
void chrono_reset_button() {
  // Resets the chronometer to 0 time.
  time_t now;
  struct tm *this_time;

  now = time(NULL);
  this_time = localtime(&now);
  chrono_data.running = false;
  chrono_data.lap_paused = false;
  chrono_data.start_ms = 0;
  chrono_data.hold_ms = 0;
  memset(&chrono_data.laps[0], 0, sizeof(chrono_data.laps[0]) * CHRONO_MAX_LAPS);
  vibes_double_pulse();
  update_chrono_laps_time();
  update_hands(this_time);
  reset_tick_timer();
}
示例#3
0
void create_chrono_objects() {
  app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "create_chrono_objects");
  hand_cache_init(&chrono_minute_cache);
  hand_cache_init(&chrono_second_cache);
  hand_cache_init(&chrono_tenth_cache);

  Layer *window_layer = window_get_root_layer(window);

  {
    // We defer loading the chrono dial until we actually need to render it.
    //load_chrono_dial();
    int height = 56;   //chrono_dial_white.bitmap->bounds.size.h;
    int width = 56;    //chrono_dial_white.bitmap->bounds.size.w;
    int x = chrono_tenth_hand_def.place_x - width / 2;
    int y = chrono_tenth_hand_def.place_y - height / 2;

    chrono_dial_layer = layer_create(GRect(x, y, width, height));
    assert(chrono_dial_layer != NULL);
  }
  layer_set_update_proc(chrono_dial_layer, &chrono_dial_layer_update_callback);
  layer_add_child(window_layer, chrono_dial_layer);

  update_chrono_laps_time();
}
示例#4
0
void
load_chrono_data() {
  ChronoData local_data;
  if (persist_read_data(PERSIST_KEY + 0x100, &local_data, sizeof(local_data)) == sizeof(local_data)) {
    chrono_data = local_data;
    saved_chrono_data = local_data;
    // Ensure the start time is within modulo 24 hours of the current
    // day, to minimize the danger of integer overflow after 49 days.
    // As long as you launch the Chronograph at least once every 49
    // days, we'll keep an accurate time measurement (but we only ever
    // show modulo 24 hours).
    app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "Loaded chrono_data");
    if (chrono_data.running) {
      unsigned int ms = get_time_ms();
      unsigned int chrono_ms = (ms - chrono_data.start_ms + MS_PER_DAY) % MS_PER_DAY;
      app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "Modulated start_ms from %u to %u", chrono_data.start_ms, ms - chrono_ms);
      chrono_data.start_ms = ms - chrono_ms;
    }
    
    update_chrono_laps_time();
  } else {
    app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "Wrong previous chrono_data size or no previous data.");
  }
}
示例#5
0
void record_chrono_lap(int chrono_ms) {
  // Lose the first one.
  memmove(&chrono_data.laps[0], &chrono_data.laps[1], sizeof(chrono_data.laps[0]) * (CHRONO_MAX_LAPS - 1));
  chrono_data.laps[CHRONO_MAX_LAPS - 1] = chrono_ms;
  update_chrono_laps_time();
}