diff options
author | Tectu <joel@unormal.org> | 2012-08-13 04:12:42 +0200 |
---|---|---|
committer | Tectu <joel@unormal.org> | 2012-08-13 04:12:42 +0200 |
commit | e27d04d002a40f3b514eeeb60d374df6a8a1280c (patch) | |
tree | 7c20e6edd42cd4f20eda183a16ce66c5e8c7105e /old/graph | |
parent | 54229cbdaaf585b5adf9b085229a22c9824c112c (diff) | |
download | uGFX-e27d04d002a40f3b514eeeb60d374df6a8a1280c.tar.gz uGFX-e27d04d002a40f3b514eeeb60d374df6a8a1280c.tar.bz2 uGFX-e27d04d002a40f3b514eeeb60d374df6a8a1280c.zip |
restructure
Diffstat (limited to 'old/graph')
-rw-r--r-- | old/graph/graph.c | 75 | ||||
-rw-r--r-- | old/graph/graph.h | 72 | ||||
-rw-r--r-- | old/graph/graph.mk | 3 |
3 files changed, 150 insertions, 0 deletions
diff --git a/old/graph/graph.c b/old/graph/graph.c new file mode 100644 index 00000000..853ab738 --- /dev/null +++ b/old/graph/graph.c @@ -0,0 +1,75 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu <joel@unormal.org> + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "glcd.h" + +#define MARKSIZE 5 // half + +static uint16_t x, y; // origins in graph +static uint16_t grid_X, grid_Y; //grids + +void graphDrawSystem(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t gridX, uint16_t gridY, uint16_t color) { + uint16_t i, length; + volatile uint16_t off; + + x = x0; + y = y0; + grid_X = gridX; + grid_Y = gridY; + + // X-Axis + length = x1 - x0; + lcdDrawLine(x0, y0, x1, y0, color); + lcdDrawLine(x1, y0, x1-5, y0+5, color); + lcdDrawLine(x1, y0, x1-5, y0-5, color); + for(i=1; i<(length / grid_X); i++) { + off = x0 + i * grid_X; + lcdDrawLine(off, y0-MARKSIZE, off, y0+MARKSIZE, color); + } + + // Y-Axis + length = y0 - y1; + lcdDrawLine(x0, y0, x0, y1, color); + lcdDrawLine(x0, y1, x0-5, y1+5, color); + lcdDrawLine(x0, y1, x0+5, y1+5, color); + for(i=1; i<(length / grid_Y); i++) { + off = y0 + i * grid_Y; + lcdDrawLine(x0-MARKSIZE, off, x0+MARKSIZE, off, color); + } +} + +void graphDrawDots(int coord[][2], uint16_t entries, uint16_t radius, uint16_t color) { + uint16_t i; + + for(i = 0; i < entries; i++) + lcdDrawCircle(coord[i][0]+x, y-coord[i][1], radius, 1, color); +} + +void graphDrawNet(int coord[][2], uint16_t entries, uint16_t radius, uint16_t lineColor, uint16_t dotColor) { + uint16_t i; + + for(i = 0; i < entries; ++i) + lcdDrawLine(coord[i-1][0]+x, y-coord[i-1][1], coord[i][0]+x, y-coord[i][1], lineColor); + for(i = 0; i < entries; ++i) + if(radius != 0) + lcdDrawCircle(coord[i][0]+x, y-coord[i][1], radius, 1, dotColor); +} + + diff --git a/old/graph/graph.h b/old/graph/graph.h new file mode 100644 index 00000000..f4286fc2 --- /dev/null +++ b/old/graph/graph.h @@ -0,0 +1,72 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu <joel@unormal.org> + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef GRAPH_H +#define GRAPH_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Description: does draw axis arrows and grid + * + * param: + * - x0, y0, x1, y1: location of arrows + * - gridX, gridY: grid size in X and Y direction + * - color: color of arrows + * + * return: none + */ +void graphDrawSystem(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t gridX, uint16_t gridY, uint16_t color); + +/* + * Description: does draw coordinates into graph as dots + * + * param: + * - coord: two dimensionl array containing X and Y coordinates + * - entries: amount of coordinates passed (sizeof(coord)/sizeof(coord[0]) + * - radius: size of the dots + * - color: color of the dots + * + * return: none + */ +void graphDrawDots(int coord[][2], uint16_t entries, uint16_t radius, uint16_t color); + +/* + * Description: does draw coordinates into graph connected by lines + * + * param: + * - coord: two dimensional array containing X and Y coordinates + * - entries: amount of coordinates passed (sizeof(coord)/sizeof(coord[0]) + * - radius: if not 0, graphDrawDots() gets invoked + * - lineColor: color of the lines + * - dotColor: color of dots, if radius != 0 + * + * return: none + */ +void graphDrawNet(int coord[][2], uint16_t entries, uint16_t radius, uint16_t lineColor, uint16_t dotColor); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/old/graph/graph.mk b/old/graph/graph.mk new file mode 100644 index 00000000..706a9412 --- /dev/null +++ b/old/graph/graph.mk @@ -0,0 +1,3 @@ +LCD_GRAPH_SRC = $(LCDLIB)/graph/graph.c + +LCD_GRAPH_INC = $(LCDLIB)/graph |