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_dust=Particules
26 SENSOR_LABEL_air=Qualité de l’air
27 SENSOR_LABEL_co_ch4_lpg=CO/CH4/LPG
36 ## Round Robin Database (RRD)
40 .rrd = $(wildcard rrd/*/*.rrd)
47 ARDUINO_DIR := /usr/share/arduino/
48 ARDMK_DIR := /usr/share/arduino/
57 Humidity_Temperature_Sensor \
62 USER_LIB_PATH := $(realpath ./libraries)
65 include $(ARDMK_DIR)/Arduino.mk
68 ino: $(TARGET_EEP) $(TARGET_HEX)
74 define view/sensor/png
77 define view/sensor/year/png
78 view/$(sensor)/$(year)/png:
81 define view/sensor/year/month/png
82 view/$(sensor)/$(year)/$(month)/png: \
83 view/$(sensor)/$(year)/$(month).png
85 view/$(sensor)/$(year)/$(month).png: \
86 rrd/$(year)/$(month).rrd
89 -w 785 -h 120 -a PNG \
91 --start $(month_begin) --end $(month_end) \
92 --vertical-label '$$(SENSOR_LABEL_$(sensor))' \
93 --x-grid HOUR:8:DAY:1:DAY:1:86400:%d \
94 DEF:$(sensor)=rrd/$(year)/$(month).rrd:$(sensor):$$(RRD_CF) \
95 LINE1:$(sensor)'#ff0000':"$(sensor)"
98 define view/sensor/year/month/day/png
99 view/$(sensor)/$(year)/$(month)/$(day)/png: \
100 view/$(sensor)/$(year)/$(month)/$(day).png
102 view/$(sensor)/$(year)/$(month)/$(day).png: \
103 rrd/$(year)/$(month).rrd
106 -w 785 -h 120 -a PNG \
108 --start $(day_begin) --end $(day_end) \
109 --vertical-label '$$(SENSOR_LABEL_$(sensor))' \
110 --x-grid MINUTE:10:HOUR:1:HOUR:1:0:%H \
111 DEF:$(sensor)=rrd/$(year)/$(month).rrd:$(sensor):$$(RRD_CF) \
112 LINE1:$(sensor)'#ff0000':"$(sensor)";
115 define view/year/month/png
116 view/$(year)/$(month)/png: \
117 $(foreach sensor,$(sensors), view/$(sensor)/$(year)/$(month)/png)
119 define view/year/month/day/png
120 view/$(year)/$(month)/$(day)/png: \
121 $(foreach sensor,$(sensors), view/$(sensor)/$(year)/$(month)/$(day)/png)
128 define view/sensor/html5
131 define view/sensor/year/html5
132 view/$(sensor)/$(year)/html5:
135 define view/sensor/year/month/html5
136 view/$(sensor)/$(year)/$(month)/html5: \
137 view/$(sensor)/$(year)/$(month).html5
139 view/$(sensor)/$(year)/$(month).html5: \
140 view/$(sensor)/$(year)/$(month)/png
142 <report sensor="$(sensor)" year="$(year)" month="$(month)"> \
143 $(foreach day,$(days), \
146 day-name="$$(shell date +'%A' -d '$(year)/$(month)/$(day)')"/>) \
148 xsltproc --output $$@ \
149 xsl/sensor/year/month.html5.xsl -
151 define view/year/month/html5
152 view/$(year)/$(month)/html5: \
153 view/$(year)/$(month).html5
155 view/$(year)/$(month).html5: \
156 view/$(year)/$(month)/png
159 <report year="$(year)" month="$(month)"> \
160 $(foreach day,$(days), \
163 day-name="$$(shell date +'%A' -d '$(year)/$(month)/$(day)')"> \
164 $(foreach sensor,$(sensors), \
165 <sensor name="$(sensor)"/> \
169 xsltproc --output $$@ \
170 xsl/year/month.html5.xsl -
176 years=$(call uniq,$(foreach rrd,$(.rrd),$(word 2,$(subst /, ,$(rrd)))))
177 months=$(foreach rrd,$(filter rrd/$(year)/%,$(.rrd)),$(basename $(word 3,$(subst /, ,$(rrd)))))
178 days=$(shell seq -w $$(date +'%d' -d '$(year)/$(month)/01 + 1 month - 1 second'))
180 month_begin=$(shell date +'%s' -d '$(year)/$(month)/01')
181 month_end=$(shell date +'%s' -d '$(year)/$(month)/01 + 1 month - 1 second')
183 day_begin=$(shell date +'%s' -d '$(year)/$(month)/$(day)')
184 day_end=$(shell date +'%s' -d '$(year)/$(month)/$(day) + 1 day - 1 second')
186 define foreach/sensor
187 .PHONY: view/$(sensor)/$(view)
188 view/$(view): view/$(sensor)/$(view)
189 $(call view/sensor/$(view))
192 define foreach/year/sensor/view
193 .PHONY: view/$(sensor)/$(year)/$(view)
194 view/$(sensor)/$(view): view/$(sensor)/$(year)/$(view)
195 $(call view/sensor/year/$(view))
198 define foreach/year/month/sensor/view
199 .PHONY: view/$(sensor)/$(year)/$(month)/$(view)
200 view/$(sensor)/$(year)/$(view): view/$(sensor)/$(year)/$(month)/$(view)
201 $(call view/sensor/year/month/$(view))
203 define foreach/year/month/view
204 .PHONY: view/$(year)/$(month)/$(view)
205 view/$(year)/$(view): view/$(year)/$(month)/$(view)
206 $(call view/year/month/$(view))
209 define foreach/year/month/day/sensor/view
210 .PHONY: view/$(sensor)/$(year)/$(month)/$(day)/$(view)
211 view/$(sensor)/$(year)/$(month)/$(view): view/$(sensor)/$(year)/$(month)/$(day)/$(view)
212 $(call view/sensor/year/month/day/$(view))
214 define foreach/year/month/day/view
215 .PHONY: view/$(year)/$(month)/$(day)/$(view)
216 view/$(year)/$(month)/$(view): view/$(year)/$(month)/$(day)/$(view)
217 $(call view/year/month/day/$(view))
220 $(foreach sensor,$(sensors), \
221 $(foreach view,$(views), \
222 $(eval $(call foreach/sensor)) \
225 $(foreach year,$(years), \
226 $(foreach view,$(views), \
227 $(eval $(call foreach/year/view)) \
229 $(foreach sensor,$(sensors), \
230 $(foreach view,$(views), \
231 $(eval $(call foreach/year/sensor/view)) \
234 $(foreach month,$(months), \
235 $(foreach view,$(views), \
236 $(eval $(call foreach/year/month/view)) \
238 $(foreach sensor,$(sensors), \
239 $(foreach view,$(views), \
240 $(eval $(call foreach/year/month/sensor/view)) \
243 $(foreach day,$(days), \
244 $(foreach view,$(views), \
245 $(eval $(call foreach/year/month/day/view)) \
247 $(foreach sensor,$(sensors), \
248 $(foreach view,$(views), \
249 $(eval $(call foreach/year/month/day/sensor/view)) \