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.
This commit is contained in:
Jacob Litewski 2024-04-11 20:13:56 -04:00
commit 0608a7c530
2 changed files with 12 additions and 14 deletions

View file

@ -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"},

View file

@ -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