m0zah/GB3TX/cw.ino
Jim Colderwood 8c790fa4e0 GB3TX
2024-04-01 18:21:09 +01:00

51 lines
839 B
C++

#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;
}
tone(3, pitch);
if (dd&1) {
delay(speed * 3);
} else {
delay(speed);
}
dd >>= 1;
noTone(3);
delay(speed);
}
}
void sendID(repeater* myrpt) {
if (myrpt->callsign == NULL) {
return;
}
for (int i=0; i < sizeof ID/sizeof ID[0]; i++) {
sendChar(myrpt->params.cw_speed, myrpt->params.cw_pitch, myrpt->callsign[i]);
delay(myrpt->params.cw_speed * 3);
}
}