]> Git — Sourcephile - julm/air-duino.git/blob - GNUmakefile
init
[julm/air-duino.git] / GNUmakefile
1 # Licence: WTFPLv2 <http://www.wtfpl.net/txt/copying/>
2 # Copyright 2015: Julien Moutinho <julm+air@autogeree.net>
3
4 RRD_CF:=AVERAGE
5 SENSORS:= \
6 humidity \
7 temperature \
8 quality \
9 particles
10
11 .rrd = $(wildcard rrd/*/*.rrd)
12
13 all: png
14
15 #
16 ## INO
17 ###
18
19 # For GNU/Linux
20 ARDUINO_DIR := /usr/share/arduino/
21 ARDMK_DIR := /usr/share/arduino/
22 AVR_TOOLS_DIR := /usr
23
24 # For Seeeduino
25 BOARD_TAG := uno
26
27 ARDUINO_LIBS := \
28 AirQuality_Sensor \
29 DustSensor \
30 Humidity_Temperature_Sensor \
31 LCD_Display9696 \
32 Wire
33
34 USER_LIB_PATH := $(abspath ./libraries)
35
36 include $(ARDMK_DIR)/Arduino.mk
37
38 ino: $(TARGET_EEP) $(TARGET_HEX)
39
40 #
41 ## PNG
42 ###
43 .PHONY: png $(addprefix png/,$(SENSORS))
44 png: $(addprefix png/,$(SENSORS))
45
46
47 ym=$(patsubst %.rrd,,$(notdir $*))
48 month_begin=$(shell date +'%s' -d '$(ym)/01')
49 month_end=$(shell date +'%s' -d '$(ym)/01 + 1 month - 1 second')
50 month_length=$(shell date +'%d' -d '$(ym)/01 + 1 month - 1 second')
51 day_begin=$(shell date +'%s' -d '$(ym)/$(day)')
52 day_end=$(shell date +'%s' -d '$(ym)/$(day) + 1 month - 1 second')
53
54 define png/sensor
55 sensor:=$1
56 label:=$2
57 png/$(sensor): \
58 $(patsubst rrd/%.rrd,png/$(sensor)/%.png,$(.rrd))
59
60 png/$(sensor)/%.png: rrd/%.rrd
61 mkdir -p png/$(sensor)/$$*
62 rrdtool graph $$@ \
63 -w 785 -h 120 -a PNG \
64 --slope-mode \
65 --start $$(month_begin) --end $$(month_end) \
66 --vertical-label '$(label)' \
67 --x-grid HOUR:8:DAY:1:DAY:1:86400:%d \
68 DEF:$(sensor)=rrd/$$*.rrd:$(sensor):$$(RRD_CF) \
69 LINE1:$(sensor)'#ff0000':"$(sensor)"
70 for day in $$(shell seq -w $$(month_length)); \
71 do \
72 day_begin=$$$$(date +'%s' -d "$$(ym)/$$$$day"); \
73 day_end=$$$$(date +'%s' -d "$$(ym)/$$$$day + 1 day - 1 second"); \
74 rrdtool graph png/$(sensor)/$$*/$$$$day.png \
75 -w 785 -h 120 -a PNG \
76 --slope-mode \
77 --start $$$$day_begin --end $$$$day_end \
78 --vertical-label '$(label)' \
79 --x-grid MINUTE:10:HOUR:1:HOUR:1:0:%H \
80 DEF:$(sensor)=rrd/$$*.rrd:$(sensor):$$(RRD_CF) \
81 LINE1:$(sensor)'#ff0000':"$(sensor)"; \
82 done
83 endef
84
85 )=)
86 $(eval $(call png/sensor,temperature,Température (°C$)))
87 $(eval $(call png/sensor,humidity,Humidité (%$)))
88 $(eval $(call png/sensor,particles,Particules))
89 $(eval $(call png/sensor,quality,Qualité de l’air))