aboutsummaryrefslogtreecommitdiffstats
path: root/demos/modules/graph
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@unormal.org>2013-02-11 09:25:45 +0100
committerJoel Bodenmann <joel@unormal.org>2013-02-11 09:25:45 +0100
commit1bfc5a9f85e7c3296095105ca8e3ee1215b22be8 (patch)
tree08f2662a3ad41936e23e00815ae9ee024bdedbfd /demos/modules/graph
parent885b3d53b3a491c62fb0634b78cb9857723ac15d (diff)
downloaduGFX-1bfc5a9f85e7c3296095105ca8e3ee1215b22be8.tar.gz
uGFX-1bfc5a9f85e7c3296095105ca8e3ee1215b22be8.tar.bz2
uGFX-1bfc5a9f85e7c3296095105ca8e3ee1215b22be8.zip
removed GDISP_LLD() macro - fix
Diffstat (limited to 'demos/modules/graph')
-rw-r--r--demos/modules/graph/gfxconf.h36
-rw-r--r--demos/modules/graph/main.c71
-rw-r--r--demos/modules/graph/result-640x480.gifbin0 -> 11301 bytes
3 files changed, 107 insertions, 0 deletions
diff --git a/demos/modules/graph/gfxconf.h b/demos/modules/graph/gfxconf.h
new file mode 100644
index 00000000..4f4258ed
--- /dev/null
+++ b/demos/modules/graph/gfxconf.h
@@ -0,0 +1,36 @@
+/**
+ * This file has a different license to the rest of the GFX system.
+ * You can copy, modify and distribute this file as you see fit.
+ * You do not need to publish your source modifications to this file.
+ * The only thing you are not permitted to do is to relicense it
+ * under a different license.
+ */
+
+#ifndef _GFXCONF_H
+#define _GFXCONF_H
+
+/* GFX sub-systems to turn on */
+#define GFX_USE_GDISP TRUE
+#define GFX_USE_GWIN TRUE
+#define GFX_USE_GEVENT FALSE
+#define GFX_USE_GTIMER FALSE
+#define GFX_USE_GINPUT FALSE
+
+/* Features for the GDISP sub-system. */
+#define GDISP_NEED_VALIDATION TRUE
+#define GDISP_NEED_CLIP TRUE
+#define GDISP_NEED_TEXT FALSE
+#define GDISP_NEED_CIRCLE TRUE
+#define GDISP_NEED_ELLIPSE FALSE
+#define GDISP_NEED_ARC FALSE
+#define GDISP_NEED_SCROLL FALSE
+#define GDISP_NEED_PIXELREAD FALSE
+#define GDISP_NEED_CONTROL FALSE
+#define GDISP_NEED_MULTITHREAD FALSE
+#define GDISP_NEED_ASYNC FALSE
+#define GDISP_NEED_MSGAPI FALSE
+
+/* Features for the GWIN sub-system. */
+#define GWIN_NEED_GRAPH TRUE
+
+#endif /* _GFXCONF_H */
diff --git a/demos/modules/graph/main.c b/demos/modules/graph/main.c
new file mode 100644
index 00000000..544d4c2b
--- /dev/null
+++ b/demos/modules/graph/main.c
@@ -0,0 +1,71 @@
+#include "ch.h"
+#include "hal.h"
+#include "gfx.h"
+#include "math.h"
+
+const GGraphPoint data[5] = {
+ { -40, -40 },
+ { 70, 40 },
+ { 140, 60 },
+ { 210, 60 },
+ { 280, 200 }
+};
+
+GGraphObject g;
+
+GGraphStyle GraphStyle1 = {
+ { GGRAPH_POINT_DOT, 0, Blue }, // point
+ { GGRAPH_LINE_NONE, 2, Gray }, // line
+ { GGRAPH_LINE_SOLID, 0, White }, // x axis
+ { GGRAPH_LINE_SOLID, 0, White }, // y axis
+ { GGRAPH_LINE_DASH, 5, Gray, 50 }, // x grid
+ { GGRAPH_LINE_DOT, 7, Yellow, 50 }, // y grid
+ GWIN_GRAPH_STYLE_POSITIVE_AXIS_ARROWS // flags
+};
+
+GGraphStyle GraphStyle2 = {
+ { GGRAPH_POINT_SQUARE, 5, Red }, // point
+ { GGRAPH_LINE_DOT, 2, Pink }, // line
+ { GGRAPH_LINE_SOLID, 0, White }, // x axis
+ { GGRAPH_LINE_SOLID, 0, White }, // y axis
+ { GGRAPH_LINE_DASH, 5, Gray, 50 }, // x grid
+ { GGRAPH_LINE_DOT, 7, Yellow, 50 }, // y grid
+ GWIN_GRAPH_STYLE_POSITIVE_AXIS_ARROWS // flags
+};
+
+int main(void) {
+ GHandle gh;
+ uint16_t i;
+
+ halInit();
+ chSysInit();
+
+ gdispInit();
+ gdispClear(Black);
+
+ gh = gwinCreateGraph(&g, 0, 0, gdispGetWidth(), gdispGetHeight());
+
+ gwinGraphSetOrigin(gh, gwinGetWidth(gh)/2, gwinGetHeight(gh)/2);
+ gwinGraphSetStyle(gh, &GraphStyle1);
+ gwinGraphDrawAxis(gh);
+
+ for(i = 0; i < gwinGetWidth(gh); i++)
+ gwinGraphDrawPoint(gh, i-gwinGetWidth(gh)/2, 80*sin(2*0.2*M_PI*i/180));
+
+ gwinGraphStartSet(gh);
+ GraphStyle1.point.color = Green;
+ gwinGraphSetStyle(gh, &GraphStyle1);
+
+ for(i = 0; i < gwinGetWidth(gh)*5; i++)
+ gwinGraphDrawPoint(gh, i/5-gwinGetWidth(gh)/2, 95*sin(2*0.2*M_PI*i/180));
+
+ gwinGraphStartSet(gh);
+ gwinGraphSetStyle(gh, &GraphStyle2);
+
+ gwinGraphDrawPoints(gh, data, sizeof(data)/sizeof(data[0]));
+
+ while(TRUE) {
+ chThdSleepMilliseconds(100);
+ }
+}
+
diff --git a/demos/modules/graph/result-640x480.gif b/demos/modules/graph/result-640x480.gif
new file mode 100644
index 00000000..6fc8b30c
--- /dev/null
+++ b/demos/modules/graph/result-640x480.gif
Binary files differ