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 USER_LIB_PATH := $(realpath ./libraries)
64 include $(ARDMK_DIR)/Arduino.mk
67 ino: $(TARGET_EEP) $(TARGET_HEX)
73 define view/sensor/png
76 define view/sensor/year/png
77 view/$(sensor)/$(year)/png:
80 define view/sensor/year/month/png
81 view/$(sensor)/$(year)/$(month)/png: \
82 view/$(sensor)/$(year)/$(month).png
84 view/$(sensor)/$(year)/$(month).png: \
85 rrd/$(year)/$(month).rrd
88 -w 785 -h 120 -a PNG \
90 --start $(month_begin) --end $(month_end) \
91 --vertical-label '$$(SENSOR_LABEL_$(sensor))' \
92 --x-grid HOUR:8:DAY:1:DAY:1:86400:%d \
93 DEF:$(sensor)=rrd/$(year)/$(month).rrd:$(sensor):$$(RRD_CF) \
94 LINE1:$(sensor)'#ff0000':"$(sensor)"
97 define view/sensor/year/month/day/png
98 view/$(sensor)/$(year)/$(month)/$(day)/png: \
99 view/$(sensor)/$(year)/$(month)/$(day).png
101 view/$(sensor)/$(year)/$(month)/$(day).png: \
102 rrd/$(year)/$(month).rrd
105 -w 785 -h 120 -a PNG \
107 --start $(day_begin) --end $(day_end) \
108 --vertical-label '$$(SENSOR_LABEL_$(sensor))' \
109 --x-grid MINUTE:10:HOUR:1:HOUR:1:0:%H \
110 DEF:$(sensor)=rrd/$(year)/$(month).rrd:$(sensor):$$(RRD_CF) \
111 LINE1:$(sensor)'#ff0000':"$(sensor)";
114 define view/year/month/png
115 view/$(year)/$(month)/png: \
116 $(foreach sensor,$(sensors), view/$(sensor)/$(year)/$(month)/png)
118 define view/year/month/day/png
119 view/$(year)/$(month)/$(day)/png: \
120 $(foreach sensor,$(sensors), view/$(sensor)/$(year)/$(month)/$(day)/png)
127 define view/sensor/html5
130 define view/sensor/year/html5
131 view/$(sensor)/$(year)/html5:
134 define view/sensor/year/month/html5
135 view/$(sensor)/$(year)/$(month)/html5: \
136 view/$(sensor)/$(year)/$(month).html5
138 view/$(sensor)/$(year)/$(month).html5: \
139 view/$(sensor)/$(year)/$(month)/png
141 <report sensor="$(sensor)" year="$(year)" month="$(month)"> \
142 $(foreach day,$(days), \
145 day-name="$$(shell date +'%A' -d '$(year)/$(month)/$(day)')"/>) \
147 xsltproc --output $$@ \
148 xsl/sensor/year/month.html5.xsl -
150 define view/year/month/html5
151 view/$(year)/$(month)/html5: \
152 view/$(year)/$(month).html5
154 view/$(year)/$(month).html5: \
155 view/$(year)/$(month)/png
158 <report year="$(year)" month="$(month)"> \
159 $(foreach day,$(days), \
162 day-name="$$(shell date +'%A' -d '$(year)/$(month)/$(day)')"> \
163 $(foreach sensor,$(sensors), \
164 <sensor name="$(sensor)"/> \
168 xsltproc --output $$@ \
169 xsl/year/month.html5.xsl -
175 years=$(call uniq,$(foreach rrd,$(.rrd),$(word 2,$(subst /, ,$(rrd)))))
176 months=$(foreach rrd,$(filter rrd/$(year)/%,$(.rrd)),$(basename $(word 3,$(subst /, ,$(rrd)))))
177 days=$(shell seq -w $$(date +'%d' -d '$(year)/$(month)/01 + 1 month - 1 second'))
179 month_begin=$(shell date +'%s' -d '$(year)/$(month)/01')
180 month_end=$(shell date +'%s' -d '$(year)/$(month)/01 + 1 month - 1 second')
182 day_begin=$(shell date +'%s' -d '$(year)/$(month)/$(day)')
183 day_end=$(shell date +'%s' -d '$(year)/$(month)/$(day) + 1 day - 1 second')
185 define foreach/sensor
186 .PHONY: view/$(sensor)/$(view)
187 view/$(view): view/$(sensor)/$(view)
188 $(call view/sensor/$(view))
191 define foreach/year/sensor/view
192 .PHONY: view/$(sensor)/$(year)/$(view)
193 view/$(sensor)/$(view): view/$(sensor)/$(year)/$(view)
194 $(call view/sensor/year/$(view))
197 define foreach/year/month/sensor/view
198 .PHONY: view/$(sensor)/$(year)/$(month)/$(view)
199 view/$(sensor)/$(year)/$(view): view/$(sensor)/$(year)/$(month)/$(view)
200 $(call view/sensor/year/month/$(view))
202 define foreach/year/month/view
203 .PHONY: view/$(year)/$(month)/$(view)
204 view/$(year)/$(view): view/$(year)/$(month)/$(view)
205 $(call view/year/month/$(view))
208 define foreach/year/month/day/sensor/view
209 .PHONY: view/$(sensor)/$(year)/$(month)/$(day)/$(view)
210 view/$(sensor)/$(year)/$(month)/$(view): view/$(sensor)/$(year)/$(month)/$(day)/$(view)
211 $(call view/sensor/year/month/day/$(view))
213 define foreach/year/month/day/view
214 .PHONY: view/$(year)/$(month)/$(day)/$(view)
215 view/$(year)/$(month)/$(view): view/$(year)/$(month)/$(day)/$(view)
216 $(call view/year/month/day/$(view))
219 $(foreach sensor,$(sensors), \
220 $(foreach view,$(views), \
221 $(eval $(call foreach/sensor)) \
224 $(foreach year,$(years), \
225 $(foreach view,$(views), \
226 $(eval $(call foreach/year/view)) \
228 $(foreach sensor,$(sensors), \
229 $(foreach view,$(views), \
230 $(eval $(call foreach/year/sensor/view)) \
233 $(foreach month,$(months), \
234 $(foreach view,$(views), \
235 $(eval $(call foreach/year/month/view)) \
237 $(foreach sensor,$(sensors), \
238 $(foreach view,$(views), \
239 $(eval $(call foreach/year/month/sensor/view)) \
242 $(foreach day,$(days), \
243 $(foreach view,$(views), \
244 $(eval $(call foreach/year/month/day/view)) \
246 $(foreach sensor,$(sensors), \
247 $(foreach view,$(views), \
248 $(eval $(call foreach/year/month/day/sensor/view)) \