|
38 | 38 | * @def RX_BUF_SIZE |
39 | 39 | * @brief Size of the command receive buffer, in bytes. |
40 | 40 | */ |
41 | | -#define RX_BUF_SIZE 64 |
| 41 | +#define RX_BUF_SIZE 256 |
42 | 42 |
|
43 | 43 | /** |
44 | 44 | * @def CMD_STR_BUZZER |
|
147 | 147 | static char s_rx_buf[ RX_BUF_SIZE ]; |
148 | 148 | static size_t s_rx_count = 0; |
149 | 149 |
|
| 150 | +bool s_immediate_autokey = false; |
| 151 | + |
150 | 152 | /* ----------------------------------------------------- MACROS ----------------------------------------------------- */ |
151 | 153 |
|
152 | 154 | /** |
@@ -236,6 +238,12 @@ static void exec_command_version( char const * const command ); |
236 | 238 | */ |
237 | 239 | static void exec_command_wpm( char const * const command ); |
238 | 240 |
|
| 241 | +/** |
| 242 | + * @fn exec_immediate_autokey_mode( void ) |
| 243 | + * @brief Executes the special "immediate autokey" mode. |
| 244 | + */ |
| 245 | +static void exec_immediate_autokey_mode( void ); |
| 246 | + |
239 | 247 | /** |
240 | 248 | * @fn print_invalid_command( char const * const ) |
241 | 249 | * @brief Sends an "Invalid command" message for the specified command. |
@@ -330,6 +338,13 @@ void debug_port_usart_rx( void ) |
330 | 338 |
|
331 | 339 | static void evaluate_rx_buf( void ) |
332 | 340 | { |
| 341 | + // Are we in immediate autokey mode? |
| 342 | + if( s_immediate_autokey ) |
| 343 | + { |
| 344 | + exec_immediate_autokey_mode(); |
| 345 | + return; |
| 346 | + } |
| 347 | + |
333 | 348 | // If we receive the terminating character... |
334 | 349 | if( s_rx_buf[ s_rx_count - 1 ] == TERMINATOR_CHAR ) |
335 | 350 | { |
@@ -694,6 +709,20 @@ static void exec_command_keyer( char const * const command ) |
694 | 709 | { |
695 | 710 | // No subcommand - interpret as a status request. no action required |
696 | 711 | } |
| 712 | + else if( string_equals( command, CMD_STR_KEYER " immediate" ) ) |
| 713 | + { |
| 714 | + // Enter immediate autokey mode |
| 715 | + s_immediate_autokey = true; |
| 716 | + debug_port_print( CMD_STR_KEYER ": Now in immediate autokey mode. Send null character to exit." NEWLINE_STR ); |
| 717 | + return; |
| 718 | + } |
| 719 | + else if( string_begins_with( command, CMD_STR_KEYER " key " ) ) |
| 720 | + { |
| 721 | + // Add remaining string to autokey buffer |
| 722 | + size_t count = keyer_autokey_str( command + 10 ); |
| 723 | + debug_port_printf( CMD_STR_KEYER ": \"%s\" (%u chars queued)" NEWLINE_STR, command + 10, count ); |
| 724 | + return; |
| 725 | + } |
697 | 726 | else if( string_equals( command, CMD_STR_KEYER " output_active_low " ENABLE_STR ) ) |
698 | 727 | { |
699 | 728 | // Set output to active low |
@@ -898,6 +927,30 @@ static void exec_command_wpm( char const * const command ) |
898 | 927 | } /* exec_command_wpm() */ |
899 | 928 |
|
900 | 929 |
|
| 930 | +static void exec_immediate_autokey_mode( void ) |
| 931 | +{ |
| 932 | + // Loop through each available character |
| 933 | + for( size_t idx = 0; idx < s_rx_count; idx++ ) |
| 934 | + { |
| 935 | + // If we receive the null character, exit autokey mode |
| 936 | + if( s_rx_buf[ idx ] == 0 ) |
| 937 | + { |
| 938 | + debug_port_print( NEWLINE_STR CMD_STR_KEYER ": Exited immediate autokey mode." NEWLINE_STR ); |
| 939 | + s_immediate_autokey = false; |
| 940 | + keyer_panic(); |
| 941 | + break; |
| 942 | + } |
| 943 | + |
| 944 | + // Otherwise, queue the character |
| 945 | + keyer_autokey_char( ( char )s_rx_buf[ idx ] ); |
| 946 | + } |
| 947 | + |
| 948 | + // All characters were consumed |
| 949 | + s_rx_count = 0; |
| 950 | + |
| 951 | +} /* exec_immediate_autokey_mode() */ |
| 952 | + |
| 953 | + |
901 | 954 | static void print_invalid_command( char const * const command ) |
902 | 955 | { |
903 | 956 | debug_port_print( INVALID_COMMAND_STR "\"" ); |
|
0 commit comments