aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@unormal.org>2012-10-24 02:57:59 +0200
committerJoel Bodenmann <joel@unormal.org>2012-10-24 02:57:59 +0200
commit6005051ac7a795cc48f6bf48ff9097dd7275ced3 (patch)
treea5b37c5c465d4239f97fa5350c9067ef421d3814
parent5ac69126489aaa36182f79ea184fc771d0ac5d27 (diff)
downloaduGFX-6005051ac7a795cc48f6bf48ff9097dd7275ced3.tar.gz
uGFX-6005051ac7a795cc48f6bf48ff9097dd7275ced3.tar.bz2
uGFX-6005051ac7a795cc48f6bf48ff9097dd7275ced3.zip
graph update
-rw-r--r--include/graph.h1
-rw-r--r--src/graph.c27
2 files changed, 20 insertions, 8 deletions
diff --git a/include/graph.h b/include/graph.h
index 3a6cbe03..14bae2b0 100644
--- a/include/graph.h
+++ b/include/graph.h
@@ -40,6 +40,7 @@ extern "C" {
void graphDrawOneQuadrat(Graph *g);
void graphDrawFourQuadrants(Graph *g);
+void graphDrawDot(coord_t x, coord_t y, uint16_t radius, color_t color);
void graphDrawDots(int coord[][2], uint16_t entries, uint16_t radius, uint16_t color);
void graphDrawNet(int coord[][2], uint16_t entries, uint16_t radius, uint16_t lineColor, uint16_t dotColor);
diff --git a/src/graph.c b/src/graph.c
index c67fa252..bd9c39c2 100644
--- a/src/graph.c
+++ b/src/graph.c
@@ -72,13 +72,15 @@ void graphDrawOneQuadrant(Graph *g) {
/* X Axis */
gdispDrawLine(g->x0, g->y1, g->x1, g->y1, g->color);
- for(i = 0; i <= (length_y / g->grid_size); i++)
- _horizontalDotLine(g->x0, g->y0 + g->grid_size * i, g->x1, g->dot_space, g->color);
+ if(g->grid_size > 0)
+ for(i = 0; i <= (length_y / g->grid_size); i++)
+ _horizontalDotLine(g->x0, g->y0 + g->grid_size * i, g->x1, g->dot_space, g->color);
/* Y Axis */
gdispDrawLine(g->x0, g->y0, g->x0, g->y1, g->color);
- for(i = 0; i <= (length_x / g->grid_size); i++)
- _verticalDotLine(g->x0 + g->grid_size * i, g->y0, g->y1, g->dot_space, g->color);
+ if(g->grid_size > 0);
+ for(i = 0; i <= (length_x / g->grid_size); i++)
+ _verticalDotLine(g->x0 + g->grid_size * i, g->y0, g->y1, g->dot_space, g->color);
}
void graphDrawFourQuadrants(Graph *g) {
@@ -98,13 +100,22 @@ void graphDrawFourQuadrants(Graph *g) {
/* X Axis */
gdispDrawLine(g->x0, middle_y, g->x1, middle_y, g->color);
- for(i = 0; i <= (length_y / g->grid_size); i++)
- _horizontalDotLine(g->x0, g->y0 + g->grid_size * i, g->x1, g->dot_space, g->color);
+ if(g->grid_size > 0)
+ for(i = 0; i <= (length_y / g->grid_size); i++)
+ _horizontalDotLine(g->x0, g->y0 + g->grid_size * i, g->x1, g->dot_space, g->color);
/* Y Axis */
gdispDrawLine(middle_x, g->y0, middle_x, g->y1, g->color);
- for(i = 0; i <= (length_x / g->grid_size); i++)
- _verticalDotLine(g->x0 + g->grid_size * i, g->y0, g->y1, g->dot_space, g->color);
+ if(g->grid_size > 0)
+ for(i = 0; i <= (length_x / g->grid_size); i++)
+ _verticalDotLine(g->x0 + g->grid_size * i, g->y0, g->y1, g->dot_space, g->color);
+}
+
+void graphDrawDot(coord_t x, coord_t y, uint16_t radius, color_t color) {
+ if(radius == 1)
+ gdispDrawPixel(origin.x + x, origin.y + y, color);
+ else
+ gdispFillCircle(origin.x + x, origin.y + y, radius, color);
}
void graphDrawDots(int coord[][2], uint16_t entries, uint16_t radius, uint16_t color) {