Commit e93028d7 authored by Explorer09's avatar Explorer09
Browse files

New macro GRAPH_HEIGHT for Graph Meter height

Currently GRAPH_HEIGHT=4 . This prevents hard-coding the height of the graph meters, and allows user to change it at compile-time.

(It's still unchangeable in runtime yet. Can a Setup option be implemented for this thing?)
parent 526eca9a
......@@ -358,6 +358,8 @@ static const char* GraphMeterMode_dotsAscii[] = {
/*20*/":", /*21*/":", /*22*/":"
};
#define GRAPH_HEIGHT 4 /* Unit: rows (lines) */
static const char** GraphMeterMode_dots;
static int GraphMeterMode_pixPerRow;
......@@ -405,14 +407,14 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
}
for (int i = nValues - (w*2) + 2, k = 0; i < nValues; i+=2, k++) {
const double dot = (1.0 / (GraphMeterMode_pixPerRow * 4));
int v1 = MIN(GraphMeterMode_pixPerRow * 4, MAX(1, data->values[i] / dot));
int v2 = MIN(GraphMeterMode_pixPerRow * 4, MAX(1, data->values[i+1] / dot));
const double dot = (1.0 / (GraphMeterMode_pixPerRow * GRAPH_HEIGHT));
int v1 = MIN(GraphMeterMode_pixPerRow * GRAPH_HEIGHT, MAX(1, data->values[i] / dot));
int v2 = MIN(GraphMeterMode_pixPerRow * GRAPH_HEIGHT, MAX(1, data->values[i+1] / dot));
int colorIdx = GRAPH_1;
for (int line = 0; line < 4; line++) {
int line1 = MIN(GraphMeterMode_pixPerRow, MAX(0, v1 - (GraphMeterMode_pixPerRow * (3 - line))));
int line2 = MIN(GraphMeterMode_pixPerRow, MAX(0, v2 - (GraphMeterMode_pixPerRow * (3 - line))));
for (int line = 0; line < GRAPH_HEIGHT; line++) {
int line1 = MIN(GraphMeterMode_pixPerRow, MAX(0, v1 - (GraphMeterMode_pixPerRow * (GRAPH_HEIGHT - 1 - line))));
int line2 = MIN(GraphMeterMode_pixPerRow, MAX(0, v2 - (GraphMeterMode_pixPerRow * (GRAPH_HEIGHT - 1 - line))));
attrset(CRT_colors[colorIdx]);
mvaddstr(y+line, x+k, GraphMeterMode_dots[line1 * (GraphMeterMode_pixPerRow + 1) + line2]);
......@@ -500,7 +502,7 @@ static MeterMode TextMeterMode = {
static MeterMode GraphMeterMode = {
.uiName = "Graph",
.h = 4,
.h = GRAPH_HEIGHT,
.draw = GraphMeterMode_draw,
};
......
......@@ -127,6 +127,8 @@ ListItem* Meter_toListItem(Meter* this, bool moving);
#endif
#define PIXPERROW_ASCII 2
#define GRAPH_HEIGHT 4 /* Unit: rows (lines) */
/* ---------- LEDMeterMode ---------- */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment