mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-22 06:13:51 -07:00
Rough Implementation of the Operations Buffer
The Operations Buffer is basically a buffer of changes to the Graph Buffer. Instead of writing all the changes to the Graph Buffer directly, I plan to have those changes written to the Operation Buffer, so you can visually see what would be changed before it's applied.
This commit is contained in:
parent
8e3efec3e2
commit
c2e43c3f46
4 changed files with 49 additions and 0 deletions
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
|
|
||||||
int g_GraphBuffer[MAX_GRAPH_TRACE_LEN];
|
int g_GraphBuffer[MAX_GRAPH_TRACE_LEN];
|
||||||
|
int g_OperationBuffer[MAX_GRAPH_TRACE_LEN];
|
||||||
size_t g_GraphTraceLen;
|
size_t g_GraphTraceLen;
|
||||||
|
|
||||||
/* write a manchester bit to the graph
|
/* write a manchester bit to the graph
|
||||||
|
@ -68,6 +69,7 @@ void AppendGraph(bool redraw, uint16_t clock, int bit) {
|
||||||
size_t ClearGraph(bool redraw) {
|
size_t ClearGraph(bool redraw) {
|
||||||
size_t gtl = g_GraphTraceLen;
|
size_t gtl = g_GraphTraceLen;
|
||||||
memset(g_GraphBuffer, 0x00, g_GraphTraceLen);
|
memset(g_GraphBuffer, 0x00, g_GraphTraceLen);
|
||||||
|
memset(g_OperationBuffer, 0x00, g_GraphTraceLen);
|
||||||
g_GraphTraceLen = 0;
|
g_GraphTraceLen = 0;
|
||||||
g_GraphStart = 0;
|
g_GraphStart = 0;
|
||||||
g_GraphStop = 0;
|
g_GraphStop = 0;
|
||||||
|
@ -78,6 +80,7 @@ size_t ClearGraph(bool redraw) {
|
||||||
|
|
||||||
return gtl;
|
return gtl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// option '1' to save g_GraphBuffer any other to restore
|
// option '1' to save g_GraphBuffer any other to restore
|
||||||
void save_restoreGB(uint8_t saveOpt) {
|
void save_restoreGB(uint8_t saveOpt) {
|
||||||
static int SavedGB[MAX_GRAPH_TRACE_LEN];
|
static int SavedGB[MAX_GRAPH_TRACE_LEN];
|
||||||
|
|
|
@ -48,6 +48,7 @@ bool fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, int *firstClockEdge);
|
||||||
#define GRAPH_RESTORE 0
|
#define GRAPH_RESTORE 0
|
||||||
|
|
||||||
extern int g_GraphBuffer[MAX_GRAPH_TRACE_LEN];
|
extern int g_GraphBuffer[MAX_GRAPH_TRACE_LEN];
|
||||||
|
extern int g_OperationBuffer[MAX_GRAPH_TRACE_LEN];
|
||||||
extern size_t g_GraphTraceLen;
|
extern size_t g_GraphTraceLen;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -778,6 +778,44 @@ void Plot::plotGridLines(QPainter *painter, QRect r) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Plot::plotOperations(int *buffer, size_t len, QPainter *painter, QRect plotRect) {
|
||||||
|
if(len == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPainterPath penPath;
|
||||||
|
int32_t x = xCoordOf(g_GraphStart, plotRect), prevX = 0;
|
||||||
|
int32_t y = yCoordOf(buffer[g_GraphStart], plotRect, gs_absVMax), prevY = 0;
|
||||||
|
int32_t past = 0, current = 0;
|
||||||
|
|
||||||
|
for (uint32_t pos = g_GraphStart; pos < len && xCoordOf(pos, plotRect) < plotRect.right(); pos++) {
|
||||||
|
if(pos == 0) continue; //Skip the first value of the buffer to prevent underflows
|
||||||
|
|
||||||
|
//Store the previous x and y values to move the pen to if we need to draw a line
|
||||||
|
prevX = x;
|
||||||
|
prevY = y;
|
||||||
|
|
||||||
|
x = xCoordOf(pos, plotRect);
|
||||||
|
current = buffer[pos];
|
||||||
|
past = buffer[pos - 1]; //Get the previous value for checking
|
||||||
|
y = yCoordOf(current, plotRect, gs_absVMax);
|
||||||
|
|
||||||
|
//We don't want to graph a line over the zero line, only operations stored in the buffer
|
||||||
|
if(current == 0 && past == 0) continue;
|
||||||
|
|
||||||
|
penPath.moveTo(prevX, prevY); //Move the pen
|
||||||
|
penPath.lineTo(x, y); //Draw the line from the previous coords to the new ones
|
||||||
|
|
||||||
|
if (g_GraphPixelsPerPoint > 10) {
|
||||||
|
QRect point(QPoint(x - 3, y - 3), QPoint(x + 3, y + 3));
|
||||||
|
painter->fillRect(point, WHITE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
painter->setPen(CITRON);
|
||||||
|
painter->drawPath(penPath);
|
||||||
|
}
|
||||||
|
|
||||||
#define HEIGHT_INFO 60
|
#define HEIGHT_INFO 60
|
||||||
#define WIDTH_AXES 80
|
#define WIDTH_AXES 80
|
||||||
|
|
||||||
|
@ -824,6 +862,12 @@ void Plot::paintEvent(QPaintEvent *event) {
|
||||||
if (g_DemodBufferLen > 8) {
|
if (g_DemodBufferLen > 8) {
|
||||||
PlotDemod(g_DemodBuffer, g_DemodBufferLen, plotRect, infoRect, &painter, 2, g_DemodStartIdx);
|
PlotDemod(g_DemodBuffer, g_DemodBufferLen, plotRect, infoRect, &painter, 2, g_DemodStartIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Plot the Operation Overlay
|
||||||
|
//setMaxAndStart(g_OperationBuffer, g_GraphTraceLen, plotRect);
|
||||||
|
plotOperations(g_OperationBuffer, g_GraphTraceLen, &painter, plotRect);
|
||||||
|
|
||||||
|
//Plot the Overlay
|
||||||
if (gs_useOverlays) {
|
if (gs_useOverlays) {
|
||||||
//init graph variables
|
//init graph variables
|
||||||
setMaxAndStart(s_OverlayBuff, g_GraphTraceLen, plotRect);
|
setMaxAndStart(s_OverlayBuff, g_GraphTraceLen, plotRect);
|
||||||
|
|
|
@ -48,6 +48,7 @@ class Plot: public QWidget {
|
||||||
void PlotGraph(int *buffer, size_t len, QRect plotRect, QRect annotationRect, QPainter *painter, int graphNum);
|
void PlotGraph(int *buffer, size_t len, QRect plotRect, QRect annotationRect, QPainter *painter, int graphNum);
|
||||||
void PlotDemod(uint8_t *buffer, size_t len, QRect plotRect, QRect annotationRect, QPainter *painter, int graphNum, uint32_t plotOffset);
|
void PlotDemod(uint8_t *buffer, size_t len, QRect plotRect, QRect annotationRect, QPainter *painter, int graphNum, uint32_t plotOffset);
|
||||||
void plotGridLines(QPainter *painter, QRect r);
|
void plotGridLines(QPainter *painter, QRect r);
|
||||||
|
void plotOperations(int *buffer, size_t len, QPainter *painter, QRect rect);
|
||||||
int xCoordOf(int i, QRect r);
|
int xCoordOf(int i, QRect r);
|
||||||
int yCoordOf(int v, QRect r, int maxVal);
|
int yCoordOf(int v, QRect r, int maxVal);
|
||||||
int valueOf_yCoord(int y, QRect r, int maxVal);
|
int valueOf_yCoord(int y, QRect r, int maxVal);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue