*to an invisible waiter* Ah, yes, thank you, Inviso-Jeeves.

This commit is contained in:
XANTRONIX Development 2019-06-07 19:59:38 -05:00
parent be52bdc014
commit 67b0a4ea95

View file

@ -235,14 +235,15 @@ static void draw_speedometer_needle(cairo_t *cr,
static void draw_thermometer(cairo_t *cr,
double x,
double y,
double r) {
double r,
double redline) {
int i;
cairo_select_font_face(cr, "Helvetica",
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cr, r * 0.15);
cairo_set_font_size(cr, r * 0.2);
cairo_set_source_rgb(cr, 1, 1, 1);
cairo_arc(cr, x, y, r, 0, 2*M_PI);
@ -251,17 +252,38 @@ static void draw_thermometer(cairo_t *cr,
/*
* Draw face numbers
*/
for (i=120; i<=260; i+=70) {
char text[5];
cairo_move_to(cr, x - 0.8 * r, y - 0.1 * r);
cairo_show_text(cr, "120");
snprintf(text, 4, "%02d", i);
cairo_move_to(cr, x - 0.15 * r, y - 0.5 * r);
cairo_show_text(cr, "190");
draw_face_number(cr, x, y,
0.75 * r,
300 * (M_PI/180),
420 * (M_PI/180),
(i - 120.0) / 140.0,
text);
cairo_move_to(cr, x + 0.5 * r, y - 0.1 * r);
cairo_show_text(cr, "260");
/*
* Draw gauge graduations
*/
for (i=0; i<=140; i+=7) {
if (i + 120 >= redline) {
cairo_set_source_rgb(cr, 1, 0, 0);
}
if (i % 35 == 0) {
draw_face_mark(cr, x, y,
0.70 * r,
0.90 * r,
300 * (M_PI/180),
420 * (M_PI/180),
i / 140.0);
} else {
draw_face_mark(cr, x, y,
0.80 * r,
0.90 * r,
300 * (M_PI/180),
420 * (M_PI/180),
i / 140.0);
}
}
}
@ -281,7 +303,7 @@ static void draw_thermometer_needle(cairo_t *cr,
cairo_arc(cr, x, y, 0.08 * r, 0, 2*M_PI);
cairo_stroke(cr);
draw_needle(cr, x, y, 0.8 * r,
draw_needle(cr, x, y, 0.9 * r,
300 * (M_PI/180),
420 * (M_PI/180),
temp / 260);
@ -291,6 +313,8 @@ static void draw_fuel_gauge(cairo_t *cr,
double x,
double y,
double r) {
cairo_set_source_rgb(cr, 1, 1, 1);
cairo_arc(cr, x, y, r, 0, 2*M_PI);
cairo_stroke(cr);
@ -332,7 +356,7 @@ static void draw_fuel_gauge_needle(cairo_t *cr,
cairo_arc(cr, x, y, 0.08 * r, 0, 2*M_PI);
cairo_stroke(cr);
draw_needle(cr, x, y, 0.8 * r,
draw_needle(cr, x, y, 0.7 * r,
300 * (M_PI/180),
420 * (M_PI/180),
level / 1.0);
@ -383,7 +407,8 @@ static void cluster_draw_bg(cairo_t *cr,
draw_thermometer(cr,
width * 0.43,
height * 0.76,
height * 0.13);
height * 0.13,
240.0);
draw_fuel_gauge(cr,
width * 0.57,
@ -446,13 +471,13 @@ static void cluster_draw(cairo_t *cr,
draw_thermometer_needle(cr,
width * 0.43,
height * 0.76,
height * 0.11,
height * 0.13,
state.temp);
draw_fuel_gauge_needle(cr,
width * 0.57,
height * 0.76,
height * 0.11,
height * 0.13,
state.fuel);
}
@ -558,7 +583,7 @@ int main(int argc, char **argv) {
break;
default:
fprintf(stderr, "Dropping unhandled XEvent.type = %d.\n", e.type);
break;
}
}