Commits

Trammell Hudson committed 6e50723

Only force redraw once in per second to avoid flicker

Comments (0)

Files changed (1)

fireworks/fireworks.c

 	const uint32_t sec = cur_ms % 60; cur_ms /= 60;
 	const uint8_t min = cur_ms % 60; cur_ms /= 60;
 	const uint8_t hour = cur_ms %= 24;
+	int force_redraw = 0;
+
 
 	if (cur_sec.value != sec)
 	{
+		force_redraw = 1;
+
 		//  new second time!
 		if (cur_sec.value != -1)
 		{
 
 		cur_sec.end.scale = (10 << VSCREEN_SHIFT);
 		cur_sec.end.y = VSCREEN_HEIGHT/2;
-		cur_sec.end.x = 20 << VSCREEN_SHIFT;
+		cur_sec.end.x = 15 << VSCREEN_SHIFT;
 
 		animate(&cur_sec, now_ms);
 	} else {
 
 		cur_min.end.scale = (10 << VSCREEN_SHIFT);
 		cur_min.end.y = VSCREEN_HEIGHT/2;
-		cur_min.end.x = -10 << VSCREEN_SHIFT;
+		cur_min.end.x = -15 << VSCREEN_SHIFT;
 
 		// They are not yet active, so this will draw the
 		// starting positions
 		animate(&cur_min, now_ms);
 	} else {
-		animate(&last_min, now_ms);
-		animate(&cur_min, now_ms);
+		if (force_redraw || animate_active(&last_min, now_ms))
+			animate(&last_min, now_ms);
+		if (force_redraw || animate_active(&cur_min, now_ms))
+			animate(&cur_min, now_ms);
 	}
 
 	if (cur_hour.value != hour)
 
 		cur_hour.end.scale = (10 << VSCREEN_SHIFT);
 		cur_hour.end.y = VSCREEN_HEIGHT/2;
-		cur_hour.end.x = -40 << VSCREEN_SHIFT;
+		cur_hour.end.x = -45 << VSCREEN_SHIFT;
 
 		// They are not yet active, so this will draw the
 		// starting positions
 		animate(&cur_hour, now_ms);
 	} else {
-		animate(&last_hour, now_ms);
-		animate(&cur_hour, now_ms);
+		if (force_redraw || animate_active(&last_hour, now_ms))
+			animate(&last_hour, now_ms);
+		if (force_redraw || animate_active(&cur_hour, now_ms))
+			animate(&cur_hour, now_ms);
 	}
 }
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.