\r
}\r
int CommandFinished;\r
+int offset = 64;\r
\r
static void ResizeCommandWindow(void)\r
{\r
\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
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
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
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
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
\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
}\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
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
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
SendMessage(CommandEdit, EM_SETSEL, strlen(str), strlen(str));\r
}\r
\r
-void ShowGui(void)\r
+void ShowGui()\r
{\r
WNDCLASSEX wc;\r
memset(&wc, 0, sizeof(wc));\r
}\r
}\r
\r
- UsbCommand c;\r
- if(ReceiveCommandPoll(&c)) {\r
- UsbCommandReceived(&c);\r
+ if (!offline)\r
+ {\r
+ UsbCommand c;\r
+ if(ReceiveCommandPoll(&c))\r
+ UsbCommandReceived(&c);\r
}\r
\r
Sleep(10);\r