diff --git a/vulpes/src/main.cpp b/vulpes/src/main.cpp index ab78e07..caf81d6 100644 --- a/vulpes/src/main.cpp +++ b/vulpes/src/main.cpp @@ -17,14 +17,10 @@ #include #include #include -// #include -//#include //arduino morse -//#include //etherkit morse #include // jled #include "jled/morse.h" //jled #include // for DS3231 #include // for DS3231 -//#include //for DS3231 #include // download zip from https://github.com/me-no-dev/ESPAsyncWebServer and install. @@ -154,10 +150,6 @@ const char index_html[] PROGMEM = R"rawliteral( )rawliteral"; -// Auxiliary variables to store the current output state -//String output26State = "off"; -//String output27State = "off"; - // Assign output variables to GPIO pins const int keyer = 32; //LED_BUILTIN for on-board (dev);//26 for LED; //32 for transmitter keyer const int blinker = LED_BUILTIN; @@ -174,18 +166,6 @@ bool toggle_led(void *) { return true; // keep timer active? true } -// Toggle GPIO pin (LED or relay) -// bool toggle_gpio_26(void *) { -// if(output26State == "off"){ -// output26State = "on"; -// digitalWrite(output26, HIGH); -// } else { -// output26State = "off"; -// digitalWrite(output26, LOW); -// } -// return true; // keep timer active? true -// } - void notFound(AsyncWebServerRequest *request) { request->send(404, "text/plain", "Not found"); } @@ -250,72 +230,6 @@ String processor(const String& var){ return String(); } -// // vvvvv Modify some functions from KB1OIQ's controller. -// // This section hasn't been tested on the hardware. - -// //int dit_len = 60 ; //milliseconds; https://morsecode.world/international/timing.html - -// //================================================================================ -// // stop_26(): set GPIO 26 to LOW. Used for dot(), dash(). -// //================================================================================ -// bool stop_26(void *){ -// output26State = "off"; -// digitalWrite(output26, LOW); -// return false; // keep timer active? true -// } - -// //================================================================================ -// // dit(): transmit a single dit -// //================================================================================ -// void dit(int dit_len = 1000) { -// output26State = "on"; -// digitalWrite(output26, HIGH); -// timer.in(dit_len, stop_26); -// } - -// //================================================================================ -// // dah(): transmit a single dah -// //================================================================================ -// void dah(int dit_len = 1000) { -// output26State = "on"; -// digitalWrite(output26, HIGH); -// timer.in(dit_len * 3, stop_26); -// } - -// //================================================================================ -// // char_space()): transmit a character space -// //================================================================================ -// // A function that does nothing except (hopefully) block the timer. -// bool empty(void *) { -// return false; -// } - -// void char_space(int dit_len = 1000) { - -// timer.in(dit_len, empty); -// } - -// void k(){ -// Serial.println("K"); -// dah(); -// char_space(); -// dit(); -// char_space(); -// dah(); -// } - -// // ^^^^ - -// //telegraph -// //Telegraph telegraph(LED_BUILTIN, 10, HIGH); -// Telegraph telegraph26(output26, 10, HIGH); - -//arduinomorse -//LEDMorseSender sender(LED_BUILTIN); - -//Etherkit Morse -//Morse morse(LED_BUILTIN, 15); - //jled from https://github.com/jandelgado/jled/blob/master/examples/morse/morse_effect.h class MorseEffect : public jled::BrightnessEvaluator { Morse morse_; @@ -379,18 +293,6 @@ auto morseMO5_blink = JLed(blinker).UserFunc(&morseEffectMO5).DelayAfter(word_space_ms).Forever(); auto morseToSend_blink = morseTEST_blink; // set this up to overwrite later - -// format and print a time_t value -// void printTime(time_t t) -// { -// char buf[25]; -// char m[4]; // temporary storage for month string (DateStrings.cpp uses shared buffer) -// strcpy(m, monthShortStr(month(t))); -// sprintf(buf, "%.2d:%.2d:%.2d %s %.2d %s %d", -// hour(t), minute(t), second(t), dayShortStr(weekday(t)), day(t), m, year(t)); -// Serial.println(buf); -// } - //================================================================================ // start_program(): a function to start the planned program at the planned time //================================================================================ @@ -407,20 +309,6 @@ void setup() { Serial.begin(115200); pinMode(alarmPin, INPUT_PULLUP); // Set alarm pin as pullup - // Disable and clear both alarms - // rtc.disableAlarm(1); - // rtc.disableAlarm(2); - // rtc.clearAlarm(1); - // rtc.clearAlarm(2); - // rtc.writeSqwPinMode(DS3231_OFF); // Place SQW pin into alarm interrupt mode - - // https://github.com/JChristensen/DS3232RTC/blob/master/examples/TimeRTC/TimeRTC.ino - // rtc.begin(); - // setSyncProvider(rtc.get); // the function to get the time from the RTC - // if(timeStatus() != timeSet) - // Serial.println("Unable to sync with the RTC"); - // else - // Serial.println("RTC has set the system time"); if (! rtc.begin()) { Serial.println("Couldn't find RTC"); @@ -444,13 +332,6 @@ void setup() { Serial.print(alarm_one.toString(buff)); Serial.println(" (only HH:MM:SS day-of-month are accurate)"); - // Timer example, blink main LED - pinMode(LED_BUILTIN, OUTPUT); // set LED pin to OUTPUT - // call the toggle_led function every 10000 millis (10 second) - //timer.every(10000, toggle_led); - // call the toggle_gpio_26 function - //timer.every(1000, toggle_gpio_26); - // Initialize the output variables as outputs pinMode(keyer, OUTPUT); pinMode(blinker, OUTPUT); @@ -460,34 +341,15 @@ void setup() { // Initialize SPIFFS SPIFFS.begin(true); - //#ifdef ESP32 if(!SPIFFS.begin(true)){ Serial.println("An Error has occurred while mounting SPIFFS"); return; } - //#else if(!SPIFFS.begin()){ Serial.println("An Error has occurred while mounting SPIFFS"); return; } - //#endif - // Make sure files exist, maybe with defaults here - // if(SPIFFS.exists("/inputString.txt") == 0){ - // writeFile(SPIFFS, "/inputString.txt", "CQ"); - // } - // if(SPIFFS.exists("/inputSend.txt") == 0){ - // writeFile(SPIFFS, "/inputSend.txt", "0"); - // } - // if(SPIFFS.exists("/inputWPM.txt") == 0){ - // writeFile(SPIFFS, "/inputWPM.txt", "10"); - // } - // if(SPIFFS.exists("/inputMsg.txt") == 0){ - // writeFile(SPIFFS, "/inputMsg.txt", "0"); - // } - // if(SPIFFS.exists("/inputFloat.txt") == 0){ - // writeFile(SPIFFS, "/inputFloat.txt", "1.1"); - // } // Read in existing data @@ -639,25 +501,12 @@ void setup() { Serial.print(alarm_one.toString(buff)); Serial.println(" (only HH:MM:SS day-of-month are accurate)"); } - // else { - // inputMessage = "No message sent"; - // } - //request->send(200, "text/plain", inputMessage); // https://techtutorialsx.com/2018/01/14/esp32-arduino-http-server-external-and-internal-redirects/ request->redirect("/"); }); server.onNotFound(notFound); server.begin(); - //telegraph - //telegraph.send("CQ CQ CQ"); - //telegraph26.send("CQ CQ CQ DE W1CDN K"); - - // arduinomorse - // sender.setup(); - // sender.setMessage(String("73 de kb3jcy ")); - // sender.startSending(); - } void loop() { @@ -677,26 +526,6 @@ void loop() { rtc.clearAlarm(2); // clear the other one just in case } - // DateTime now = rtc.now(); - // Serial.print(now.year(), DEC); - // Serial.print('/'); - // Serial.print(now.month(), DEC); - // Serial.print('/'); - // Serial.print(now.day(), DEC); - // Serial.print(" ("); - // Serial.print(now.dayOfTheWeek()); - // Serial.print(") "); - // Serial.print(now.hour(), DEC); - // Serial.print(':'); - // Serial.print(now.minute(), DEC); - // Serial.print(':'); - // Serial.print(now.second(), DEC); - // Serial.println(); - - - //arduinomorse - //sender.continueSending(); - // See which message we are sending // Only do this when the message has been updated. if(yourInputMsg != yourInputMsg_old){ @@ -756,21 +585,4 @@ void loop() { } //morseToSend.Update(); - - - // Blink LED according to seconds entered - // if (yourInputInt > 0) { - // Serial.println("GPIO 26 on"); - // output26State = "on"; - // digitalWrite(output26, HIGH); - // delay(yourInputInt * 1000); - // Serial.println(yourInputInt); - // Serial.println("GPIO 26 off"); - // output26State = "off"; - // digitalWrite(output26, LOW); - // delay(yourInputInt * 1000); - // } else { - // output26State = "off"; - // } - } \ No newline at end of file