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)";
116 define view/sensor/html5
119 define view/sensor/year/html5
120 view/$(sensor)/$(year)/html5:
123 define view/sensor/year/month/html5
124 view/$(sensor)/$(year)/$(month)/html5: \
125 view/$(sensor)/$(year)/$(month).html5
127 view/$(sensor)/$(year)/$(month).html5: \
128 view/$(sensor)/$(year)/$(month)/png
130 <report sensor="$(sensor)" year="$(year)" month="$(month)"> \
131 $(foreach day,$(days), \
134 day-name="$$(shell date +'%A' -d '$(year)/$(month)/$(day)')"/>) \
136 xsltproc --output $$@ \
137 xsl/sensor/year/month.html5.xsl -
139 define view/year/month/html5
140 view/$(year)/$(month)/html5: \
141 view/$(year)/$(month).html5
143 view/$(year)/$(month).html5: \
144 $(foreach sensor,$(sensors), view/$(sensor)/$(year)/$(month)/png)
147 <report year="$(year)" month="$(month)"> \
148 $(foreach day,$(days), \
151 day-name="$$(shell date +'%A' -d '$(year)/$(month)/$(day)')"> \
152 $(foreach sensor,$(sensors), \
153 <sensor name="$(sensor)"/> \
157 xsltproc --output $$@ \
158 xsl/year/month.html5.xsl -
161 define view/sensor/year/month/day/html5
162 #view/$(sensor)/$(year)/$(month)/$(day)/html5: \
163 #view/$(sensor)/$(year)/$(month)/$(day).html5
170 years=$(call uniq,$(foreach rrd,$(.rrd),$(word 2,$(subst /, ,$(rrd)))))
171 months=$(foreach rrd,$(filter rrd/$(year)/%,$(.rrd)),$(basename $(word 3,$(subst /, ,$(rrd)))))
172 days=$(shell seq -w $$(date +'%d' -d '$(year)/$(month)/01 + 1 month - 1 second'))
174 month_begin=$(shell date +'%s' -d '$(year)/$(month)/01')
175 month_end=$(shell date +'%s' -d '$(year)/$(month)/01 + 1 month - 1 second')
177 day_begin=$(shell date +'%s' -d '$(year)/$(month)/$(day)')
178 day_end=$(shell date +'%s' -d '$(year)/$(month)/$(day) + 1 day - 1 second')
180 define foreach/sensor
181 .PHONY: view/$(sensor)/$(view)
182 view/$(view): view/$(sensor)/$(view)
183 $(call view/sensor/$(view))
186 define foreach/year/sensor/view
187 .PHONY: view/$(sensor)/$(year)/$(view)
188 view/$(sensor)/$(view): view/$(sensor)/$(year)/$(view)
189 $(call view/sensor/year/$(view))
192 define foreach/year/month/sensor/view
193 .PHONY: view/$(sensor)/$(year)/$(month)/$(view)
194 view/$(sensor)/$(year)/$(view): view/$(sensor)/$(year)/$(month)/$(view)
195 $(call view/sensor/year/month/$(view))
197 define foreach/year/month/view
198 .PHONY: view/$(year)/$(month)/$(view)
199 view/$(year)/$(view): view/$(year)/$(month)/$(view)
200 $(call view/year/month/$(view))
203 define foreach/year/month/day/sensor/view
204 .PHONY: view/$(sensor)/$(year)/$(month)/$(day)/$(view)
205 view/$(sensor)/$(year)/$(month)/$(view): view/$(sensor)/$(year)/$(month)/$(day)/$(view)
206 $(call view/sensor/year/month/day/$(view))
209 $(foreach sensor,$(sensors), \
210 $(foreach view,$(views), \
211 $(eval $(call foreach/sensor)) \
214 $(foreach year,$(years), \
215 $(foreach view,$(views), \
216 $(eval $(call foreach/year/view)) \
218 $(foreach sensor,$(sensors), \
219 $(foreach view,$(views), \
220 $(eval $(call foreach/year/sensor/view)) \
223 $(foreach month,$(months), \
224 $(foreach view,$(views), \
225 $(eval $(call foreach/year/month/view)) \
227 $(foreach sensor,$(sensors), \
228 $(foreach view,$(views), \
229 $(eval $(call foreach/year/month/sensor/view)) \
232 $(foreach day,$(days), \
233 $(foreach view,$(views), \
234 $(eval $(call foreach/year/month/day/view)) \
236 $(foreach sensor,$(sensors), \
237 $(foreach view,$(views), \
238 $(eval $(call foreach/year/month/day/sensor/view)) \