Commits

Trammell Hudson committed f774c5f

demo mode works

Comments (0)

Files changed (1)

 #include "image.h"
 #include "sin_table.h"
 
+#define CONFIG_DEMO_MODE
+#ifdef CONFIG_DEMO_MODE
+static struct pulse_time_tm now;
+#endif
 
 static uint8_t last_sec;
 static uint16_t last_angle;
 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 };
+static const color24_t hand_color = { 0, 0, 20 };
 
 
 void
 button_down(void)
 {
+	last_sec = -1;
 	init();
-	last_sec = -1;
-	last_angle = -1;
 }
 
 
 void
 init(void)
 {
+#ifndef CONFIG_DEMO_MODE
+	// If not in demo mode, we read the current time
 	struct pulse_time_tm now;
 	pulse_get_time_date(&now);
+#else
+	// In demo mode we only read the year once
+	if (last_sec == (uint8_t) -1)
+		pulse_get_time_date(&now);
+	now.tm_sec = 0;
+	now.tm_min = 0;
+#endif
+
+	last_sec = -1;
+	last_angle = -1;
+
 
 	//uint32_t phase = moon_phase(now.tm_year, now.tm_mon, now.tm_mday);
 	uint32_t phase = moon_phase(now.tm_year, now.tm_mon + 1, now.tm_mday + 1);
 		image_id,
 		IMG_X,
 		IMG_Y,
+		CX - sx,
+		CY - sy,
+		CX + sx,
+		CY + sy
+	);
+
+	draw_line_bg(
+		image_id,
+		IMG_X,
+		IMG_Y,
 		CX + sx,
 		CY + sy,
 		CX + dx,
 		CY + dy
 	);
 
+	draw_line(
+		hand_color,
+		CX - sx,
+		CY - sy,
+		CX + sx,
+		CY + sy
+	);
+
 	last_angle = angle;
 }
 
 	uint32_t cur_ms
 )
 {
+#ifdef CONFIG_DEMO_MODE
+	if (++now.tm_hour == 24)
+	{
+		now.tm_hour = 0;
+		if (++now.tm_mday == 31)
+		{
+			now.tm_mday = 0;
+			if (++now.tm_mon == 12)
+				now.tm_mon = 0;
+		}
+	}
+#else
 	struct pulse_time_tm now;
 	pulse_get_time_date(&now);
 
 	if (last_sec == now.tm_sec)
 		return;
+#endif
 
 	// Every night at midnight redraw it all
 	// or every time they hit the button
-	if (last_sec == -1
+	if (last_sec == (uint8_t) -1
 	||  (now.tm_hour == 0 && now.tm_min == 0 && now.tm_sec == 0))
 		init();
 		
 	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 = ((hour * 60 * 60 + min * 60 + sec) * 32768) / (24 * 60 * 60 / 2);
+
 	//uint16_t hour_angle = (sec * 65536) / 60;
 	draw_hour_hand(hour_angle);
 
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.