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')
58 $$(patsubst rrd/%.rrd,png/$(sensor)/%.png,$$(.rrd))
61 png/$(sensor)/%.png: rrd/%.rrd
62 mkdir -p png/$(sensor)/$$*
64 -w 785 -h 120 -a PNG \
66 --start $$(month_begin) --end $$(month_end) \
67 --vertical-label '$$(SENSOR_LABEL_$(sensor))' \
68 --x-grid HOUR:8:DAY:1:DAY:1:86400:%d \
69 DEF:$(sensor)=rrd/$$*.rrd:$(sensor):$$(RRD_CF) \
70 LINE1:$(sensor)'#ff0000':"$(sensor)"
71 for day in $$(shell seq -w $$(month_length)); \
73 day_begin=$$$$(date +'%s' -d "$$(ym)/$$$$day"); \
74 day_end=$$$$(date +'%s' -d "$$(ym)/$$$$day + 1 day - 1 second"); \
75 rrdtool graph png/$(sensor)/$$*/$$$$day.png \
76 -w 785 -h 120 -a PNG \
78 --start $$$$day_begin --end $$$$day_end \
79 --vertical-label '$$(SENSOR_LABEL_$(sensor))' \
80 --x-grid MINUTE:10:HOUR:1:HOUR:1:0:%H \
81 DEF:$(sensor)=rrd/$$*.rrd:$(sensor):$$(RRD_CF) \
82 LINE1:$(sensor)'#ff0000':"$(sensor)"; \
86 SENSOR_LABEL_temperature=Température (°C)
87 SENSOR_LABEL_humidity=Humidité (%)
88 SENSOR_LABEL_particles=Particules
89 SENSOR_LABEL_quality=Qualité de l’air
90 $(foreach sensor,$(SENSORS),$(eval $(call png/sensor)))