Commits

Trammell Hudson committed cdd4926

Hour hand drawing works

  • Participants
  • Parent commits c2fdeca

Comments (0)

Files changed (1)

 
 
 static uint8_t last_sec;
+static uint16_t last_angle;
 static PulseResource image_id;
 #define CX (SCREEN_WIDTH/2)
 #define CY (81/2 + 8)
 static const color24_t day_color = { 99, 45, 59 };
 static const color24_t date_color = { 65, 34, 52 };
 static const color24_t time_color = { 248, 90, 64 };
+static const color24_t hand_color = { 50, 64, 183 };
 
 
 void
 {
 	init();
 	last_sec = -1;
+	last_angle = -1;
 }
 
 
 	uint16_t angle
 )
 {
-	int32_t rad = 40;
-	static uint16_t last_angle;
+	const int32_t rad = 32;
 
 	if (angle == last_angle)
 		return;
 
 	// Fill in the old hand
+	int32_t s = sin_lookup(last_angle);
+	int32_t c = cos_lookup(last_angle);
+	int32_t dx = +(s * rad) / 32768;
+	int32_t dy = -(c * rad) / 32768;
+	int32_t sx = +(c * 5) / 32768;
+	int32_t sy = +(s * 5) / 32768;
+	
 	draw_line_bg(
 		image_id,
 		IMG_X,
 		IMG_Y,
-		CX,
-		CY,
-		CX + (sin_lookup(last_angle) * rad) / 32768,
-		CY - (cos_lookup(last_angle) * rad) / 32768
+		CX + sx,
+		CY + sy,
+		CX + dx,
+		CY + dy
+	);
+
+	draw_line_bg(
+		image_id,
+		IMG_X,
+		IMG_Y,
+		CX - sx,
+		CY - sy,
+		CX + dx,
+		CY + dy
+	);
+
+	s = sin_lookup(angle);
+	c = cos_lookup(angle);
+	dx = +(s * rad) / 32768;
+	dy = -(c * rad) / 32768;
+	sx = +(c * 5) / 32768;
+	sy = +(s * 5) / 32768;
+
+
+	draw_line(
+		hand_color,
+		CX + sx,
+		CY + sy,
+		CX + dx,
+		CY + dy
 	);
 
 	draw_line(
-		COLOR_BLUE,
-		CX,
-		CY,
-		CX + (sin_lookup(angle) * rad) / 32768,
-		CY - (cos_lookup(angle) * rad) / 32768
+		hand_color,
+		CX - sx,
+		CY - sy,
+		CX + dx,
+		CY + dy
 	);
 
 	last_angle = angle;
 	uint32_t min = now.tm_min;
 	uint32_t sec = now.tm_sec;
 	
-	//uint16_t hour_angle = ((hour * 60 + min) * 65536) / (24 * 60);
-	uint16_t hour_angle = (sec * 65536) / 60;
+	uint16_t hour_angle = ((hour * 60 + min) * 65536) / (24 * 60);
+	//uint16_t hour_angle = (sec * 65536) / 60;
 	draw_hour_hand(hour_angle);
 
 	// This seems inconsistent sometimes it is full year,