From 48de083c0d3d31d08b056ca1167e8a8e66948146 Mon Sep 17 00:00:00 2001 From: vk3il Date: Sun, 7 May 2017 21:49:16 +1000 Subject: [PATCH 1/7] Added AUTO_BAND feature Added AUTO_BAND feature and extended S_ERROR to include an error number for debugging purposes. --- SODA_POP/SODA_POP.h | 5 +++ SODA_POP/SODA_POP.ino | 102 +++++++++++++++++++++++++++++++++++++++--- SODA_POP/buttons.ino | 2 +- SODA_POP/display.ino | 4 +- SODA_POP/settings.h | 3 ++ 5 files changed, 108 insertions(+), 8 deletions(-) diff --git a/SODA_POP/SODA_POP.h b/SODA_POP/SODA_POP.h index 03beeb5..4cb68b2 100644 --- a/SODA_POP/SODA_POP.h +++ b/SODA_POP/SODA_POP.h @@ -87,6 +87,11 @@ byte memory_index_character; #define EEPROM_CW_SPEED 7 // 1 byte #endif +#ifdef AUTO_BAND +#define PCA9536_BUS_ADDR 0x41 // I2C address for PCA9536 +#undef OPT_BAND_SELECT +#endif + #endif // vim: tabstop=2 shiftwidth=2 expandtab: diff --git a/SODA_POP/SODA_POP.ino b/SODA_POP/SODA_POP.ino index 60facce..ac2f4a1 100644 --- a/SODA_POP/SODA_POP.ino +++ b/SODA_POP/SODA_POP.ino @@ -70,6 +70,7 @@ Si5351 si5351; #define IF_DEFAULT 491480000 byte memory_pointer; +byte errno; // Global error number for S_ERROR const int MUTE = A3; const int TXEN = 13; // production A0 @@ -142,11 +143,18 @@ void setup() TIMSK1 |= 1 << OCIE1A; interrupts(); +#ifdef AUTO_BAND + if (EEPROM.read(6) == 0xff) // EEPROM 6 becomes a "not calibrated" flag + state.state = S_CALIBRATION_CORRECTION; // Not sure that this will have the desired effect as + // state.state is set to S_DEFAULT a few lines below... + read_module_band(); +#else state.band = (enum band) EEPROM.read(6); // check for operating band if (state.band == BAND_UNKNOWN) { state.band = (enum band) 0; state.state = S_CALIBRATION_CORRECTION; } +#endif fetch_calibration_data(); //load calibration data si5351.set_correction(cal_value); //correct the clock chip error @@ -194,7 +202,7 @@ void loop() case S_CALIBRATION_PEAK_RX: loop_calibration_peak_rx(); break; case S_ERROR: loop_error(); break; default: - error(); + error(1); break; } @@ -237,6 +245,10 @@ void loop_default() state.idle_for = DISABLE_DISPLAY_AFTER - 500; #endif +#ifdef AUTO_BAND + if (tcount mod 5000 == 1) read_module_band(); // Check the band module for changes every 5s +#endif + if (key_active()) { state.state = S_KEYING; // Tuning with the rotary encoder @@ -795,8 +807,12 @@ void loop_calibration_peak_if() EEPROM.write(EEPROM_IF_FREQ + 1, state.op_freq >> 8); EEPROM.write(EEPROM_IF_FREQ + 2, state.op_freq >> 16); EEPROM.write(EEPROM_IF_FREQ + 3, state.op_freq >> 24); - + #ifdef AUTO_BAND + EEPROM.write(6,0); // Reset the "not calibrated" flag now that we've written the cal values + state.state = S_CALIBRATION_PEAK_RX; +#else state.state = S_CALIBRATION_CHANGE_BAND; +#endif invalidate_frequencies(); invalidate_display(); @@ -865,7 +881,7 @@ void key_handle_end() state.state = S_DEFAULT; } else if (state.state == S_MEM_ENTER) { if (memory_pointer == MEMORY_LENGTH) { - error(); + error(2); return; } buffer[memory_pointer++] = morse_char; @@ -1090,10 +1106,86 @@ void ee_erase() * Enter the error state. This error is non-recoverable and should only be used * in very rare cases. */ -void error() +void error(int er) { + errno = er; state.state = S_ERROR; - invalidate_display(); } +#ifdef AUTO_BAND +/* + * Read the input latch of the PCA9536 and return a 4-bit value + * If the band module can't be read or the value is out of range, display an error and wait for a valid band module + */ + +byte PCA9536_read() +{ + byte reg_val; + byte err = FALSE; // Flag for error reading band value + + while (!err) { + Wire.beginTransmission(PCA9536_BUS_ADDR); + Wire.write(0); // We read only from register 0, the input latch + Wire.endTransmission(); + Wire.requestFrom(PCA9536_BUS_ADDR, 1); + if (Wire.available() != 1) { // Unable to read the band module ID (most + // likely it's not plugged in properly, or being changed!) + digit4 = LED_N_6; + digit3 = LED_n; + digit2 = LED_E; + digit1 = LED_r; + err = TRUE; + delay(500); + } else { + reg_val = Wire.read() & 0x0f; + if( reg_val < 2 || reg_val > 11) { // Module has an un-supported configuration + digit4 = LED_N_6; + digit3 = LED_n; + digit2 = LED_E; + digit1 = LED_r; + err = TRUE; + delay(500); + } else err = FALSE; + } + } + return reg_val; +} + +/* + * Check if the band module has changed and if it has, reset bandlimits and operating frequency + */ + +void read_module_band() +{ + enum band new_band; + + switch (PCA9536_read()) { // Map returned value to current band table range + case 2: new_band = BAND_160; break; + case 3: new_band = BAND_80; break; +#ifdef BAND_60 + case 4: new_band = BAND_60; break; +#endif + case 5: new_band = BAND_40; break; + case 6: new_band = BAND_30; break; + case 7: new_band = BAND_20; break; + case 8: new_band = BAND_17; break; + case 9: new_band = BAND_15; break; + case 10: new_band = BAND_12; break; + case 11: new_band = BAND_10; break; + default: new_band = BAND_UNKNOWN; error(3); break; + } + + if (new_band != state.band) { + digitalWrite(MUTE, LOW); // Make sure we are in receieve mode + state.band = new_band; + digit4 = LED_N_6; + digit3 = LED_n; + setup_band(); // Set the band limits and default + // operating frequency for the selected band + invalidate_display(); + delay(2000); // Allow time to view the band on the display + } +} + +#endif // vim: tabstop=2 shiftwidth=2 expandtab: diff --git a/SODA_POP/buttons.ino b/SODA_POP/buttons.ino index 1d0fced..b486b38 100644 --- a/SODA_POP/buttons.ino +++ b/SODA_POP/buttons.ino @@ -150,7 +150,7 @@ unsigned int time_encoder_button() } /** - * Debounche the keyer button. + * Debounce the keyer button. */ void debounce_keyer() { diff --git a/SODA_POP/display.ino b/SODA_POP/display.ino index ad56ec1..a2c82eb 100644 --- a/SODA_POP/display.ino +++ b/SODA_POP/display.ino @@ -165,8 +165,8 @@ void invalidate_display() case S_ERROR: state.display.digits[3] = LED_E; state.display.digits[2] = LED_r; - state.display.digits[1] = LED_r; - state.display.digits[0] = 0x00; + state.display.digits[1] = 0x00; + state.display.digits[0] = LED_DIGITS[errno]; state.display.dots = 0x2; break; } diff --git a/SODA_POP/settings.h b/SODA_POP/settings.h index 7afd8b3..d69ec36 100644 --- a/SODA_POP/settings.h +++ b/SODA_POP/settings.h @@ -37,6 +37,9 @@ /* Band selection by pressing RIT for 2s */ #define OPT_BAND_SELECT +/* Autoband selection based on plugged in module - enabled by PCA9536 PIO on board module */ +#define AUTO_BAND + /* Erase EEPROM by pressing RIT for 8s */ #define OPT_ERASE_EEPROM From 3b0c6e74da20a28d233984be32b12342f24a341e Mon Sep 17 00:00:00 2001 From: vk3il Date: Sun, 7 May 2017 22:51:22 +1000 Subject: [PATCH 2/7] Syntax error correction Syntax error corections --- SODA_POP/SODA_POP.h | 3 +++ SODA_POP/SODA_POP.ino | 37 +++++++++++++++++-------------------- SODA_POP/settings.h | 4 ++-- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/SODA_POP/SODA_POP.h b/SODA_POP/SODA_POP.h index 4cb68b2..5d9dfe6 100644 --- a/SODA_POP/SODA_POP.h +++ b/SODA_POP/SODA_POP.h @@ -92,6 +92,9 @@ byte memory_index_character; #undef OPT_BAND_SELECT #endif +#define TRUE 1 +#define FALSE 0 + #endif // vim: tabstop=2 shiftwidth=2 expandtab: diff --git a/SODA_POP/SODA_POP.ino b/SODA_POP/SODA_POP.ino index ac2f4a1..3a656ed 100644 --- a/SODA_POP/SODA_POP.ino +++ b/SODA_POP/SODA_POP.ino @@ -246,7 +246,7 @@ void loop_default() #endif #ifdef AUTO_BAND - if (tcount mod 5000 == 1) read_module_band(); // Check the band module for changes every 5s + if (tcount % 5000 == 1) read_module_band(); // Check the band module for changes every 5s #endif if (key_active()) { @@ -1128,24 +1128,22 @@ byte PCA9536_read() Wire.write(0); // We read only from register 0, the input latch Wire.endTransmission(); Wire.requestFrom(PCA9536_BUS_ADDR, 1); - if (Wire.available() != 1) { // Unable to read the band module ID (most - // likely it's not plugged in properly, or being changed!) - digit4 = LED_N_6; - digit3 = LED_n; - digit2 = LED_E; - digit1 = LED_r; + err = FALSE; + if (Wire.available() != 1) // Unable to read the band module ID (most + // likely it's not plugged in properly, or being changed!) err = TRUE; - delay(500); - } else { + else { reg_val = Wire.read() & 0x0f; - if( reg_val < 2 || reg_val > 11) { // Module has an un-supported configuration - digit4 = LED_N_6; - digit3 = LED_n; - digit2 = LED_E; - digit1 = LED_r; - err = TRUE; - delay(500); - } else err = FALSE; + if( reg_val < 2 || reg_val > 11) // Module has an un-supported configuration + err = TRUE; + } + if (err) { + state.display.digits[3] = LED_N_6; + state.display.digits[2] = LED_n; + state.display.digits[1] = LED_E; + state.display.digits[0] = LED_r; + state.display.dots = 0x0; + delay(500); } } return reg_val; @@ -1178,12 +1176,11 @@ void read_module_band() if (new_band != state.band) { digitalWrite(MUTE, LOW); // Make sure we are in receieve mode state.band = new_band; - digit4 = LED_N_6; - digit3 = LED_n; setup_band(); // Set the band limits and default // operating frequency for the selected band - invalidate_display(); + display_band(); delay(2000); // Allow time to view the band on the display + invalidate_display(); } } diff --git a/SODA_POP/settings.h b/SODA_POP/settings.h index d69ec36..7f8c5f1 100644 --- a/SODA_POP/settings.h +++ b/SODA_POP/settings.h @@ -26,7 +26,7 @@ * #define DEFAULT_OP_FREQ_20 1405500000 * ... setting the default frequency to 14.055 MHz on 20m. */ -#define PLAN_IARU2 +#define PLAN_IARU3 /* Custom default operating frequencies, per band, in mHz. * See bands.h for defaults */ @@ -50,7 +50,7 @@ #define OPT_DFE /* Disable display when idle */ -#define OPT_DISABLE_DISPLAY +//#define OPT_DISABLE_DISPLAY #define DISABLE_DISPLAY_AFTER 2500 /* Time to disable display after, in ms */ /* More message memories. Select using the rotary encoder. */ From 5009fba8900ddb31cc98cf65a5793f1f561a170c Mon Sep 17 00:00:00 2001 From: vk3il Date: Mon, 8 May 2017 11:59:34 +1000 Subject: [PATCH 3/7] Added debug code to PCA9536_read() Need to find out why PCA9536 isn't responding. --- SODA_POP/SODA_POP.ino | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/SODA_POP/SODA_POP.ino b/SODA_POP/SODA_POP.ino index 3a656ed..b27ead2 100644 --- a/SODA_POP/SODA_POP.ino +++ b/SODA_POP/SODA_POP.ino @@ -1126,9 +1126,10 @@ byte PCA9536_read() while (!err) { Wire.beginTransmission(PCA9536_BUS_ADDR); Wire.write(0); // We read only from register 0, the input latch - Wire.endTransmission(); + err = Wire.endTransmission(); + if (err) error(err); // if transmit failed, stop for debugging Wire.requestFrom(PCA9536_BUS_ADDR, 1); - err = FALSE; + err = FALSE; if (Wire.available() != 1) // Unable to read the band module ID (most // likely it's not plugged in properly, or being changed!) err = TRUE; From 7404de27aac951acff2aa0a471307e8f5408f76b Mon Sep 17 00:00:00 2001 From: vk3il Date: Mon, 8 May 2017 12:18:07 +1000 Subject: [PATCH 4/7] Debugging Added repeated start condition to I2C transmission --- SODA_POP/SODA_POP.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SODA_POP/SODA_POP.ino b/SODA_POP/SODA_POP.ino index b27ead2..6f29ab9 100644 --- a/SODA_POP/SODA_POP.ino +++ b/SODA_POP/SODA_POP.ino @@ -1126,7 +1126,7 @@ byte PCA9536_read() while (!err) { Wire.beginTransmission(PCA9536_BUS_ADDR); Wire.write(0); // We read only from register 0, the input latch - err = Wire.endTransmission(); + err = Wire.endTransmission(false); // Transmit repeated start rather than stop at end of transmission if (err) error(err); // if transmit failed, stop for debugging Wire.requestFrom(PCA9536_BUS_ADDR, 1); err = FALSE; From de6aae9567564955eeb64d97396ccb574585e41a Mon Sep 17 00:00:00 2001 From: vk3il Date: Tue, 9 May 2017 22:49:40 +1000 Subject: [PATCH 5/7] Debugging Ironed out bugs in I2C PIO code - now appears to be working --- SODA_POP/SODA_POP.ino | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/SODA_POP/SODA_POP.ino b/SODA_POP/SODA_POP.ino index 6f29ab9..253acac 100644 --- a/SODA_POP/SODA_POP.ino +++ b/SODA_POP/SODA_POP.ino @@ -1121,15 +1121,14 @@ void error(int er) byte PCA9536_read() { byte reg_val; - byte err = FALSE; // Flag for error reading band value + byte err = TRUE; // Flag for error reading band value - while (!err) { + while (err) { Wire.beginTransmission(PCA9536_BUS_ADDR); - Wire.write(0); // We read only from register 0, the input latch - err = Wire.endTransmission(false); // Transmit repeated start rather than stop at end of transmission - if (err) error(err); // if transmit failed, stop for debugging + Wire.write(byte(0x00)); // We read only from register 0, the input latch + Wire.endTransmission(false); // Transmit repeated start rather than stop at end of transmission Wire.requestFrom(PCA9536_BUS_ADDR, 1); - err = FALSE; + err = FALSE; if (Wire.available() != 1) // Unable to read the band module ID (most // likely it's not plugged in properly, or being changed!) err = TRUE; @@ -1147,6 +1146,7 @@ byte PCA9536_read() delay(500); } } + invalidate_display(); return reg_val; } From 311fd653e869c5afd354ee0ac2dcc8e84c7db089 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Tue, 16 May 2017 15:06:28 +0000 Subject: [PATCH 6/7] Preparing #22 for merging. Sensible defaults and code style. --- SODA_POP/SODA_POP.h | 5 +-- SODA_POP/SODA_POP.ino | 78 +++++++++++++++++++++---------------------- SODA_POP/display.ino | 4 +-- SODA_POP/settings.h | 7 ++-- 4 files changed, 45 insertions(+), 49 deletions(-) diff --git a/SODA_POP/SODA_POP.h b/SODA_POP/SODA_POP.h index 5d9dfe6..85c251f 100644 --- a/SODA_POP/SODA_POP.h +++ b/SODA_POP/SODA_POP.h @@ -87,14 +87,11 @@ byte memory_index_character; #define EEPROM_CW_SPEED 7 // 1 byte #endif -#ifdef AUTO_BAND +#ifdef OPT_AUTO_BAND #define PCA9536_BUS_ADDR 0x41 // I2C address for PCA9536 #undef OPT_BAND_SELECT #endif -#define TRUE 1 -#define FALSE 0 - #endif // vim: tabstop=2 shiftwidth=2 expandtab: diff --git a/SODA_POP/SODA_POP.ino b/SODA_POP/SODA_POP.ino index 253acac..4d9d098 100644 --- a/SODA_POP/SODA_POP.ino +++ b/SODA_POP/SODA_POP.ino @@ -143,16 +143,16 @@ void setup() TIMSK1 |= 1 << OCIE1A; interrupts(); -#ifdef AUTO_BAND - if (EEPROM.read(6) == 0xff) // EEPROM 6 becomes a "not calibrated" flag - state.state = S_CALIBRATION_CORRECTION; // Not sure that this will have the desired effect as - // state.state is set to S_DEFAULT a few lines below... +#ifdef OPT_AUTO_BAND + state.state = EEPROM.read(6) == 0xff ? S_CALIBRATION_CORRECTION : S_DEFAULT; read_module_band(); #else state.band = (enum band) EEPROM.read(6); // check for operating band if (state.band == BAND_UNKNOWN) { state.band = (enum band) 0; state.state = S_CALIBRATION_CORRECTION; + } else { + state.state = S_DEFAULT; } #endif @@ -163,7 +163,6 @@ void setup() invalidate_display(); delay(1000); - state.state = S_DEFAULT; invalidate_display(); digitalWrite(MUTE, LOW); @@ -245,8 +244,9 @@ void loop_default() state.idle_for = DISABLE_DISPLAY_AFTER - 500; #endif -#ifdef AUTO_BAND - if (tcount % 5000 == 1) read_module_band(); // Check the band module for changes every 5s +#ifdef OPT_AUTO_BAND + if (tcount % 5000 == 0) // Check the band module for changes every 5s + read_module_band(); #endif if (key_active()) { @@ -807,8 +807,8 @@ void loop_calibration_peak_if() EEPROM.write(EEPROM_IF_FREQ + 1, state.op_freq >> 8); EEPROM.write(EEPROM_IF_FREQ + 2, state.op_freq >> 16); EEPROM.write(EEPROM_IF_FREQ + 3, state.op_freq >> 24); - #ifdef AUTO_BAND - EEPROM.write(6,0); // Reset the "not calibrated" flag now that we've written the cal values + #ifdef OPT_AUTO_BAND + EEPROM.write(6, 0); // Reset the "not calibrated" flag now that we've written the cal values state.state = S_CALIBRATION_PEAK_RX; #else state.state = S_CALIBRATION_CHANGE_BAND; @@ -1106,37 +1106,36 @@ void ee_erase() * Enter the error state. This error is non-recoverable and should only be used * in very rare cases. */ -void error(int er) +void error(byte er) { errno = er; state.state = S_ERROR; } -#ifdef AUTO_BAND +#ifdef OPT_AUTO_BAND /* * Read the input latch of the PCA9536 and return a 4-bit value * If the band module can't be read or the value is out of range, display an error and wait for a valid band module */ - byte PCA9536_read() { byte reg_val; - byte err = TRUE; // Flag for error reading band value - - while (err) { - Wire.beginTransmission(PCA9536_BUS_ADDR); - Wire.write(byte(0x00)); // We read only from register 0, the input latch - Wire.endTransmission(false); // Transmit repeated start rather than stop at end of transmission - Wire.requestFrom(PCA9536_BUS_ADDR, 1); - err = FALSE; - if (Wire.available() != 1) // Unable to read the band module ID (most - // likely it's not plugged in properly, or being changed!) - err = TRUE; - else { - reg_val = Wire.read() & 0x0f; - if( reg_val < 2 || reg_val > 11) // Module has an un-supported configuration - err = TRUE; - } + boolean err = true; // Flag for error reading band value + + while (err) { + Wire.beginTransmission(PCA9536_BUS_ADDR); + Wire.write(byte(0x00)); // We read only from register 0, the input latch + Wire.endTransmission(false); // Transmit repeated start rather than stop at end of transmission + Wire.requestFrom(PCA9536_BUS_ADDR, 1); + err = false; + if (Wire.available() != 1) // Unable to read the band module ID (most + // likely it's not plugged in properly, or being changed!) + err = true; + else { + reg_val = Wire.read() & 0x0f; + if(reg_val < 2 || reg_val > 11) // Module has an un-supported configuration + err = true; + } if (err) { state.display.digits[3] = LED_N_6; state.display.digits[2] = LED_n; @@ -1144,21 +1143,20 @@ byte PCA9536_read() state.display.digits[0] = LED_r; state.display.dots = 0x0; delay(500); - } - } + } + } invalidate_display(); - return reg_val; + return reg_val; } /* * Check if the band module has changed and if it has, reset bandlimits and operating frequency */ - void read_module_band() -{ +{ enum band new_band; - - switch (PCA9536_read()) { // Map returned value to current band table range + + switch (PCA9536_read()) { // Map returned value to current band table range case 2: new_band = BAND_160; break; case 3: new_band = BAND_80; break; #ifdef BAND_60 @@ -1173,17 +1171,17 @@ void read_module_band() case 11: new_band = BAND_10; break; default: new_band = BAND_UNKNOWN; error(3); break; } - + if (new_band != state.band) { - digitalWrite(MUTE, LOW); // Make sure we are in receieve mode - state.band = new_band; - setup_band(); // Set the band limits and default + digitalWrite(MUTE, LOW); // Make sure we are in receieve mode + state.band = new_band; + setup_band(); // Set the band limits and default // operating frequency for the selected band display_band(); delay(2000); // Allow time to view the band on the display invalidate_display(); } } - #endif + // vim: tabstop=2 shiftwidth=2 expandtab: diff --git a/SODA_POP/display.ino b/SODA_POP/display.ino index a2c82eb..249f013 100644 --- a/SODA_POP/display.ino +++ b/SODA_POP/display.ino @@ -165,8 +165,8 @@ void invalidate_display() case S_ERROR: state.display.digits[3] = LED_E; state.display.digits[2] = LED_r; - state.display.digits[1] = 0x00; - state.display.digits[0] = LED_DIGITS[errno]; + state.display.digits[0] = LED_DIGITS[errno / 10]; + state.display.digits[0] = LED_DIGITS[errno % 10]; state.display.dots = 0x2; break; } diff --git a/SODA_POP/settings.h b/SODA_POP/settings.h index 7f8c5f1..8ab9125 100644 --- a/SODA_POP/settings.h +++ b/SODA_POP/settings.h @@ -22,11 +22,12 @@ * - PLAN_IARU1 * - PLAN_IARU2 * - PLAN_IARU3 + * - PLAN_VK * It is possible to override the default operating frequency using: * #define DEFAULT_OP_FREQ_20 1405500000 * ... setting the default frequency to 14.055 MHz on 20m. */ -#define PLAN_IARU3 +#define PLAN_IARU2 /* Custom default operating frequencies, per band, in mHz. * See bands.h for defaults */ @@ -37,8 +38,8 @@ /* Band selection by pressing RIT for 2s */ #define OPT_BAND_SELECT -/* Autoband selection based on plugged in module - enabled by PCA9536 PIO on board module */ -#define AUTO_BAND +/* Autoband selection based on plugged in module with PCA9536 PIO */ +//#define OPT_AUTO_BAND /* Erase EEPROM by pressing RIT for 8s */ #define OPT_ERASE_EEPROM From 1197d0a5b003262ef1cfc18a7e044beb3ac1b5be Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Tue, 16 May 2017 15:14:13 +0000 Subject: [PATCH 7/7] Prepare for merge --- README.md | 3 +++ SODA_POP/SODA_POP.ino | 16 ++++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d7e7aa0..9fd56de 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,7 @@ There are several features that can be added to the rig if you want to. This is done by adding and removing `#define` lines to `settings.h`. - `OPT_BAND_SELECT`: change the band by pressing RIT for 2s. +- `OPT_AUTO_BAND`: auto-select bands using a PCA9536 PIO (thanks VK3IL). - `OPT_ERASE_EEPROM`: erase the EEPROM by holding RIT for 8s. - `OPT_STORE_CW_SPEED`: store the CW speed in EEPROM. - `OPT_DFE`: direct frequency entry by holding the encoder button for 1s. @@ -208,6 +209,8 @@ Some images of the connections: ## Changelog +- 2017-05-16: + - `OPT_AUTO_BAND` (PR [#22](/../../pull/22) by VK3IL) - 2017-05-04: - Beacon mode (issue [#6](/../../issues/6)) - More logical UX for sending and storing memories, using RIT to cancel diff --git a/SODA_POP/SODA_POP.ino b/SODA_POP/SODA_POP.ino index 4d9d098..9c519a1 100644 --- a/SODA_POP/SODA_POP.ino +++ b/SODA_POP/SODA_POP.ino @@ -70,7 +70,7 @@ Si5351 si5351; #define IF_DEFAULT 491480000 byte memory_pointer; -byte errno; // Global error number for S_ERROR +byte errno; // Global error number for S_ERROR const int MUTE = A3; const int TXEN = 13; // production A0 @@ -1119,20 +1119,16 @@ void error(byte er) */ byte PCA9536_read() { - byte reg_val; - boolean err = true; // Flag for error reading band value - - while (err) { + for (boolean err = true; err; err = false) { Wire.beginTransmission(PCA9536_BUS_ADDR); Wire.write(byte(0x00)); // We read only from register 0, the input latch Wire.endTransmission(false); // Transmit repeated start rather than stop at end of transmission Wire.requestFrom(PCA9536_BUS_ADDR, 1); - err = false; - if (Wire.available() != 1) // Unable to read the band module ID (most + if (Wire.available() != 1) { // Unable to read the band module ID (most // likely it's not plugged in properly, or being changed!) err = true; - else { - reg_val = Wire.read() & 0x0f; + } else { + byte reg_val = Wire.read() & 0x0f; if(reg_val < 2 || reg_val > 11) // Module has an un-supported configuration err = true; } @@ -1173,7 +1169,7 @@ void read_module_band() } if (new_band != state.band) { - digitalWrite(MUTE, LOW); // Make sure we are in receieve mode + digitalWrite(MUTE, LOW); // Make sure we are in receive mode state.band = new_band; setup_band(); // Set the band limits and default // operating frequency for the selected band