Commits

Trammell Hudson committed bf92fdd

Move the time to stay in the black ocean area

Comments (0)

Files changed (1)

worldmap/src/worldmap.c

 #include <pebble_fonts.h>
 
 PBL_APP_INFO(
-	"World map",
+	"Polar Map",
 	"hudson",
 	1, // Version
 	RESOURCE_ID_IMAGE_MENU_ICON,
 )
 {
 	(void) ctx;
+#undef CONFIG_DEBUG
+#ifdef CONFIG_DEBUG
+	// Fake the time
+	PblTm real_ptm = { .tm_hour = 17, .tm_min = 27 };
+	PblTm * ptm = &real_ptm;
+/*
+	static int h = 0;
+	if (++h == 24)
+		h = 0;
+	ptm->tm_hour = h;
+*/
+#else
+	// real time
 	const PblTm * const ptm = event->tick_time;
+#endif
+
+	// Adjust hour by GMT offset and reverse angle
+	// Note that this image is has GMT "noon" at the bottom.
+	// (world rotates "backwards" relative to the sun)
+	const int32_t angle = 0
+		+ (TRIG_MAX_ANGLE * gmt_offset) / 24
+		+ (TRIG_MAX_ANGLE * (ptm->tm_hour + gmt_offset)) / 24
+		+ (TRIG_MAX_ANGLE * ptm->tm_min) / (60 * 24)
+		;
+
+	const int q = (((angle + TRIG_MAX_ANGLE) & TRIG_MAX_RATIO) * 32) / TRIG_MAX_ANGLE;
+
+	// Check for quadrants to determine where to move the time
+	if (q <= 7)
+	{
+		// Upper left
+		time_layer.layer.frame.origin = GPoint(0,-6);
+	} else
+	if (q <= 15)
+	{
+		// Lower left
+		time_layer.layer.frame.origin = GPoint(0,150);
+	} else
+	if (q <= 23)
+	{
+		// Lower right
+		time_layer.layer.frame.origin = GPoint(90, 150);
+	} else
+	if (q <= 31)
+	{
+		// Upper right
+		time_layer.layer.frame.origin = GPoint(90, -6);
+	}
+
+#ifdef CONFIG_DBEUG
+	ptm->tm_min = q;
+#endif
 
 	string_format_time(
 		time_text,
 
 	text_layer_set_text(&time_layer, time_text);
 
-	// Adjust hour by GMT offset and reverse angle
-	// Note that this image is has GMT "noon" at the bottom.
-	// (world rotates "backwards" relative to the sun)
-	
-	const int32_t angle = 0
-		- (TRIG_MAX_ANGLE * gmt_offset) / 24
-		- (TRIG_MAX_ANGLE * (ptm->tm_hour + gmt_offset)) / 24
-		- (TRIG_MAX_ANGLE * ptm->tm_min) / (60 * 24)
-		;
-/*
-	const int32_t angle = 0
-		+ (TRIG_MAX_ANGLE * ptm->tm_sec) / 60;
-*/
-
-	rotbmp_pair_layer_set_angle(&map_container.layer, angle);
+	rotbmp_pair_layer_set_angle(&map_container.layer, -angle);
 	layer_mark_dirty(&map_container.layer.layer);
 }
 
 
 	rotbmp_pair_layer_set_src_ic(&map_container.layer, GPoint(100,100));
 
-	// No dest_ic routines?
+	// No dest_ic routines?  Relocate the point of rotation to
+	// the center of the map for both layers.
 	map_container.layer.white_layer.dest_ic = GPoint(144/2, 168/2);
 	map_container.layer.black_layer.dest_ic = GPoint(144/2, 168/2);
 
 		.deinit_handler	= handle_deinit,
 		.tick_info	= {
 			.tick_handler = handle_tick,
+#ifdef CONFIG_DEBUG
 			.tick_units = MINUTE_UNIT,
-			//.tick_units = SECOND_UNIT,
+#else
+			.tick_units = SECOND_UNIT,
+#endif
 		},
 	};