Skip to content

Commit 1d642ed

Browse files
committed
Add Input/Output mirror graph mode
1 parent 8b3aa9d commit 1d642ed

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Meter.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,27 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
337337
GraphMeterMode_drawGraph(this, x + captionLen, y, w, this->h, -1);
338338
}
339339

340+
static void IOMeterMode_draw(Meter* this, int x, int y, int w) {
341+
assert(x >= 0);
342+
assert(w <= INT_MAX - x);
343+
344+
// Draw the caption
345+
const int captionLen = 3;
346+
const char* caption = Meter_getCaption(this);
347+
if (w >= captionLen) {
348+
attrset(CRT_colors[METER_TEXT]);
349+
mvaddnstr(y, x, caption, captionLen);
350+
}
351+
w -= captionLen;
352+
353+
// Draw the top graph, half height
354+
GraphMeterMode_drawGraph(this, x + captionLen, y, w, GRAPH_HEIGHT / 2, 0);
355+
356+
// Draw the bottom graph, half height
357+
y += GRAPH_HEIGHT / 2;
358+
GraphMeterMode_drawGraph(this, x + captionLen, y, w, GRAPH_HEIGHT / 2, 1);
359+
}
360+
340361
/* ---------- LEDMeterMode ---------- */
341362

342363
static const char* const LEDMeterMode_digitsAscii[] = {
@@ -442,6 +463,11 @@ static const MeterMode Meter_modes[] = {
442463
.h = DEFAULT_GRAPH_HEIGHT,
443464
.draw = GraphMeterMode_draw,
444465
},
466+
[IO_METERMODE] = {
467+
.uiName = "In/Out",
468+
.h = GRAPH_HEIGHT,
469+
.draw = IOMeterMode_draw,
470+
},
445471
[LED_METERMODE] = {
446472
.uiName = "LED",
447473
.h = 3,

MeterMode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ enum MeterModeId_ {
1313
BAR_METERMODE = 1,
1414
TEXT_METERMODE,
1515
GRAPH_METERMODE,
16+
IO_METERMODE,
1617
LED_METERMODE,
1718
LAST_METERMODE
1819
};

0 commit comments

Comments
 (0)