mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
plot: fix mean, rework annotations
This commit is contained in:
parent
77f4371cd1
commit
e179fdb3b0
5 changed files with 25 additions and 15 deletions
|
@ -1905,9 +1905,9 @@ static int CmdScale(const char *Cmd) {
|
||||||
"Set cursor display scale.\n"
|
"Set cursor display scale.\n"
|
||||||
"Setting the scale makes the differential `dt` reading between the yellow and purple markers meaningful.\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.",
|
"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 125 -u ms -> for LF sampled at 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 1.695 -u us -> for HF sampled at 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"
|
"data scale --sr 16 -u ETU -> for HF with 16 samples per ETU. Reading will be in ETUs"
|
||||||
);
|
);
|
||||||
void *argtable[] = {
|
void *argtable[] = {
|
||||||
arg_param_begin,
|
arg_param_begin,
|
||||||
|
@ -1922,8 +1922,8 @@ static int CmdScale(const char *Cmd) {
|
||||||
CursorScaleFactor = 1;
|
CursorScaleFactor = 1;
|
||||||
}
|
}
|
||||||
int len = 0;
|
int len = 0;
|
||||||
CursorScaleFactorUint[0] = '\x00';
|
CursorScaleFactorUnit[0] = '\x00';
|
||||||
CLIParamStrToBuf(arg_get_str(ctx, 2), (uint8_t*)CursorScaleFactorUint, sizeof(CursorScaleFactorUint), &len);
|
CLIParamStrToBuf(arg_get_str(ctx, 2), (uint8_t*)CursorScaleFactorUnit, sizeof(CursorScaleFactorUnit), &len);
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
|
|
@ -27,7 +27,7 @@ void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cm
|
||||||
void ExitGraphics(void);
|
void ExitGraphics(void);
|
||||||
|
|
||||||
extern double CursorScaleFactor;
|
extern double CursorScaleFactor;
|
||||||
extern char CursorScaleFactorUint[11];
|
extern char CursorScaleFactorUnit[11];
|
||||||
extern int PlotGridX, PlotGridY, PlotGridXdefault, PlotGridYdefault, GridOffset;
|
extern int PlotGridX, PlotGridY, PlotGridXdefault, PlotGridYdefault, GridOffset;
|
||||||
extern uint32_t CursorCPos, CursorDPos;
|
extern uint32_t CursorCPos, CursorDPos;
|
||||||
extern int CommandFinished;
|
extern int CommandFinished;
|
||||||
|
|
|
@ -424,7 +424,8 @@ void Plot::PlotGraph(int *buffer, size_t len, QRect plotRect, QRect annotationRe
|
||||||
if (len == 0) return;
|
if (len == 0) return;
|
||||||
// clock_t begin = clock();
|
// clock_t begin = clock();
|
||||||
QPainterPath penPath;
|
QPainterPath penPath;
|
||||||
int vMin = INT_MAX, vMax = INT_MIN, vMean = 0, v = 0;
|
int vMin = INT_MAX, vMax = INT_MIN, v = 0;
|
||||||
|
int64_t vMean = 0;
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
int x = xCoordOf(GraphStart, plotRect);
|
int x = xCoordOf(GraphStart, plotRect);
|
||||||
int y = yCoordOf(buffer[GraphStart], plotRect, g_absVMax);
|
int y = yCoordOf(buffer[GraphStart], plotRect, g_absVMax);
|
||||||
|
@ -447,7 +448,8 @@ void Plot::PlotGraph(int *buffer, size_t len, QRect plotRect, QRect annotationRe
|
||||||
if (v > vMax) vMax = v;
|
if (v > vMax) vMax = v;
|
||||||
vMean += v;
|
vMean += v;
|
||||||
}
|
}
|
||||||
vMean /= (i - GraphStart);
|
GraphStop = i;
|
||||||
|
vMean /= (GraphStop - GraphStart);
|
||||||
|
|
||||||
painter->setPen(getColor(graphNum));
|
painter->setPen(getColor(graphNum));
|
||||||
|
|
||||||
|
@ -483,10 +485,9 @@ void Plot::PlotGraph(int *buffer, size_t len, QRect plotRect, QRect annotationRe
|
||||||
//Graph annotations
|
//Graph annotations
|
||||||
painter->drawPath(penPath);
|
painter->drawPath(penPath);
|
||||||
char str[200];
|
char str[200];
|
||||||
sprintf(str, "max=%d min=%d mean=%d n=%u/%zu CursorAVal=[%d] CursorBVal=[%d]",
|
sprintf(str, "max=%d min=%d mean=%" PRId64 " n=%u/%zu CursorAVal=[%d] CursorBVal=[%d]",
|
||||||
vMax, vMin, vMean, i, len, buffer[CursorAPos], buffer[CursorBPos]);
|
vMax, vMin, vMean, GraphStop - GraphStart, len, buffer[CursorAPos], buffer[CursorBPos]);
|
||||||
painter->drawText(20, annotationRect.bottom() - 23 - 20 * graphNum, str);
|
painter->drawText(20, annotationRect.bottom() - 23 - 20 * graphNum, str);
|
||||||
|
|
||||||
//clock_t end = clock();
|
//clock_t end = clock();
|
||||||
//double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
|
//double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
|
||||||
//printf("Plot time %f\n", elapsed_secs);
|
//printf("Plot time %f\n", elapsed_secs);
|
||||||
|
@ -596,11 +597,19 @@ void Plot::paintEvent(QPaintEvent *event) {
|
||||||
|
|
||||||
//Draw annotations
|
//Draw annotations
|
||||||
char str[200];
|
char str[200];
|
||||||
sprintf(str, "@%u dt=%i [%2.2f %s] zoom=%2.2f CursorAPos=%u CursorBPos=%u GridX=%d GridY=%d (%s) GridXoffset=%d",
|
char scalestr[30] = {0};
|
||||||
|
if (CursorScaleFactor != 1) {
|
||||||
|
if (CursorScaleFactorUnit[0] == '\x00') {
|
||||||
|
sprintf(scalestr, "[%2.2f] ", ((int32_t)(CursorBPos - CursorAPos)) / CursorScaleFactor);
|
||||||
|
} else {
|
||||||
|
sprintf(scalestr, "[%2.2f %s] ", ((int32_t)(CursorBPos - CursorAPos)) / CursorScaleFactor, CursorScaleFactorUnit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sprintf(str, "@%u..%u dt=%i %szoom=%2.2f CursorAPos=%u CursorBPos=%u GridX=%d GridY=%d (%s) GridXoffset=%d",
|
||||||
GraphStart,
|
GraphStart,
|
||||||
|
GraphStop,
|
||||||
CursorBPos - CursorAPos,
|
CursorBPos - CursorAPos,
|
||||||
((int32_t)(CursorBPos - CursorAPos)) / CursorScaleFactor,
|
scalestr,
|
||||||
CursorScaleFactorUint,
|
|
||||||
GraphPixelsPerPoint,
|
GraphPixelsPerPoint,
|
||||||
CursorAPos,
|
CursorAPos,
|
||||||
CursorBPos,
|
CursorBPos,
|
||||||
|
|
|
@ -32,6 +32,7 @@ class Plot: public QWidget {
|
||||||
private:
|
private:
|
||||||
QWidget *master;
|
QWidget *master;
|
||||||
uint32_t GraphStart; // Starting point/offset for the left side of the graph
|
uint32_t GraphStart; // Starting point/offset for the left side of the graph
|
||||||
|
uint32_t GraphStop; // Stop point/offset for the right side of the graph
|
||||||
double GraphPixelsPerPoint; // How many visual pixels are between each sample point (x axis)
|
double GraphPixelsPerPoint; // How many visual pixels are between each sample point (x axis)
|
||||||
uint32_t CursorAPos;
|
uint32_t CursorAPos;
|
||||||
uint32_t CursorBPos;
|
uint32_t CursorBPos;
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
session_arg_t session;
|
session_arg_t session;
|
||||||
|
|
||||||
double CursorScaleFactor = 1;
|
double CursorScaleFactor = 1;
|
||||||
char CursorScaleFactorUint[11] = {0};
|
char CursorScaleFactorUnit[11] = {0};
|
||||||
int PlotGridX = 0, PlotGridY = 0, PlotGridXdefault = 64, PlotGridYdefault = 64;
|
int PlotGridX = 0, PlotGridY = 0, PlotGridXdefault = 64, PlotGridYdefault = 64;
|
||||||
uint32_t CursorCPos = 0, CursorDPos = 0;
|
uint32_t CursorCPos = 0, CursorDPos = 0;
|
||||||
double GraphPixelsPerPoint = 1.f; // How many visual pixels are between each sample point (x axis)
|
double GraphPixelsPerPoint = 1.f; // How many visual pixels are between each sample point (x axis)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue