]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - client/graph.c
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
7 //-----------------------------------------------------------------------------
9 //-----------------------------------------------------------------------------
16 int GraphBuffer
[MAX_GRAPH_TRACE_LEN
];
19 /* write a bit to the graph */
20 void AppendGraph(int redraw
, int clock
, int bit
)
24 for (i
= 0; i
< (int)(clock
/ 2); ++i
)
25 GraphBuffer
[GraphTraceLen
++] = bit
^ 1;
27 for (i
= (int)(clock
/ 2); i
< clock
; ++i
)
28 GraphBuffer
[GraphTraceLen
++] = bit
;
34 /* clear out our graph window */
35 int ClearGraph(int redraw
)
37 int gtl
= GraphTraceLen
;
49 int DetectClock(int peak
)
55 /* Detect peak if we don't have one */
57 for (i
= 0; i
< GraphTraceLen
; ++i
)
58 if (GraphBuffer
[i
] > peak
)
59 peak
= GraphBuffer
[i
];
61 for (i
= 1; i
< GraphTraceLen
; ++i
)
63 /* If this is the beginning of a peak */
64 if (GraphBuffer
[i
- 1] != GraphBuffer
[i
] && GraphBuffer
[i
] == peak
)
66 /* Find lowest difference between peaks */
67 if (lastpeak
&& i
- lastpeak
< clock
)
76 /* Get or auto-detect clock rate */
77 int GetClock(const char *str
, int peak
, int verbose
)
81 sscanf(str
, "%i", &clock
);
85 /* Auto-detect clock */
88 clock
= DetectClock(peak
);
89 /* Only print this message if we're not looping something */
91 PrintAndLog("Auto-detected clock rate: %d", clock
);