From 557a3b3e35fc1de1306b6309d248e133a804d3f1 Mon Sep 17 00:00:00 2001 From: g7uhn Date: Mon, 16 Nov 2020 22:40:57 +0000 Subject: [PATCH] Fixed "opt in" statement --- Arduino/src/main.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Arduino/src/main.cpp b/Arduino/src/main.cpp index a0afb23..a775aed 100644 --- a/Arduino/src/main.cpp +++ b/Arduino/src/main.cpp @@ -21,6 +21,9 @@ such that you can restore your radio if the worst happens! :-) */ +// uncomment this if you want to use the functions that WRITE to the EEPROM and accept the responsibility stated above! :-) +// #define EEPROM_WRITES + // Include libraries #include // required for PlatformIO IDE (not required if you're using Arduino IDE) #include @@ -29,9 +32,6 @@ #include #include // https://github.com/stdevPavelmc/ft817/tree/main/lib/ft817 -// uncomment this if you want to use the functions that WRITE to the EEPROM and accept the responsibility stated above! :-) -//#define EEPROM_WRITES - // Declarations Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3); // pins for (CLK,DIN,D/C,CE,RST) FT817 radio; // define “radio” so that we may pass CAT and EEPROM commands @@ -137,7 +137,6 @@ boolean page1SoftkeyStatus6() {} void setup(void) { // Start serial - // Serial.begin(9600); // serial port for the main sketch to talk to PC serial monitor radio.begin(38400); // start the serial port for the CAT library // Set up some pins @@ -173,9 +172,6 @@ void setup(void) display.drawFastHLine(0, 30, 24, BLACK); display.drawFastHLine(60, 30, 24, BLACK); - // Display the FT-817 A,B,C keys g7uhn TO DO: move this into a periodic check of radio status along with SW1-6 status indications - //displayABCkeys(); - // Display the soft keys by calling changePage() changePage(); @@ -187,6 +183,22 @@ void setup(void) void loop() // MAIN LOOP { + #ifndef EEPROM_WRITES // if user has not accepted risk/responsibility of EEPROM writes, display a reminder :-) + display.setCursor(0, 0); + display.setTextSize(1); + display.setTextColor(BLACK, WHITE); + display.println(" Please agree "); + display.println(" to EEPROM "); + display.println(" writes to "); + display.println(" continue... "); + display.println(" See notes in "); + display.println(" the code "); + display.display(); + delay(2000); + #endif + + #ifdef EEPROM_WRITES // if user has accepted the risk/responsibility of EEPROM writes, go ahead and run the main code block... + // Using two loops to avoid polling the radio too quickly with things we don't need a fast refresh on: // 1) a "fast refresh" loop is run within the main loop for status items that we do want a quick refresh rate e.g. frequency and mode display // 2) actions we only need a "slow refresh" are performed outside of the fast loop in the main loop e.g. status bits against soft-key labels @@ -399,6 +411,7 @@ display.display(); // update display sw9status = HIGH; // reset sw9status to high +#endif } // END OF MAIN LOOP