Commits

Trammell Hudson  committed e5f8a12

12/24 hour styling

  • Participants
  • Parent commits 166ffc0

Comments (0)

Files changed (4)

File th10/src/Makefile

 SRCS += th10.c
 
 FONTS := \
-	fonts/Arial-Black.ttf:30 \
+	fonts/GillSans.ttc:32 \
 
 #fonts/Arial.ttf:16 \
 

File th10/src/fonts/Arial-Black.ttf

Binary file removed.

File th10/src/fonts/GillSans.ttc

Binary file added.

File th10/src/th10.c

 );
 
 
-// Local timezone GMT offset
-static const int gmt_offset = -5;
-
 static Window window;
 static Layer hand_layer;
 static Layer bg_layer;
 static PblTm now;
-static GFont font_thick;
+static GFont font_time;
+
+static int use_24hour;
 
 
 // Dimensions of the watch face
 #define W PEBBLE_SCREEN_WIDTH
 #define H PEBBLE_SCREEN_HEIGHT
 #define R (W/2 - 2)
-#define MOON_RADIUS 16
 
 // Hour hand
 static GPath hour_path;
 static GPoint hour_points[] = {
-	{ -8, 25 },
-	{ -10, 45 },
-	{  0,  60 },
-	{ +10, 45 },
-	{ +8, 25 },
-	{ -8, 25 },
+	{  -8, -25 },
+	{ -10, -45 },
+	{   0,  -60 },
+	{ +10, -45 },
+	{  +8, -25 },
+	{  -8, -25 },
 };
 
 static GPath minute_path;
 static GPoint minute_points[] = {
-	{ -5, 20 },
-	{ -9, 50 },
-	{  0, 72 },
-	{ +9, 50 },
-	{ +5, 20 },
-	{ -5, 20 },
+	{ -5, -20 },
+	{ -9, -50 },
+	{  0, -72 },
+	{ +9, -50 },
+	{ +5, -20 },
+	{ -5, -20 },
 };
 
 static GPath major_tick_path;
 	{ -4, 84 },
 };
 
+static GPath hour_tick_path;
+static GPoint hour_tick_points[] = {
+	{ -4, 70 },
+	{ +4, 70 },
+	{ +4, 84 },
+	{ -4, 84 },
+};
+
 static GPath minor_tick_path;
 static GPoint minor_tick_points[] = {
 	{ 0, 72 },
 
 	// Draw the hour hand outline in black and filled with white
 	// above the minute hand
-	int hour_angle = ((now.tm_hour * 60 + now.tm_min) * TRIG_MAX_ANGLE) / (60 * 24);
+	int hour_angle;
+	if (use_24hour)
+	{
+		hour_angle = ((now.tm_hour * 60 + now.tm_min) * TRIG_MAX_ANGLE) / (60 * 24);
+	} else {
+		int hour = now.tm_hour;
+		if (hour > 12)
+			hour -= 12;
+		hour_angle = ((hour * 60 + now.tm_min) * TRIG_MAX_ANGLE) / (60 * 12);
+	}
 
 	gpath_rotate_to(&hour_path, hour_angle);
 	graphics_context_set_stroke_color(ctx, GColorBlack);
 	for (int min = 0 ; min < 60 ; min++)
 	{
 		const int angle = (min * TRIG_MAX_ANGLE) / 60;
+		if ((min % 15) == 0)
+		{
+			gpath_rotate_to(&hour_tick_path, angle);
+			gpath_draw_filled(ctx, &hour_tick_path);
+		} else
 		if ((min % 5) == 0)
 		{
 			gpath_rotate_to(&major_tick_path, angle);
 			gpath_draw_outline(ctx, &minor_tick_path);
 		}
 	}
+
+	// And the large labels
+	graphics_text_draw(ctx,
+		use_24hour ? "24" : "12",
+		font_time,
+		GRect(W/2-30,8,60,50),
+		GTextOverflowModeTrailingEllipsis,
+		GTextAlignmentCenter,
+		NULL
+	);
+
+	graphics_text_draw(ctx,
+		use_24hour ? "06" : "3",
+		font_time,
+		GRect(W/2,H/2-22,70,50),
+		GTextOverflowModeTrailingEllipsis,
+		GTextAlignmentRight,
+		NULL
+	);
+
+	graphics_text_draw(ctx,
+		use_24hour ? "12" : "6",
+		font_time,
+		GRect(W/2-30,120,60,50),
+		GTextOverflowModeTrailingEllipsis,
+		GTextAlignmentCenter,
+		NULL
+	);
+
+	graphics_text_draw(ctx,
+		use_24hour ? "18" : "9",
+		font_time,
+		GRect(W/2-70,H/2-22,60,50),
+		GTextOverflowModeTrailingEllipsis,
+		GTextAlignmentLeft,
+		NULL
+	);
 }
 
 #define GPATH_INIT(PATH, POINTS) ({ \
 	GPATH_INIT(&major_tick_path, major_tick_points);
 	gpath_move_to(&major_tick_path, GPoint(W/2,H/2));
 
+	GPATH_INIT(&hour_tick_path, hour_tick_points);
+	gpath_move_to(&hour_tick_path, GPoint(W/2,H/2));
+
 	GPATH_INIT(&minor_tick_path, minor_tick_points);
 	gpath_move_to(&minor_tick_path, GPoint(W/2,H/2));
 
 	get_time(&now);
+	use_24hour = clock_is_24h_style();
 
 	window_init(&window, "Main");
 	window_stack_push(&window, true);
 
 	resource_init_current_app(&RESOURCES);
 
-	//font_thin = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ARIAL_16));
-	font_thick = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ARIAL_BLACK_30));
+	font_time = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GILLSANS_32));
 
 	layer_init(&bg_layer, GRect(0, 0, W, H));
 	layer_add_child(&window.layer, &bg_layer);
 {
 	(void) ctx;
 
-	//fonts_unload_custom_font(font_thin);
-	fonts_unload_custom_font(font_thick);
+	fonts_unload_custom_font(font_time);
 }