|
@@ -9,6 +9,9 @@
|
|
|
|
|
|
I2C i2c(PA_10, PA_9);
|
|
I2C i2c(PA_10, PA_9);
|
|
// SWO_Channel swo("swo");
|
|
// SWO_Channel swo("swo");
|
|
|
|
+#ifdef REVISION_B
|
|
|
|
+Serial serial(PB_6, PB_7);
|
|
|
|
+#endif
|
|
|
|
|
|
typedef enum {
|
|
typedef enum {
|
|
Decrementing = 0,
|
|
Decrementing = 0,
|
|
@@ -164,6 +167,10 @@ void RngUpdateCallback(void) {
|
|
|
|
|
|
int main() {
|
|
int main() {
|
|
|
|
|
|
|
|
+#ifdef REVISION_B
|
|
|
|
+ serial.baud(115200);
|
|
|
|
+#endif
|
|
|
|
+
|
|
// Initialize pointers in global data structure
|
|
// Initialize pointers in global data structure
|
|
for (int i = 0; i < NUM_TUBES; i++) {
|
|
for (int i = 0; i < NUM_TUBES; i++) {
|
|
for (int j = 0; j < NUM_DIGITS; j++) {
|
|
for (int j = 0; j < NUM_DIGITS; j++) {
|
|
@@ -187,6 +194,7 @@ int main() {
|
|
|
|
|
|
int nextSecond, nextMinute, nextHour;
|
|
int nextSecond, nextMinute, nextHour;
|
|
int prevMinute, prevHour;
|
|
int prevMinute, prevHour;
|
|
|
|
+ int day, date, month, year;
|
|
bool startup = true;
|
|
bool startup = true;
|
|
|
|
|
|
// Start I2C at 400kHz for DS3231
|
|
// Start I2C at 400kHz for DS3231
|
|
@@ -221,8 +229,8 @@ int main() {
|
|
|
|
|
|
// wait(3);
|
|
// wait(3);
|
|
|
|
|
|
- // DS3231_SetTime(00, 24, 10, true);
|
|
|
|
- // DS3231_SetDate(6, 17, 2, 19, 0);
|
|
|
|
|
|
+ // DS3231_SetTime(00, 13, 21);
|
|
|
|
+ // DS3231_SetDate(MONDAY, 11, 3, 19, 0);
|
|
|
|
|
|
// Setup a ticker to refresh the display at 1kHz
|
|
// Setup a ticker to refresh the display at 1kHz
|
|
RefreshTicker.attach_us(RefreshTickerCallback, REFRESH_RATE_US);
|
|
RefreshTicker.attach_us(RefreshTickerCallback, REFRESH_RATE_US);
|
|
@@ -264,6 +272,10 @@ int main() {
|
|
prevHour = nextHour;
|
|
prevHour = nextHour;
|
|
|
|
|
|
DS3231_GetTime(&nextSecond, &nextMinute, &nextHour);
|
|
DS3231_GetTime(&nextSecond, &nextMinute, &nextHour);
|
|
|
|
+ DS3231_GetDate(&day, &date, &month, &year);
|
|
|
|
+
|
|
|
|
+ // Compensate for daylight savings time
|
|
|
|
+ nextHour = IsDst(day, date, month, nextHour) ? (nextHour + 1) % 12 : nextHour % 12;
|
|
|
|
|
|
// Update the display configuration based on the new/previous time
|
|
// Update the display configuration based on the new/previous time
|
|
if (startup || prevHour / 10 != nextHour / 10) {
|
|
if (startup || prevHour / 10 != nextHour / 10) {
|