From 067cd632d89dae99b3062fa3e7a74be783d80534 Mon Sep 17 00:00:00 2001 From: DigitalConfections Date: Tue, 11 Aug 2020 21:15:54 -0400 Subject: [PATCH] Ver 0.21 o Corrects several errors that prevented the DIP switch from being read correctly after a sync. --- Arduino-microfox/Arduino-microfox.ino | 22 +++++++++++++--------- Arduino-microfox/defs.h | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Arduino-microfox/Arduino-microfox.ino b/Arduino-microfox/Arduino-microfox.ino index cea158b..1d730dd 100644 --- a/Arduino-microfox/Arduino-microfox.ino +++ b/Arduino-microfox/Arduino-microfox.ino @@ -170,12 +170,6 @@ void softwareReset(void); pinMode(PIN_AUDIO_OUT, OUTPUT); digitalWrite(PIN_AUDIO_OUT, OFF); - pinMode(PIN_SYNC, INPUT_PULLUP); /* Sync button */ - pinMode(PIN_DIP_0, INPUT_PULLUP); /* DIP switch LSB */ - pinMode(PIN_DIP_1, INPUT_PULLUP); /* DIP switch middle bit */ - pinMode(PIN_DIP_2, INPUT_PULLUP); /* DIP switch MSB */ - digitalWrite(PIN_LED, OFF); /* Turn off led sync switch is now open */ - /* Set unused pins as outputs pulled high */ pinMode(PIN_UNUSED_7, INPUT_PULLUP); pinMode(PIN_UNUSED_8, INPUT_PULLUP); @@ -296,7 +290,7 @@ void softwareReset(void); ************************************************************************/ ISR(PCINT2_vect) { - BOOL pinVal = digitalRead(3); + BOOL pinVal = digitalRead(PIN_SYNC); if(pinVal) /* Sync is high */ { @@ -1554,13 +1548,19 @@ void doSynchronization() g_sync_pin_stable = FALSE; digitalWrite(PIN_LED,LOW); g_on_the_air = FALSE; - g_fox_counter = 1; /* Don't count on the 1-sec timer setting this in time */ + g_fox_counter = 1; /* Don't count on the 1-sec timer resetting this quickly enough */ sei(); } void setupForFox() { cli(); + pinMode(PIN_SYNC, INPUT_PULLUP); /* Sync button */ + pinMode(PIN_DIP_0, INPUT_PULLUP); /* DIP switch LSB */ + pinMode(PIN_DIP_1, INPUT_PULLUP); /* DIP switch middle bit */ + pinMode(PIN_DIP_2, INPUT_PULLUP); /* DIP switch MSB */ + digitalWrite(PIN_LED, OFF); /* Turn off led sync switch is now open */ + g_seconds_since_sync = 0; /* Total elapsed time counter */ g_on_the_air = FALSE; /* Controls transmitter Morse activity */ g_code_throttle = 0; /* Adjusts Morse code speed */ @@ -1593,14 +1593,18 @@ void setupForFox() } else /* Read DIP Switches */ { + g_fox = (FoxType)0; + if(digitalRead(PIN_DIP_0) == LOW) /*Lsb */ { - g_fox++; + g_fox += 1; } + if(digitalRead(PIN_DIP_1) == LOW) /* middle bit */ { g_fox += 2; } + if(digitalRead(PIN_DIP_2) == LOW) /* MSB */ { g_fox += 4; diff --git a/Arduino-microfox/defs.h b/Arduino-microfox/defs.h index 38377a5..6085098 100644 --- a/Arduino-microfox/defs.h +++ b/Arduino-microfox/defs.h @@ -70,7 +70,7 @@ /****************************************************** * Set the text that gets displayed to the user */ -#define SW_REVISION "0.20" +#define SW_REVISION "0.21" //#define TRANQUILIZE_WATCHDOG