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 \
61 #Grove_Barometer_HP20x
63 USER_LIB_PATH := $(realpath ./libraries)
66 include $(ARDMK_DIR)/Arduino.mk
69 ino: $(TARGET_EEP) $(TARGET_HEX)
75 define view/sensor/png
78 define view/sensor/year/png
79 view/$(sensor)/$(year)/png:
82 define view/sensor/year/month/png
83 view/$(sensor)/$(year)/$(month)/png: \
84 view/$(sensor)/$(year)/$(month).png
86 view/$(sensor)/$(year)/$(month).png: \
87 rrd/$(year)/$(month).rrd
90 -w 785 -h 120 -a PNG \
92 --start $(month_begin) --end $(month_end) \
93 --vertical-label '$$(SENSOR_LABEL_$(sensor))' \
94 --x-grid HOUR:8:DAY:1:DAY:1:86400:%d \
95 DEF:$(sensor)=rrd/$(year)/$(month).rrd:$(sensor):$$(RRD_CF) \
96 LINE1:$(sensor)'#ff0000':"$(sensor)"
99 define view/sensor/year/month/day/png
100 view/$(sensor)/$(year)/$(month)/$(day)/png: \
101 view/$(sensor)/$(year)/$(month)/$(day).png
103 view/$(sensor)/$(year)/$(month)/$(day).png: \
104 rrd/$(year)/$(month).rrd
107 -w 785 -h 120 -a PNG \
109 --start $(day_begin) --end $(day_end) \
110 --vertical-label '$$(SENSOR_LABEL_$(sensor))' \
111 --x-grid MINUTE:10:HOUR:1:HOUR:1:0:%H \
112 DEF:$(sensor)=rrd/$(year)/$(month).rrd:$(sensor):$$(RRD_CF) \
113 LINE1:$(sensor)'#ff0000':"$(sensor)";
116 define view/year/month/png
117 view/$(year)/$(month)/png: \
118 $(foreach sensor,$(sensors), view/$(sensor)/$(year)/$(month)/png)
120 define view/year/month/day/png
121 view/$(year)/$(month)/$(day)/png: \
122 $(foreach sensor,$(sensors), view/$(sensor)/$(year)/$(month)/$(day)/png)
129 define view/sensor/html5
132 define view/sensor/year/html5
133 view/$(sensor)/$(year)/html5:
136 define view/sensor/year/month/html5
137 view/$(sensor)/$(year)/$(month)/html5: \
138 view/$(sensor)/$(year)/$(month).html5
140 view/$(sensor)/$(year)/$(month).html5: \
141 view/$(sensor)/$(year)/$(month)/png
143 <report sensor="$(sensor)" year="$(year)" month="$(month)"> \
144 $(foreach day,$(days), \
147 day-name="$$(shell date +'%A' -d '$(year)/$(month)/$(day)')"/>) \
149 xsltproc --output $$@ \
150 xsl/sensor/year/month.html5.xsl -
152 define view/year/month/html5
153 view/$(year)/$(month)/html5: \
154 view/$(year)/$(month).html5
156 view/$(year)/$(month).html5: \
157 view/$(year)/$(month)/png
160 <report year="$(year)" month="$(month)"> \
161 $(foreach day,$(days), \
164 day-name="$$(shell date +'%A' -d '$(year)/$(month)/$(day)')"> \
165 $(foreach sensor,$(sensors), \
166 <sensor name="$(sensor)"/> \
170 xsltproc --output $$@ \
171 xsl/year/month.html5.xsl -
177 years=$(call uniq,$(foreach rrd,$(.rrd),$(word 2,$(subst /, ,$(rrd)))))
178 months=$(foreach rrd,$(filter rrd/$(year)/%,$(.rrd)),$(basename $(word 3,$(subst /, ,$(rrd)))))
179 days=$(shell seq -w $$(date +'%d' -d '$(year)/$(month)/01 + 1 month - 1 second'))
181 month_begin=$(shell date +'%s' -d '$(year)/$(month)/01')
182 month_end=$(shell date +'%s' -d '$(year)/$(month)/01 + 1 month - 1 second')
184 day_begin=$(shell date +'%s' -d '$(year)/$(month)/$(day)')
185 day_end=$(shell date +'%s' -d '$(year)/$(month)/$(day) + 1 day - 1 second')
187 define foreach/sensor
188 .PHONY: view/$(sensor)/$(view)
189 view/$(view): view/$(sensor)/$(view)
190 $(call view/sensor/$(view))
193 define foreach/year/sensor/view
194 .PHONY: view/$(sensor)/$(year)/$(view)
195 view/$(sensor)/$(view): view/$(sensor)/$(year)/$(view)
196 $(call view/sensor/year/$(view))
199 define foreach/year/month/sensor/view
200 .PHONY: view/$(sensor)/$(year)/$(month)/$(view)
201 view/$(sensor)/$(year)/$(view): view/$(sensor)/$(year)/$(month)/$(view)
202 $(call view/sensor/year/month/$(view))
204 define foreach/year/month/view
205 .PHONY: view/$(year)/$(month)/$(view)
206 view/$(year)/$(view): view/$(year)/$(month)/$(view)
207 $(call view/year/month/$(view))
210 define foreach/year/month/day/sensor/view
211 .PHONY: view/$(sensor)/$(year)/$(month)/$(day)/$(view)
212 view/$(sensor)/$(year)/$(month)/$(view): view/$(sensor)/$(year)/$(month)/$(day)/$(view)
213 $(call view/sensor/year/month/day/$(view))
215 define foreach/year/month/day/view
216 .PHONY: view/$(year)/$(month)/$(day)/$(view)
217 view/$(year)/$(month)/$(view): view/$(year)/$(month)/$(day)/$(view)
218 $(call view/year/month/day/$(view))
221 $(foreach sensor,$(sensors), \
222 $(foreach view,$(views), \
223 $(eval $(call foreach/sensor)) \
226 $(foreach year,$(years), \
227 $(foreach view,$(views), \
228 $(eval $(call foreach/year/view)) \
230 $(foreach sensor,$(sensors), \
231 $(foreach view,$(views), \
232 $(eval $(call foreach/year/sensor/view)) \
235 $(foreach month,$(months), \
236 $(foreach view,$(views), \
237 $(eval $(call foreach/year/month/view)) \
239 $(foreach sensor,$(sensors), \
240 $(foreach view,$(views), \
241 $(eval $(call foreach/year/month/sensor/view)) \
244 $(foreach day,$(days), \
245 $(foreach view,$(views), \
246 $(eval $(call foreach/year/month/day/view)) \
248 $(foreach sensor,$(sensors), \
249 $(foreach view,$(views), \
250 $(eval $(call foreach/year/month/day/sensor/view)) \