From 180ec86ef0c5a005b7a677b6da3d98b8b127782f Mon Sep 17 00:00:00 2001
From: iceman1001 <iceman@iuse.se>
Date: Mon, 20 Jun 2016 13:26:45 +0200
Subject: [PATCH] @marshmellow42 's fix the AskEdgeDetect cleaning tool.
 https://github.com/marshmellow42/proxmark3/commit/de53156e1ea6982f03a6c39adf1ae17a57056132

---
 client/cmddata.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/client/cmddata.c b/client/cmddata.c
index d0c2dfb3..40884a14 100644
--- a/client/cmddata.c
+++ b/client/cmddata.c
@@ -877,13 +877,16 @@ int CmdGraphShiftZero(const char *Cmd)
 int CmdAskEdgeDetect(const char *Cmd)
 {
 	int thresLen = 25;
+	int last = 0;
 	sscanf(Cmd, "%i", &thresLen); 
 
-	for(int i = 1; i<GraphTraceLen; i++){
-		if (GraphBuffer[i]-GraphBuffer[i-1]>=thresLen) //large jump up
-			GraphBuffer[i-1] = 127;
-		else if(GraphBuffer[i]-GraphBuffer[i-1]<=-1*thresLen) //large jump down
-			GraphBuffer[i-1] = -127;
+	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;
 	}
 	RepaintGraphWindow();
 	return 0;
-- 
2.39.5