1 # Licence: GPLv3+ <http://www.gnu.org/licenses/gpl.txt>
2 # Copyright 2015: Julien Moutinho <julm+air@autogeree.net>
12 uniq,$(wordlist 2,$(words $1),$1),$2 $(if \
13 $(filter $(firstword $1),$2),,$(firstword $1))) \
23 SENSOR_LABEL_temperature=Température (°C)
24 SENSOR_LABEL_humidity=Humidité (%)
25 SENSOR_LABEL_particles=Particules
26 SENSOR_LABEL_quality=Qualité de l’air
34 ## Round Robin Database (RRD)
38 .rrd = $(wildcard rrd/*/*.rrd)
45 ARDUINO_DIR := /usr/share/arduino/
46 ARDMK_DIR := /usr/share/arduino/
55 Humidity_Temperature_Sensor \
59 USER_LIB_PATH := $(abspath ./libraries)
61 include $(ARDMK_DIR)/Arduino.mk
63 ino: $(TARGET_EEP) $(TARGET_HEX)
72 define out/sensor/year/png
73 out/$(sensor)/$(year)/png:
76 define out/sensor/year/month/png
77 out/$(sensor)/$(year)/$(month)/png: \
78 out/$(sensor)/$(year)/$(month).png
80 out/$(sensor)/$(year)/$(month).png: \
81 rrd/$(year)/$(month).rrd
84 -w 785 -h 120 -a PNG \
86 --start $(month_begin) --end $(month_end) \
87 --vertical-label '$$(SENSOR_LABEL_$(sensor))' \
88 --x-grid HOUR:8:DAY:1:DAY:1:86400:%d \
89 DEF:$(sensor)=rrd/$(year)/$(month).rrd:$(sensor):$$(RRD_CF) \
90 LINE1:$(sensor)'#ff0000':"$(sensor)"
93 define out/sensor/year/month/day/png
94 out/$(sensor)/$(year)/$(month)/$(day)/png: \
95 out/$(sensor)/$(year)/$(month)/$(day).png
97 out/$(sensor)/$(year)/$(month)/$(day).png: \
98 rrd/$(year)/$(month).rrd
101 -w 785 -h 120 -a PNG \
103 --start $(day_begin) --end $(day_end) \
104 --vertical-label '$$(SENSOR_LABEL_$(sensor))' \
105 --x-grid MINUTE:10:HOUR:1:HOUR:1:0:%H \
106 DEF:$(sensor)=rrd/$(year)/$(month).rrd:$(sensor):$$(RRD_CF) \
107 LINE1:$(sensor)'#ff0000':"$(sensor)";
114 define out/sensor/html5
117 define out/sensor/year/html5
118 out/$(sensor)/$(year)/html5:
121 define out/sensor/year/month/html5
122 out/$(sensor)/$(year)/$(month)/html5: \
123 out/$(sensor)/$(year)/$(month).html5
125 out/$(sensor)/$(year)/$(month).html5: \
126 out/$(sensor)/$(year)/$(month)/png
128 <report sensor="$(sensor)" year="$(year)" month="$(month)"> \
129 $(foreach day,$(days), \
132 day-name="$$(shell date +'%A' -d '$(year)/$(month)/$(day)')"/>) \
134 xsltproc --output $$@ \
135 xsl/sensor/year/month.html5.xsl -
137 define out/year/month/html5
138 out/$(year)/$(month)/html5: \
139 out/$(year)/$(month).html5
141 out/$(year)/$(month).html5: \
142 $(foreach sensor,$(sensors), out/$(sensor)/$(year)/$(month)/png)
145 <report year="$(year)" month="$(month)"> \
146 $(foreach day,$(days), \
149 day-name="$$(shell date +'%A' -d '$(year)/$(month)/$(day)')"> \
150 $(foreach sensor,$(sensors), \
151 <sensor name="$(sensor)"/> \
155 xsltproc --output $$@ \
156 xsl/year/month.html5.xsl -
159 define out/sensor/year/month/day/html5
160 #out/$(sensor)/$(year)/$(month)/$(day)/html5: \
161 #out/$(sensor)/$(year)/$(month)/$(day).html5
168 years=$(call uniq,$(foreach rrd,$(.rrd),$(word 2,$(subst /, ,$(rrd)))))
169 months=$(foreach rrd,$(filter rrd/$(year)/%,$(.rrd)),$(basename $(word 3,$(subst /, ,$(rrd)))))
170 days=$(shell seq -w $$(date +'%d' -d '$(year)/$(month)/01 + 1 month - 1 second'))
172 month_begin=$(shell date +'%s' -d '$(year)/$(month)/01')
173 month_end=$(shell date +'%s' -d '$(year)/$(month)/01 + 1 month - 1 second')
175 day_begin=$(shell date +'%s' -d '$(year)/$(month)/$(day)')
176 day_end=$(shell date +'%s' -d '$(year)/$(month)/$(day) + 1 day - 1 second')
178 define foreach/sensor
179 .PHONY: out/$(sensor)/$(out)
180 out/$(out): out/$(sensor)/$(out)
181 $(call out/sensor/$(out))
184 define foreach/year/sensor/out
185 .PHONY: out/$(sensor)/$(year)/$(out)
186 out/$(sensor)/$(out): out/$(sensor)/$(year)/$(out)
187 $(call out/sensor/year/$(out))
190 define foreach/year/month/sensor/out
191 .PHONY: out/$(sensor)/$(year)/$(month)/$(out)
192 out/$(sensor)/$(year)/$(out): out/$(sensor)/$(year)/$(month)/$(out)
193 $(call out/sensor/year/month/$(out))
195 define foreach/year/month/out
196 .PHONY: out/$(year)/$(month)/$(out)
197 out/$(year)/$(out): out/$(year)/$(month)/$(out)
198 $(call out/year/month/$(out))
201 define foreach/year/month/day/sensor/out
202 .PHONY: out/$(sensor)/$(year)/$(month)/$(day)/$(out)
203 out/$(sensor)/$(year)/$(month)/$(out): out/$(sensor)/$(year)/$(month)/$(day)/$(out)
204 $(call out/sensor/year/month/day/$(out))
207 $(foreach sensor,$(sensors), \
208 $(foreach out,$(outs), \
209 $(eval $(call foreach/sensor)) \
212 $(foreach year,$(years), \
213 $(foreach out,$(outs), \
214 $(eval $(call foreach/year/out)) \
216 $(foreach sensor,$(sensors), \
217 $(foreach out,$(outs), \
218 $(eval $(call foreach/year/sensor/out)) \
221 $(foreach month,$(months), \
222 $(foreach out,$(outs), \
223 $(eval $(call foreach/year/month/out)) \
225 $(foreach sensor,$(sensors), \
226 $(foreach out,$(outs), \
227 $(eval $(call foreach/year/month/sensor/out)) \
230 $(foreach day,$(days), \
231 $(foreach out,$(outs), \
232 $(eval $(call foreach/year/month/day/out)) \
234 $(foreach sensor,$(sensors), \
235 $(foreach out,$(outs), \
236 $(eval $(call foreach/year/month/day/sensor/out)) \