Skip to content

Commit 6a2842f

Browse files
author
DESKTOP-M9CCUTI\ian
committed
added help to button command
1 parent cac1152 commit 6a2842f

File tree

8 files changed

+55
-8
lines changed

8 files changed

+55
-8
lines changed

commands/global/button_scr.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#define BUTTON_FLAG_FILE_CONFIGURED 1u<<2
2525

2626
uint8_t button_flags[BP_BUTT_MAX-1];
27-
char button_script_files[BP_BUTT_MAX-1][BP_FILENAME_MAX + 1];
27+
char button_script_files[BP_BUTT_MAX-1][BP_FILENAME_MAX];
2828

2929
typedef struct {
3030
const char *verb;
@@ -48,8 +48,13 @@ static const char * const usage[]= {
4848
};
4949

5050
static const struct ui_help_options options[]= {
51-
//{1,"", T_HELP_FLASH}, //flash command help
52-
// {0,"-f",T_HELP_FLASH_FILE_FLAG}, //file to read/write/verify
51+
{1,"", T_HELP_BUTTON},
52+
{0,"short",T_HELP_BUTTON_SHORT},
53+
{0,"long",T_HELP_BUTTON_LONG},
54+
{0,"-f",T_HELP_BUTTON_FILE},
55+
{0,"-d",T_HELP_BUTTON_HIDE},
56+
{0,"-e",T_HELP_BUTTON_EXIT},
57+
{0,"-h",T_HELP_FLAG},
5358
};
5459

5560
void button_scr_handler(struct command_result *res){
@@ -80,9 +85,9 @@ void button_scr_handler(struct command_result *res){
8085
}
8186

8287
//grab the file name, error if none
83-
char button_script_file[BP_FILENAME_MAX + 1];
88+
char button_script_file[BP_FILENAME_MAX];
8489
command_var_t arg;
85-
if(!cmdln_args_find_flag_string('f',&arg, BP_FILENAME_MAX, button_script_file)){
90+
if(!cmdln_args_find_flag_string('f',&arg, BP_FILENAME_MAX-1, button_script_file)){
8691
printf("Specify a script file with the -f flag (-f script.scr)\r\n");
8792
ui_help_show(true,usage,count_of(usage), &options[0],count_of(options) );
8893
return;
@@ -104,7 +109,7 @@ void button_scr_handler(struct command_result *res){
104109
button_flags[button_code-1]|=BUTTON_FLAG_FILE_CONFIGURED;
105110

106111
//copy to button press type array
107-
memcpy(button_script_files[button_code-1], button_script_file, BP_FILENAME_MAX);
112+
memcpy(button_script_files[button_code-1], button_script_file, BP_FILENAME_MAX-1);
108113
printf("Button script file set to '%s'\r\n", button_script_file);
109114

110115
//set other flag options

translation/base.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,12 @@ enum T_translations{
408408
T_HELP_CMD_PAUSE_KEY,
409409
T_HELP_CMD_PAUSE_BUTTON,
410410
T_HELP_CMD_PAUSE_EXIT,
411+
T_HELP_BUTTON,
412+
T_HELP_BUTTON_SHORT,
413+
T_HELP_BUTTON_LONG,
414+
T_HELP_BUTTON_FILE,
415+
T_HELP_BUTTON_HIDE,
416+
T_HELP_BUTTON_EXIT,
411417

412418
T_LAST_ITEM_ALWAYS_AT_THE_END //LEAVE THIS ITEM AT THE END!!! It helps the compiler report errors if there are missing translations
413419
};

translation/bs-ba.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,12 @@ static char const * const bs_ba[]={
403403
[T_HELP_CMD_PAUSE_KEY]="Press any key to continue (default)",
404404
[T_HELP_CMD_PAUSE_BUTTON]="Press the Bus Pirate button to continue",
405405
[T_HELP_CMD_PAUSE_EXIT]="'x' key to exit (e.g. script mode)",
406+
[T_HELP_BUTTON]="Assign script file to button press",
407+
[T_HELP_BUTTON_SHORT]="Assign script file to short button press",
408+
[T_HELP_BUTTON_LONG]="Assign script file to long button press",
409+
[T_HELP_BUTTON_FILE]="Script file to assign to button press",
410+
[T_HELP_BUTTON_HIDE]="Hide comments",
411+
[T_HELP_BUTTON_EXIT]="Exit script on error",
406412

407413
};
408414

translation/en-us.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,13 @@ static char const * const en_us[]={
422422
[T_HELP_CMD_PAUSE]="pause for user input, optional exit",
423423
[T_HELP_CMD_PAUSE_KEY]="Press any key to continue (default)",
424424
[T_HELP_CMD_PAUSE_BUTTON]="Press the Bus Pirate button to continue",
425-
[T_HELP_CMD_PAUSE_EXIT]="'x' key to exit (e.g. script mode)"
425+
[T_HELP_CMD_PAUSE_EXIT]="'x' key to exit (e.g. script mode)",
426+
[T_HELP_BUTTON]="Assign script file to button press",
427+
[T_HELP_BUTTON_SHORT]="Assign script file to short button press",
428+
[T_HELP_BUTTON_LONG]="Assign script file to long button press",
429+
[T_HELP_BUTTON_FILE]="Script file to assign to button press",
430+
[T_HELP_BUTTON_HIDE]="Hide comments",
431+
[T_HELP_BUTTON_EXIT]="Exit script on error"
426432
};
427433

428434
static_assert(count_of(en_us)==T_LAST_ITEM_ALWAYS_AT_THE_END, "Missing english translations!");

translation/en-us.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,5 +400,11 @@
400400
"T_HELP_CMD_TUTORIAL": "Run tutorial files",
401401
"T_HELP_CMD_PAUSE_KEY": "Press any key to continue (default)",
402402
"T_HELP_CMD_PAUSE_BUTTON": "Press the Bus Pirate button to continue",
403-
"T_HELP_CMD_PAUSE_EXIT": "'x' key to exit (e.g. script mode)"
403+
"T_HELP_CMD_PAUSE_EXIT": "'x' key to exit (e.g. script mode)",
404+
"T_HELP_BUTTON": "Assign script file to button press",
405+
"T_HELP_BUTTON_SHORT": "Assign script file to short button press",
406+
"T_HELP_BUTTON_LONG": "Assign script file to long button press",
407+
"T_HELP_BUTTON_FILE": "Script file to assign to button press",
408+
"T_HELP_BUTTON_HIDE": "Hide comments",
409+
"T_HELP_BUTTON_EXIT": "Exit script on error"
404410
}

translation/it-it.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,12 @@ static char const * const it_it[]={
403403
[T_HELP_CMD_PAUSE_KEY]="Press any key to continue (default)",
404404
[T_HELP_CMD_PAUSE_BUTTON]="Press the Bus Pirate button to continue",
405405
[T_HELP_CMD_PAUSE_EXIT]="'x' key to exit (e.g. script mode)",
406+
[T_HELP_BUTTON]="Assign script file to button press",
407+
[T_HELP_BUTTON_SHORT]="Assign script file to short button press",
408+
[T_HELP_BUTTON_LONG]="Assign script file to long button press",
409+
[T_HELP_BUTTON_FILE]="Script file to assign to button press",
410+
[T_HELP_BUTTON_HIDE]="Hide comments",
411+
[T_HELP_BUTTON_EXIT]="Exit script on error",
406412

407413
};
408414

translation/pl-pl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,12 @@ static char const * const pl_pl[]={
403403
[T_HELP_CMD_PAUSE_KEY]="Press any key to continue (default)",
404404
[T_HELP_CMD_PAUSE_BUTTON]="Press the Bus Pirate button to continue",
405405
[T_HELP_CMD_PAUSE_EXIT]="'x' key to exit (e.g. script mode)",
406+
[T_HELP_BUTTON]="Assign script file to button press",
407+
[T_HELP_BUTTON_SHORT]="Assign script file to short button press",
408+
[T_HELP_BUTTON_LONG]="Assign script file to long button press",
409+
[T_HELP_BUTTON_FILE]="Script file to assign to button press",
410+
[T_HELP_BUTTON_HIDE]="Hide comments",
411+
[T_HELP_BUTTON_EXIT]="Exit script on error",
406412

407413
};
408414

translation/zh-cn.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,12 @@ static char const * const zh_cn[]={
403403
[T_HELP_CMD_PAUSE_KEY]="Press any key to continue (default)",
404404
[T_HELP_CMD_PAUSE_BUTTON]="Press the Bus Pirate button to continue",
405405
[T_HELP_CMD_PAUSE_EXIT]="'x' key to exit (e.g. script mode)",
406+
[T_HELP_BUTTON]="Assign script file to button press",
407+
[T_HELP_BUTTON_SHORT]="Assign script file to short button press",
408+
[T_HELP_BUTTON_LONG]="Assign script file to long button press",
409+
[T_HELP_BUTTON_FILE]="Script file to assign to button press",
410+
[T_HELP_BUTTON_HIDE]="Hide comments",
411+
[T_HELP_BUTTON_EXIT]="Exit script on error",
406412

407413
};
408414

0 commit comments

Comments
 (0)