diff --git a/client/cmddata.c b/client/cmddata.c index f86c23025..0458a8df2 100644 --- a/client/cmddata.c +++ b/client/cmddata.c @@ -1020,6 +1020,18 @@ int CmdGraphShiftZero(const char *Cmd) return 0; } +int AskEdgeDetect(const int *in, int *out, int len, int threshold) { + int last = 0; + for(int i = 1; i= threshold) //large jump up + last = 127; + else if(in[i]-in[i-1] <= -1 * threshold) //large jump down + last = -127; + out[i-1] = last; + } + return 0; +} + //by marshmellow //use large jumps in read samples to identify edges of waves and then amplify that wave to max //similar to dirtheshold, threshold commands @@ -1027,19 +1039,12 @@ int CmdGraphShiftZero(const char *Cmd) int CmdAskEdgeDetect(const char *Cmd) { int thresLen = 25; - int last = 0; + int ans = 0; sscanf(Cmd, "%i", &thresLen); - for(int i = 1; i < GraphTraceLen; ++i){ - if (GraphBuffer[i] - GraphBuffer[i-1] >= thresLen) //large jump up - last = 127; - else if(GraphBuffer[i] - GraphBuffer[i-1] <= -1 * thresLen) //large jump down - last = -127; - - GraphBuffer[i-1] = last; - } + ans = AskEdgeDetect(GraphBuffer, GraphBuffer, GraphTraceLen, thresLen); RepaintGraphWindow(); - return 0; + return ans; } /* Print our clock rate */ diff --git a/client/cmddata.h b/client/cmddata.h index 9c5872e04..09cb447e7 100644 --- a/client/cmddata.h +++ b/client/cmddata.h @@ -78,6 +78,8 @@ int getSamples(const char *Cmd, bool silent); void setGrid_Clock(uint8_t clock); int directionalThreshold(const int* in, int *out, size_t len, int8_t up, int8_t down); +extern int AskEdgeDetect(const int *in, int *out, int len, int threshold); + int CmdDataIIR(const char *Cmd); #define MAX_DEMOD_BUF_LEN (1024*128)