Trammell Hudson avatar Trammell Hudson committed 1bae5a9 Draft

Draw the time with the planets

Comments (0)

Files changed (4)

 #include "bits.h"
 #include "clock.h"
 
+volatile uint8_t now_hour = 15;
+volatile uint8_t now_min = 0;
+volatile uint8_t now_sec = 0;
+volatile uint16_t now_ms;
+volatile uint16_t now; // ms since boot
+
 // Define CONFIG_HZ_IRQ to enable a timer interrupt rather than
 // polling the interrupt flag.
 #define CONFIG_HZ_IRQ
 #include <stdint.h>
 
 /** Track the number of miliseconds, sec, min and hour since midnight */
-volatile uint8_t now_hour;
-volatile uint8_t now_min;
-volatile uint8_t now_sec;
-volatile uint16_t now_ms;
-volatile uint16_t now; // ms since boot
+extern volatile uint8_t now_hour;
+extern volatile uint8_t now_min;
+extern volatile uint8_t now_sec;
+extern volatile uint16_t now_ms;
+extern volatile uint16_t now; // ms since boot
 
 
 void
 
 	clock_init();
 
-	planet_loop();
-
 	while (1)
 	{
+		planet_loop();
+
+#if 0
 		if (count++ == 100)
 		{
 			count = 0;
 			draw_digit(x-8, y-4, h / 10);
 			draw_digit(x+2, y-4, h % 10);
 		}
+#endif
 
 		// Draw the hour hand
 		cli();
 		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;
 		line_vert(0,0,255);
 		line_vert(255,0,255);
 */
+#endif
 	}
 }
 
 	float g = gravity(dx, dy);
 
 	// Project the gravity in the direction of the sun.
-	const float dt = 3600 * 24; // one day
+	const float dt = 3600.0; // one day
 	float theta = atan2(dy, dx);
 	s->vx += g * cos(theta) * dt;
 	s->vy += g * sin(theta) * dt;
 	int i
 )
 {
-	// Scale x and y so that 2 au == 128
-	uint8_t x = (s->x / ONE_AU) * 64 + 128;
-	uint8_t y = (s->y / ONE_AU) * 64 + 128;
+	// Scale x and y so that 1.6 au == 128
+	float x = (s->x / (ONE_AU * 1.6)) * 128 + 128;
+	float y = (s->y / (ONE_AU * 1.6)) * 128 + 128;
+	if (x < 0 || x > 250 || y < 0 || y > 250)
+		return;
 
 	//line(x, y, x+s->vx*100, y+s->vy*100);
 	draw_digit(x, y, i);
 void
 planet_loop(void)
 {
-	while (1)
+	for (int i = 0 ; i < PLANET_COUNT ; i++)
 	{
-		for (int i = 0 ; i < PLANET_COUNT ; i++)
-		{
-			planet_draw(&planets[i], i+1);
-			planet_update(&planets[i]);
-		}
+		planet_draw(&planets[i], i+1);
+		planet_update(&planets[i]);
+	}
 
-		PORTB = PORTD = 128;
-	}
+	PORTB = PORTD = 128;
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.