Split speedometer out into separate files
This commit is contained in:
parent
130c6cb0f0
commit
c40ad06140
2 changed files with 12 additions and 75 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <hexagram/window.h>
|
||||
#include <hexagram/gauge.h>
|
||||
#include <hexagram/tacho.h>
|
||||
#include <hexagram/speedo.h>
|
||||
|
||||
typedef struct _hexagram_cluster_state {
|
||||
double rpm, rps, temp, fuel;
|
||||
|
@ -19,70 +20,6 @@ static hexagram_cluster_state state = {
|
|||
0, 0, 0, 0
|
||||
};
|
||||
|
||||
static void draw_speedometer(cairo_t *cr,
|
||||
double x,
|
||||
double y,
|
||||
double r) {
|
||||
int i;
|
||||
|
||||
cairo_select_font_face(cr, "Helvetica",
|
||||
CAIRO_FONT_SLANT_NORMAL,
|
||||
CAIRO_FONT_WEIGHT_NORMAL);
|
||||
|
||||
cairo_set_font_size(cr, r * 0.125);
|
||||
|
||||
cairo_set_source_rgb(cr, 1, 1, 1);
|
||||
cairo_arc(cr, x, y, r, 0, 2*M_PI);
|
||||
cairo_stroke(cr);
|
||||
|
||||
/*
|
||||
* Draw face numbers
|
||||
*/
|
||||
for (i=0; i<=180; i+=20) {
|
||||
char text[5];
|
||||
|
||||
snprintf(text, 4, "%02d", i);
|
||||
|
||||
hexagram_gauge_draw_number(cr, x, y,
|
||||
0.85 * r,
|
||||
232 * (M_PI/180),
|
||||
488 * (M_PI/180),
|
||||
i / 180.0,
|
||||
text);
|
||||
}
|
||||
|
||||
for (i=0; i<=180; i+=2) {
|
||||
hexagram_gauge_draw_mark(cr, x, y,
|
||||
((i % 10)? 0.75: 0.7) * r,
|
||||
0.8 * r,
|
||||
232 * (M_PI/180),
|
||||
488 * (M_PI/180),
|
||||
i / 180.0);
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_speedometer_needle(cairo_t *cr,
|
||||
double x,
|
||||
double y,
|
||||
double r,
|
||||
double kph) {
|
||||
if (kph > 290) {
|
||||
kph = 290;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.8 * r,
|
||||
232 * (M_PI/180),
|
||||
488 * (M_PI/180),
|
||||
kph / 290);
|
||||
}
|
||||
|
||||
static void draw_thermometer(cairo_t *cr,
|
||||
double x,
|
||||
double y,
|
||||
|
@ -250,7 +187,7 @@ static void cluster_draw_bg(cairo_t *cr,
|
|||
height * 0.4,
|
||||
6500);
|
||||
|
||||
draw_speedometer(cr,
|
||||
hexagram_speedo_draw_face(cr,
|
||||
width * 0.8,
|
||||
height * 0.5,
|
||||
height * 0.4);
|
||||
|
@ -315,7 +252,7 @@ static void cluster_draw(cairo_t *cr,
|
|||
height * 0.4,
|
||||
state.rpm);
|
||||
|
||||
draw_speedometer_needle(cr,
|
||||
hexagram_speedo_draw_needle(cr,
|
||||
width * 0.8,
|
||||
height * 0.5,
|
||||
height * 0.4,
|
||||
|
|
|
@ -8,12 +8,12 @@ CFLAGS += -fPIC -I$(INCLUDE_PATH) $(shell pkg-config --cflags cairo x11)
|
|||
LDFLAGS = $(shell pkg-config --libs cairo x11) -lXext
|
||||
|
||||
HEADERS = dict.h hash.h can.h capture.h pcapng.h module.h window.h \
|
||||
gauge.h tacho.h sim.h
|
||||
gauge.h tacho.h speedo.h sim.h
|
||||
|
||||
HEADERS_LOCAL = util.h
|
||||
|
||||
OBJS = dict.o hash.o can.o capture.o pcapng.o module.o window.o \
|
||||
gauge.o tacho.o sim.o
|
||||
gauge.o tacho.o speedo.o sim.o
|
||||
|
||||
VERSION_MAJOR = 0
|
||||
VERSION_MINOR = 0.1
|
||||
|
|
Loading…
Add table
Reference in a new issue