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)
62 include $(ARDMK_DIR)/Arduino.mk
65 ino: $(TARGET_EEP) $(TARGET_HEX)
71 define view/sensor/png
74 define view/sensor/year/png
75 view/$(sensor)/$(year)/png:
78 define view/sensor/year/month/png
79 view/$(sensor)/$(year)/$(month)/png: \
80 view/$(sensor)/$(year)/$(month).png
82 view/$(sensor)/$(year)/$(month).png: \
83 rrd/$(year)/$(month).rrd
86 -w 785 -h 120 -a PNG \
88 --start $(month_begin) --end $(month_end) \
89 --vertical-label '$$(SENSOR_LABEL_$(sensor))' \
90 --x-grid HOUR:8:DAY:1:DAY:1:86400:%d \
91 DEF:$(sensor)=rrd/$(year)/$(month).rrd:$(sensor):$$(RRD_CF) \
92 LINE1:$(sensor)'#ff0000':"$(sensor)"
95 define view/sensor/year/month/day/png
96 view/$(sensor)/$(year)/$(month)/$(day)/png: \
97 view/$(sensor)/$(year)/$(month)/$(day).png
99 view/$(sensor)/$(year)/$(month)/$(day).png: \
100 rrd/$(year)/$(month).rrd
103 -w 785 -h 120 -a PNG \
105 --start $(day_begin) --end $(day_end) \
106 --vertical-label '$$(SENSOR_LABEL_$(sensor))' \
107 --x-grid MINUTE:10:HOUR:1:HOUR:1:0:%H \
108 DEF:$(sensor)=rrd/$(year)/$(month).rrd:$(sensor):$$(RRD_CF) \
109 LINE1:$(sensor)'#ff0000':"$(sensor)";
112 define view/year/month/png
113 view/$(year)/$(month)/png: \
114 $(foreach sensor,$(sensors), view/$(sensor)/$(year)/$(month)/png)
116 define view/year/month/day/png
117 view/$(year)/$(month)/$(day)/png: \
118 $(foreach sensor,$(sensors), view/$(sensor)/$(year)/$(month)/$(day)/png)
125 define view/sensor/html5
128 define view/sensor/year/html5
129 view/$(sensor)/$(year)/html5:
132 define view/sensor/year/month/html5
133 view/$(sensor)/$(year)/$(month)/html5: \
134 view/$(sensor)/$(year)/$(month).html5
136 view/$(sensor)/$(year)/$(month).html5: \
137 view/$(sensor)/$(year)/$(month)/png
139 <report sensor="$(sensor)" year="$(year)" month="$(month)"> \
140 $(foreach day,$(days), \
143 day-name="$$(shell date +'%A' -d '$(year)/$(month)/$(day)')"/>) \
145 xsltproc --output $$@ \
146 xsl/sensor/year/month.html5.xsl -
148 define view/year/month/html5
149 view/$(year)/$(month)/html5: \
150 view/$(year)/$(month).html5
152 view/$(year)/$(month).html5: \
153 $(foreach sensor,$(sensors), view/$(sensor)/$(year)/$(month)/png)
156 <report year="$(year)" month="$(month)"> \
157 $(foreach day,$(days), \
160 day-name="$$(shell date +'%A' -d '$(year)/$(month)/$(day)')"> \
161 $(foreach sensor,$(sensors), \
162 <sensor name="$(sensor)"/> \
166 xsltproc --output $$@ \
167 xsl/year/month.html5.xsl -
170 define view/sensor/year/month/day/html5
171 #view/$(sensor)/$(year)/$(month)/$(day)/html5: \
172 #view/$(sensor)/$(year)/$(month)/$(day).html5
179 years=$(call uniq,$(foreach rrd,$(.rrd),$(word 2,$(subst /, ,$(rrd)))))
180 months=$(foreach rrd,$(filter rrd/$(year)/%,$(.rrd)),$(basename $(word 3,$(subst /, ,$(rrd)))))
181 days=$(shell seq -w $$(date +'%d' -d '$(year)/$(month)/01 + 1 month - 1 second'))
183 month_begin=$(shell date +'%s' -d '$(year)/$(month)/01')
184 month_end=$(shell date +'%s' -d '$(year)/$(month)/01 + 1 month - 1 second')
186 day_begin=$(shell date +'%s' -d '$(year)/$(month)/$(day)')
187 day_end=$(shell date +'%s' -d '$(year)/$(month)/$(day) + 1 day - 1 second')
189 define foreach/sensor
190 .PHONY: view/$(sensor)/$(view)
191 view/$(view): view/$(sensor)/$(view)
192 $(call view/sensor/$(view))
195 define foreach/year/sensor/view
196 .PHONY: view/$(sensor)/$(year)/$(view)
197 view/$(sensor)/$(view): view/$(sensor)/$(year)/$(view)
198 $(call view/sensor/year/$(view))
201 define foreach/year/month/sensor/view
202 .PHONY: view/$(sensor)/$(year)/$(month)/$(view)
203 view/$(sensor)/$(year)/$(view): view/$(sensor)/$(year)/$(month)/$(view)
204 $(call view/sensor/year/month/$(view))
206 define foreach/year/month/view
207 .PHONY: view/$(year)/$(month)/$(view)
208 view/$(year)/$(view): view/$(year)/$(month)/$(view)
209 $(call view/year/month/$(view))
212 define foreach/year/month/day/sensor/view
213 .PHONY: view/$(sensor)/$(year)/$(month)/$(day)/$(view)
214 view/$(sensor)/$(year)/$(month)/$(view): view/$(sensor)/$(year)/$(month)/$(day)/$(view)
215 $(call view/sensor/year/month/day/$(view))
217 define foreach/year/month/day/view
218 .PHONY: view/$(year)/$(month)/$(day)/$(view)
219 view/$(year)/$(month)/$(view): view/$(year)/$(month)/$(day)/$(view)
220 $(call view/year/month/day/$(view))
223 $(foreach sensor,$(sensors), \
224 $(foreach view,$(views), \
225 $(eval $(call foreach/sensor)) \
228 $(foreach year,$(years), \
229 $(foreach view,$(views), \
230 $(eval $(call foreach/year/view)) \
232 $(foreach sensor,$(sensors), \
233 $(foreach view,$(views), \
234 $(eval $(call foreach/year/sensor/view)) \
237 $(foreach month,$(months), \
238 $(foreach view,$(views), \
239 $(eval $(call foreach/year/month/view)) \
241 $(foreach sensor,$(sensors), \
242 $(foreach view,$(views), \
243 $(eval $(call foreach/year/month/sensor/view)) \
246 $(foreach day,$(days), \
247 $(foreach view,$(views), \
248 $(eval $(call foreach/year/month/day/view)) \
250 $(foreach sensor,$(sensors), \
251 $(foreach view,$(views), \
252 $(eval $(call foreach/year/month/day/sensor/view)) \