Exemplo n.º 1
0
void animate_moon(AppContextRef ctx, AppTimerHandle handle, uint32_t cookie) {
    (void)ctx;
    (void)handle;
    animationCount++;
    
    if(animationCount*animationStep <= 1 ){
        phasePercent += animationStep;
        if(phasePercent>=1)phasePercent--;
        layer_mark_dirty(&shadow_layer);
        timer_handle = app_timer_send_event(ctx, animationSpeed, 1);
    }
    else{
        PblTm t;
        get_time(&t);
        setPhase(daysSinceNewMoon(t.tm_year+1900,t.tm_yday,t.tm_hour));
        
        curHour=t.tm_hour;
        curMin=t.tm_min;
        curSec=t.tm_sec;
        layer_mark_dirty(&shadow_layer);
        layer_mark_dirty(&phase_layer);
        if(showHours){
            layer_mark_dirty(&hour_layer);
            layer_mark_dirty(&minute_layer);
            layer_mark_dirty(&top_layer);
        }
    }
}
Exemplo n.º 2
0
void second_tick(AppContextRef ctx, PebbleTickEvent *t) {
    (void)ctx;
    
    curHour=t->tick_time->tm_hour;
    curMin=t->tick_time->tm_min;
    curSec=t->tick_time->tm_sec;

    if (showSeconds && (t->units_changed & SECOND_UNIT)) {
        layer_mark_dirty(&second_layer);
    }
    if (showMinutes && t->units_changed & MINUTE_UNIT) {
        layer_mark_dirty(&minute_layer);
        layer_mark_dirty(&hour_layer);
    }
    if (t->units_changed & HOUR_UNIT) {
        
        setPhase(daysSinceNewMoon(t->tick_time->tm_year+1900,t->tick_time->tm_yday,t->tick_time->tm_hour));
        
        layer_mark_dirty(&shadow_layer);
        layer_mark_dirty(&phase_layer);
        
        if(showHours){
            layer_mark_dirty(&top_layer);
        }
    }
}
Exemplo n.º 3
0
void handle_init(AppContextRef ctx) {
    (void)ctx;

    window_init(&window, "Watchface");
    window_stack_push(&window, true /* Animated */);
    window_set_background_color(&window, GColorBlack);
        
    PblTm t;
    get_time(&t);
    setPhase(daysSinceNewMoon(t.tm_year+1900,t.tm_yday,t.tm_hour));
    
    curHour=t.tm_hour;
    curMin=t.tm_min;
    curSec=t.tm_sec;
    
    if(showDetailedMoonGraphic){
        
        resource_init_current_app(&LUNARCLOCK_IMAGE_RESOURCES);
        bmp_init_container(RESOURCE_ID_IMAGE_MOON, &moonimage_container);
        layer_add_child(&window.layer, &moonimage_container.layer.layer);
    }else{
        layer_init(&moon_layer, window.layer.frame);
        moon_layer.update_proc = &moon_layer_update_callback;
        layer_add_child(&window.layer, &moon_layer);
    }
    layer_init(&shadow_layer, window.layer.frame);
    shadow_layer.update_proc = &shadow_layer_update_callback;
    layer_add_child(&window.layer, &shadow_layer);
    
    layer_init(&phase_layer, window.layer.frame);
    phase_layer.update_proc = &phase_layer_update_callback;
    layer_add_child(&window.layer, &phase_layer);
    
    if(showHours){
        layer_init(&hour_layer, window.layer.frame);
        hour_layer.update_proc = &hour_layer_update_callback;
        layer_add_child(&window.layer, &hour_layer);
        
        gpath_init(&hour_hand, &hour_hand_info);
        gpath_move_to(&hour_hand, GPoint(centerx, centery));
        
    }
    if(showMinutes){
        layer_init(&minute_layer, window.layer.frame);
        minute_layer.update_proc = &minute_layer_update_callback;
        layer_add_child(&window.layer, &minute_layer);
        
        gpath_init(&minute_hand, &minute_hand_info);
        gpath_move_to(&minute_hand, GPoint(centerx, centery));
    }
    if(showSeconds){
        layer_init(&second_layer, window.layer.frame);
        second_layer.update_proc = &second_layer_update_callback;
        layer_add_child(&window.layer, &second_layer);
    }
    layer_init(&top_layer, window.layer.frame);
    top_layer.update_proc = &top_layer_update_callback;
    layer_add_child(&window.layer, &top_layer);
}