Ejemplo n.º 1
0
void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
    if (units_changed & SECOND_UNIT) {
        g_stat_timer++;

        if (g_stat_timer == 8) {        
            set_new_stat_text();
            g_stat_timer = 0;
        }
    }
    if (units_changed & MINUTE_UNIT) {
#ifndef LOCK_SHIP
        int new_craft_index = rand() % (c_craft_info_count - 1);
        if (new_craft_index >= g_current_craft) {
            new_craft_index++;
        }
        
        load_holomesh(new_craft_index);
        update_title_and_info();
#endif

        update_time_display(tick_time);
    }
    if (units_changed & DAY_UNIT) {
        update_date_display(tick_time);
    }
}
Ejemplo n.º 2
0
static void down_click_handler(ClickRecognizerRef recognizer, void *context) {
  time_t today = get_today();
  
  if (day_diff(today, s_skip_until) >= 28)
    // If the skip date is already set to 4 weeks from today, wrap around to today
    s_skip_until = today;
  else
    // Set the date to the next date
    s_skip_until += (24 * 60 * 60);
  
  update_date_display();
}
Ejemplo n.º 3
0
static void up_click_handler(ClickRecognizerRef recognizer, void *context) {
  time_t today = get_today();
  
  if (s_skip_until <= today)
      // If the skip date was already set to today, wrap around to 4 weeks from now
      s_skip_until = today + (28 * 24 * 60 * 60);
  else
      // Set the date to the previous date
      s_skip_until -= (24 * 60 * 60);
  
  update_date_display();
}
Ejemplo n.º 4
0
//Hippo Command, I put my pants on backwards!
void handle_init(void) {
    APP_LOG(APP_LOG_LEVEL_DEBUG, "INIT MEMORY: %u bytes used, %u bytes free", (unsigned) heap_bytes_used(), (unsigned) heap_bytes_free());
    
    // TODO: restore this once done profiling
#ifndef LOCK_SHIP
    srand(time(NULL));
    load_holomesh(rand() % c_craft_info_count);
#else
    load_holomesh(LOCK_SHIP);
#endif
    
    APP_LOG(APP_LOG_LEVEL_DEBUG, "UI MEMORY: %u bytes used, %u bytes free", (unsigned) heap_bytes_used(), (unsigned) heap_bytes_free());

    my_window = window_create();
    window_set_background_color(my_window, GColorBlack);

    GRect logoRect = GRect(0, 12, c_viewportWidth, c_viewportWidth);
    logoLayer = bitmap_layer_create(logoRect);
    bitmap_layer_set_bitmap(logoLayer, logoBitmap);
    layer_add_child(window_get_root_layer(my_window), bitmap_layer_get_layer(logoLayer));

    // Fonts    
    g_font_sw = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_14));
    g_font_sw_symbol = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SYMBOL_14));
    g_font_time = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);
    g_font_info = fonts_get_system_font(FONT_KEY_GOTHIC_14);
    
    // Paint layer
    frameBufferLayer = bitmap_layer_create(GRect(0, 0, c_viewportWidth, c_viewportHeight));
    layer_add_child(window_get_root_layer(my_window), bitmap_layer_get_layer(frameBufferLayer));
    
    frameBufferBitmap = gbitmap_create_blank_with_palette(
        GSize(c_viewportWidth, c_viewportHeight),
        GBitmapFormat2BitPalette,
        c_palette,
        false);
    bitmap_layer_set_bitmap(frameBufferLayer, frameBufferBitmap);
    bitmap_layer_set_compositing_mode(frameBufferLayer, GCompOpSet);
    
    paint();

    GRect layerSize = GRect(0, 0, c_viewportWidth, c_viewportHeight);

    // Two small text layers
    textLayer = text_layer_create(layerSize);
    text_layer_set_background_color(textLayer, GColorClear);
    text_layer_set_text_color(textLayer, GColorYellow);
    text_layer_set_font(textLayer, g_font_sw);
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(textLayer));

    //Jet Force Push-up, you silly-billy.   
    textLayerSym = text_layer_create(layerSize);
    text_layer_set_background_color(textLayerSym, GColorClear);
    text_layer_set_text_color(textLayerSym, GColorYellow);
    text_layer_set_font(textLayerSym, g_font_sw_symbol);
    layer_set_hidden(text_layer_get_layer(textLayerSym), true);
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(textLayerSym));

    //Hippo Command, I also put my watch on backwards!

    // Info text layer
    infoTextLayer = text_layer_create(layerSize);
    text_layer_set_background_color(infoTextLayer, GColorClear);
    text_layer_set_text_color(infoTextLayer, GColorYellow);
    text_layer_set_font(infoTextLayer, g_font_info);
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(infoTextLayer));
    
    // Time
    GSize timeSize = graphics_text_layout_get_content_size(
        "00:00 AM",
        g_font_time,
        layerSize,
        0,
        GTextAlignmentLeft);
    GRect timeRect = { GPoint(DT_EDGE_PAD, c_viewportHeight - timeSize.h), GSize(c_viewportWidth, timeSize.h) };
    timeLayer = text_layer_create(timeRect);
    text_layer_set_background_color(timeLayer, GColorClear);
    text_layer_set_text_color(timeLayer, GColorYellow);
    text_layer_set_font(timeLayer, g_font_time);
    //text_layer_set_text(timeLayer, "23:45 AM");
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(timeLayer));
    
    // Date
    dateLayer = text_layer_create(layerSize);
    text_layer_set_background_color(dateLayer, GColorClear);
    text_layer_set_text_color(dateLayer, GColorYellow);
    text_layer_set_font(dateLayer, g_font_info);
    layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(dateLayer));
    


    time_t t = time(NULL);
    update_time_display(localtime(&t));
    update_date_display(localtime(&t));
    update_title_and_info();
    
    APP_LOG(APP_LOG_LEVEL_DEBUG, "FINAL MEMORY: %u bytes used, %u bytes free", (unsigned) heap_bytes_used(), (unsigned) heap_bytes_free());
    
    window_stack_push(my_window, true);
    tick_timer_service_subscribe(SECOND_UNIT | MINUTE_UNIT, tick_handler);
    
    g_timer = app_timer_register(c_refreshTimer, animation_timer_trigger, NULL);
    
    accel_data_service_subscribe(c_accelSampleCount, accel_data_handler);
    accel_service_set_sampling_rate(ACCEL_SAMPLING_25HZ);
}