From e573c1ed1b0e19b6dcdbf79b75aca7fd0793a4cf Mon Sep 17 00:00:00 2001 From: mattbk Date: Sun, 27 Aug 2023 22:35:16 -0500 Subject: [PATCH] Snapshot. --- vulpes/src/main.cpp | 75 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 5 deletions(-) diff --git a/vulpes/src/main.cpp b/vulpes/src/main.cpp index 83b97a9..a5966d0 100644 --- a/vulpes/src/main.cpp +++ b/vulpes/src/main.cpp @@ -66,7 +66,8 @@ const int output26 = 26; const int output27 = 27; // Timers -auto timer = timer_create_default(); +//auto timer = timer_create_default(); +Timer<1> timer; auto time_until_start = timer_create_default(); // Example from https://github.com/contrem/arduino-timer#examples @@ -143,15 +144,74 @@ 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(); +} + +// ^^^^ + +//================================================================================ +// setup(): stuff that only gets done once, after power up (KB1OIQ's description) +//================================================================================ void setup() { Serial.begin(115200); // 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); + //timer.every(10000, toggle_led); // call the toggle_gpio_26 function - timer.every(1000, toggle_gpio_26); + //timer.every(1000, toggle_gpio_26); // Initialize the output variables as outputs pinMode(output26, OUTPUT); @@ -224,6 +284,11 @@ void setup() { }); server.onNotFound(notFound); server.begin(); + + + // Try to send "K" on startup? What about spaces? Don't use delay(); + k(); + } void loop() { @@ -232,8 +297,8 @@ void loop() { timer.tick(); String yourInputString = readFile(SPIFFS, "/inputString.txt"); - int yourInputInt = readFile(SPIFFS, "/inputInt.txt").toInt(); - float yourInputFloat = readFile(SPIFFS, "/inputFloat.txt").toFloat(); + // int yourInputInt = readFile(SPIFFS, "/inputInt.txt").toInt(); + // float yourInputFloat = readFile(SPIFFS, "/inputFloat.txt").toFloat(); // Blink LED according to seconds entered // if (yourInputInt > 0) {