diff --git a/examples/cluster.c b/examples/cluster.c index dd77535..1e3b7c1 100644 --- a/examples/cluster.c +++ b/examples/cluster.c @@ -13,6 +13,7 @@ #include #include #include +#include typedef struct _hexagram_cluster_state { double rpm, rps, temp, fuel; @@ -22,28 +23,6 @@ static hexagram_cluster_state state = { 0, 0, 0, 0 }; -static void draw_mfd(cairo_t *cr, - double x, - double y, - double width, - double height) { - cairo_set_source_rgb(cr, 0.75, 0, 0); - cairo_move_to(cr, x, y); - cairo_line_to(cr, x + width, y); - cairo_line_to(cr, x + width, y + height); - cairo_line_to(cr, x, y + height); - cairo_line_to(cr, x, y); - cairo_fill(cr); - - cairo_set_source_rgb(cr, 1, 1, 1); - cairo_move_to(cr, x, y); - cairo_line_to(cr, x + width, y); - cairo_line_to(cr, x + width, y + height); - cairo_line_to(cr, x, y + height); - cairo_line_to(cr, x, y); - cairo_stroke(cr); -} - static void cluster_draw_bg(cairo_t *cr, double width, double height) { @@ -76,11 +55,11 @@ static void cluster_draw_bg(cairo_t *cr, height * 0.13, 0.125); - draw_mfd(cr, - width * 0.42, - height * 0.1, - width * 0.16, - height * 0.5); + hexagram_mfd_draw(cr, + width * 0.42, + height * 0.1, + width * 0.16, + height * 0.5); } static void cluster_update(struct can_frame *frame) { diff --git a/include/hexagram/mfd.h b/include/hexagram/mfd.h new file mode 100644 index 0000000..44e6c81 --- /dev/null +++ b/include/hexagram/mfd.h @@ -0,0 +1,12 @@ +#ifndef _HEXAGRAM_MFD_H +#define _HEXAGRAM_MFD_H + +#include + +void hexagram_mfd_draw(cairo_t *cr, + double x, + double y, + double width, + double height); + +#endif /* _HEXAGRAM_MFD_H */ diff --git a/src/Makefile b/src/Makefile index bdc83c5..4082c9f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 speedo.h thermo.h fuel.h sim.h + gauge.h tacho.h speedo.h thermo.h fuel.h mfd.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 speedo.o thermo.o fuel.o sim.o + gauge.o tacho.o speedo.o thermo.o fuel.o mfd.o sim.o VERSION_MAJOR = 0 VERSION_MINOR = 0.1 diff --git a/src/mfd.c b/src/mfd.c new file mode 100644 index 0000000..f5679ae --- /dev/null +++ b/src/mfd.c @@ -0,0 +1,23 @@ +#include + +void hexagram_mfd_draw(cairo_t *cr, + double x, + double y, + double width, + double height) { + cairo_set_source_rgb(cr, 0.75, 0, 0); + cairo_move_to(cr, x, y); + cairo_line_to(cr, x + width, y); + cairo_line_to(cr, x + width, y + height); + cairo_line_to(cr, x, y + height); + cairo_line_to(cr, x, y); + cairo_fill(cr); + + cairo_set_source_rgb(cr, 1, 1, 1); + cairo_move_to(cr, x, y); + cairo_line_to(cr, x + width, y); + cairo_line_to(cr, x + width, y + height); + cairo_line_to(cr, x, y + height); + cairo_line_to(cr, x, y); + cairo_stroke(cr); +}