Calling a "program" anything you want to schedule for the future, like "n minutes on, m minutes off, with this message."
- Enter start/stop/duration into webform
- #3 in the middle
Once RTC chip gets here, this will get more complex.
See https://github.com/contrem/arduino-timer as referenced in #3.
In this example, continuePlayingMySong() would increment (internally?) and then know what it was supposed to be doing. So in terms of K, it would be something like 111010111 for timing, with 1 being gpio on and 0 being off.
// call the repeat_x_times function every 1000 millis (1 second)
timer.every(1000, repeat_x_times, (void *)10);
I am also looking at other timing libraries; this one might not be the best for this part of the project.
I wrote some code and then tested it. The problem with arduino-timer is that it (as it is supposed to) doesn't block, or at least I can't make it.
Here is an idea: https://github.com/contrem/arduino-timer/discussions/53#discussioncomment-1269463
`timer.every(shortestNoteLength, continuePlayingMySong);`
In this example, `continuePlayingMySong()` would increment (internally?) and then know what it was supposed to be doing. So in terms of `K`, it would be something like
`111010111` for timing, with 1 being gpio on and 0 being off.
Maybe increments would look like this example?
```
size_t repeat_count = 1;
bool repeat_x_times(void *opaque) {
size_t limit = (size_t)opaque;
Serial.print("repeat_x_times: ");
Serial.print(repeat_count);
Serial.print("/");
Serial.println(limit);
return ++repeat_count <= limit; // remove this task after limit reached
}
```
```
// call the repeat_x_times function every 1000 millis (1 second)
timer.every(1000, repeat_x_times, (void *)10);
```
**I am also looking at other timing libraries; this one might not be the best *for this part* of the project.**
To summarize, there are a few places where timers are needed:
to start/stop sending anything at all at the beginning/end of the event/race
to start/stop sending a defined message at the beginning of the "on" cycle
to start/stop sending each character in a message (dit and dah)
For the first two, arduino-timer.h looks really useful.
For the last (which I need to code first), it looks like I can do one of these
use millis() to track time inside a function with while
not sure if this will work or not
"And note - you do not use "while" loops in any program that requires multi-tasking - doing more than one thing at a time. And "delay()" is itself, a while loop, so you cannot use that." https://forum.arduino.cc/t/millis-and-while-loop/615016/5
use a library like Switch_lib
might need to modify to use milliseconds directly
use another library
To summarize, there are a few places where timers are needed:
- to start/stop sending anything at all at the beginning/end of the event/race
- to start/stop sending a defined message at the beginning of the "on" cycle
- to start/stop sending each character in a message (dit and dah)
For the first two, `arduino-timer.h` looks really useful.
For the last (which I need to code first), it looks like I can do one of these
- use `millis()` to track time inside a function with `while`
- not sure if this will work or not
- "And note - you do not use "while" loops in any program that requires multi-tasking - doing more than one thing at a time. And "delay()" is itself, a while loop, so you cannot use that." https://forum.arduino.cc/t/millis-and-while-loop/615016/5
- use a library like `Switch_lib`
- might need to modify to use milliseconds directly
- use another library
Maybe stop trying to reinvent the wheel.
- https://github.com/ggoraa/MorsDuino
- https://github.com/milador/EasyMorse uses delay()
- https://github.com/markfickett/arduinomorse looks neat
- https://github.com/imfrancisd/MorseCodeMachine uses delay()
- https://github.com/DefProc/lewis can also listen, a little more complex
- https://charlesreid1.com/wiki/Arduino/Morse_Library
- https://github.com/ridencww/cww_MorseTx uses delay()
- https://github.com/etherkit/MorseArduino allegedly doesn't block https://github.com/etherkit/MorseArduino/issues/1, but I can't get it to work at all
- https://search.arduino.cc/search?tab=reference&q=morse more to look at
- https://github.com/jandelgado/jled looks neat, haven't tried
ETA: This might be OK. The webserver is asynchronous, so I'm able to enter a new value into the webform to control whether the message sends, and it gets caught in if() on the next loop(). You just can't (yet) stop the message in the middle, but for this application you would have to wait less than a minute at most.
Unless you want it running continuously for training, hmm. Weighing the perfect and the good here.
Found a bunch I couldn't make work.
Telegraph works, but uses delay(). Sigh. https://git.kj7rrv.com/kj7rrv/Telegraph/src/branch/main/Telegraph.cpp
ETA: This might be OK. The webserver is asynchronous, so I'm able to enter a new value into the webform to control whether the message sends, and it gets caught in `if()` on the next `loop()`. You just can't (yet) stop the message in the middle, but for this application you would have to wait less than a minute at most.
Unless you want it running continuously for training, hmm. Weighing the perfect and the good here.
This issue has gotten a bit muddled, but I will note that as of 3977971341, I can control whether a gpio/LED is sending a Morse message or not from the web UI.
use this issue to discuss scheduling program start
This issue has gotten a bit muddled, but I will note that as of 39779713415f553833cc20805401087171900b2a, I can control whether a gpio/LED is sending a Morse message or not from the web UI.
# use #3 to discuss sending code
# use this issue to discuss scheduling program start
mattbk
changed title from Set timer to start and stop keying radio to Set timer to start and stop program2023-08-31 09:51:36 -05:00
Hi! I'm the developer of the Telegraph library. It looks like you found a solution, but if you ever want to use Telegraph but it doesn't do everything you'd need, feel free to submit an issue or PR on its repo. 73
Hi! I'm the developer of the Telegraph library. It looks like you found a solution, but if you ever want to use Telegraph but it doesn't do everything you'd need, feel free to submit an issue or PR on its repo. 73
@kj7rr, thanks for the work you've done. I'll think about any changes I might make, but this whole codebase is pretty much me learning by breaking things!
@kj7rr, thanks for the work you've done. I'll think about any changes I might make, but this whole codebase is pretty much me learning by breaking things!
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Calling a "program" anything you want to schedule for the future, like "n minutes on, m minutes off, with this message."
Once RTC chip gets here, this will get more complex.
See https://github.com/contrem/arduino-timer as referenced in #3.
I wrote some code and then tested it. The problem with arduino-timer is that it (as it is supposed to) doesn't block, or at least I can't make it.
Here is an idea: https://github.com/contrem/arduino-timer/discussions/53#discussioncomment-1269463
timer.every(shortestNoteLength, continuePlayingMySong);In this example,
continuePlayingMySong()would increment (internally?) and then know what it was supposed to be doing. So in terms ofK, it would be something like111010111for timing, with 1 being gpio on and 0 being off.Maybe increments would look like this example?
I am also looking at other timing libraries; this one might not be the best for this part of the project.
To summarize, there are a few places where timers are needed:
For the first two,
arduino-timer.hlooks really useful.For the last (which I need to code first), it looks like I can do one of these
millis()to track time inside a function withwhileSwitch_libMaybe stop trying to reinvent the wheel.
Found a bunch I couldn't make work.
Telegraph works, but uses delay(). Sigh. https://git.kj7rrv.com/kj7rrv/Telegraph/src/branch/main/Telegraph.cpp
ETA: This might be OK. The webserver is asynchronous, so I'm able to enter a new value into the webform to control whether the message sends, and it gets caught in
if()on the nextloop(). You just can't (yet) stop the message in the middle, but for this application you would have to wait less than a minute at most.Unless you want it running continuously for training, hmm. Weighing the perfect and the good here.
Errors in arduinomorse:

JLED looks like a winner! I can start and stop sending midstream from the webui.
Sometimes it stops with the LED on, so will need to fix that.
This issue has gotten a bit muddled, but I will note that as of
3977971341, I can control whether a gpio/LED is sending a Morse message or not from the web UI.use #3 to discuss sending code
use this issue to discuss scheduling program start
Set timer to start and stop keying radioto Set timer to start and stop programClosed in #24.
Hi! I'm the developer of the Telegraph library. It looks like you found a solution, but if you ever want to use Telegraph but it doesn't do everything you'd need, feel free to submit an issue or PR on its repo. 73
@kj7rr, thanks for the work you've done. I'll think about any changes I might make, but this whole codebase is pretty much me learning by breaking things!