From 3d2169b83376f84533277bb0d03f9f1212d613bf Mon Sep 17 00:00:00 2001 From: Jacob Litewski Date: Wed, 10 Apr 2024 19:09:37 -0400 Subject: [PATCH 1/5] Cursor A graph scrolling implementation If Cursor A goes off the screen, it will reposition the window to place the cursor in the middle of it. --- client/src/proxguiqt.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/client/src/proxguiqt.cpp b/client/src/proxguiqt.cpp index 23ba3f332..760257bcd 100644 --- a/client/src/proxguiqt.cpp +++ b/client/src/proxguiqt.cpp @@ -1260,33 +1260,55 @@ void Plot::keyPressEvent(QKeyEvent *event) { RepaintGraphWindow(); break; - case Qt::Key_BracketLeft: + case Qt::Key_BracketLeft: { if(event->modifiers() & Qt::ControlModifier) { CursorAPos -= 5; } else { CursorAPos -= 1; } + if((CursorAPos >= g_GraphStop) || (CursorAPos <= g_GraphStart)) { + uint32_t halfway = PageWidth / 2; + + if((CursorAPos - halfway) > g_GraphTraceLen) { + g_GraphStart = 0; + } else { + g_GraphStart = CursorAPos - halfway; + } + } + if(CursorAPos < g_GraphStart) { CursorAPos = g_GraphStart; } RepaintGraphWindow(); break; + } - case Qt::Key_BracketRight: + case Qt::Key_BracketRight: { if(event->modifiers() & Qt::ControlModifier) { CursorAPos += 5; } else { CursorAPos += 1; } + if((CursorAPos >= g_GraphStop) || (CursorAPos <= g_GraphStart)) { + uint32_t halfway = PageWidth / 2; + + if((CursorAPos + halfway) >= g_GraphTraceLen) { + g_GraphStart = g_GraphTraceLen - halfway; + } else { + g_GraphStart = CursorAPos - halfway; + } + } + if(CursorAPos >= g_GraphTraceLen) { CursorAPos = g_GraphTraceLen; } RepaintGraphWindow(); break; + } case Qt::Key_BraceLeft: if(event->modifiers() & Qt::ControlModifier) { From 8e3efec3e261dd5bdcb42355b2fa4e083d17121c Mon Sep 17 00:00:00 2001 From: Jacob Litewski Date: Thu, 11 Apr 2024 08:39:32 -0400 Subject: [PATCH 2/5] Rename s_Buff to s_OverlayBuff --- client/src/proxguiqt.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/client/src/proxguiqt.cpp b/client/src/proxguiqt.cpp index 760257bcd..cd465acde 100644 --- a/client/src/proxguiqt.cpp +++ b/client/src/proxguiqt.cpp @@ -45,7 +45,7 @@ extern "C" int preferences_save(void); -static int s_Buff[MAX_GRAPH_TRACE_LEN]; +static int s_OverlayBuff[MAX_GRAPH_TRACE_LEN]; static bool gs_useOverlays = false; static int gs_absVMax = 0; static uint32_t startMax; // Maximum offset in the graph (right side of graph) @@ -340,7 +340,7 @@ void SliderWidget::moveEvent(QMoveEvent *event) { void ProxWidget::applyOperation() { //printf("ApplyOperation()"); save_restoreGB(GRAPH_SAVE); - memcpy(g_GraphBuffer, s_Buff, sizeof(int) * g_GraphTraceLen); + memcpy(g_GraphBuffer, s_OverlayBuff, sizeof(int) * g_GraphTraceLen); RepaintGraphWindow(); } void ProxWidget::stickOperation() { @@ -348,21 +348,21 @@ void ProxWidget::stickOperation() { //printf("stickOperation()"); } void ProxWidget::vchange_autocorr(int v) { - int ans = AutoCorrelate(g_GraphBuffer, s_Buff, g_GraphTraceLen, v, true, false); + int ans = AutoCorrelate(g_GraphBuffer, s_OverlayBuff, g_GraphTraceLen, v, true, false); if (g_debugMode) printf("vchange_autocorr(w:%d): %d\n", v, ans); gs_useOverlays = true; RepaintGraphWindow(); } void ProxWidget::vchange_askedge(int v) { //extern int AskEdgeDetect(const int *in, int *out, int len, int threshold); - int ans = AskEdgeDetect(g_GraphBuffer, s_Buff, g_GraphTraceLen, v); + int ans = AskEdgeDetect(g_GraphBuffer, s_OverlayBuff, g_GraphTraceLen, v); if (g_debugMode) printf("vchange_askedge(w:%d)%d\n", v, ans); gs_useOverlays = true; RepaintGraphWindow(); } void ProxWidget::vchange_dthr_up(int v) { int down = opsController->horizontalSlider_dirthr_down->value(); - directionalThreshold(g_GraphBuffer, s_Buff, g_GraphTraceLen, v, down); + directionalThreshold(g_GraphBuffer, s_OverlayBuff, g_GraphTraceLen, v, down); //printf("vchange_dthr_up(%d)", v); gs_useOverlays = true; RepaintGraphWindow(); @@ -370,7 +370,7 @@ void ProxWidget::vchange_dthr_up(int v) { void ProxWidget::vchange_dthr_down(int v) { //printf("vchange_dthr_down(%d)", v); int up = opsController->horizontalSlider_dirthr_up->value(); - directionalThreshold(g_GraphBuffer, s_Buff, g_GraphTraceLen, v, up); + directionalThreshold(g_GraphBuffer, s_OverlayBuff, g_GraphTraceLen, v, up); gs_useOverlays = true; RepaintGraphWindow(); } @@ -566,7 +566,7 @@ void Plot::setMaxAndStart(int *buffer, size_t len, QRect plotRect) { uint32_t t = (plotRect.right() - plotRect.left() - 40) / g_GraphPixelsPerPoint; if (len >= t) { startMax = len - t; - } + } } if (g_GraphStart > startMax) { @@ -826,8 +826,8 @@ void Plot::paintEvent(QPaintEvent *event) { } if (gs_useOverlays) { //init graph variables - setMaxAndStart(s_Buff, g_GraphTraceLen, plotRect); - PlotGraph(s_Buff, g_GraphTraceLen, plotRect, infoRect, &painter, 1); + setMaxAndStart(s_OverlayBuff, g_GraphTraceLen, plotRect); + PlotGraph(s_OverlayBuff, g_GraphTraceLen, plotRect, infoRect, &painter, 1); } // End graph drawing From c2e43c3f466625fa750586c9482cb4e0b35b3d12 Mon Sep 17 00:00:00 2001 From: Jacob Litewski Date: Thu, 11 Apr 2024 08:57:26 -0400 Subject: [PATCH 3/5] 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. --- client/src/graph.c | 3 +++ client/src/graph.h | 1 + client/src/proxguiqt.cpp | 44 ++++++++++++++++++++++++++++++++++++++++ client/src/proxguiqt.h | 1 + 4 files changed, 49 insertions(+) diff --git a/client/src/graph.c b/client/src/graph.c index 8b97dcfad..c7a6fae8f 100644 --- a/client/src/graph.c +++ b/client/src/graph.c @@ -26,6 +26,7 @@ int g_GraphBuffer[MAX_GRAPH_TRACE_LEN]; +int g_OperationBuffer[MAX_GRAPH_TRACE_LEN]; size_t g_GraphTraceLen; /* 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 gtl = g_GraphTraceLen; memset(g_GraphBuffer, 0x00, g_GraphTraceLen); + memset(g_OperationBuffer, 0x00, g_GraphTraceLen); g_GraphTraceLen = 0; g_GraphStart = 0; g_GraphStop = 0; @@ -78,6 +80,7 @@ size_t ClearGraph(bool redraw) { return gtl; } + // option '1' to save g_GraphBuffer any other to restore void save_restoreGB(uint8_t saveOpt) { static int SavedGB[MAX_GRAPH_TRACE_LEN]; diff --git a/client/src/graph.h b/client/src/graph.h index 3a05dd8eb..b5cbf99e0 100644 --- a/client/src/graph.h +++ b/client/src/graph.h @@ -48,6 +48,7 @@ bool fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, int *firstClockEdge); #define GRAPH_RESTORE 0 extern int g_GraphBuffer[MAX_GRAPH_TRACE_LEN]; +extern int g_OperationBuffer[MAX_GRAPH_TRACE_LEN]; extern size_t g_GraphTraceLen; #ifdef __cplusplus diff --git a/client/src/proxguiqt.cpp b/client/src/proxguiqt.cpp index cd465acde..26645b75c 100644 --- a/client/src/proxguiqt.cpp +++ b/client/src/proxguiqt.cpp @@ -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 WIDTH_AXES 80 @@ -824,6 +862,12 @@ void Plot::paintEvent(QPaintEvent *event) { if (g_DemodBufferLen > 8) { 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) { //init graph variables setMaxAndStart(s_OverlayBuff, g_GraphTraceLen, plotRect); diff --git a/client/src/proxguiqt.h b/client/src/proxguiqt.h index 244d083e3..5fd739073 100644 --- a/client/src/proxguiqt.h +++ b/client/src/proxguiqt.h @@ -48,6 +48,7 @@ class Plot: public QWidget { 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 plotGridLines(QPainter *painter, QRect r); + void plotOperations(int *buffer, size_t len, QPainter *painter, QRect rect); int xCoordOf(int i, QRect r); int yCoordOf(int v, QRect r, int maxVal); int valueOf_yCoord(int y, QRect r, int maxVal); From 6b72e39f51a99249446f3498b950cb30ab396fd1 Mon Sep 17 00:00:00 2001 From: Jacob Litewski Date: Thu, 11 Apr 2024 20:06:36 -0400 Subject: [PATCH 4/5] Command Organization in cmddata.c Getting ready to do some refactoring! --- client/src/cmddata.c | 101 +++++++++++++++++++++---------------------- client/src/graph.c | 8 +++- 2 files changed, 56 insertions(+), 53 deletions(-) diff --git a/client/src/cmddata.c b/client/src/cmddata.c index a5e6c7784..fc09bb5ef 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -3788,60 +3788,59 @@ static int CmdXor(const char *Cmd) { } static command_t CommandTable[] = { - {"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("General") "-------------------------"}, - {"help", CmdHelp, AlwaysAvailable, "This help"}, - {"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("Modulation") "-------------------------"}, - {"biphaserawdecode", CmdBiphaseDecodeRaw, AlwaysAvailable, "Biphase decode bin stream in DemodBuffer"}, - {"detectclock", CmdDetectClockRate, AlwaysAvailable, "Detect ASK, FSK, NRZ, PSK clock rate of wave in GraphBuffer"}, - {"fsktonrz", CmdFSKToNRZ, AlwaysAvailable, "Convert fsk2 to nrz wave for alternate fsk demodulating (for weak fsk)"}, - {"manrawdecode", Cmdmandecoderaw, AlwaysAvailable, "Manchester decode binary stream in DemodBuffer"}, - {"modulation", CmdDataModulationSearch, AlwaysAvailable, "Identify LF signal for clock and modulation"}, - {"rawdemod", CmdRawDemod, AlwaysAvailable, "Demodulate the data in the GraphBuffer and output binary"}, + {"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("General") "-------------------------"}, + {"help", CmdHelp, AlwaysAvailable, "This help"}, + {"plot", CmdPlot, AlwaysAvailable, "Show graph window"}, + {"hide", CmdHide, AlwaysAvailable, "Hide graph window"}, + {"load", CmdLoad, AlwaysAvailable, "Load contents of file into graph window"}, + {"save", CmdSave, AlwaysAvailable, "Save signal trace data"}, + {"clear", CmdBuffClear, AlwaysAvailable, "Clears various buffers used by the graph window"}, - {"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("Graph") "-------------------------"}, - {"askedgedetect", CmdAskEdgeDetect, AlwaysAvailable, "Adjust Graph for manual ASK demod"}, - {"autocorr", CmdAutoCorr, AlwaysAvailable, "Autocorrelation over window"}, - {"dirthreshold", CmdDirectionalThreshold, AlwaysAvailable, "Max rising higher up-thres/ Min falling lower down-thres"}, - {"decimate", CmdDecimate, AlwaysAvailable, "Decimate samples"}, - {"envelope", CmdEnvelope, AlwaysAvailable, "Generate square envelope of samples"}, - {"undecimate", CmdUndecimate, AlwaysAvailable, "Un-decimate samples"}, - {"hide", CmdHide, AlwaysAvailable, "Hide graph window"}, - {"hpf", CmdHpf, AlwaysAvailable, "Remove DC offset from trace"}, - {"iir", CmdDataIIR, AlwaysAvailable, "Apply IIR buttersworth filter on plot data"}, - {"grid", CmdGrid, AlwaysAvailable, "overlay grid on graph window"}, - {"ltrim", CmdLtrim, AlwaysAvailable, "Trim samples from left of trace"}, - {"mtrim", CmdMtrim, AlwaysAvailable, "Trim out samples from the specified start to the specified stop"}, - {"norm", CmdNorm, AlwaysAvailable, "Normalize max/min to +/-128"}, - {"plot", CmdPlot, AlwaysAvailable, "Show graph window"}, + {"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("Modulation") "-------------------------"}, + {"detectclock", CmdDetectClockRate, AlwaysAvailable, "Detect ASK, FSK, NRZ, PSK clock rate of wave in GraphBuffer"}, + {"biphaserawdecode", CmdBiphaseDecodeRaw, AlwaysAvailable, "Biphase decode bin stream in DemodBuffer"}, + {"fsktonrz", CmdFSKToNRZ, AlwaysAvailable, "Convert fsk2 to nrz wave for alternate fsk demodulating (for weak fsk)"}, + {"manrawdecode", Cmdmandecoderaw, AlwaysAvailable, "Manchester decode binary stream in DemodBuffer"}, + {"modulation", CmdDataModulationSearch, AlwaysAvailable, "Identify LF signal for clock and modulation"}, + {"rawdemod", CmdRawDemod, AlwaysAvailable, "Demodulate the data in the GraphBuffer and output binary"}, - {"cthreshold", CmdCenterThreshold, AlwaysAvailable, "Average out all values between"}, + {"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("Graph") "-------------------------"}, + {"norm", CmdNorm, AlwaysAvailable, "Normalize max/min to +/-128"}, + {"askedgedetect", CmdAskEdgeDetect, AlwaysAvailable, "Adjust Graph for manual ASK demod"}, + {"autocorr", CmdAutoCorr, AlwaysAvailable, "Autocorrelation over window"}, + {"cthreshold", CmdCenterThreshold, AlwaysAvailable, "Average out all values between"}, + {"dirthreshold", CmdDirectionalThreshold, AlwaysAvailable, "Max rising higher up-thres/ Min falling lower down-thres"}, + {"envelope", CmdEnvelope, AlwaysAvailable, "Generate square envelope of samples"}, + {"decimate", CmdDecimate, AlwaysAvailable, "Decimate samples"}, + {"undecimate", CmdUndecimate, AlwaysAvailable, "Un-decimate samples"}, + {"hpf", CmdHpf, AlwaysAvailable, "Remove DC offset from trace"}, + {"iir", CmdDataIIR, AlwaysAvailable, "Apply IIR buttersworth filter on plot data"}, + {"grid", CmdGrid, AlwaysAvailable, "overlay grid on graph window"}, + {"ltrim", CmdLtrim, AlwaysAvailable, "Trim samples from left of trace"}, + {"rtrim", CmdRtrim, AlwaysAvailable, "Trim samples from right of trace"}, + {"mtrim", CmdMtrim, AlwaysAvailable, "Trim out samples from the specified start to the specified stop"}, + {"setgraphmarkers", CmdSetGraphMarkers, AlwaysAvailable, "Set blue and orange marker in graph window"}, + {"shiftgraphzero", CmdGraphShiftZero, AlwaysAvailable, "Shift 0 for Graphed wave + or - shift value"}, + {"timescale", CmdTimeScale, AlwaysAvailable, "Set cursor display timescale"}, + {"zerocrossings", CmdZerocrossings, AlwaysAvailable, "Count time between zero-crossings"}, + {"convertbitstream", CmdConvertBitStream, AlwaysAvailable, "Convert GraphBuffer's 0/1 values to 127 / -127"}, + {"getbitstream", CmdGetBitStream, AlwaysAvailable, "Convert GraphBuffer's >=1 values to 1 and <1 to 0"}, - {"rtrim", CmdRtrim, AlwaysAvailable, "Trim samples from right of trace"}, - {"setgraphmarkers", CmdSetGraphMarkers, AlwaysAvailable, "Set blue and orange marker in graph window"}, - {"shiftgraphzero", CmdGraphShiftZero, AlwaysAvailable, "Shift 0 for Graphed wave + or - shift value"}, - {"timescale", CmdTimeScale, AlwaysAvailable, "Set cursor display timescale"}, - {"zerocrossings", CmdZerocrossings, AlwaysAvailable, "Count time between zero-crossings"}, - {"convertbitstream", CmdConvertBitStream, AlwaysAvailable, "Convert GraphBuffer's 0/1 values to 127 / -127"}, - {"getbitstream", CmdGetBitStream, AlwaysAvailable, "Convert GraphBuffer's >=1 values to 1 and <1 to 0"}, - - {"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("Operations") "-------------------------"}, - {"asn1", CmdAsn1Decoder, AlwaysAvailable, "ASN1 decoder"}, - {"atr", CmdAtrLookup, AlwaysAvailable, "ATR lookup"}, - {"bin2hex", Cmdbin2hex, AlwaysAvailable, "Converts binary to hexadecimal"}, - {"bitsamples", CmdBitsamples, IfPm3Present, "Get raw samples as bitstring"}, - {"bmap", CmdBinaryMap, AlwaysAvailable, "Convert hex value according a binary template"}, - {"clear", CmdBuffClear, AlwaysAvailable, "Clears bigbuf on deviceside and graph window"}, - {"crypto", CmdCryptography, AlwaysAvailable, "Encrypt and decrypt data"}, - {"diff", CmdDiff, AlwaysAvailable, "Diff of input files"}, - {"hexsamples", CmdHexsamples, IfPm3Present, "Dump big buffer as hex bytes"}, - {"hex2bin", Cmdhex2bin, AlwaysAvailable, "Converts hexadecimal to binary"}, - {"load", CmdLoad, AlwaysAvailable, "Load contents of file into graph window"}, - {"num", CmdNumCon, AlwaysAvailable, "Converts dec/hex/bin"}, - {"print", CmdPrintDemodBuff, AlwaysAvailable, "Print the data in the DemodBuffer"}, - {"samples", CmdSamples, IfPm3Present, "Get raw samples for graph window ( GraphBuffer )"}, - {"save", CmdSave, AlwaysAvailable, "Save signal trace data ( GraphBuffer )"}, - {"setdebugmode", CmdSetDebugMode, AlwaysAvailable, "Set Debugging Level on client side"}, - {"xor", CmdXor, AlwaysAvailable, "Xor a input string"}, + {"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("Operations") "-------------------------"}, + {"asn1", CmdAsn1Decoder, AlwaysAvailable, "ASN1 decoder"}, + {"atr", CmdAtrLookup, AlwaysAvailable, "ATR lookup"}, + {"bin2hex", Cmdbin2hex, AlwaysAvailable, "Converts binary to hexadecimal"}, + {"bitsamples", CmdBitsamples, IfPm3Present, "Get raw samples as bitstring"}, + {"bmap", CmdBinaryMap, AlwaysAvailable, "Convert hex value according a binary template"}, + {"crypto", CmdCryptography, AlwaysAvailable, "Encrypt and decrypt data"}, + {"diff", CmdDiff, AlwaysAvailable, "Diff of input files"}, + {"hexsamples", CmdHexsamples, IfPm3Present, "Dump big buffer as hex bytes"}, + {"hex2bin", Cmdhex2bin, AlwaysAvailable, "Converts hexadecimal to binary"}, + {"num", CmdNumCon, AlwaysAvailable, "Converts dec/hex/bin"}, + {"print", CmdPrintDemodBuff, AlwaysAvailable, "Print the data in the DemodBuffer"}, + {"samples", CmdSamples, IfPm3Present, "Get raw samples for graph window ( GraphBuffer )"}, + {"setdebugmode", CmdSetDebugMode, AlwaysAvailable, "Set Debugging Level on client side"}, + {"xor", CmdXor, AlwaysAvailable, "Xor a input string"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/src/graph.c b/client/src/graph.c index c7a6fae8f..7d77aabf2 100644 --- a/client/src/graph.c +++ b/client/src/graph.c @@ -95,6 +95,7 @@ void save_restoreGB(uint8_t saveOpt) { Savedg_GridOffsetAdj = g_GridOffset; } else if (GB_Saved) { //restore memcpy(g_GraphBuffer, SavedGB, sizeof(g_GraphBuffer)); + memcpy(g_OperationBuffer, SavedGB, sizeof(g_OperationBuffer)); g_GraphTraceLen = SavedGBlen; g_GridOffset = Savedg_GridOffsetAdj; RepaintGraphWindow(); @@ -106,11 +107,14 @@ void setGraphBuf(const uint8_t *src, size_t size) { ClearGraph(false); - if (size > MAX_GRAPH_TRACE_LEN) + if (size > MAX_GRAPH_TRACE_LEN) { size = MAX_GRAPH_TRACE_LEN; + } - for (size_t i = 0; i < size; ++i) + for (size_t i = 0; i < size; ++i) { g_GraphBuffer[i] = src[i] - 128; + g_OperationBuffer[i] = src[i] - 128; + } g_GraphTraceLen = size; RepaintGraphWindow(); From 0608a7c5304fe73fc57b024c72fa90858440a397 Mon Sep 17 00:00:00 2001 From: Jacob Litewski Date: Thu, 11 Apr 2024 20:13:56 -0400 Subject: [PATCH 5/5] Minor Changes to the Operation Buffer Implementation Instead of being initialized as all zeros and showing changes if those values are not zero, it now has a copy of the Graph Buffer data, and will show changes if it's different from what's stored in the Graph Buffer. --- client/src/cmddata.c | 16 ++++++++-------- client/src/proxguiqt.cpp | 10 ++++------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/client/src/cmddata.c b/client/src/cmddata.c index fc09bb5ef..bdeca3043 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -3790,11 +3790,11 @@ static int CmdXor(const char *Cmd) { static command_t CommandTable[] = { {"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("General") "-------------------------"}, {"help", CmdHelp, AlwaysAvailable, "This help"}, - {"plot", CmdPlot, AlwaysAvailable, "Show graph window"}, - {"hide", CmdHide, AlwaysAvailable, "Hide graph window"}, + {"clear", CmdBuffClear, AlwaysAvailable, "Clears various buffers used by the graph window"}, + {"hide", CmdHide, AlwaysAvailable, "Hide the graph window"}, + {"plot", CmdPlot, AlwaysAvailable, "Show the graph window"}, {"load", CmdLoad, AlwaysAvailable, "Load contents of file into graph window"}, {"save", CmdSave, AlwaysAvailable, "Save signal trace data"}, - {"clear", CmdBuffClear, AlwaysAvailable, "Clears various buffers used by the graph window"}, {"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("Modulation") "-------------------------"}, {"detectclock", CmdDetectClockRate, AlwaysAvailable, "Detect ASK, FSK, NRZ, PSK clock rate of wave in GraphBuffer"}, @@ -3805,26 +3805,26 @@ static command_t CommandTable[] = { {"rawdemod", CmdRawDemod, AlwaysAvailable, "Demodulate the data in the GraphBuffer and output binary"}, {"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("Graph") "-------------------------"}, - {"norm", CmdNorm, AlwaysAvailable, "Normalize max/min to +/-128"}, {"askedgedetect", CmdAskEdgeDetect, AlwaysAvailable, "Adjust Graph for manual ASK demod"}, {"autocorr", CmdAutoCorr, AlwaysAvailable, "Autocorrelation over window"}, {"cthreshold", CmdCenterThreshold, AlwaysAvailable, "Average out all values between"}, {"dirthreshold", CmdDirectionalThreshold, AlwaysAvailable, "Max rising higher up-thres/ Min falling lower down-thres"}, - {"envelope", CmdEnvelope, AlwaysAvailable, "Generate square envelope of samples"}, {"decimate", CmdDecimate, AlwaysAvailable, "Decimate samples"}, {"undecimate", CmdUndecimate, AlwaysAvailable, "Un-decimate samples"}, + {"envelope", CmdEnvelope, AlwaysAvailable, "Generate square envelope of samples"}, + {"grid", CmdGrid, AlwaysAvailable, "overlay grid on graph window"}, {"hpf", CmdHpf, AlwaysAvailable, "Remove DC offset from trace"}, {"iir", CmdDataIIR, AlwaysAvailable, "Apply IIR buttersworth filter on plot data"}, - {"grid", CmdGrid, AlwaysAvailable, "overlay grid on graph window"}, {"ltrim", CmdLtrim, AlwaysAvailable, "Trim samples from left of trace"}, - {"rtrim", CmdRtrim, AlwaysAvailable, "Trim samples from right of trace"}, {"mtrim", CmdMtrim, AlwaysAvailable, "Trim out samples from the specified start to the specified stop"}, + {"rtrim", CmdRtrim, AlwaysAvailable, "Trim samples from right of trace"}, + {"norm", CmdNorm, AlwaysAvailable, "Normalize max/min to +/-128"}, {"setgraphmarkers", CmdSetGraphMarkers, AlwaysAvailable, "Set blue and orange marker in graph window"}, {"shiftgraphzero", CmdGraphShiftZero, AlwaysAvailable, "Shift 0 for Graphed wave + or - shift value"}, {"timescale", CmdTimeScale, AlwaysAvailable, "Set cursor display timescale"}, - {"zerocrossings", CmdZerocrossings, AlwaysAvailable, "Count time between zero-crossings"}, {"convertbitstream", CmdConvertBitStream, AlwaysAvailable, "Convert GraphBuffer's 0/1 values to 127 / -127"}, {"getbitstream", CmdGetBitStream, AlwaysAvailable, "Convert GraphBuffer's >=1 values to 1 and <1 to 0"}, + {"zerocrossings", CmdZerocrossings, AlwaysAvailable, "Count time between zero-crossings"}, {"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("Operations") "-------------------------"}, {"asn1", CmdAsn1Decoder, AlwaysAvailable, "ASN1 decoder"}, diff --git a/client/src/proxguiqt.cpp b/client/src/proxguiqt.cpp index 26645b75c..79d86d0db 100644 --- a/client/src/proxguiqt.cpp +++ b/client/src/proxguiqt.cpp @@ -538,6 +538,7 @@ static const QColor GREEN = QColor(100, 255, 100); static const QColor RED = QColor(255, 100, 100); static const QColor BLUE = QColor(100, 100, 255); static const QColor YELLOW = QColor(255, 255, 0); +static const QColor CITRON = QColor(215, 197, 46); static const QColor PINK = QColor(255, 0, 255); static const QColor ORANGE = QColor(255, 153, 0); static const QColor LIGHTBLUE = QColor(100, 209, 246); @@ -786,22 +787,19 @@ void Plot::plotOperations(int *buffer, size_t len, QPainter *painter, QRect plot 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; + int32_t 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; + //We only want to graph changes between the Graph Buffer and the Operation Buffer + if(current == g_GraphBuffer[pos]) continue; penPath.moveTo(prevX, prevY); //Move the pen penPath.lineTo(x, y); //Draw the line from the previous coords to the new ones