2024-04-01 18:21:09 +01:00
|
|
|
#include "cw.h"
|
|
|
|
|
2024-05-06 11:28:43 +01:00
|
|
|
void sendChar(repeater* myrpt, char c) {
|
2024-04-01 18:21:09 +01:00
|
|
|
if (c < 47 || c > 90) {
|
2024-05-06 11:28:43 +01:00
|
|
|
delay(myrpt->params.cw_speed * 3 * 2);
|
2024-04-01 18:21:09 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (c > 57 && c < 65) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int index = c - 47;
|
|
|
|
if (c >= 65) {
|
|
|
|
index = c - 54;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index >= sizeof morse/sizeof morse[0])
|
|
|
|
return;
|
|
|
|
|
|
|
|
int dd = morse[index];
|
|
|
|
|
2024-05-06 11:28:43 +01:00
|
|
|
if (digitalRead(PIP_ATT) && myrpt->state != SLEEP)
|
|
|
|
digitalWrite(PIP_ATT, LOW);
|
2024-04-01 18:21:09 +01:00
|
|
|
for (int i=0; i < 8; i++) {
|
|
|
|
if (dd == 1) {
|
|
|
|
return;
|
|
|
|
}
|
2024-05-06 11:28:43 +01:00
|
|
|
/*
|
|
|
|
* attenuate pips in active T/T
|
|
|
|
*/
|
|
|
|
if (busy(myrpt) && !digitalRead(PIP_ATT))
|
|
|
|
digitalWrite(PIP_ATT, HIGH);
|
|
|
|
tone(PIP, myrpt->params.cw_pitch);
|
2024-04-01 18:21:09 +01:00
|
|
|
if (dd&1) {
|
2024-05-06 11:28:43 +01:00
|
|
|
delay(myrpt->params.cw_speed * 3);
|
2024-04-01 18:21:09 +01:00
|
|
|
} else {
|
2024-05-06 11:28:43 +01:00
|
|
|
delay(myrpt->params.cw_speed);
|
2024-04-01 18:21:09 +01:00
|
|
|
}
|
|
|
|
dd >>= 1;
|
2024-04-06 22:42:50 +01:00
|
|
|
noTone(PIP);
|
2024-05-06 11:28:43 +01:00
|
|
|
delay(myrpt->params.cw_speed);
|
2024-04-01 18:21:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sendID(repeater* myrpt) {
|
2024-05-06 11:28:43 +01:00
|
|
|
myrpt->id_time = millis();
|
2024-04-01 18:21:09 +01:00
|
|
|
if (myrpt->callsign == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2024-05-06 11:28:43 +01:00
|
|
|
|
|
|
|
delay(500);
|
|
|
|
|
|
|
|
if (myrpt->state == SLEEP)
|
|
|
|
digitalWrite(PIP_ATT, HIGH);
|
2024-04-01 18:21:09 +01:00
|
|
|
|
|
|
|
for (int i=0; i < sizeof ID/sizeof ID[0]; i++) {
|
2024-05-06 11:28:43 +01:00
|
|
|
sendChar(myrpt, myrpt->callsign[i]);
|
2024-04-01 18:21:09 +01:00
|
|
|
delay(myrpt->params.cw_speed * 3);
|
|
|
|
}
|
2024-04-06 22:22:59 +01:00
|
|
|
if (digitalRead(PIP_ATT))
|
2024-04-06 19:10:18 +01:00
|
|
|
digitalWrite(PIP_ATT, LOW);
|
2024-04-01 18:21:09 +01:00
|
|
|
}
|
|
|
|
|