Skip to content

Commit 4bb0288

Browse files
committed
Clarify terminology for keyer types. (#5)
1 parent 0552e76 commit 4bb0288

7 files changed

Lines changed: 120 additions & 105 deletions

File tree

.vscode/c_cpp_properties.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
"_CONFIG_DFLT_INPUT_POLARITY_TRS_2_TIP=INPUT_POLARITY_ACTIVE_LOW",
3333
"_CONFIG_DFLT_INPUT_TYPE_TRS_2_RING=INPUT_TYPE_NONE",
3434
"_CONFIG_DFLT_INPUT_POLARITY_TRS_2_RING=INPUT_POLARITY_ACTIVE_LOW",
35-
"_CONFIG_DFLT_KEYER_MODE=KEYER_MODE_IAMBIC",
36-
"_CONFIG_DFLT_KEYER_OUTPUT_ACTIVE_LOW=true",
37-
"_CONFIG_DFLT_KEYER_INVERT_PADDLES=false"
35+
"_CONFIG_DFLT_KEYER_PADDLE_MODE=KEYER_PADDLE_MODE_IAMBIC",
36+
"_CONFIG_DFLT_KEYER_PADDLE_INVERT=false",
37+
"_CONFIG_DFLT_KEYER_OUTPUT_ACTIVE_LOW=true"
3838
],
3939
"compilerPath": "/usr/bin/avr-gcc",
4040
"compilerArgs": [

configuration.cmake

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ set(CONFIG_DFLT_INPUT_TYPE_TRS_2_RING INPUT_TYPE_NONE
6060
CACHE STRING "Input type for the ring of TRS 0. (input_type_t)")
6161
set(CONFIG_DFLT_INPUT_POLARITY_TRS_2_RING INPUT_POLARITY_ACTIVE_LOW
6262
CACHE STRING "Input polarity for the ring of TRS 0. (input_polarity_t)")
63-
set(CONFIG_DFLT_KEYER_MODE KEYER_MODE_IAMBIC
64-
CACHE STRING "Keyer mode. (keyer_mode_t)")
63+
set(CONFIG_DFLT_KEYER_PADDLE_MODE KEYER_PADDLE_MODE_IAMBIC
64+
CACHE STRING "Keyer paddle mode. (keyer_paddle_mode_t)")
65+
set(CONFIG_DFLT_KEYER_PADDLE_INVERT false
66+
CACHE STRING "Set to true to invert the paddles. (true / false)")
6567
set(CONFIG_DFLT_KEYER_OUTPUT_ACTIVE_LOW true
6668
CACHE STRING "Set to true for active low keyer output. (true / false)")
67-
set(CONFIG_DFLT_KEYER_INVERT_PADDLES false
68-
CACHE STRING "Set to true to invert the paddles. (true / false)")
6969

7070
# Set compile definitions
7171
add_compile_definitions(
@@ -88,7 +88,7 @@ add_compile_definitions(
8888
_CONFIG_DFLT_INPUT_POLARITY_TRS_2_TIP=${CONFIG_DFLT_INPUT_POLARITY_TRS_2_TIP}
8989
_CONFIG_DFLT_INPUT_TYPE_TRS_2_RING=${CONFIG_DFLT_INPUT_TYPE_TRS_2_RING}
9090
_CONFIG_DFLT_INPUT_POLARITY_TRS_2_RING=${CONFIG_DFLT_INPUT_POLARITY_TRS_2_RING}
91-
_CONFIG_DFLT_KEYER_MODE=${CONFIG_DFLT_KEYER_MODE}
91+
_CONFIG_DFLT_KEYER_PADDLE_MODE=${CONFIG_DFLT_KEYER_PADDLE_MODE}
92+
_CONFIG_DFLT_KEYER_PADDLE_INVERT=${CONFIG_DFLT_KEYER_PADDLE_INVERT}
9293
_CONFIG_DFLT_KEYER_OUTPUT_ACTIVE_LOW=${CONFIG_DFLT_KEYER_OUTPUT_ACTIVE_LOW}
93-
_CONFIG_DFLT_KEYER_INVERT_PADDLES=${CONFIG_DFLT_KEYER_INVERT_PADDLES}
9494
)

src/main/application/config.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ void config_default( config_t * config )
7373
config->input_polarity[ INPUT_PIN_TRS_2_RING ] = _CONFIG_DFLT_INPUT_POLARITY_TRS_2_RING;
7474

7575
// Keyer configuration
76-
config->keyer_mode = _CONFIG_DFLT_KEYER_MODE;
76+
config->keyer_paddle_mode = _CONFIG_DFLT_KEYER_PADDLE_MODE;
77+
config->keyer_paddle_invert = _CONFIG_DFLT_KEYER_PADDLE_INVERT;
7778
config->keyer_output_active_low = _CONFIG_DFLT_KEYER_OUTPUT_ACTIVE_LOW;
78-
config->keyer_invert_paddles = _CONFIG_DFLT_KEYER_INVERT_PADDLES;
7979

8080
// Ensure we generated a valid configuration
8181
assert_always( validate_config( config ) );

src/main/application/config.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ typedef struct
4646
/** The configured input polarity for each input pin. */
4747
input_polarity_t input_polarity[ INPUT_PIN_COUNT ];
4848

49-
/** The keyer mode. */
50-
keyer_mode_t keyer_mode;
49+
/** The keyer's paddle mode. */
50+
keyer_paddle_mode_t keyer_paddle_mode;
51+
52+
/** If set to `true`, the keyer will emit dashes from the left paddle and dots from the right paddle. */
53+
bool keyer_paddle_invert;
5154

5255
/** If set to `true`, the keyer's output is active low. */
5356
bool keyer_output_active_low;
5457

55-
/** If set to `true`, the keyer will emit dashes from the left paddle and dots from the right paddle. */
56-
bool keyer_invert_paddles;
57-
5858
} config_t;
5959

6060
/* ----------------------------------------------------- MACROS ----------------------------------------------------- */

src/main/application/debug_port.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -534,13 +534,13 @@ static void exec_command_input( char const * const command )
534534

535535
static void exec_command_keyer( char const * const command )
536536
{
537-
static char const * s_mode_tbl[] =
537+
static char const * s_paddle_mode_tbl[] =
538538
{
539-
stringize( KEYER_MODE_IAMBIC ),
540-
stringize( KEYER_MODE_ULTIMATIC ),
541-
stringize( KEYER_MODE_ULTIMATIC_ALTERNATE ),
539+
stringize( KEYER_PADDLE_MODE_IAMBIC ),
540+
stringize( KEYER_PADDLE_MODE_ULTIMATIC ),
541+
stringize( KEYER_PADDLE_MODE_ULTIMATIC_ALTERNATE ),
542542
};
543-
_Static_assert( array_count( s_mode_tbl ) == KEYER_MODE_COUNT, "Invalid string table!" );
543+
_Static_assert( array_count( s_paddle_mode_tbl ) == KEYER_PADDLE_MODE_COUNT, "Invalid string table!" );
544544

545545
// Drop "keyer" prefix
546546
char const * c = command + 5;
@@ -549,16 +549,6 @@ static void exec_command_keyer( char const * const command )
549549
{
550550
// No subcommand - interpret as a status request. no action required
551551
}
552-
else if( string_equals( c, " invert_paddles " ENABLE_STR ) )
553-
{
554-
// Set invert paddles to true
555-
keyer_set_invert_paddles( true );
556-
}
557-
else if( string_equals( c, " invert_paddles " DISABLE_STR ) )
558-
{
559-
// Set invert paddles to false
560-
keyer_set_invert_paddles( false );
561-
}
562552
else if( string_equals( c, " output_active_low " ENABLE_STR ) )
563553
{
564554
// Set output to active low
@@ -569,20 +559,30 @@ static void exec_command_keyer( char const * const command )
569559
// Set output to active high
570560
keyer_set_output_active_low( false );
571561
}
572-
else if( string_equals( c, " " stringize( KEYER_MODE_IAMBIC ) ) )
562+
else if( string_equals( c, " " stringize( KEYER_PADDLE_MODE_IAMBIC ) ) )
573563
{
574564
// Set to iambic mode
575-
keyer_set_mode( KEYER_MODE_IAMBIC );
565+
keyer_set_paddle_mode( KEYER_PADDLE_MODE_IAMBIC );
576566
}
577-
else if( string_equals( c, " " stringize( KEYER_MODE_ULTIMATIC ) ) )
567+
else if( string_equals( c, " " stringize( KEYER_PADDLE_MODE_ULTIMATIC ) ) )
578568
{
579569
// Set to ultimatic mode
580-
keyer_set_mode( KEYER_MODE_ULTIMATIC );
570+
keyer_set_paddle_mode( KEYER_PADDLE_MODE_ULTIMATIC );
581571
}
582-
else if( string_equals( c, " " stringize( KEYER_MODE_ULTIMATIC_ALTERNATE ) ) )
572+
else if( string_equals( c, " " stringize( KEYER_PADDLE_MODE_ULTIMATIC_ALTERNATE ) ) )
583573
{
584574
// Set to ultimatic alternate mode
585-
keyer_set_mode( KEYER_MODE_ULTIMATIC_ALTERNATE );
575+
keyer_set_paddle_mode( KEYER_PADDLE_MODE_ULTIMATIC_ALTERNATE );
576+
}
577+
else if( string_equals( c, " paddle_invert " ENABLE_STR ) )
578+
{
579+
// Set invert paddles to true
580+
keyer_set_paddle_invert( true );
581+
}
582+
else if( string_equals( c, " paddle_invert " DISABLE_STR ) )
583+
{
584+
// Set invert paddles to false
585+
keyer_set_paddle_invert( false );
586586
}
587587
else
588588
{
@@ -592,10 +592,10 @@ static void exec_command_keyer( char const * const command )
592592
}
593593

594594
// Print status info
595-
debug_port_printf( "Keyer: %s (active low %s, invert paddles %s)" NEWLINE_STR,
596-
s_mode_tbl[ keyer_get_mode() ],
597-
keyer_get_output_active_low() ? ENABLED_STR : DISABLED_STR,
598-
keyer_get_invert_paddles() ? ENABLED_STR : DISABLED_STR );
595+
debug_port_printf( "Keyer: %s (%s - %s)" NEWLINE_STR,
596+
keyer_get_on() ? ON_STR : OFF_STR,
597+
s_paddle_mode_tbl[ keyer_get_paddle_mode() ],
598+
keyer_get_paddle_invert() ? "inverted" : "normal" );
599599

600600
} /* exec_command_keyer() */
601601

src/main/application/keyer.c

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -175,25 +175,32 @@ static void update_ticks( void );
175175

176176
/* --------------------------------------------------- PROCEDURES --------------------------------------------------- */
177177

178-
bool keyer_get_invert_paddles( void )
178+
bool keyer_get_on( void )
179179
{
180-
return( config()->keyer_invert_paddles );
180+
return( get_keyed() );
181181

182-
} /* keyer_get_invert_paddles() */
182+
} /* keyer_get_on() */
183183

184184

185-
keyer_mode_t keyer_get_mode( void )
185+
bool keyer_get_output_active_low( void )
186186
{
187-
return( config()->keyer_mode );
187+
return( config()->keyer_output_active_low );
188188

189-
} /* keyer_get_mode() */
189+
} /* keyer_get_output_active_low() */
190190

191191

192-
bool keyer_get_output_active_low( void )
192+
bool keyer_get_paddle_invert( void )
193193
{
194-
return( config()->keyer_output_active_low );
194+
return( config()->keyer_paddle_invert );
195195

196-
} /* keyer_get_output_active_low() */
196+
} /* keyer_get_paddle_invert() */
197+
198+
199+
keyer_paddle_mode_t keyer_get_paddle_mode( void )
200+
{
201+
return( config()->keyer_paddle_mode );
202+
203+
} /* keyer_get_paddle_mode() */
197204

198205

199206
void keyer_init( void )
@@ -228,34 +235,34 @@ void keyer_panic( void )
228235
} /* keyer_panic() */
229236

230237

231-
void keyer_set_invert_paddles( bool invert )
238+
void keyer_set_output_active_low( bool active_low )
232239
{
233240
config_t config;
234241
config_get( & config );
235-
config.keyer_invert_paddles = invert;
242+
config.keyer_output_active_low = active_low;
236243
config_set( & config );
237244

238-
} /* keyer_set_invert_paddles() */
245+
} /* keyer_set_output_active_low() */
239246

240247

241-
void keyer_set_mode( keyer_mode_t mode )
248+
void keyer_set_paddle_invert( bool invert )
242249
{
243250
config_t config;
244251
config_get( & config );
245-
config.keyer_mode = mode;
252+
config.keyer_paddle_invert = invert;
246253
config_set( & config );
247254

248-
} /* keyer_set_mode() */
255+
} /* keyer_set_paddle_invert() */
249256

250257

251-
void keyer_set_output_active_low( bool active_lo )
258+
void keyer_set_paddle_mode( keyer_paddle_mode_t mode )
252259
{
253260
config_t config;
254261
config_get( & config );
255-
config.keyer_output_active_low = active_lo;
262+
config.keyer_paddle_mode = mode;
256263
config_set( & config );
257264

258-
} /* keyer_set_output_active_low() */
265+
} /* keyer_set_paddle_mode() */
259266

260267

261268
void keyer_tick( tick_t tick )
@@ -411,7 +418,7 @@ static state_t get_next_state( void )
411418
static input_type_field_t inputs = 0;
412419
input_type_field_t prev_inputs = inputs;
413420
inputs = input_types_get_on();
414-
bool invert_paddles = keyer_get_invert_paddles();
421+
bool paddle_invert = keyer_get_paddle_invert();
415422

416423
// Determine next state
417424
if( is_bit_set( inputs, INPUT_TYPE_STRAIGHT_KEY ) )
@@ -422,29 +429,29 @@ static state_t get_next_state( void )
422429
else if( is_bit_set( inputs, INPUT_TYPE_PADDLE_LEFT ) &&
423430
is_bit_set( inputs, INPUT_TYPE_PADDLE_RIGHT ) )
424431
{
425-
switch( keyer_get_mode() )
432+
switch( keyer_get_paddle_mode() )
426433
{
427-
case KEYER_MODE_IAMBIC:
434+
case KEYER_PADDLE_MODE_IAMBIC:
428435
// Always do interleaved in iambic mode
429436
return( STATE_INTERLEAVED );
430437

431-
case KEYER_MODE_ULTIMATIC:
438+
case KEYER_PADDLE_MODE_ULTIMATIC:
432439
// The first activated paddle wins
433440
return( s_state );
434441

435-
case KEYER_MODE_ULTIMATIC_ALTERNATE:
442+
case KEYER_PADDLE_MODE_ULTIMATIC_ALTERNATE:
436443
// The most recently activated paddle wins
437444
if( is_bit_set( inputs, INPUT_TYPE_PADDLE_LEFT ) &&
438445
is_bit_clear( prev_inputs, INPUT_TYPE_PADDLE_LEFT ) )
439446
{
440447
// Left paddle was more recently activated
441-
return( invert_paddles ? STATE_DASHES : STATE_DOTS );
448+
return( paddle_invert ? STATE_DASHES : STATE_DOTS );
442449
}
443450
else if( is_bit_set( inputs, INPUT_TYPE_PADDLE_RIGHT ) &&
444451
is_bit_clear( prev_inputs, INPUT_TYPE_PADDLE_RIGHT ) )
445452
{
446453
// Right paddle was more recently activated
447-
return( invert_paddles ? STATE_DOTS : STATE_DASHES );
454+
return( paddle_invert ? STATE_DOTS : STATE_DASHES );
448455
}
449456
else
450457
{
@@ -457,14 +464,14 @@ static state_t get_next_state( void )
457464
fail();
458465
}
459466
}
460-
else if( ( ! invert_paddles && is_bit_set( inputs, INPUT_TYPE_PADDLE_LEFT ) ) ||
461-
( invert_paddles && is_bit_set( inputs, INPUT_TYPE_PADDLE_RIGHT ) ) )
467+
else if( ( ! paddle_invert && is_bit_set( inputs, INPUT_TYPE_PADDLE_LEFT ) ) ||
468+
( paddle_invert && is_bit_set( inputs, INPUT_TYPE_PADDLE_RIGHT ) ) )
462469
{
463470
// The left paddle traditionally emits dots
464471
return( STATE_DOTS );
465472
}
466-
else if( ( ! invert_paddles && is_bit_set( inputs, INPUT_TYPE_PADDLE_RIGHT ) ) ||
467-
( invert_paddles && is_bit_set( inputs, INPUT_TYPE_PADDLE_LEFT ) ) )
473+
else if( ( ! paddle_invert && is_bit_set( inputs, INPUT_TYPE_PADDLE_RIGHT ) ) ||
474+
( paddle_invert && is_bit_set( inputs, INPUT_TYPE_PADDLE_LEFT ) ) )
468475
{
469476
// The right paddle traditionally emits dashes
470477
return( STATE_DASHES );

0 commit comments

Comments
 (0)