]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - winsrc/gui.cpp
- Added new Makefile.linux in bootrom directory
[proxmark3-svn] / winsrc / gui.cpp
index e4e530b334043c4af025d391a82bb9ad097b94fc..05f05e1aa78fb24287b2fd40e60f0c4889b1130e 100644 (file)
@@ -64,6 +64,7 @@ void ExecCmd(char *cmd)
 \r
 }\r
 int CommandFinished;\r
+int offset = 64;\r
 \r
 static void ResizeCommandWindow(void)\r
 {\r
@@ -122,8 +123,8 @@ static void PaintGraph(HDC hdc)
 \r
        SelectObject(hdc, WhitePen);\r
 \r
-       MoveToEx(hdc, r.left + 40, r.top, NULL);\r
-       LineTo(hdc, r.left + 40, r.bottom);\r
+       MoveToEx(hdc, r.left + offset, r.top, NULL);\r
+       LineTo(hdc, r.left + offset, r.bottom);\r
 \r
        int zeroHeight = r.top + (r.bottom - r.top) / 2;\r
        SelectObject(hdc, GreyPen);\r
@@ -131,7 +132,7 @@ static void PaintGraph(HDC hdc)
        LineTo(hdc, r.right, zeroHeight);\r
 \r
        int startMax =\r
-               (GraphTraceLen - (int)((r.right - r.left - 40) / GraphPixelsPerPoint));\r
+               (GraphTraceLen - (int)((r.right - r.left - offset) / GraphPixelsPerPoint));\r
        if(startMax < 0) {\r
                startMax = 0;\r
        }\r
@@ -151,7 +152,7 @@ static void PaintGraph(HDC hdc)
                if(fabs((double)GraphBuffer[i]) > absYMax) {\r
                        absYMax = (int)fabs((double)GraphBuffer[i]);\r
                }\r
-               int x = 40 + (int)((i - GraphStart)*GraphPixelsPerPoint);\r
+               int x = offset + (int)((i - GraphStart)*GraphPixelsPerPoint);\r
                if(x > r.right) {\r
                        break;\r
                }\r
@@ -163,12 +164,15 @@ static void PaintGraph(HDC hdc)
        SetBkColor(hdc, RGB(0, 0, 0));\r
 \r
        // number of points that will be plotted\r
-       int span = (int)((r.right - r.left) / GraphPixelsPerPoint);\r
-       // one label every 100 pixels, let us say\r
-       int labels = (r.right - r.left - 40) / 100;\r
+       double span = (int)((r.right - r.left) / GraphPixelsPerPoint);\r
+\r
+       // one label every offset pixels, let us say\r
+       int labels = (r.right - r.left - offset) / offset;\r
        if(labels <= 0) labels = 1;\r
-       int pointsPerLabel = span / labels;\r
+       // round to nearest power of 2\r
+       int pointsPerLabel = (int)(log(span / labels)/log(2.0));\r
        if(pointsPerLabel <= 0) pointsPerLabel = 1;\r
+       pointsPerLabel = (int)pow(2.0,pointsPerLabel);\r
 \r
        int yMin = INT_MAX;\r
        int yMax = INT_MIN;\r
@@ -179,7 +183,7 @@ static void PaintGraph(HDC hdc)
                if(i >= GraphTraceLen) {\r
                        break;\r
                }\r
-               int x = 40 + (int)((i - GraphStart)*GraphPixelsPerPoint);\r
+               int x = offset + (int)((i - GraphStart)*GraphPixelsPerPoint);\r
                if(x > r.right + GraphPixelsPerPoint) {\r
                        break;\r
                }\r
@@ -212,8 +216,8 @@ static void PaintGraph(HDC hdc)
 \r
                if(((i - GraphStart) % pointsPerLabel == 0) && i != GraphStart) {\r
                        SelectObject(hdc, WhitePen);\r
-                       MoveToEx(hdc, x, zeroHeight - 3, NULL);\r
-                       LineTo(hdc, x, zeroHeight + 3);\r
+                       MoveToEx(hdc, x, zeroHeight - 8, NULL);\r
+                       LineTo(hdc, x, zeroHeight + 8);\r
 \r
                        char str[100];\r
                        sprintf(str, "+%d", (i - GraphStart));\r
@@ -244,9 +248,9 @@ static void PaintGraph(HDC hdc)
        }\r
 \r
        char str[100];\r
-       sprintf(str, "@%d   max=%d min=%d mean=%d n=%d/%d    dt=%d [%.3f]",\r
+       sprintf(str, "@%d   max=%d min=%d mean=%d n=%d/%d    dt=%d [%.3f] zoom=%.3f",\r
                GraphStart, yMax, yMin, yMean, n, GraphTraceLen,\r
-               CursorBPos - CursorAPos, (CursorBPos - CursorAPos)/CursorScaleFactor);\r
+               CursorBPos - CursorAPos, (CursorBPos - CursorAPos)/CursorScaleFactor, GraphPixelsPerPoint);\r
        TextOut(hdc, 50, r.bottom - 20, str, strlen(str));\r
 }\r
 \r
@@ -277,28 +281,28 @@ static LRESULT CALLBACK
                case WM_KEYDOWN:\r
                        switch(wParam) {\r
                                case VK_DOWN:\r
-                                       if(GraphPixelsPerPoint <= 50) {\r
+                                       if(GraphPixelsPerPoint <= 8) {\r
                                                GraphPixelsPerPoint *= 2;\r
                                        }\r
                                        break;\r
 \r
                                case VK_UP:\r
-                                       if(GraphPixelsPerPoint >= 0.02) {\r
+                                       if(GraphPixelsPerPoint >= 0.01) {\r
                                                GraphPixelsPerPoint /= 2;\r
                                        }\r
                                        break;\r
 \r
                                case VK_RIGHT:\r
-                                       if(GraphPixelsPerPoint < 20) {\r
-                                               GraphStart += (int)(20 / GraphPixelsPerPoint);\r
+                                       if(GraphPixelsPerPoint < 16) {\r
+                                               GraphStart += (int)(16 / GraphPixelsPerPoint);\r
                                        } else {\r
                                                GraphStart++;\r
                                        }\r
                                        break;\r
 \r
                                case VK_LEFT:\r
-                                       if(GraphPixelsPerPoint < 20) {\r
-                                               GraphStart -= (int)(20 / GraphPixelsPerPoint);\r
+                                       if(GraphPixelsPerPoint < 16) {\r
+                                               GraphStart -= (int)(16 / GraphPixelsPerPoint);\r
                                        } else {\r
                                                GraphStart--;\r
                                        }\r
@@ -314,7 +318,7 @@ nopaint:
                case WM_LBUTTONDOWN:\r
                case WM_RBUTTONDOWN: {\r
                        int x = LOWORD(lParam);\r
-                       x -= 40;\r
+                       x -= offset;\r
                        x = (int)(x / GraphPixelsPerPoint);\r
                        x += GraphStart;\r
                        if(msg == WM_LBUTTONDOWN) {\r
Impressum, Datenschutz