diff --git a/client/src/cmddata.c b/client/src/cmddata.c index 74f6b4a23..7e5025814 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -50,20 +50,6 @@ static int usage_data_save(void) { PrintAndLogEx(NORMAL, " data save f mytrace w - save graphbuffer to wave file"); return PM3_SUCCESS; } -static int usage_data_scale(void) { - PrintAndLogEx(NORMAL, "Set cursor display scale."); - PrintAndLogEx(NORMAL, "Setting the scale makes the differential `dt` reading between the yellow and purple markers meaningful. "); - PrintAndLogEx(NORMAL, "once the scale is set, the differential reading between brackets is the time duration in seconds."); - PrintAndLogEx(NORMAL, "For example, if acquiring in 125kHz, use scale 125."); - PrintAndLogEx(NORMAL, ""); - PrintAndLogEx(NORMAL, "Usage: data scale [h] "); - PrintAndLogEx(NORMAL, "Options:"); - PrintAndLogEx(NORMAL, " h this help"); - PrintAndLogEx(NORMAL, " sets scale of carrier frequency expressed in kHz"); - PrintAndLogEx(NORMAL, "Samples:"); - PrintAndLogEx(NORMAL, " data scale 125 - if sampled in 125kHz"); - return PM3_SUCCESS; -} static int usage_data_printdemodbuf(void) { PrintAndLogEx(NORMAL, "Usage: data printdemodbuffer x o l "); PrintAndLogEx(NORMAL, "Options:"); @@ -1913,14 +1899,32 @@ int CmdSave(const char *Cmd) { } static int CmdScale(const char *Cmd) { - char cmdp = tolower(param_getchar(Cmd, 0)); - if (strlen(Cmd) == 0 || cmdp == 'h') return usage_data_scale(); - CursorScaleFactor = atoi(Cmd); + CLIParserContext *ctx; + CLIParserInit(&ctx, "data scale", + "Set cursor display scale.\n" + "Setting the scale makes the differential `dt` reading between the yellow and purple markers meaningful.\n" + "once the scale is set, the differential reading between brackets can become a time duration.", + "data scale --sr 125 -u ms -> if sampled in 125 kHz, reading will be in milliseconds\n" + "data scale --sr 1.695 -u us -> if HF, sampling is 1.695 MHz. Reading will be in microseconds\n" + "data scale --sr 16 -u ETU -> if HF, 16 samples per ETU. Reading will be in ETUs" + ); + void *argtable[] = { + arg_param_begin, + arg_dbl1(NULL, "sr", "", "sets scale according to sampling rate"), + arg_str0("u", "unit", "", "time unit to display (max 10 chars)"), + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, false); + CursorScaleFactor = arg_get_dbl_def(ctx, 1, 0); if (CursorScaleFactor == 0) { PrintAndLogEx(FAILED, "bad, can't have zero scale"); CursorScaleFactor = 1; } + int len = 0; + CursorScaleFactorUint[0] = '\x00'; + CLIParamStrToBuf(arg_get_str(ctx, 2), (uint8_t*)CursorScaleFactorUint, sizeof(CursorScaleFactorUint), &len); + CLIParserFree(ctx); RepaintGraphWindow(); return PM3_SUCCESS; } diff --git a/client/src/proxgui.h b/client/src/proxgui.h index cc9c9e118..00c954123 100644 --- a/client/src/proxgui.h +++ b/client/src/proxgui.h @@ -27,6 +27,7 @@ void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cm void ExitGraphics(void); extern double CursorScaleFactor; +extern char CursorScaleFactorUint[11]; extern int PlotGridX, PlotGridY, PlotGridXdefault, PlotGridYdefault, GridOffset; extern uint32_t CursorCPos, CursorDPos; extern int CommandFinished; diff --git a/client/src/proxguiqt.cpp b/client/src/proxguiqt.cpp index 52f0a8955..ed4e049dd 100644 --- a/client/src/proxguiqt.cpp +++ b/client/src/proxguiqt.cpp @@ -596,10 +596,11 @@ void Plot::paintEvent(QPaintEvent *event) { //Draw annotations char str[200]; - sprintf(str, "@%u dt=%u [%2.2f] zoom=%2.2f CursorAPos=%u CursorBPos=%u GridX=%d GridY=%d (%s) GridXoffset=%d", + sprintf(str, "@%u dt=%i [%2.2f %s] zoom=%2.2f CursorAPos=%u CursorBPos=%u GridX=%d GridY=%d (%s) GridXoffset=%d", GraphStart, CursorBPos - CursorAPos, ((int32_t)(CursorBPos - CursorAPos)) / CursorScaleFactor, + CursorScaleFactorUint, GraphPixelsPerPoint, CursorAPos, CursorBPos, diff --git a/client/src/ui.c b/client/src/ui.c index f05a96682..579b21f42 100644 --- a/client/src/ui.c +++ b/client/src/ui.c @@ -38,6 +38,7 @@ session_arg_t session; double CursorScaleFactor = 1; +char CursorScaleFactorUint[11] = {0}; int PlotGridX = 0, PlotGridY = 0, PlotGridXdefault = 64, PlotGridYdefault = 64; uint32_t CursorCPos = 0, CursorDPos = 0; double GraphPixelsPerPoint = 1.f; // How many visual pixels are between each sample point (x axis)