Source

vectorscope / scopeclock.c

Diff from to

scopeclock.c

 }
 
 
+static void
+analog_clock(void)
+{
+	// Draw all the digits around the outside
+	for (uint8_t h = 0 ; h < 24 ; h++)
+	{
+		uint16_t h2 = h;
+		h2 = (h2 * 682) / 64;
+		uint8_t x = sin_lookup(h2) * 7 / 8 + 128;
+		uint8_t y = cos_lookup(h2) * 7 / 8 + 128;
+		draw_digit(x-8, y-4, h / 10);
+		draw_digit(x+2, y-4, h % 10);
+	}
+
+	// Draw the hour hand
+	cli();
+	uint16_t ms = now_ms;
+	uint8_t h = now_hour;
+	uint8_t m = now_min;
+	uint8_t s = now_sec;
+	sei();
+
+	const uint8_t cx = 72;
+	const uint8_t cy = 64;
+
+	draw_digit_big( 0+cx, cy, h / 10);
+	draw_digit_big(16+cx, cy, h % 10);
+	draw_digit_big(40+cx, cy, m / 10);
+	draw_digit_big(56+cx, cy, m % 10);
+	draw_digit_big(80+cx, cy, s / 10);
+	draw_digit_big(96+cx, cy, s % 10);
+
+	{
+		uint16_t h2 = h;
+		h2 = (h2 * 682 + m*11) / 64;
+		uint8_t hx = sin_lookup(h2) * 3 / 8 + 128;
+		uint8_t hy = cos_lookup(h2) * 3 / 8 + 128;
+		line(128, 128, hx, hy);
+	}
+
+
+	{
+		uint16_t m2 = m;
+		m2 = (m2 * 273 + s*4) / 64;
+		uint8_t mx = sin_lookup(m2) * 5 / 8 + 128;
+		uint8_t my = cos_lookup(m2) * 5 / 8 + 128;
+		line(128, 128, mx, my);
+		line_horiz(mx - 5, my, 10);
+		line_vert(mx, my - 5, 10);
+	}
+
+
+	// seconds to "degrees" = 
+	{
+		uint16_t s2 = s;
+		s2 = (s2 * 1092 + ms) / 256;
+		uint8_t sx = sin_lookup(s2) * 6 / 8 + 128;
+		uint8_t sy = cos_lookup(s2) * 6 / 8 + 128;
+		line(128, 128, sx, sy);
+	}
+
+/*
+	line_horiz(0,0,255);
+	line_horiz(0,255,255);
+	line_vert(0,0,255);
+	line_vert(255,0,255);
+*/
+}
+
 int main(void)
 {
 	// set for 16 MHz clock
 
 	while (1)
 	{
-		planet_loop();
-
-#if 0
-		if (count++ == 100)
-		{
-			count = 0;
-			if (px < 30)
-				px++;
-			else
-				px = 0;
-	
-			if (py < 120)
-				py += 3;
-			else
-				py = 0;
-		}
-
-
-		// Draw all the digits around the outside
-		for (uint8_t h = 0 ; h < 24 ; h++)
-		{
-			uint16_t h2 = h;
-			h2 = (h2 * 682) / 64;
-			uint8_t x = sin_lookup(h2) * 7 / 8 + 128;
-			uint8_t y = cos_lookup(h2) * 7 / 8 + 128;
-			draw_digit(x-8, y-4, h / 10);
-			draw_digit(x+2, y-4, h % 10);
-		}
-#endif
-
-		// Draw the hour hand
-		cli();
-		uint16_t ms = now_ms;
-		uint8_t h = now_hour;
-		uint8_t m = now_min;
-		uint8_t s = now_sec;
-		sei();
-
-		const uint8_t cx = 72;
-		const uint8_t cy = 64;
-
-		draw_digit_big( 0+cx, cy, h / 10);
-		draw_digit_big(16+cx, cy, h % 10);
-		draw_digit_big(40+cx, cy, m / 10);
-		draw_digit_big(56+cx, cy, m % 10);
-		draw_digit_big(80+cx, cy, s / 10);
-		draw_digit_big(96+cx, cy, s % 10);
-
-#if 0
-		{
-			uint16_t h2 = h;
-			h2 = (h2 * 682 + m*11) / 64;
-			uint8_t hx = sin_lookup(h2) * 3 / 8 + 128;
-			uint8_t hy = cos_lookup(h2) * 3 / 8 + 128;
-			line(128, 128, hx, hy);
-		}
-
-
-		{
-			uint16_t m2 = m;
-			m2 = (m2 * 273 + s*4) / 64;
-			uint8_t mx = sin_lookup(m2) * 5 / 8 + 128;
-			uint8_t my = cos_lookup(m2) * 5 / 8 + 128;
-			line(128, 128, mx, my);
-			line_horiz(mx - 5, my, 10);
-			line_vert(mx, my - 5, 10);
-		}
-
-
-		// seconds to "degrees" = 
-		{
-			uint16_t s2 = s;
-			s2 = (s2 * 1092 + ms) / 256;
-			uint8_t sx = sin_lookup(s2) * 6 / 8 + 128;
-			uint8_t sy = cos_lookup(s2) * 6 / 8 + 128;
-			line(128, 128, sx, sy);
-		}
-
-/*
-		line_horiz(0,0,255);
-		line_horiz(0,255,255);
-		line_vert(0,0,255);
-		line_vert(255,0,255);
-*/
-#endif
+		if (0)
+			planet_loop();
+		else
+			analog_clock();
 	}
 }