Commits

Trammell Hudson  committed 66ab229

PWM second hand

  • Participants
  • Parent commits 6c53bf5

Comments (0)

Files changed (1)

File alphaclock_18_Rev1_0/alphaclock_18_Rev1_0.pde

 			digit_write_pwm(j, c, dots, on_period, off_period);
 		}
 	}
+
+	const uint8_t pos = (SecNow * 2) / 15; // 0-7
+	const uint16_t rem = (SecNow * 2) % 15; // 0-15
+	const uint8_t old_on = (on_period * (16 - rem)) / 128; // fade fast
+	uint16_t old_off = (off_period * (rem+1)) / 15; // fade fast
+	if (old_off > 255)
+		old_off = 255;
+
+	for (byte i = 0 ; i < loops ; i++)
+	{
+		// Draw the two spinners for the second hand
+#define SPINNER ('`' + 1)
+		digit_write_pwm(NUM_DIGITS-1, SPINNER + pos, '_', on_period, off_period);
+		digit_write_pwm(NUM_DIGITS-1, SPINNER + (pos + 7) % 8, '_', old_on, old_off);
+	}
 }
 
 
       // "Normal" time display:
       //display[0] = AMPM24HdisplayNow;
       //display[0] = (SecNow % 8) + 1 + 8  + '`'; // chaser
+      display_char(0, HrNowTens + '0');
+      display_char(1, HrNowOnes + '0');
+      display_char(2, MinNowTens + '0');
       display_char(3, MinNowOnes + '0');
-      display_char(2, MinNowTens + '0');
-      display_char(1, HrNowOnes + '0');
-      display_char(0, HrNowTens + '0');
-      display_char(4, (SecNow % 8) + 1 + '`'); // Spinner
+      display_char(4, ' '); // leave blank for spinner
 
       // Leading-Zero blanking for 12-hour mode:
 
     }
 
     // Add time delimiter (colon) for time display, whether that's "real" time or the alarm.
-    display_dots[1] = DOT_BOTTOM;
-    display_dots[2] = DOT_TOP;
+    if (SecNow % 2)
+	{
+	    display_dots[1] = DOT_BOTTOM;
+	    display_dots[2] = DOT_TOP;
+	} else {
+	    display_dots[1] = ' ';
+	    display_dots[2] = ' ';
+	}
 
     if (AlarmEnabled)
       display_dots[0] = DOT_TOP;