diff options
Diffstat (limited to 'demos/modules/graph/main.c')
-rw-r--r-- | demos/modules/graph/main.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/demos/modules/graph/main.c b/demos/modules/graph/main.c new file mode 100644 index 00000000..bd2da2f6 --- /dev/null +++ b/demos/modules/graph/main.c @@ -0,0 +1,54 @@ +#include "ch.h"
+#include "hal.h"
+#include "gfx.h"
+#include "math.h"
+
+int data[5][2] = {
+ { 0, 0 },
+ { 10, 10 },
+ { 20, 20 },
+ { 30, 30 },
+ { 40, 40 }
+};
+
+GGraphObject g;
+
+GGraphStyle GraphStyle2 = {
+ { GGRAPH_POINT_DOT, 0, Green }, // point
+ { GGRAPH_LINE_DOT, 2, Gray }, // line
+ { GGRAPH_LINE_SOLID, 0, White }, // x axis
+ { GGRAPH_LINE_SOLID, 0, White }, // y axis
+ { GGRAPH_LINE_NONE, 0, White, 0 }, // x grid
+ { GGRAPH_LINE_NONE, 0, White, 0 }, // y grid
+ GWIN_GRAPH_STYLE_XAXIS_ARROWS|GWIN_GRAPH_STYLE_YAXIS_ARROWS // flags
+};
+
+int main(void) {
+ GHandle gh;
+ uint16_t i;
+
+ halInit();
+ chSysInit();
+
+ gdispInit();
+ gdispClear(Black);
+
+ gh = gwinCreateGraph(0, 0, gdispGetWidth(), gdispGetHeight());
+
+ gwinGraphSetOrigin(gh, 150, 150);
+ gwinGraphDrawAxis(gh);
+
+ for(i = 0; i < 2500; i++)
+ gwinGraphDrawPoint(gh, i-170, 80*sin(2*0.2*M_PI*i/180));
+
+ gwinGraphStartSet(gh);
+ gwinGraphSetStyle(gh, &GraphStyle2);
+
+ for(i = 0; i < 2500; i++)
+ gwinGraphDrawPoint(gh, i/5-150, 95*sin(2*0.2*M_PI*i/180));
+
+ while(TRUE) {
+ chThdSleepMilliseconds(100);
+ }
+}
+
|