diff options
author | Andrew Hannam <andrewh@inmarket.com.au> | 2012-12-06 22:24:28 +1000 |
---|---|---|
committer | Andrew Hannam <andrewh@inmarket.com.au> | 2012-12-06 22:24:28 +1000 |
commit | ec89b8e82d890066f60c48349da062add76db6cd (patch) | |
tree | 2cf66747b0fb82e4fc45cdc141456f79ab36e86c /demos/modules | |
parent | 07f34835358ef65de310934ae726b66c7ca46f68 (diff) | |
download | uGFX-ec89b8e82d890066f60c48349da062add76db6cd.tar.gz uGFX-ec89b8e82d890066f60c48349da062add76db6cd.tar.bz2 uGFX-ec89b8e82d890066f60c48349da062add76db6cd.zip |
Fixes to GWIN graph and demo
Diffstat (limited to 'demos/modules')
-rw-r--r-- | demos/modules/graph/main.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/demos/modules/graph/main.c b/demos/modules/graph/main.c index bd2da2f6..40267522 100644 --- a/demos/modules/graph/main.c +++ b/demos/modules/graph/main.c @@ -13,9 +13,19 @@ int data[5][2] = { 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_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
+};
+
GGraphStyle GraphStyle2 = {
{ GGRAPH_POINT_DOT, 0, Green }, // point
- { GGRAPH_LINE_DOT, 2, Gray }, // line
+ { GGRAPH_LINE_NONE, 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
@@ -33,19 +43,20 @@ int main(void) { gdispInit();
gdispClear(Black);
- gh = gwinCreateGraph(0, 0, gdispGetWidth(), gdispGetHeight());
+ gh = gwinCreateGraph(&g, 0, 0, gdispGetWidth(), gdispGetHeight());
- gwinGraphSetOrigin(gh, 150, 150);
+ gwinGraphSetOrigin(gh, gwinGetWidth(gh)/2, gwinGetHeight(gh)/2);
+ gwinGraphSetStyle(gh, &GraphStyle1);
gwinGraphDrawAxis(gh);
- for(i = 0; i < 2500; i++)
- gwinGraphDrawPoint(gh, i-170, 80*sin(2*0.2*M_PI*i/180));
+ for(i = 0; i < gwinGetWidth(gh); i++)
+ gwinGraphDrawPoint(gh, i-gwinGetWidth(gh)/2, 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));
+ for(i = 0; i < gwinGetWidth(gh)*5; i++)
+ gwinGraphDrawPoint(gh, i/5-gwinGetWidth(gh)/2, 95*sin(2*0.2*M_PI*i/180));
while(TRUE) {
chThdSleepMilliseconds(100);
|