5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
23 coord_t
getCurveYCoord(FnFuncP fn
, int x
, int width
)
25 return limit(-width
, -divRoundClosest(fn(divRoundClosest(x
* RESX
, width
)) * width
, RESX
), +width
);
28 void drawFunction(FnFuncP fn
, int x
, int y
, int width
)
31 int right
= x
+ width
;
34 lcdDrawSolidHorizontalLine(left
, y
, width
*2+1, CURVE_AXIS_COLOR
);
35 lcdDrawSolidVerticalLine(x
, y
-width
, width
*2, CURVE_AXIS_COLOR
);
38 lcdDrawVerticalLine(left
+width
/2, y
-width
, width
*2, STASHED
, CURVE_AXIS_COLOR
);
39 lcdDrawVerticalLine(right
-width
/2, y
-width
, width
*2, STASHED
, CURVE_AXIS_COLOR
);
40 lcdDrawHorizontalLine(left
, y
-width
/2, width
*2+1, STASHED
, CURVE_AXIS_COLOR
);
41 lcdDrawHorizontalLine(left
, y
+width
/2, width
*2+1, STASHED
, CURVE_AXIS_COLOR
);
44 lcdDrawSolidVerticalLine(left
, y
-width
, width
*2, TEXT_COLOR
);
45 lcdDrawSolidVerticalLine(right
, y
-width
, width
*2, TEXT_COLOR
);
46 lcdDrawSolidHorizontalLine(left
, y
-width
, width
*2+1, TEXT_COLOR
);
47 lcdDrawSolidHorizontalLine(left
, y
+width
, width
*2+1, TEXT_COLOR
);
49 coord_t prev_yv
= (coord_t
)-1;
51 for (int xv
=-width
; xv
<=width
; xv
+=1) {
52 coord_t yv
= y
+ getCurveYCoord(fn
, xv
, width
);
53 if (prev_yv
!= (coord_t
)-1) {
55 for (int y
=prev_yv
; y
<=yv
; y
+=1) {
56 lcdDrawBitmapPattern(x
+xv
-2, y
-2, LBM_POINT
, TEXT_COLOR
);
60 for (int y
=yv
; y
<=prev_yv
; y
+=1) {
61 lcdDrawBitmapPattern(x
+xv
-2, y
-2, LBM_POINT
, TEXT_COLOR
);
69 void drawCurveVerticalScale(int x
)
71 for (int i
=0; i
<=20; i
++) {
72 lcdDrawSolidHorizontalLine(x
, CURVE_CENTER_Y
-CURVE_SIDE_WIDTH
+i
*CURVE_SIDE_WIDTH
/10, 10, TEXT_COLOR
);
76 void drawCurveHorizontalScale()
78 for (int i
=0; i
<=20; i
++) {
79 lcdDrawSolidVerticalLine(CURVE_CENTER_X
-CURVE_SIDE_WIDTH
+i
*CURVE_SIDE_WIDTH
/10, CURVE_CENTER_Y
+CURVE_SIDE_WIDTH
+5, 10, TEXT_COLOR
);
83 void drawCurveCoord(int x
, int y
, const char * text
, bool active
)
85 lcd
->drawSolidFilledRect(x
, y
, CURVE_COORD_WIDTH
, CURVE_COORD_HEIGHT
, CURVE_CURSOR_COLOR
);
86 lcdDrawText(x
+3+(CURVE_COORD_WIDTH
-1-getTextWidth(text
, SMLSIZE
))/2, y
+1, text
, LEFT
|SMLSIZE
|TEXT_BGCOLOR
);
88 lcdDrawBitmapPattern(x
, y
, LBM_CURVE_COORD_SHADOW
, TEXT_COLOR
);
92 void drawCurvePoint(int x
, int y
, LcdFlags color
)
94 lcdDrawBitmapPattern(x
, y
, LBM_CURVE_POINT
, color
);
95 lcdDrawBitmapPattern(x
, y
, LBM_CURVE_POINT_CENTER
, TEXT_BGCOLOR
);