2012-06-01 08:32:14 +00:00
|
|
|
#include "glcd.h"
|
|
|
|
|
|
|
|
#define MARKSIZE 5 // half
|
|
|
|
|
2012-06-23 19:15:31 +00:00
|
|
|
static uint16_t x, y; // origins in graph
|
|
|
|
static uint16_t grid_X, grid_Y; //grids
|
2012-06-01 08:32:14 +00:00
|
|
|
|
2012-06-23 19:15:31 +00:00
|
|
|
void graphDrawSystem(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t gridX, uint16_t gridY, uint16_t color) {
|
2012-06-01 08:32:14 +00:00
|
|
|
uint16_t i, length;
|
|
|
|
volatile uint16_t off;
|
|
|
|
|
|
|
|
x = x0;
|
|
|
|
y = y0;
|
2012-06-23 19:15:31 +00:00
|
|
|
grid_X = gridX;
|
|
|
|
grid_Y = gridY;
|
2012-06-01 08:32:14 +00:00
|
|
|
|
|
|
|
// 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);
|
2012-06-23 19:15:31 +00:00
|
|
|
for(i=1; i<(length / grid_X); i++) {
|
|
|
|
off = x0 + i * grid_X;
|
2012-06-01 08:32:14 +00:00
|
|
|
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);
|
2012-06-23 19:15:31 +00:00
|
|
|
for(i=1; i<(length / grid_Y); i++) {
|
2012-06-23 19:34:24 +00:00
|
|
|
off = y0 + i * grid_Y;
|
2012-06-01 08:32:14 +00:00
|
|
|
lcdDrawLine(x0-MARKSIZE, off, x0+MARKSIZE, off, color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-20 11:51:48 +00:00
|
|
|
void graphDrawDots(int coord[][2], uint16_t entries, uint16_t radius, uint16_t color) {
|
2012-06-01 08:32:14 +00:00
|
|
|
uint16_t i;
|
|
|
|
|
2012-06-20 11:51:48 +00:00
|
|
|
for(i = 0; i < entries; i++)
|
2012-06-01 08:32:14 +00:00
|
|
|
lcdDrawCircle(coord[i][0]+x, y-coord[i][1], radius, 1, color);
|
|
|
|
}
|
|
|
|
|
2012-06-20 11:51:48 +00:00
|
|
|
void graphDrawNet(int coord[][2], uint16_t entries, uint16_t radius, uint16_t lineColor, uint16_t dotColor) {
|
2012-06-01 08:32:14 +00:00
|
|
|
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);
|
2012-06-20 11:51:48 +00:00
|
|
|
for(i = 0; i < entries; ++i)
|
2012-06-01 08:32:14 +00:00
|
|
|
if(radius != 0)
|
|
|
|
lcdDrawCircle(coord[i][0]+x, y-coord[i][1], radius, 1, dotColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
|