diff --git a/games/morse/morse.6 b/games/morse/morse.6 index e2272599cbd0..30c0b453074a 100644 --- a/games/morse/morse.6 +++ b/games/morse/morse.6 @@ -33,7 +33,7 @@ .\" @(#)bcd.6 8.1 (Berkeley) 5/31/93 .\" $FreeBSD$ .\" -.Dd May 11, 2004 +.Dd June 7, 2005 .Dt MORSE 6 .Os .Sh NAME @@ -44,6 +44,7 @@ .Op Fl elps .Op Fl d Ar device .Op Fl w Ar speed +.Op Fl c Ar speed .Op Fl f Ar frequency .Op Ar string ... .Sh DESCRIPTION @@ -73,6 +74,14 @@ support. Set the sending speed in words per minute. If not specified, the default speed of 20 WPM is used. +.It Fl c Ar speed +Farnsworth support. +Set the spacing between characters in words per minute. +This is independent of the speed +that the individual characters are sent. +If not specified, defaults to the effective value of the +.Fl w +option. .It Fl f Ar frequency Set the sidetone frequency to something other than the default 600 Hz. .It Fl d Ar device @@ -91,6 +100,8 @@ or .Pp The .Fl w +, +.Fl c and .Fl f flags only work in conjunction with either the @@ -176,6 +187,11 @@ added by Ability to key an external device added by .An J\(:org Wunsch (DL8DTL). +.Pp +Farnsworth support for +.Nm +added by +.An Stephen Cravey (N5UUU). .Sh BUGS Only understands a few European characters (German and French), diff --git a/games/morse/morse.c b/games/morse/morse.c index f04f1b5c365c..eb9e4d4b7d24 100644 --- a/games/morse/morse.c +++ b/games/morse/morse.c @@ -266,12 +266,14 @@ void show(const char *), play(const char *), morse(char); void ttyout(const char *); void sighandler(int); -#define GETOPTOPTS "d:ef:lsw:" +#define GETOPTOPTS "c:d:ef:lsw:" #define USAGE \ -"usage: morse [-els] [-d device] [-w speed] [-f frequency] [string ...]\n" +"usage: morse [-els] [-d device] [-w speed] [-c speed] [-f frequency] [string ...]\n" static int pflag, lflag, sflag, eflag; -static int wpm = 20; /* words per minute */ +static int wpm = 20; /* effective words per minute */ +static int cpm; /* effective words per minute between + * characters */ #define FREQUENCY 600 static int freq = FREQUENCY; static char *device; /* for tty-controlled generator */ @@ -280,6 +282,7 @@ static char *device; /* for tty-controlled generator */ #define CHAR_SPACE 3 #define WORD_SPACE (7 - CHAR_SPACE - 1) static float dot_clock; +static float cdot_clock; int spkr, line; struct termios otty, ntty; int olflags; @@ -287,10 +290,10 @@ int olflags; #ifdef SPEAKER tone_t sound; #undef GETOPTOPTS -#define GETOPTOPTS "d:ef:lpsw:" +#define GETOPTOPTS "c:d:ef:lpsw:" #undef USAGE #define USAGE \ -"usage: morse [-elps] [-d device] [-w speed] [-f frequency] [string ...]\n" +"usage: morse [-elps] [-d device] [-w speed] [-c speed] [-f frequency] [string ...]\n" #endif static const struct morsetab *hightab; @@ -303,6 +306,9 @@ main(int argc, char **argv) while ((ch = getopt(argc, argv, GETOPTOPTS)) != -1) switch ((char) ch) { + case 'c': + cpm = atoi(optarg); + break; case 'd': device = optarg; break; @@ -340,7 +346,9 @@ main(int argc, char **argv) fputs("morse: only one of -p, -d and -l, -s allowed\n", stderr); exit(1); } - if ((pflag || device) && ((wpm < 1) || (wpm > 60))) { + if (cpm == 0) + cpm = wpm; + if ((pflag || device) && ((wpm < 1) || (wpm > 60) || (cpm < 1) || (cpm > 60))) { fputs("morse: insane speed\n", stderr); exit(1); } @@ -385,6 +393,12 @@ main(int argc, char **argv) dot_clock = dot_clock / 2; /* dot_clock runs at twice */ /* the dot rate */ dot_clock = dot_clock * 100; /* scale for ioctl */ + + cdot_clock = cpm / 2.4; /* dots/sec */ + cdot_clock = 1 / cdot_clock; /* duration of a dot */ + cdot_clock = cdot_clock / 2; /* dot_clock runs at twice */ + /* the dot rate */ + cdot_clock = cdot_clock * 100; /* scale for ioctl */ } argc -= optind; @@ -492,7 +506,7 @@ play(const char *s) break; case ' ': sound.frequency = 0; - sound.duration = dot_clock * WORD_SPACE; + sound.duration = cdot_clock * WORD_SPACE; break; default: sound.duration = 0; @@ -511,7 +525,7 @@ play(const char *s) } } sound.frequency = 0; - sound.duration = dot_clock * CHAR_SPACE; + sound.duration = cdot_clock * CHAR_SPACE; ioctl(spkr, SPKRTONE, &sound); #endif } @@ -534,7 +548,7 @@ ttyout(const char *s) break; case ' ': on = 0; - duration = dot_clock * WORD_SPACE; + duration = cdot_clock * WORD_SPACE; break; default: on = 0; @@ -554,7 +568,7 @@ ttyout(const char *s) duration = dot_clock * 10000; usleep(duration); } - duration = dot_clock * CHAR_SPACE * 10000; + duration = cdot_clock * CHAR_SPACE * 10000; usleep(duration); }