|
@@ -36,7 +36,7 @@
|
|
#define WINDOW_X 1
|
|
#define WINDOW_X 1
|
|
#define WINDOW_Y 123
|
|
#define WINDOW_Y 123
|
|
#define WINDOW_W 318
|
|
#define WINDOW_W 318
|
|
-#define WINDOW_H 118
|
|
|
|
|
|
+#define WINDOW_H 218
|
|
|
|
|
|
#define MIN_U 0
|
|
#define MIN_U 0
|
|
#define MIN_I 0
|
|
#define MIN_I 0
|
|
@@ -50,17 +50,17 @@ static long map(long x, long in_min, long in_max, long out_min, long out_max) {
|
|
|
|
|
|
// A graph styling
|
|
// A graph styling
|
|
static GGraphStyle GraphStyle1 = {
|
|
static GGraphStyle GraphStyle1 = {
|
|
- { GGRAPH_POINT_DOT, 0, GFX_BLUE }, // Point
|
|
|
|
|
|
+ { GGRAPH_POINT_DOT, 4, GFX_BLUE }, // Point
|
|
{ GGRAPH_LINE_NONE, 2, GFX_GRAY }, // Line
|
|
{ GGRAPH_LINE_NONE, 2, GFX_GRAY }, // Line
|
|
- { GGRAPH_LINE_SOLID, 0, GFX_WHITE }, // X axis
|
|
|
|
- { GGRAPH_LINE_SOLID, 0, GFX_WHITE }, // Y axis
|
|
|
|
- { GGRAPH_LINE_DASH, 5, GFX_GRAY, 50 }, // X grid
|
|
|
|
- { GGRAPH_LINE_DOT, 7, GFX_YELLOW, 50 }, // Y grid
|
|
|
|
- GWIN_GRAPH_STYLE_POSITIVE_AXIS_ARROWS // Flags
|
|
|
|
|
|
+ { GGRAPH_LINE_NONE, 0, GFX_WHITE }, // X axis
|
|
|
|
+ { GGRAPH_LINE_NONE, 0, GFX_WHITE }, // Y axis
|
|
|
|
+ { GGRAPH_LINE_DOT, 5, GFX_GRAY, 25 }, // X grid
|
|
|
|
+ { GGRAPH_LINE_DOT, 5, GFX_YELLOW, 25 }, // Y grid
|
|
|
|
+ GWIN_GRAPH_STYLE_ALL_AXIS_ARROWS // Flags
|
|
};
|
|
};
|
|
|
|
|
|
static GHandle gh;
|
|
static GHandle gh;
|
|
-static gCoord pos_X;
|
|
|
|
|
|
+static gCoord pos_X, win_H, win_W;
|
|
|
|
|
|
void graph_Init(void) {
|
|
void graph_Init(void) {
|
|
// Create the graph window
|
|
// Create the graph window
|
|
@@ -75,15 +75,19 @@ void graph_Init(void) {
|
|
gh = gwinGraphCreate(0, &wi);
|
|
gh = gwinGraphCreate(0, &wi);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ win_H = gwinGetHeight(gh);
|
|
|
|
+ win_W = gwinGetWidth(gh);
|
|
|
|
+
|
|
// clear area
|
|
// clear area
|
|
gdispFillArea(WINDOW_X, WINDOW_Y, WINDOW_W, WINDOW_H, GFX_BLACK);
|
|
gdispFillArea(WINDOW_X, WINDOW_Y, WINDOW_W, WINDOW_H, GFX_BLACK);
|
|
|
|
+ //gwinFillArea(gh, 0, 0, win_W, win_H);
|
|
|
|
|
|
// Set the graph origin and style
|
|
// Set the graph origin and style
|
|
- gwinGraphSetOrigin(gh, gwinGetWidth(gh)/2, gwinGetHeight(gh)/2);
|
|
|
|
|
|
+ gwinGraphSetOrigin(gh, 0, 0);
|
|
gwinGraphSetStyle(gh, &GraphStyle1);
|
|
gwinGraphSetStyle(gh, &GraphStyle1);
|
|
gwinGraphDrawAxis(gh);
|
|
gwinGraphDrawAxis(gh);
|
|
|
|
|
|
- pos_X = WINDOW_X;
|
|
|
|
|
|
+ pos_X = 0;
|
|
}
|
|
}
|
|
|
|
|
|
void graph_Draw(uint32_t u_value, uint32_t i_value) {
|
|
void graph_Draw(uint32_t u_value, uint32_t i_value) {
|
|
@@ -91,11 +95,11 @@ void graph_Draw(uint32_t u_value, uint32_t i_value) {
|
|
|
|
|
|
// Modify the style
|
|
// Modify the style
|
|
gwinGraphStartSet(gh);
|
|
gwinGraphStartSet(gh);
|
|
- GraphStyle1.point.color = GFX_GREEN;
|
|
|
|
|
|
+ GraphStyle1.point.color = GFX_BLUE;
|
|
gwinGraphSetStyle(gh, &GraphStyle1);
|
|
gwinGraphSetStyle(gh, &GraphStyle1);
|
|
|
|
|
|
// Draw voltage point
|
|
// Draw voltage point
|
|
- pos_Y = map(u_value, MIN_U, MAX_U, WINDOW_Y, WINDOW_H);
|
|
|
|
|
|
+ pos_Y = map(u_value, MIN_U, MAX_U, 0, win_H);
|
|
gwinGraphDrawPoint(gh, pos_X, pos_Y);
|
|
gwinGraphDrawPoint(gh, pos_X, pos_Y);
|
|
|
|
|
|
// Modify the style
|
|
// Modify the style
|
|
@@ -104,11 +108,11 @@ void graph_Draw(uint32_t u_value, uint32_t i_value) {
|
|
gwinGraphSetStyle(gh, &GraphStyle1);
|
|
gwinGraphSetStyle(gh, &GraphStyle1);
|
|
|
|
|
|
// Draw current point
|
|
// Draw current point
|
|
- pos_Y = map(i_value, MIN_I, MAX_I, WINDOW_Y, WINDOW_H);
|
|
|
|
|
|
+ pos_Y = map(i_value, MIN_I, MAX_I, 0, win_H);
|
|
gwinGraphDrawPoint(gh, pos_X, pos_Y);
|
|
gwinGraphDrawPoint(gh, pos_X, pos_Y);
|
|
|
|
|
|
pos_X ++;
|
|
pos_X ++;
|
|
- if (pos_X >= WINDOW_W) {
|
|
|
|
- pos_X = WINDOW_X;
|
|
|
|
|
|
+ if (pos_X >= win_W) {
|
|
|
|
+ pos_X = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|