2024-04-01 18:21:09 +01:00
|
|
|
#include "cw.h"
|
|
|
|
|
|
|
|
void sendChar(int speed, int pitch, char c) {
|
|
|
|
if (c < 47 || c > 90) {
|
|
|
|
delay(speed * 3 * 2);
|
|
|
|
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];
|
|
|
|
|
|
|
|
for (int i=0; i < 8; i++) {
|
|
|
|
if (dd == 1) {
|
|
|
|
return;
|
|
|
|
}
|
2024-04-06 22:42:50 +01:00
|
|
|
tone(PIP, pitch);
|
2024-04-01 18:21:09 +01:00
|
|
|
if (dd&1) {
|
|
|
|
delay(speed * 3);
|
|
|
|
} else {
|
|
|
|
delay(speed);
|
|
|
|
}
|
|
|
|
dd >>= 1;
|
2024-04-06 22:42:50 +01:00
|
|
|
noTone(PIP);
|
2024-04-01 18:21:09 +01:00
|
|
|
delay(speed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sendID(repeater* myrpt) {
|
|
|
|
if (myrpt->callsign == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i=0; i < sizeof ID/sizeof ID[0]; i++) {
|
2024-04-06 19:10:18 +01:00
|
|
|
/* attenuate pips in active T/T
|
|
|
|
* unless first ID from sleep
|
|
|
|
*/
|
2024-04-06 22:28:05 +01:00
|
|
|
if (busy(myrpt) && !digitalRead(PIP_ATT))
|
2024-04-06 19:10:18 +01:00
|
|
|
digitalWrite(PIP_ATT, HIGH);
|
|
|
|
|
2024-04-01 18:21:09 +01:00
|
|
|
sendChar(myrpt->params.cw_speed, myrpt->params.cw_pitch, myrpt->callsign[i]);
|
|
|
|
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
|
|
|
}
|
|
|
|
|