Split thermometer into separate files
This commit is contained in:
parent
c40ad06140
commit
478d1142e5
2 changed files with 13 additions and 80 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include <hexagram/gauge.h>
|
#include <hexagram/gauge.h>
|
||||||
#include <hexagram/tacho.h>
|
#include <hexagram/tacho.h>
|
||||||
#include <hexagram/speedo.h>
|
#include <hexagram/speedo.h>
|
||||||
|
#include <hexagram/thermo.h>
|
||||||
|
|
||||||
typedef struct _hexagram_cluster_state {
|
typedef struct _hexagram_cluster_state {
|
||||||
double rpm, rps, temp, fuel;
|
double rpm, rps, temp, fuel;
|
||||||
|
@ -20,74 +21,6 @@ static hexagram_cluster_state state = {
|
||||||
0, 0, 0, 0
|
0, 0, 0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
static void draw_thermometer(cairo_t *cr,
|
|
||||||
double x,
|
|
||||||
double y,
|
|
||||||
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.2);
|
|
||||||
|
|
||||||
cairo_set_source_rgb(cr, 1, 1, 1);
|
|
||||||
cairo_arc(cr, x, y, r, 0, 2*M_PI);
|
|
||||||
cairo_stroke(cr);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Draw face numbers
|
|
||||||
*/
|
|
||||||
cairo_move_to(cr, x - 0.8 * r, y - 0.1 * r);
|
|
||||||
cairo_show_text(cr, "120");
|
|
||||||
|
|
||||||
cairo_move_to(cr, x - 0.15 * r, y - 0.5 * r);
|
|
||||||
cairo_show_text(cr, "190");
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
hexagram_gauge_draw_mark(cr, x, y,
|
|
||||||
((i % 35)? 0.8: 0.7) * r,
|
|
||||||
0.90 * r,
|
|
||||||
300 * (M_PI/180),
|
|
||||||
420 * (M_PI/180),
|
|
||||||
i / 140.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void draw_thermometer_needle(cairo_t *cr,
|
|
||||||
double x,
|
|
||||||
double y,
|
|
||||||
double r,
|
|
||||||
double temp) {
|
|
||||||
if (temp > 260) {
|
|
||||||
temp = 260;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Draw a tiny boi circle
|
|
||||||
*/
|
|
||||||
cairo_set_source_rgb(cr, 1, 1, 1);
|
|
||||||
cairo_arc(cr, x, y, 0.08 * r, 0, 2*M_PI);
|
|
||||||
cairo_stroke(cr);
|
|
||||||
|
|
||||||
hexagram_gauge_draw_needle(cr, x, y, 0.9 * r,
|
|
||||||
300 * (M_PI/180),
|
|
||||||
420 * (M_PI/180),
|
|
||||||
temp / 260);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void draw_fuel_gauge(cairo_t *cr,
|
static void draw_fuel_gauge(cairo_t *cr,
|
||||||
double x,
|
double x,
|
||||||
double y,
|
double y,
|
||||||
|
@ -192,11 +125,11 @@ static void cluster_draw_bg(cairo_t *cr,
|
||||||
height * 0.5,
|
height * 0.5,
|
||||||
height * 0.4);
|
height * 0.4);
|
||||||
|
|
||||||
draw_thermometer(cr,
|
hexagram_thermo_draw_face(cr,
|
||||||
width * 0.43,
|
width * 0.43,
|
||||||
height * 0.76,
|
height * 0.76,
|
||||||
height * 0.13,
|
height * 0.13,
|
||||||
240.0);
|
240.0);
|
||||||
|
|
||||||
draw_fuel_gauge(cr,
|
draw_fuel_gauge(cr,
|
||||||
width * 0.57,
|
width * 0.57,
|
||||||
|
@ -258,11 +191,11 @@ static void cluster_draw(cairo_t *cr,
|
||||||
height * 0.4,
|
height * 0.4,
|
||||||
(2.032 * state.rps * 3600) / 1000.0);
|
(2.032 * state.rps * 3600) / 1000.0);
|
||||||
|
|
||||||
draw_thermometer_needle(cr,
|
hexagram_thermo_draw_needle(cr,
|
||||||
width * 0.43,
|
width * 0.43,
|
||||||
height * 0.76,
|
height * 0.76,
|
||||||
height * 0.13,
|
height * 0.13,
|
||||||
state.temp);
|
state.temp);
|
||||||
|
|
||||||
draw_fuel_gauge_needle(cr,
|
draw_fuel_gauge_needle(cr,
|
||||||
width * 0.57,
|
width * 0.57,
|
||||||
|
|
|
@ -8,12 +8,12 @@ CFLAGS += -fPIC -I$(INCLUDE_PATH) $(shell pkg-config --cflags cairo x11)
|
||||||
LDFLAGS = $(shell pkg-config --libs cairo x11) -lXext
|
LDFLAGS = $(shell pkg-config --libs cairo x11) -lXext
|
||||||
|
|
||||||
HEADERS = dict.h hash.h can.h capture.h pcapng.h module.h window.h \
|
HEADERS = dict.h hash.h can.h capture.h pcapng.h module.h window.h \
|
||||||
gauge.h tacho.h speedo.h sim.h
|
gauge.h tacho.h speedo.h thermo.h sim.h
|
||||||
|
|
||||||
HEADERS_LOCAL = util.h
|
HEADERS_LOCAL = util.h
|
||||||
|
|
||||||
OBJS = dict.o hash.o can.o capture.o pcapng.o module.o window.o \
|
OBJS = dict.o hash.o can.o capture.o pcapng.o module.o window.o \
|
||||||
gauge.o tacho.o speedo.o sim.o
|
gauge.o tacho.o speedo.o thermo.o sim.o
|
||||||
|
|
||||||
VERSION_MAJOR = 0
|
VERSION_MAJOR = 0
|
||||||
VERSION_MINOR = 0.1
|
VERSION_MINOR = 0.1
|
||||||
|
|
Loading…
Add table
Reference in a new issue