From 401ebece9224f3624e2ee8f15fa0a08355437c9a Mon Sep 17 00:00:00 2001 From: DigitalConfections Date: Sun, 14 Jun 2020 15:19:05 -0400 Subject: [PATCH] Version 0.12 The > GO serial command can now be used anytime to re-sync the transmitter, not just right after power-up --- Arduino-microfox/Arduino-microfox.ino | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Arduino-microfox/Arduino-microfox.ino b/Arduino-microfox/Arduino-microfox.ino index 900e1e4..0d81f06 100644 --- a/Arduino-microfox/Arduino-microfox.ino +++ b/Arduino-microfox/Arduino-microfox.ino @@ -178,7 +178,7 @@ void wdt_init(WDReset resetType); { while(initializeEEPROMVars()) { - ; /* Initialize variables stored in EEPROM */ + ; /* Initialize variables stored in EEPROM */ } setUpTemp(); @@ -867,10 +867,17 @@ ISR( TIMER2_COMPB_vect ) * modified from ISR example for microfox by Jerry Boyd WB8WFK * this runs once a second and generates the cycle and sets control flags for the main controller. */ -ISR(TIMER1_COMPA_vect) /*timer1 interrupt 1Hz */ +ISR(TIMER1_COMPA_vect) /*timer1 interrupt 1Hz */ { static int id_countdown = 0; + if(g_seconds_since_sync == 0) /* sync just occurred */ + { + id_countdown = g_id_interval; + g_fox_counter = 1; + g_lastSeconds = 0; + } + g_seconds_since_sync++; /* Total elapsed time counter */ g_fox_seconds_into_interval++; @@ -1283,13 +1290,19 @@ void __attribute__((optimize("O0"))) handleLinkBusMsgs() { if(g_start_override) { - lb_send_string((char*)"Already synced!\n",FALSE); + lb_send_string((char*)"Re-sync successful!\n",FALSE); } else { g_start_override = TRUE; lb_send_string((char*)"Running!\n",FALSE); } + + cli(); + TCNT1 = 0; /* Initialize 1-second counter value to 0 */ + g_seconds_since_sync = 0; + g_fox_seconds_into_interval = 0; + sei(); } break;