static int cw_busy=0;
static int cat_cw_seen=0;
-static int dotlen;
-static int dashlen;
static int dotsamples;
static int dashsamples;
+static int InterCharacterSamples;
//
-// send_dash() send a "key-down" of a dashlen, followed by a "key-up" of a dotlen
-// send_dot() send a "key-down" of a dotlen, followed by a "key-up" of a dotlen
-// send_space(int len) send a "key_down" of zero, followed by a "key-up" of len*dotlen
+// send_dash() send a "key-down" of a dashlen, followed by a "key-up" of a dotlen
+// send_dot() send a "key-down" of a dotlen, followed by a "key-up" of a dotlen
+// send_space(int smpl) send a "key_down" of zero, followed by a "key-up" of smpl
//
// The "trick" to get proper timing is, that we really specify the number of samples
// for the next element (dash/dot/nothing) and the following pause. 30 wpm is no
cw_key_up = dotsamples;
}
-void send_space(int len) {
+void send_space(int smpl) {
int TimeToGo;
for(;;) {
TimeToGo=cw_key_up+cw_key_down;
}
// If local CW keying has set in, do not interfere
if (cw_key_hit || cw_not_ready) return;
- cw_key_up = len*dotsamples;
+ cw_key_up = smpl;
}
void rigctl_send_cw_char(char cw_char) {
// The last element (dash or dot) sent already has one dotlen space appended.
// If the current character is another "printable" sign, we need an additional
- // pause of 2 dotlens to form the inter-character spacing of 3 dotlens.
+ // pause of about 2 dotlens to form the inter-character spacing.
// However if the current character is a "space" we must produce an inter-word
// spacing (7 dotlens) and therefore need 6 additional dotlens
// We need no longer take care of a sequence of spaces since adjacent spaces
// are now filtered out while filling the CW character (ring-) buffer.
+ //
+ // The value of InterCharacterSamples is close to 2*dotsamples, but may be
+ // a little longer if inter-character space is a little bit stretched.
+ // here.
if (cw_char == ' ') {
- send_space(6); // produce inter-word space of 7 dotlens
+ send_space(6*dotsamples); // produce inter-word space of 7 dotlens
} else {
- send_space(2); // produce inter-character space of 3 dotlens
+ send_space(InterCharacterSamples); // produce inter-character space
}
}
// This may happen if cw_buf was empty or contained only blanks
if (num_buf == 0) continue;
- // these values may have changed, so recompute them here
+ // The dot and dash length may have changed, so recompute them here
// This means that we can change the speed (KS command) while
// the buffer is being sent
+ // Note that InterCharacterSamples is the amount of "silent"
+ // samples *in addition to* the one-dotlength pause that follows
+ // each dot or dash.
+ //
- dotlen = 1200000L/(long)cw_keyer_speed;
- dashlen = (dotlen * 3 * cw_keyer_weight) / 50L;
+#ifdef STRETCHED_CW
+ //
+ // Stretch inter-character spacing from 3 to 3.5 dots,
+ // so the dotlen must be shortened a little bit to give
+ // the same speed in words per minute:
+ // "PARIS" now has 52 dots instead of 50.
+ //
+ // 55385 = 60 * 48000 / 52
+ // 3323 = (60 * 48000 * 3) / (52 * 50)
+ // 138462 = (60 * 48000 * 5) / (52 * 2)
+ dotsamples = 55385 / cw_keyer_speed;
+ dashsamples = (3323 * cw_keyer_weight) / cw_keyer_speed;
+ InterCharacterSamples = 141284 / cw_keyer_speed;
+#else
+ //
+ // Standard CW timing with 3 dotlength inter-character spacing.
+ //
+ // 57600 = 60 * 48000 / 50
+ // 3456 = (60 * 48000 * 3) / (50 * 50)
+ // 115200 = (60 * 48000 * 2) / 50
dotsamples = 57600 / cw_keyer_speed;
dashsamples = (3456 * cw_keyer_weight) / cw_keyer_speed;
+ InterCharacterSamples = 115200 / cw_keyer_speed;
+#endif
+
CAT_cw_is_active=1;
if (!mox) {
// activate PTT