]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - client/graph.c
6 int GraphBuffer
[MAX_GRAPH_TRACE_LEN
];
9 /* write a bit to the graph */
10 void AppendGraph(int redraw
, int clock
, int bit
)
14 for (i
= 0; i
< (int)(clock
/ 2); ++i
)
15 GraphBuffer
[GraphTraceLen
++] = bit
^ 1;
17 for (i
= (int)(clock
/ 2); i
< clock
; ++i
)
18 GraphBuffer
[GraphTraceLen
++] = bit
;
24 /* clear out our graph window */
25 int ClearGraph(int redraw
)
27 int gtl
= GraphTraceLen
;
39 int DetectClock(int peak
)
45 /* Detect peak if we don't have one */
47 for (i
= 0; i
< GraphTraceLen
; ++i
)
48 if (GraphBuffer
[i
] > peak
)
49 peak
= GraphBuffer
[i
];
51 for (i
= 1; i
< GraphTraceLen
; ++i
)
53 /* If this is the beginning of a peak */
54 if (GraphBuffer
[i
- 1] != GraphBuffer
[i
] && GraphBuffer
[i
] == peak
)
56 /* Find lowest difference between peaks */
57 if (lastpeak
&& i
- lastpeak
< clock
)
66 /* Get or auto-detect clock rate */
67 int GetClock(const char *str
, int peak
, int verbose
)
71 sscanf(str
, "%i", &clock
);
75 /* Auto-detect clock */
78 clock
= DetectClock(peak
);
79 /* Only print this message if we're not looping something */
81 PrintAndLog("Auto-detected clock rate: %d", clock
);