Ejemplo n.º 1
0
static void display_time(struct tm *tick_time) {
    
    // TODO: Use `units_changed` and more intelligence to reduce
    //       redundant digit unload/load?
	
	// This is to make sure the screen is not refreshed every second
	if (tick_time->tm_min != min)  {
		if (was_BTconnected_last_time)  {
			window_set_background_color(window, background_color);
			display_value(get_display_hour(tick_time->tm_hour), 0, false);
			display_value(tick_time->tm_min, 1, true);
			min = tick_time->tm_min;
		}
		else  {
			// Destroy previous inverter layer to make sure there's no inverted spot if first digit is missing (ie: " 0:12")
			inverter_layer_destroy(inv_layer);
			window_set_background_color(window, background_color);
			display_value(get_display_hour(tick_time->tm_hour), 0, false);
			display_value(tick_time->tm_min, 1, true);
			min = tick_time->tm_min;
			//Inverter layer
			inv_layer = inverter_layer_create(GRect(0, 0, 144, 168));
			layer_add_child(window_get_root_layer(window), (Layer*) inv_layer);	
		}		
	}
}
Ejemplo n.º 2
0
static void handle_tick(struct tm *tick_time, TimeUnits units_changed){  
#ifdef DEBUGTIME
  int hours = get_display_hour(debugHours);
#else
  int hours = get_display_hour(tick_time->tm_hour);
#endif

#ifdef DEBUGTIME
  int minutes = debugMinutes;
#else
  int minutes = tick_time->tm_min;
#endif
  
  update_hours(hours);
  update_minutes(minutes);

#ifdef DEBUGTIME
  ++debugHours;
  if(debugHours > 24){
    debugHours = 1;
  }
  ++debugMinutes;
  if(debugMinutes > 59){
    debugMinutes = 0;
  }    
#endif
  
  //strftime(date_text, sizeof(date_text), dateFormat, tick_time);
  //text_layer_set_text(date_text_layer, date_text);
}
Ejemplo n.º 3
0
void handle_minute_tick(struct tm *tick_time, TimeUnits units_changed) {
  display_value(get_display_hour(tick_time->tm_hour), 0, true, true, 1, 0);
  display_value(get_display_hour(tick_time->tm_hour), 0, true, false, 3, 2);
  display_value(tick_time->tm_min, 1, true, false, 1, 0);
  display_value(tick_time->tm_min, 1, true, true, 3, 2);

  layer_mark_dirty(window_get_root_layer(window));
}
Ejemplo n.º 4
0
static void update_hours(struct tm *tick_time) {

  if(appStarted && hourlyvibe) {
    //vibe!
    vibes_short_pulse();
  }
  
  unsigned short display_hour = get_display_hour(tick_time->tm_hour);

  set_container_image(&time_digits_images[0], time_digits_layers[0], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour/10], GPoint(0, 14)); //n3v3r original 5-> je zahl nun 4 breiter
  set_container_image(&time_digits_images[1], time_digits_layers[1], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour%10], GPoint(32, 14)); //n3v3r original 33

  if (!clock_is_24h_style()) {
    if (tick_time->tm_hour >= 12) {
      set_container_image(&time_format_image, time_format_layer, RESOURCE_ID_IMAGE_PM_MODE, GPoint(60, 2));
      layer_set_hidden(bitmap_layer_get_layer(time_format_layer), false);
    } 
    else {
      layer_set_hidden(bitmap_layer_get_layer(time_format_layer), true);
    }
    
    if (display_hour/10 == 0) {
      layer_set_hidden(bitmap_layer_get_layer(time_digits_layers[0]), true);
    }
    else {
      layer_set_hidden(bitmap_layer_get_layer(time_digits_layers[0]), false);
    }

  }
}
Ejemplo n.º 5
0
void display_layer_update_callback(Layer *me, GContext* ctx) {
  (void)me;

  PblTm t;

  get_time(&t);

  unsigned short display_hour = get_display_hour(t.tm_hour);

  draw_cell_row_for_digit(ctx, display_hour, HOURS_MAX_COLS, HOURS_ROW);
  draw_cell_row_for_digit(ctx, t.tm_min, MINUTES_MAX_COLS, MINUTES_ROW);
  draw_cell_row_for_digit(ctx, t.tm_sec, SECONDS_MAX_COLS, SECONDS_ROW);

// Yeah, there's a better way to do this

  graphics_text_draw(ctx, "1", fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect(SECONDS_MAX_COLS*CELL_SIZE, TEXT_ROW*CELL_SIZE, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);
  graphics_text_draw(ctx, "2", fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect((SECONDS_MAX_COLS-1)*CELL_SIZE, TEXT_ROW*CELL_SIZE, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);
  graphics_text_draw(ctx, "4", fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect((SECONDS_MAX_COLS-2)*CELL_SIZE, TEXT_ROW*CELL_SIZE, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);
  graphics_text_draw(ctx, "8", fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect((SECONDS_MAX_COLS-3)*CELL_SIZE, TEXT_ROW*CELL_SIZE, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);
  graphics_text_draw(ctx, "16", fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect((SECONDS_MAX_COLS-4)*CELL_SIZE-4, TEXT_ROW*CELL_SIZE, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);
  graphics_text_draw(ctx, "32", fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect((SECONDS_MAX_COLS-5)*CELL_SIZE-4, TEXT_ROW*CELL_SIZE, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);

  graphics_text_draw(ctx, "H", fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect(0, HOURS_ROW*CELL_SIZE, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);
  graphics_text_draw(ctx, "M", fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect(0, MINUTES_ROW*CELL_SIZE, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);
  graphics_text_draw(ctx, "S", fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect(0, SECONDS_ROW*CELL_SIZE, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);

}
Ejemplo n.º 6
0
void update_display(PblTm *current_time) {
  // TODO: Only update changed values?

  set_container_image(&day_name_image, DAY_NAME_IMAGE_RESOURCE_IDS[current_time->tm_wday], GPoint(69, 61));

  // TODO: Remove leading zero?
  set_container_image(&date_digits_images[0], DATENUM_IMAGE_RESOURCE_IDS[current_time->tm_mday/10], GPoint(108, 61));
  set_container_image(&date_digits_images[1], DATENUM_IMAGE_RESOURCE_IDS[current_time->tm_mday%10], GPoint(121, 61));


  unsigned short display_hour = get_display_hour(current_time->tm_hour);

  // TODO: Remove leading zero?
  set_container_image(&time_digits_images[0], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour/10], GPoint(10, 84));
  set_container_image(&time_digits_images[1], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour%10], GPoint(40, 84));

  set_container_image(&time_digits_images[2], BIG_DIGIT_IMAGE_RESOURCE_IDS[current_time->tm_min/10], GPoint(77, 84));
  set_container_image(&time_digits_images[3], BIG_DIGIT_IMAGE_RESOURCE_IDS[current_time->tm_min%10], GPoint(105, 84));

  if (!clock_is_24h_style()) {
    if (current_time->tm_hour >= 12) {
      set_container_image(&time_format_image, RESOURCE_ID_IMAGE_PM_MODE, GPoint(17, 68));
    } else {
      layer_remove_from_parent(&time_format_image.layer.layer);
      bmp_deinit_container(&time_format_image);
    }

    if (display_hour/10 == 0) {
      layer_remove_from_parent(&time_digits_images[0].layer.layer);
      bmp_deinit_container(&time_digits_images[0]);
    }
  }

}
void update_display(PblTm *current_time) {

  unsigned short display_hour = get_display_hour(current_time->tm_hour);

  set_container_image(&time_digits_images[0], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour/10], GPoint(49, 151));
  set_container_image(&time_digits_images[1], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour%10], GPoint(61, 151));

  set_container_image(&time_digits_images[2], BIG_DIGIT_IMAGE_RESOURCE_IDS[current_time->tm_min/10], GPoint(76, 151));
  set_container_image(&time_digits_images[3], BIG_DIGIT_IMAGE_RESOURCE_IDS[current_time->tm_min%10], GPoint(87, 151));

/*
  if (!clock_is_24h_style()) {
    if (current_time->tm_hour >= 12) {
      set_container_image(&time_format_image, RESOURCE_ID_IMAGE_PM_MODE, GPoint(17, 68));
    } else {
      set_container_image(&time_format_image, RESOURCE_ID_IMAGE_AM_MODE, GPoint(17, 68));
    }

    if (display_hour/10 == 0) {
      layer_remove_from_parent(&time_digits_images[0].layer.layer);
      bmp_deinit_container(&time_digits_images[0]);
    }
  }
*/
}
Ejemplo n.º 8
0
static void update_hours(struct tm *tick_time) {

  /* removed hourly vibe (and it's setting)
  if(appStarted && settings.HourlyVibe) {
    //vibe!
    vibes_short_pulse();
  }
  */
  
  unsigned short display_hour = get_display_hour(tick_time->tm_hour);

  set_container_image(&time_digits_images[0], time_digits_layers[0], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour/10], GPoint(10, 84));
  set_container_image(&time_digits_images[1], time_digits_layers[1], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour%10], GPoint(40, 84));

  if (!clock_is_24h_style()) {
    if (tick_time->tm_hour >= 12) {
      set_container_image(&time_format_image, time_format_layer, RESOURCE_ID_IMAGE_PM_MODE, GPoint(17, 68));
      layer_set_hidden(bitmap_layer_get_layer(time_format_layer), false);
    } 
    else {
      layer_set_hidden(bitmap_layer_get_layer(time_format_layer), true);
    }
    
    if (display_hour/10 == 0) {
      layer_set_hidden(bitmap_layer_get_layer(time_digits_layers[0]), true);
    }
    else {
      layer_set_hidden(bitmap_layer_get_layer(time_digits_layers[0]), false);
    }

  }
}
Ejemplo n.º 9
0
static void update_time (struct tm *current_time) {
  unsigned short display_hour = get_display_hour(current_time->tm_hour);

  int yPos = 70;
  // TODO: Remove leading zero?
  set_container_image(&time_digits_images[0], time_digits_layers[0], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour/10], GPoint(18, yPos));
  set_container_image(&time_digits_images[1], time_digits_layers[1], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour%10], GPoint(38, yPos));

  set_container_image(&time_digits_images[2], time_digits_layers[2], BIG_DIGIT_IMAGE_RESOURCE_IDS[current_time->tm_min/10], GPoint(65, yPos));
  set_container_image(&time_digits_images[3], time_digits_layers[3], BIG_DIGIT_IMAGE_RESOURCE_IDS[current_time->tm_min%10], GPoint(85, yPos));

  if (!clock_is_24h_style()) {
    if (current_time->tm_hour >= 12) {
      layer_set_hidden(bitmap_layer_get_layer(time_format_layer), false);
      set_container_image(&time_format_image, time_format_layer, RESOURCE_ID_IMAGE_PM_MODE, GPoint(7, 75));
    } else {
      layer_set_hidden(bitmap_layer_get_layer(time_format_layer), true);
    }

    if (display_hour/10 == 0) {
    	layer_set_hidden(bitmap_layer_get_layer(time_digits_layers[0]), true);
    } else {
    	layer_set_hidden(bitmap_layer_get_layer(time_digits_layers[0]), false);
    }
  }
}
static void update_display(struct tm *current_time) {
  set_container_image(&s_day_name_bitmap, s_day_name_layer, DAY_NAME_IMAGE_RESOURCE_IDS[current_time->tm_wday], GPoint(69, 61));
  set_container_image(&s_date_digits[0], s_date_digits_layers[0], DATENUM_IMAGE_RESOURCE_IDS[current_time->tm_mday / 10], GPoint(108, 61));
  set_container_image(&s_date_digits[1], s_date_digits_layers[1], DATENUM_IMAGE_RESOURCE_IDS[current_time->tm_mday % 10], GPoint(121, 61));

  unsigned short display_hour = get_display_hour(current_time->tm_hour);
  set_container_image(&s_time_digits[0], s_time_digits_layers[0], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour / 10], GPoint(10, 84));
  set_container_image(&s_time_digits[1], s_time_digits_layers[1], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour % 10], GPoint(40, 84));

  set_container_image(&s_time_digits[2], s_time_digits_layers[2], BIG_DIGIT_IMAGE_RESOURCE_IDS[current_time->tm_min / 10], GPoint(77, 84));
  set_container_image(&s_time_digits[3], s_time_digits_layers[3], BIG_DIGIT_IMAGE_RESOURCE_IDS[current_time->tm_min % 10], GPoint(105, 84));

  if (!clock_is_24h_style()) {
    if (current_time->tm_hour >= 12) {
    	layer_set_hidden(bitmap_layer_get_layer(s_time_format_layer), false);
      set_container_image(&s_time_format_bitmap, s_time_format_layer, RESOURCE_ID_IMAGE_PM_MODE, GPoint(17, 68));
    } else {
    	layer_set_hidden(bitmap_layer_get_layer(s_time_format_layer), true);
    }

    if (display_hour / 10 == 0) {
    	layer_set_hidden(bitmap_layer_get_layer(s_time_digits_layers[0]), true);
    } else {
    	layer_set_hidden(bitmap_layer_get_layer(s_time_digits_layers[0]), false);
    }
  }
}
Ejemplo n.º 11
0
static void update_hours(struct tm *tick_time) {

	if (appStarted && hourlyvibe) {
    //vibe!
    vibes_short_pulse();
	}
	
  unsigned short display_hour = get_display_hour(tick_time->tm_hour);

  set_container_image(&normal_time_digits_images[0], normal_time_digits_layers[0], NORMAL_IMAGE_RESOURCE_IDS[display_hour/10], GPoint(0, 40));
  set_container_image(&normal_time_digits_images[1], normal_time_digits_layers[1], NORMAL_IMAGE_RESOURCE_IDS[display_hour%10], GPoint(34, 40));

	
	if (!clock_is_24h_style()) {
	
	if (display_hour/10 == 0) {		
		 	layer_set_hidden(bitmap_layer_get_layer(normal_time_digits_layers[0]), true); 
		  } else  if (flip == 0) {
		    layer_set_hidden(bitmap_layer_get_layer(normal_time_digits_layers[0]), false);
            	}
	}		
	
				 static char ampm_text[] = "am";

		     if (!clock_is_24h_style()) {


		strftime(ampm_text, sizeof(ampm_text), "%P", tick_time);
        text_layer_set_text(layer_ampm_text, ampm_text);
			 }
}
void display_time(PblTm *tick_time) {

  // TODO: Use `units_changed` and more intelligence to reduce
  //       redundant digit unload/load?

  display_value(get_display_hour(tick_time->tm_hour), 0, false);
  display_value(tick_time->tm_min, 1, true);
}
void handle_tick(AppContextRef ctx, PebbleTickEvent *evt) {
	PblTm now;
	int ho, mi, da, mo, i;

    if (splashEnded) {
        if (animation_is_scheduled(&anim))
            animation_unschedule(&anim);
        
        get_time(&now);
        
        ho = get_display_hour(now.tm_hour);
        mi = now.tm_min;
        da = now.tm_mday;
        mo = now.tm_mon+1;
        
        for (i=0; i<NUMSLOTS; i++) {
            slot[i].prevDigit = slot[i].curDigit;
        }
        
        slot[0].curDigit = ho/10;
        slot[1].curDigit = ho%10;
        slot[2].curDigit = mi/10;
        slot[3].curDigit = mi%10;
		if (US_DATE) {
			slot[6].curDigit = da/10;
			slot[7].curDigit = da%10;
			slot[4].curDigit = mo/10;
			slot[5].curDigit = mo%10;
		} else {
			slot[4].curDigit = da/10;
			slot[5].curDigit = da%10;
			slot[6].curDigit = mo/10;
			slot[7].curDigit = mo%10;
		}
		
		if (NO_ZERO) {
			if (slot[0].curDigit == 0) {
				slot[0].curDigit = 10;
				if (slot[0].prevDigit == 10) {
					slot[0].curDigit++;
				}
			}
			if (slot[4].curDigit == 0) {
				slot[4].curDigit = 10;
				if (slot[4].prevDigit == 10) {
					slot[4].curDigit++;
				}
			}
			if (slot[6].curDigit == 0) {
				slot[6].curDigit = 10;
				if (slot[6].prevDigit == 10) {
					slot[6].curDigit++;
				}
			}
		}
        animation_schedule(&anim);
    }
}
Ejemplo n.º 14
0
static void display_time(struct tm *tick_time) {

  // TODO: Use `units_changed` and more intelligence to reduce
  //       redundant digit unload/load?

  display_value(get_display_hour(tick_time->tm_hour), 0, false);
  display_value(tick_time->tm_min, 1, true); 
  snprintf(dayText, 3, "%2.2d", tick_time->tm_mday); 
  text_layer_set_text(dayLayer, showDay ? dayText : "  ");
}
Ejemplo n.º 15
0
void display_time(struct tm *tick_time) {
  showing_time = 1;
  unsigned short hour = get_display_hour(tick_time->tm_hour);
  int min = tick_time->tm_min;

  //int particles_per_group = NUM_PARTICLES / 2;

  int hr_digit_tens = hour / 10; 
  int hr_digit_ones = hour % 10; 
  int min_digit_tens = min / 10; 
  int min_digit_ones = min % 10; 
  // GRect window_bounds = layer_get_bounds(window_get_root_layer(window));
  // int w = window_bounds.size.w;
  // int h = window_bounds.size.h;

  // take out 5 particles
  // 2 for colon
  // 3 for floaters
  int save = 5;

  if(hr_digit_tens == 0) {
    int particles_per_group = (NUM_PARTICLES - save)/ 3;
    swarm_to_digit(hr_digit_ones,                          0, particles_per_group,   25, 60);
    swarm_to_digit(min_digit_tens,     particles_per_group, particles_per_group*2,   65, 60);
    swarm_to_digit(min_digit_ones, (particles_per_group*2), NUM_PARTICLES - save,    95, 60);

    // top colon
    particles[NUM_PARTICLES-2].grav_center = FPoint(57, 69);
    particles[NUM_PARTICLES-2].power = TIGHT_POWER;
    particles[NUM_PARTICLES-2].goal_size = 3.0F;

    // bottom colon
    particles[NUM_PARTICLES-1].grav_center = FPoint(57, 89);
    particles[NUM_PARTICLES-1].power = TIGHT_POWER;
    particles[NUM_PARTICLES-1].goal_size = 3.0F;

  } else {
    int particles_per_group = (NUM_PARTICLES - save)/ 4;
    swarm_to_digit(hr_digit_tens,                          0, particles_per_group,   10, 60);
    swarm_to_digit(hr_digit_ones,      particles_per_group, particles_per_group*2, 40, 60);
    swarm_to_digit(min_digit_tens, (particles_per_group*2), particles_per_group*3, 80, 60);
    swarm_to_digit(min_digit_ones, (particles_per_group*3), NUM_PARTICLES - save,  110, 60);

    // top colon
    particles[NUM_PARTICLES-2].grav_center = FPoint(68, 69);
    particles[NUM_PARTICLES-2].power = TIGHT_POWER;
    particles[NUM_PARTICLES-2].goal_size = 3.0F;

    // bottom colon
    particles[NUM_PARTICLES-1].grav_center = FPoint(68, 89);
    particles[NUM_PARTICLES-1].power = TIGHT_POWER;
    particles[NUM_PARTICLES-1].goal_size = 3.0F;
  }

}
Ejemplo n.º 16
0
void update_display_hours(PblTm *tick_time) {
    static char am_pm_text[] = "PM";

    display_value(get_display_hour(tick_time->tm_hour), 0, false);
    // AM/PM
    string_format_time(am_pm_text, sizeof(am_pm_text), "%p", tick_time);

    if (!clock_is_24h_style()) {
      text_layer_set_text(&ampm, am_pm_text);
    }
}
Ejemplo n.º 17
0
static void display_layer_update_callback(Layer *layer, GContext *ctx) { 
  time_t now = time(NULL);
  struct tm *t = localtime(&now);
  
  draw_col(ctx, t->tm_year%100, DATE_TYPE, YEAR_COL, YEAR_MAX_ROWS);
  draw_col(ctx, t->tm_mon + 1, DATE_TYPE, MONTH_COL, MONTH_MAX_ROWS);
  draw_col(ctx, t->tm_mday, DATE_TYPE, DAY_COL, DAY_MAX_ROWS);

  draw_col(ctx, get_display_hour(t->tm_hour), TIME_TYPE, HOURS_COL, HOURS_MAX_ROWS);
  draw_col(ctx, t->tm_min, TIME_TYPE, MINUTES_COL, MINUTES_MAX_ROWS);
  draw_col(ctx, t->tm_sec, TIME_TYPE, SECONDS_COL, SECONDS_MAX_ROWS);
}
Ejemplo n.º 18
0
static void handle_second_tick(struct tm* tick_time, TimeUnits units_changed) {
  static int day_m = 40;
  static int hour_m = 33;
  static int min_m = 77;
  static bool clock24 = false;
  
  if (clock24 != clock_is_24h_style()) {
    clock24 = clock_is_24h_style();
    for (int slot_number = 4; slot_number < TOTAL_IMAGE_SLOTS; slot_number++) {
      GRect bounds = layer_get_frame(bitmap_layer_get_layer(digit_slot[slot_number]));
      if (clock24) {
        bounds.origin.y = 19;
      } else {
        bounds.origin.y = 35;
      }
      layer_set_frame(bitmap_layer_get_layer(digit_slot[slot_number]), bounds);
    }
    GRect bounds = layer_get_frame(text_layer_get_layer(date_layer));
    if (clock24) {
      bounds.origin.y = 52;
    } else {
      bounds.origin.y = 62;
    }
    layer_set_frame(text_layer_get_layer(date_layer), bounds);
    layer_set_hidden((Layer *)ampm_layer, clock24);
  }
  
  if (day_m != tick_time->tm_mday) {
    day_m = tick_time->tm_mday;
    update_date(tick_time);
    text_layer_set_text(date_layer, date_text);
  }
  if (hour_m != tick_time->tm_hour) {
    hour_m = tick_time->tm_hour;
    display_value(get_display_hour(tick_time->tm_hour), 0, true);
    if (!clock_is_24h_style()) {
      if (hour_m >=12) {
        text_layer_set_text(ampm_layer, "PM");
      } else {
        text_layer_set_text(ampm_layer, "AM");
      }
    }
  }
    
  if (min_m != tick_time->tm_min) {
    min_m = tick_time->tm_min;
    display_value(tick_time->tm_min, 1, true);  
  }
  display_value(tick_time->tm_sec, 2, true);
}
Ejemplo n.º 19
0
static void display_time(struct tm *tick_time) {
    display_value(get_display_hour(tick_time->tm_hour), 0);
    display_value(tick_time->tm_min, 1);
    //Displays a subtle reminder on the hour
    if(tick_time->tm_min % 60 == 0) {
        gbitmap_destroy(block_o_bitmap);
        ichigan_bitmap = gbitmap_create_with_resource(RESOURCE_ID_Ichigan);
        bitmap_layer_set_bitmap(block_o_layer, ichigan_bitmap);
    }
    //Reset's the clock after the subtle reminder
    if(tick_time->tm_min % 60 == 1) {
        gbitmap_destroy(ichigan_bitmap);
        block_o_bitmap = gbitmap_create_with_resource(RESOURCE_ID_block_o_background);
        bitmap_layer_set_bitmap(block_o_layer, block_o_bitmap);
    }
}
Ejemplo n.º 20
0
void display_layer_update_callback(Layer *me, GContext* ctx) {
    (void)me;
    
    PblTm t;
    
    get_time(&t);
    
    unsigned short display_hour = get_display_hour(t.tm_hour);
    graphics_context_set_fill_color(ctx, GColorWhite);
    
    
    for (int cell_column_index = 0; cell_column_index < display_hour/10; cell_column_index++) {
        
        
        graphics_fill_rect(ctx, cell_location(0, cell_column_index), 0, GCornerNone);
    }
    for (int cell_column_index = 0; cell_column_index < display_hour%10; cell_column_index++) {
        
        
        graphics_fill_rect(ctx, cell_location(1, cell_column_index), 0, GCornerNone);
    }
    
    for (int cell_column_index = 0; cell_column_index < t.tm_min/10; cell_column_index++) {
        
        
        graphics_fill_rect(ctx, cell_location(2, cell_column_index), 0, GCornerNone);
    }
    for (int cell_column_index = 0; cell_column_index < t.tm_min%10; cell_column_index++) {
        
        
        graphics_fill_rect(ctx, cell_location(3, cell_column_index), 0, GCornerNone);
    }
    
    for (int cell_column_index = 0; cell_column_index < t.tm_sec/10; cell_column_index++) {
        
        
        graphics_fill_rect(ctx, cell_location(4, cell_column_index), 0, GCornerNone);
    }
    for (int cell_column_index = 0; cell_column_index < t.tm_sec%10; cell_column_index++) {
        
        
        graphics_fill_rect(ctx, cell_location(5, cell_column_index), 0, GCornerNone);
    }
    
}
Ejemplo n.º 21
0
void display_layer_update_callback(Layer *me, GContext* ctx) {

  PblTm t;

  get_time(&t);

  unsigned short display_hour = get_display_hour(t.tm_hour);

  draw_cell_row_for_digit(ctx, display_hour / 10, HOURS_FIRST_DIGIT_MAX_COLS, HOURS_FIRST_DIGIT_ROW);
  draw_cell_row_for_digit(ctx, display_hour % 10, DEFAULT_MAX_COLS, HOURS_SECOND_DIGIT_ROW);

  draw_cell_row_for_digit(ctx, t.tm_min / 10, MINUTES_FIRST_DIGIT_MAX_COLS, MINUTES_FIRST_DIGIT_ROW);
  draw_cell_row_for_digit(ctx, t.tm_min % 10, DEFAULT_MAX_COLS, MINUTES_SECOND_DIGIT_ROW);

  draw_cell_row_for_digit(ctx, t.tm_sec / 10, SECONDS_FIRST_DIGIT_MAX_COLS, SECONDS_FIRST_DIGIT_ROW);
  draw_cell_row_for_digit(ctx, t.tm_sec % 10, DEFAULT_MAX_COLS, SECONDS_SECOND_DIGIT_ROW);

}
Ejemplo n.º 22
0
static void handle_tick(struct tm *tick_time, TimeUnits units_changed)
{
    if (units_changed & DAY_UNIT)
    {
        // Get the day and convert text uppercase
        strftime(mDayText, mDayTextSize, "%a %m/%d", tick_time);
        for (int i = 0; mDayText[i] != 0; i++)
        {
            if (mDayText[i] >= 'a' && mDayText[i] <= 'z')
            {
                mDayText[i] -= 0x20;
            }
        }
    }

    if (units_changed & HOUR_UNIT)
    {
        unsigned short display_hour = get_display_hour(tick_time->tm_hour);

        GPoint hourPoint = mBigHour ? GPoint(DIGIT_X1, DIGIT_Y) : GPoint(DIGIT_X1_S-SCREEN_W2-BHOFFSET, DIGIT_Y);;
        set_container_image(&time_digits_images[0], time_digits_layers[0], display_hour/10, hourPoint, mBigHour);
        hourPoint.x = mBigHour ? DIGIT_X2 : DIGIT_X2_S-SCREEN_W2-BHOFFSET;
        set_container_image(&time_digits_images[1], time_digits_layers[1], display_hour%10, hourPoint, mBigHour);

        if (!clock_is_24h_style())
        {
            if (display_hour / 10 == 0)
            {
                layer_set_hidden(bitmap_layer_get_layer(time_digits_layers[0]), true);
            }
            else
            {
                layer_set_hidden(bitmap_layer_get_layer(time_digits_layers[0]), false);
            }
        }
    }
    if (units_changed & MINUTE_UNIT)
    {
        GPoint minutePoint = mBigHour ? GPoint(DIGIT_X1_S, DIGIT_Y) : GPoint(SCREEN_W2+DIGIT_X1-BHOFFSET, DIGIT_Y);
        set_container_image(&time_digits_images[2], time_digits_layers[2], tick_time->tm_min/10, minutePoint, !mBigHour);
        minutePoint.x = mBigHour ? DIGIT_X2_S : SCREEN_W2+DIGIT_X2-BHOFFSET;
        set_container_image(&time_digits_images[3], time_digits_layers[3], tick_time->tm_min%10, minutePoint, !mBigHour);
    }	
}
Ejemplo n.º 23
0
void update_display(PblTm *current_time) {
  unsigned short display_hour = get_display_hour(current_time->tm_hour);

  int h1 = display_hour/10;
  set_container_image(&time_digits_images[0], NUMBER_IMAGE_RESOURCE_IDS[h1][0],NUMBER_IMAGE_RESOURCE_IDS[h1][1], GPoint(73 + offset[h1][0], 32 + offset[h1][1]), h1, 1);
  set_container_image(&mirror_time_digits_images[0], MIRROR_NUMBER_IMAGE_RESOURCE_IDS[h1][0],MIRROR_NUMBER_IMAGE_RESOURCE_IDS[h1][1], GPoint(42 + moffset[h1][0], 32 + moffset[h1][1]), h1, 2);

  int h2 = display_hour%10;
  set_container_image(&time_digits_images[1], NUMBER_IMAGE_RESOURCE_IDS[h2][0],NUMBER_IMAGE_RESOURCE_IDS[h2][1], GPoint(104 + offset[h2][0], 32 + offset[h2][1]), h2, 2);
  set_container_image(&mirror_time_digits_images[1], MIRROR_NUMBER_IMAGE_RESOURCE_IDS[h2][0],MIRROR_NUMBER_IMAGE_RESOURCE_IDS[h2][1], GPoint(11 + moffset[h2][0], 32 + moffset[h2][1]), h2, 1);

  int m1 = current_time->tm_min/10;
  set_container_image(&time_digits_images[2], NUMBER_IMAGE_RESOURCE_IDS[m1][0],NUMBER_IMAGE_RESOURCE_IDS[m1][1], GPoint(11 + offset[m1][0], 85 + offset[m1][1]), m1, 1);
  set_container_image(&mirror_time_digits_images[2], MIRROR_NUMBER_IMAGE_RESOURCE_IDS[m1][0],MIRROR_NUMBER_IMAGE_RESOURCE_IDS[m1][1], GPoint(104 + moffset[m1][0], 85 + moffset[m1][1]), m1, 2);

  int m2 = current_time->tm_min%10;
  set_container_image(&time_digits_images[3], NUMBER_IMAGE_RESOURCE_IDS[m2][0],NUMBER_IMAGE_RESOURCE_IDS[m2][1], GPoint(42 + offset[m2][0], 85 + offset[m2][1]), m2, 2);
  set_container_image(&mirror_time_digits_images[3], MIRROR_NUMBER_IMAGE_RESOURCE_IDS[m2][0],MIRROR_NUMBER_IMAGE_RESOURCE_IDS[m2][1], GPoint(73 + moffset[m2][0], 85 + moffset[m2][1]), m2, 1);
}
Ejemplo n.º 24
0
void update_display(PblTm *current_time) {
    // TODO: Only update changed values?
    
    set_container_image(&day_name_image, DAY_NAME_IMAGE_RESOURCE_IDS[current_time->tm_wday], GPoint(79, 3));
    
    // TODO: Remove leading zero?
    set_container_image(&date_digits_images[0], DATENUM_IMAGE_RESOURCE_IDS[current_time->tm_mday/10], GPoint(111, 3));
    set_container_image(&date_digits_images[1], DATENUM_IMAGE_RESOURCE_IDS[current_time->tm_mday%10], GPoint(118, 3));
    
    
    unsigned short display_hour = get_display_hour(current_time->tm_hour);
    
    // TODO: Remove leading zero?
    set_container_image(&time_digits_images[0], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour/10], GPoint(38, 30));
    set_container_image(&time_digits_images[1], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour%10], GPoint(62, 30));
    
    set_container_image(&time_digits_images[2], BIG_DIGIT_IMAGE_RESOURCE_IDS[current_time->tm_min/10], GPoint(86, 30));
    set_container_image(&time_digits_images[3], BIG_DIGIT_IMAGE_RESOURCE_IDS[current_time->tm_min%10], GPoint(110, 30));
    
    unsigned int unix_time;
    /* Convert time to seconds since epoch. */
    unix_time = ((0-TIME_ZONE_OFFSET)*3600) + /* time zone offset */
    + current_time->tm_sec /* start with seconds */
    + current_time->tm_min*60 /* add minutes */
    + current_time->tm_hour*3600 /* add hours */
    + current_time->tm_yday*86400 /* add days */
    + (current_time->tm_year-70)*31536000 /* add years since 1970 */
    + ((current_time->tm_year-69)/4)*86400 /* add a day after leap years, starting in 1973 */
    - ((current_time->tm_year-1)/100)*86400 /* remove a leap day every 100 years, starting in 2001 */
    + ((current_time->tm_year+299)/400)*86400; /* add a leap day back every 400 years, starting in 2001*/
    
    /* Draw each digit in the correct location. */
    for(int i=0; i<TOTAL_DIGITS; i++) {
        
        /* int digit_colum = i % TOTAL_COLUMNS; */
        int denominator = my_pow(10,i); /* The loop starts at the most significant digit and goes down from there. */
        int digit_value = (int)unix_time/(1000000000 / denominator); /* This gives the value for the current digit. (Casting should give us the floor of the value.) */
        unix_time = unix_time % (1000000000 / denominator); /* This subtracts the value for the current digit so that it doesn't interfere with the next iteration of the loop. */
        set_container_image(&digits[i], BLOCK_NUMBER[digit_value], GPoint(40 + (i * 9), 90)); /* Now we set this digit. */
    }
    
    
}
Ejemplo n.º 25
0
void bluetooth_handler(bool connected) {
	//	This handler is called when BT connection state changes

	// Destroy inverter layer if BT changed from disconnected to connected
	if ((connected) && (!(was_BTconnected_last_time)))  {
		inverter_layer_destroy(inv_layer);
	}
	time_t now = time(NULL);
    struct tm *tick_time = localtime(&now);
	window_set_background_color(window, background_color);
	display_value(get_display_hour(tick_time->tm_hour), 0, false);
	display_value(tick_time->tm_min, 1, true);
	//Inverter layer in case of disconnect
	if (!(connected)) {
		inv_layer = inverter_layer_create(GRect(0, 0, 144, 168));
		layer_add_child(window_get_root_layer(window), (Layer*) inv_layer);	
		vibes_double_pulse();
	}
	was_BTconnected_last_time = connected;
}
Ejemplo n.º 26
0
static void update_hours(struct tm *tick_time) {
	
   if (appStarted && hourlyvibe) {
    //vibe!
    vibes_short_pulse();
  } 
   unsigned short display_hour = get_display_hour(tick_time->tm_hour);

  set_container_image(&time_digits_images[0], time_digits_layers[0], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour/10], GPoint(56, 130));
  set_container_image(&time_digits_images[1], time_digits_layers[1], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour%10], GPoint(56, 93));
	
  if (!clock_is_24h_style() ) { 
   if (display_hour/10 == 0) {
      layer_set_hidden(bitmap_layer_get_layer(time_digits_layers[0]), true);
    }
    else {
      layer_set_hidden(bitmap_layer_get_layer(time_digits_layers[0]), false);
    }
  }
}
Ejemplo n.º 27
0
void update_display(PblTm *tick_time) {

  static char month_text[] = "AAA";
  static char date_text[] = "00"; 
  static char am_pm_text[] = "P";
  
  string_format_time(month_text, sizeof(month_text), "%b", tick_time);
  string_format_time(date_text, sizeof(date_text), "%e", tick_time);
  string_format_time(am_pm_text, sizeof(am_pm_text), "%p", tick_time);
  
  text_layer_set_text(&text_layer_4, month_text);
  text_layer_set_text(&text_layer_5, date_text);  
  
  if (!clock_is_24h_style()) {
	text_layer_set_text(&text_layer_6, am_pm_text);  
  }
  
  display_value(get_display_hour(tick_time->tm_hour), 0, false);
  display_value(tick_time->tm_min, 1, true);
}
Ejemplo n.º 28
0
void display_layer_update_cb(Layer *me, GContext* ctx) {
  time_t now = time(NULL);
  struct tm *t = localtime(&now);

  unsigned short display_hour = get_display_hour(t->tm_hour);
  unsigned short display_min = t->tm_min;
  unsigned short display_sec = t->tm_sec;

  unsigned short row1, row2;
  if (DEBUG) {
    row1 = display_min;
    row2 = display_sec;
  } else {
    row1 = display_hour;
    row2 = display_min;
  }

  draw_rect(0, 0, TILES_X, TILES_Y, 0);
  draw_digit(row1/10, 0, 0);
  draw_digit(row1%10, 1, 0);
  draw_digit(row2/10, 0, 1);
  draw_digit(row2%10, 1, 1);

  // now redraw tiles that have changed
  for (size_t j = 0; j < TILES_Y; j++) {
    for (size_t i = 0; i < TILES_X; i++) {
      unsigned char v = frames[current_frame][i][j];
      // TODO: make this only redraw when tiles have changed. At the moment,
      // I am marking the entire display_layer as dirty which seems to mean
      // I have to repaint the whole thing. Probably what I want is is separate
      // layer for each tile?

      // if (v != frames[prev_frame][i][j]) {
        draw_tile(ctx, i, j, v == 1);
        frames[prev_frame][i][j] = v;
      // }
    }
  }

  swap(&current_frame, &prev_frame);
}
Ejemplo n.º 29
0
void update_display(PblTm *current_time) {

	
	unsigned short display_hour = get_display_hour(current_time->tm_hour);

  // TODO: Remove leading zero?

  set_container_image(&time_digits_images[0], IMAGE_RESOURCE_IDS[display_hour/10],         GPoint(-5, 91));
  set_container_image(&time_digits_images[1], IMAGE_RESOURCE_IDS[display_hour%10],         GPoint(18, 68));
  set_container_image(&time_colon_image,      RESOURCE_ID_IMAGE_COLON,                     GPoint(40,42));
  set_container_image(&time_digits_images[2], IMAGE_RESOURCE_IDS[current_time->tm_min/10], GPoint(54, 34));
  set_container_image(&time_digits_images[3], IMAGE_RESOURCE_IDS[current_time->tm_min%10], GPoint(77, 11));
	
  if (!clock_is_24h_style()) {
    if (display_hour/10 == 0) {
      layer_remove_from_parent(&time_digits_images[0].layer.layer);
      rotbmp_deinit_container(&time_digits_images[0]);
    }
  }

}
Ejemplo n.º 30
0
static void update_display(struct tm *current_time, TimeUnits units_changed){
  if(blink == 0){
    if(current_time->tm_sec % 2 == 0){
      layer_set_hidden(bitmap_layer_get_layer(dots_layer), false);
    } else {
      layer_set_hidden(bitmap_layer_get_layer(dots_layer), true);
    }
  }
	
  if(battery_state_service_peek().is_charging){
    if(current_time->tm_sec % 2 == 0){
      layer_set_hidden(bitmap_layer_get_layer(meter_bar_layer), false);
      is_hidden = false;
    } else {
      layer_set_hidden(bitmap_layer_get_layer(meter_bar_layer), true);
      is_hidden = true;
      }
  } else {
    if(is_hidden){
      layer_set_hidden(bitmap_layer_get_layer(meter_bar_layer), false);
      is_hidden = false;
    }
  }

  if (units_changed & MINUTE_UNIT) {
    set_container_image(&time_digits_images[2], time_digits_layers[2], BIG_DIGIT_IMAGE_RESOURCE_IDS[current_time->tm_min/10]);
    set_container_image(&time_digits_images[3], time_digits_layers[3], BIG_DIGIT_IMAGE_RESOURCE_IDS[current_time->tm_min%10]);
	  
    if (units_changed & HOUR_UNIT) {
      // TODO implement hourly display changes
      unsigned short display_hour = get_display_hour(current_time->tm_hour);
	
      set_container_image(&time_digits_images[0], time_digits_layers[0], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour/10]);
      set_container_image(&time_digits_images[1], time_digits_layers[1], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour%10]);
			
      if(display_hour < 10 && zeroes == 0) {
        layer_set_hidden(bitmap_layer_get_layer(time_digits_layers[0]), true);
      } else {
	    layer_set_hidden(bitmap_layer_get_layer(time_digits_layers[0]), false);
      }
		
	  if(!clock_is_24h_style()){
		  strftime(text_buffer, sizeof(text_buffer), "%p", current_time);
		  text_layer_set_text(time_format_layer, text_buffer);
	  }	else {
		  text_layer_set_text(time_format_layer, "24H");
	  }

		if (units_changed & DAY_UNIT) {
			char *formating0 = "%b";
			char *formating1 = "%e";
			if(date == 0){
				formating0 ="%b";
				if(zeroes == 0){
					formating1 = "%e";
				} else {
					formating1 = "%d";
				}
			} else {
				if(zeroes == 0){
					formating0 = "%e";
				} else {
					formating0 = "%d";
				}
				formating1 = "%b";
			}

			strftime(text_buffer0, sizeof(text_buffer0), formating0, current_time);
			text_layer_set_text(date_layer[0], text_buffer0);
			strftime(text_buffer1, sizeof(text_buffer1), formating1, current_time);
			text_layer_set_text(date_layer[1], text_buffer1);

			GRect frame = (GRect){{0, 15}, {15, 2}};
			if(square == 1){
				frame = (GRect){{0, 3}, {15, 13}};
			}

			int offset[] = {0, 16, 33, 48, 67, 82, 94};
			int width[] = {15, 17, 14, 19, 14, 12, 15};

			frame.origin.x = offset[current_time->tm_wday];
			frame.size.w = width[current_time->tm_wday];
			if(square == 0){
				frame.origin.x = frame.origin.x + 1;
				frame.size.w = frame.size.w - 2;
			}
			layer_set_frame(inverter_layer_get_layer(day_inv_layer), frame);

			if(units_changed & MONTH_UNIT){
				//Showing of month name is already solved during the day show
			}
		}
    }
  }
}