Key radio as well as blinking LED #44
|
@ -27,7 +27,8 @@
|
|||
AsyncWebServer server(80);
|
||||
|
||||
// Assign output variables to GPIO pins
|
||||
const int keyer = 32; //LED_BUILTIN for on-board (dev);//26 for LED; //32 for transmitter keyer
|
||||
//LED_BUILTIN for ESP32 onboard LED, 32 for transmitter keyer
|
||||
const int keyer = 32;
|
||||
const int blinker = LED_BUILTIN;
|
||||
|
||||
RTC_DS3231 rtc; // set up RTC
|
||||
|
@ -63,9 +64,6 @@ bool programRunning;
|
|||
int yourInputStepLength;
|
||||
int yourInputCycleID;
|
||||
int yourInputNtransmitters;
|
||||
//int step_length = 10000; // 10 secs
|
||||
//int cycle_id = 1; // number of this transmitter in cycle
|
||||
//int n_transmitters = 2; //number of transmitters total
|
||||
long start_millis = 0;
|
||||
long stop_millis = 0;
|
||||
long pause_until_millis = 0;
|
||||
|
@ -247,8 +245,8 @@ String processor(const String& var){
|
|||
|
||||
|
||||
// Set up arduinomorse pin and default WPM
|
||||
LEDMorseSender sender(blinker, 10.0f) ; // the 'f' makes sure this is a float
|
||||
// TODO also for keyer once blinker works
|
||||
LEDMorseSender sender_blink(blinker, 10.0f) ; // the 'f' makes sure this is a float
|
||||
LEDMorseSender sender_key(keyer, 10.0f) ; // the 'f' makes sure this is a float
|
||||
|
||||
// Speed is milliseconds per dit, which is 1000 * (60 / (50 * WPM))
|
||||
// 60 is 20 wpm, 120 is 10 wpm, 90 is 15 wpm, etc.
|
||||
|
@ -264,7 +262,8 @@ void setup() {
|
|||
Serial.begin(115200);
|
||||
|
||||
// Get arduinomorse ready to go
|
||||
sender.setup();
|
||||
sender_blink.setup();
|
||||
sender_key.setup();
|
||||
|
||||
pinMode(alarmPin, INPUT_PULLUP); // Set alarm pin as pullup
|
||||
|
||||
|
@ -297,10 +296,10 @@ void setup() {
|
|||
|
||||
// Initialize the output variables as outputs
|
||||
pinMode(keyer, OUTPUT);
|
||||
//pinMode(blinker, OUTPUT);
|
||||
pinMode(blinker, OUTPUT);
|
||||
// Set outputs to LOW
|
||||
digitalWrite(keyer, LOW);
|
||||
//digitalWrite(blinker, LOW);
|
||||
digitalWrite(blinker, LOW);
|
||||
|
||||
// Initialize SPIFFS
|
||||
SPIFFS.begin(true);
|
||||
|
@ -327,17 +326,23 @@ void setup() {
|
|||
// On restart, keep doing what you were doing before
|
||||
yourInputMsg_old = yourInputMsg;
|
||||
if(yourInputMsg == 0){
|
||||
sender.setMessage(String("test test test de w1cdn "));
|
||||
sender_blink.setMessage(String("test test test de w1cdn "));
|
||||
sender_key.setMessage(String("test test test de w1cdn "));
|
||||
} else if(yourInputMsg == 1){
|
||||
sender.setMessage(String("moe "));
|
||||
sender_blink.setMessage(String("moe "));
|
||||
sender_key.setMessage(String("moe "));
|
||||
} else if(yourInputMsg == 2){
|
||||
sender.setMessage(String("moi "));
|
||||
sender_blink.setMessage(String("moi "));
|
||||
sender_key.setMessage(String("moi "));
|
||||
} else if(yourInputMsg == 3){
|
||||
sender.setMessage(String("mos "));
|
||||
sender_blink.setMessage(String("mos "));
|
||||
sender_key.setMessage(String("mos "));
|
||||
} else if(yourInputMsg == 4){
|
||||
sender.setMessage(String("moh "));
|
||||
sender_blink.setMessage(String("moh "));
|
||||
sender_key.setMessage(String("moh "));
|
||||
} else if(yourInputMsg == 5){
|
||||
sender.setMessage(String("mo5 "));
|
||||
sender_blink.setMessage(String("mo5 "));
|
||||
sender_key.setMessage(String("mo5 "));
|
||||
}
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
|
@ -392,17 +397,23 @@ void setup() {
|
|||
|
||||
// Check the message every time the form is submitted.
|
||||
if(yourInputMsg == 0){
|
||||
sender.setMessage(String("test test test de w1cdn "));
|
||||
sender_blink.setMessage(String("test test test de w1cdn "));
|
||||
sender_key.setMessage(String("test test test de w1cdn "));
|
||||
} else if(yourInputMsg == 1){
|
||||
sender.setMessage(String("moe "));
|
||||
sender_blink.setMessage(String("moe "));
|
||||
sender_key.setMessage(String("moe "));
|
||||
} else if(yourInputMsg == 2){
|
||||
sender.setMessage(String("moi "));
|
||||
sender_blink.setMessage(String("moi "));
|
||||
sender_key.setMessage(String("moi "));
|
||||
} else if(yourInputMsg == 3){
|
||||
sender.setMessage(String("mos "));
|
||||
sender_blink.setMessage(String("mos "));
|
||||
sender_key.setMessage(String("mos "));
|
||||
} else if(yourInputMsg == 4){
|
||||
sender.setMessage(String("moh "));
|
||||
sender_blink.setMessage(String("moh "));
|
||||
sender_key.setMessage(String("moh "));
|
||||
} else if(yourInputMsg == 5){
|
||||
sender.setMessage(String("mo5 "));
|
||||
sender_blink.setMessage(String("mo5 "));
|
||||
sender_key.setMessage(String("mo5 "));
|
||||
}
|
||||
}
|
||||
// GET inputStepLength value on <ESP_IP>/get?inputStepLength=<inputMessage>
|
||||
|
@ -497,26 +508,6 @@ void setup() {
|
|||
|
||||
void loop() {
|
||||
|
||||
// See which message we are sending
|
||||
// Only do this when the message has been updated.
|
||||
// if(yourInputMsg != yourInputMsg_old){
|
||||
// if(yourInputMsg == 0){
|
||||
// sender.setMessage(String("test test test de w1cdn "));
|
||||
// } else if(yourInputMsg == 1){
|
||||
// sender.setMessage(String("moe "));
|
||||
// } else if(yourInputMsg == 2){
|
||||
// sender.setMessage(String("moi "));
|
||||
// } else if(yourInputMsg == 3){
|
||||
// sender.setMessage(String("mos "));
|
||||
// } else if(yourInputMsg == 4){
|
||||
// sender.setMessage(String("moh "));
|
||||
// } else if(yourInputMsg == 5){
|
||||
// sender.setMessage(String("mo5 "));
|
||||
// }
|
||||
// // Keeps the key/led from locking up
|
||||
// yourInputMsg_old = yourInputMsg;
|
||||
// }
|
||||
|
||||
// This statement from https://github.com/garrysblog/DS3231-Alarm-With-Adafruit-RTClib-Library/blob/master/DS3231-RTClib-Adafruit-Alarm-Poll-alarmFired/DS3231-RTClib-Adafruit-Alarm-Poll-alarmFired.ino
|
||||
// Check if alarm by polling SQW alarm pin
|
||||
if((yourInputSend == 2) & (digitalRead(alarmPin) == LOW)) {
|
||||
|
@ -542,33 +533,39 @@ void loop() {
|
|||
// Subtract 2 rather than 1 here to account for start_millis duration at beginning of repeat.
|
||||
pause_until_millis = stop_millis + (yourInputStepLength * (yourInputNtransmitters - 2));
|
||||
}
|
||||
//sender.startSending();
|
||||
programRunning = true;
|
||||
startProgram = false;
|
||||
}
|
||||
|
||||
// if you want to send continuous code, and it's not sending, then start it up
|
||||
if((yourInputSend == 1)){
|
||||
if (!sender.continueSending()){
|
||||
// Set the internal counters to the message's beginning.
|
||||
// Here, this results in repeating the message indefinitely.
|
||||
sender.startSending();
|
||||
}
|
||||
// If not sending, start sending. Yes, these need to be separate statements.
|
||||
if (!sender_blink.continueSending()){
|
||||
sender_blink.startSending();
|
||||
}
|
||||
if (!sender_key.continueSending()){
|
||||
sender_key.startSending();
|
||||
}
|
||||
// if you want to send cycle code and it's not sending, then start it up
|
||||
} else if((yourInputSend == 2) & (programRunning == true)){
|
||||
if((millis() < start_millis)){
|
||||
// Shut the pin off manually
|
||||
digitalWrite(blinker, LOW);
|
||||
digitalWrite(keyer, LOW);
|
||||
} else if((millis() >= start_millis) & (millis() <= stop_millis)){
|
||||
if (!sender.continueSending()){
|
||||
// Set the internal counters to the message's beginning.
|
||||
// Here, this results in repeating the message indefinitely.
|
||||
sender.startSending();
|
||||
// If not sending, start sending. Yes, these need to be separate statements
|
||||
// for the blinker and keyer.
|
||||
if (!sender_blink.continueSending()){
|
||||
sender_blink.startSending();
|
||||
}
|
||||
if (!sender_key.continueSending()){
|
||||
sender_key.startSending();
|
||||
}
|
||||
} else if((millis() >= stop_millis) & (millis() <= pause_until_millis)){
|
||||
// do nothing in this case -- in between cycles
|
||||
// Shut the pin off manually
|
||||
digitalWrite(blinker, LOW);
|
||||
digitalWrite(keyer, LOW);
|
||||
} else if((millis() >= pause_until_millis)){
|
||||
startProgram = true;
|
||||
}
|
||||
|
@ -577,9 +574,9 @@ void loop() {
|
|||
// do we need something here?
|
||||
// if you don't want to send code
|
||||
} else if(yourInputSend == 0){
|
||||
//sender.setMessage(String("")) ; // Not sure this is the right way to stop things.
|
||||
// Shut the pin off manually
|
||||
digitalWrite(blinker, LOW);
|
||||
digitalWrite(keyer, LOW);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user