]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmddata.c
Fixed undecimation command
[proxmark3-svn] / client / cmddata.c
index fa056b6794b72eb24d96c30bc990881593d6e495..8f73b4007de21700047bc3f903372211e092214f 100644 (file)
@@ -540,6 +540,43 @@ int CmdDec(const char *Cmd)
   RepaintGraphWindow();
   return 0;
 }
+/**
+ * Undecimate - I'd call it 'interpolate', but we'll save that
+ * name until someone does an actual interpolation command, not just
+ * blindly repeating samples
+ * @param Cmd
+ * @return
+ */
+int CmdUndec(const char *Cmd)
+{
+       if(param_getchar(Cmd, 0) == 'h')
+       {
+               PrintAndLog("Usage: data undec [factor]");
+               PrintAndLog("This function performs un-decimation, by repeating each sample N times");
+               PrintAndLog("Options:        ");
+               PrintAndLog("       h            This help");
+               PrintAndLog("       factor       The number of times to repeat each sample.[default:2]");
+               PrintAndLog("Example: 'data undec 3'");
+               return 0;
+       }
+
+       uint8_t factor = param_get8ex(Cmd, 0,2, 10);
+       //We have memory, don't we?
+       int swap[MAX_GRAPH_TRACE_LEN] = { 0 };
+       uint32_t g_index = 0 ,s_index = 0;
+       while(g_index < GraphTraceLen && s_index < MAX_GRAPH_TRACE_LEN)
+       {
+               int count = 0;
+               for(count = 0; count < factor && s_index+count < MAX_GRAPH_TRACE_LEN; count ++)
+                       swap[s_index+count] = GraphBuffer[g_index];
+               s_index+=count;
+       }
+
+       memcpy(GraphBuffer,swap, s_index * sizeof(int));
+       GraphTraceLen = s_index;
+       RepaintGraphWindow();
+       return 0;
+}
 
 /* Print our clock rate */
 // uses data from graphbuffer
@@ -1651,7 +1688,8 @@ static command_t CommandTable[] =
   {"threshold",     CmdThreshold,       1, "<threshold> -- Maximize/minimize every value in the graph window depending on threshold"},
        {"dirthreshold",  CmdDirectionalThreshold,   1, "<thres up> <thres down> -- Max rising higher up-thres/ Min falling lower down-thres, keep rest as prev."},
        {"tune",          CmdTuneSamples,     0, "Get hw tune samples for graph window"},
-  {"zerocrossings", CmdZerocrossings,   1, "Count time between zero-crossings"},
+       {"undec",         CmdUndec,         1, "Un-decimate samples by 2"},
+       {"zerocrossings", CmdZerocrossings,   1, "Count time between zero-crossings"},
   {NULL, NULL, 0, NULL}
 };
 
Impressum, Datenschutz