1 # Licence: WTFPLv2 <http://www.wtfpl.net/txt/copying/>
2 # Copyright 2015: Julien Moutinho <julm+air@autogeree.net>
14 .rrd = $(wildcard rrd/*/*.rrd)
23 ARDUINO_DIR := /usr/share/arduino/
24 ARDMK_DIR := /usr/share/arduino/
33 Humidity_Temperature_Sensor \
37 USER_LIB_PATH := $(abspath ./libraries)
39 include $(ARDMK_DIR)/Arduino.mk
41 ino: $(TARGET_EEP) $(TARGET_HEX)
46 .PHONY: png $(addprefix png/,$(SENSORS))
47 png: $(addprefix png/,$(SENSORS))
49 ym=$(patsubst %.rrd,,$(notdir $*))
50 month_begin=$(shell date +'%s' -d '$(ym)/01')
51 month_end=$(shell date +'%s' -d '$(ym)/01 + 1 month - 1 second')
52 month_length=$(shell date +'%d' -d '$(ym)/01 + 1 month - 1 second')
53 day_begin=$(shell date +'%s' -d '$(ym)/$(day)')
54 day_end=$(shell date +'%s' -d '$(ym)/$(day) + 1 month - 1 second')
60 $$(patsubst rrd/%.rrd,png/$$(sensor)/%.png,$$(.rrd))
63 png/$$(sensor)/%.png: rrd/%.rrd
64 mkdir -p png/$$(sensor)/$$*
66 -w 785 -h 120 -a PNG \
68 --start $$(month_begin) --end $$(month_end) \
69 --vertical-label '$$(label)' \
70 --x-grid HOUR:8:DAY:1:DAY:1:86400:%d \
71 DEF:$$(sensor)=rrd/$$*.rrd:$$(sensor):$$(RRD_CF) \
72 LINE1:$$(sensor)'#ff0000':"$$(sensor)"
73 for day in $$(shell seq -w $$(month_length)); \
75 day_begin=$$$$(date +'%s' -d "$$(ym)/$$$$day"); \
76 day_end=$$$$(date +'%s' -d "$$(ym)/$$$$day + 1 day - 1 second"); \
77 rrdtool graph png/$$(sensor)/$$*/$$$$day.png \
78 -w 785 -h 120 -a PNG \
80 --start $$$$day_begin --end $$$$day_end \
81 --vertical-label '$$(label)' \
82 --x-grid MINUTE:10:HOUR:1:HOUR:1:0:%H \
83 DEF:$$(sensor)=rrd/$$*.rrd:$$(sensor):$$(RRD_CF) \
84 LINE1:$$(sensor)'#ff0000':"$$(sensor)"; \
89 $(eval $(call png/sensor,temperature,Température (°C$)))
90 $(eval $(call png/sensor,humidity,Humidité (%$)))
91 $(eval $(call png/sensor,particles,Particules))
92 $(eval $(call png/sensor,quality,Qualité de l’air))