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)
61 include $(ARDMK_DIR)/Arduino.mk
63 ino: $(TARGET_EEP) $(TARGET_HEX)
69 define view/sensor/png
72 define view/sensor/year/png
73 view/$(sensor)/$(year)/png:
76 define view/sensor/year/month/png
77 view/$(sensor)/$(year)/$(month)/png: \
78 view/$(sensor)/$(year)/$(month).png
80 view/$(sensor)/$(year)/$(month).png: \
81 rrd/$(year)/$(month).rrd
84 -w 785 -h 120 -a PNG \
86 --start $(month_begin) --end $(month_end) \
87 --vertical-label '$$(SENSOR_LABEL_$(sensor))' \
88 --x-grid HOUR:8:DAY:1:DAY:1:86400:%d \
89 DEF:$(sensor)=rrd/$(year)/$(month).rrd:$(sensor):$$(RRD_CF) \
90 LINE1:$(sensor)'#ff0000':"$(sensor)"
93 define view/sensor/year/month/day/png
94 view/$(sensor)/$(year)/$(month)/$(day)/png: \
95 view/$(sensor)/$(year)/$(month)/$(day).png
97 view/$(sensor)/$(year)/$(month)/$(day).png: \
98 rrd/$(year)/$(month).rrd
101 -w 785 -h 120 -a PNG \
103 --start $(day_begin) --end $(day_end) \
104 --vertical-label '$$(SENSOR_LABEL_$(sensor))' \
105 --x-grid MINUTE:10:HOUR:1:HOUR:1:0:%H \
106 DEF:$(sensor)=rrd/$(year)/$(month).rrd:$(sensor):$$(RRD_CF) \
107 LINE1:$(sensor)'#ff0000':"$(sensor)";
114 define view/sensor/html5
117 define view/sensor/year/html5
118 view/$(sensor)/$(year)/html5:
121 define view/sensor/year/month/html5
122 view/$(sensor)/$(year)/$(month)/html5: \
123 view/$(sensor)/$(year)/$(month).html5
125 view/$(sensor)/$(year)/$(month).html5: \
126 view/$(sensor)/$(year)/$(month)/png
128 <report sensor="$(sensor)" year="$(year)" month="$(month)"> \
129 $(foreach day,$(days), \
132 day-name="$$(shell date +'%A' -d '$(year)/$(month)/$(day)')"/>) \
134 xsltproc --output $$@ \
135 xsl/sensor/year/month.html5.xsl -
137 define view/year/month/html5
138 view/$(year)/$(month)/html5: \
139 view/$(year)/$(month).html5
141 view/$(year)/$(month).html5: \
142 $(foreach sensor,$(sensors), view/$(sensor)/$(year)/$(month)/png)
145 <report year="$(year)" month="$(month)"> \
146 $(foreach day,$(days), \
149 day-name="$$(shell date +'%A' -d '$(year)/$(month)/$(day)')"> \
150 $(foreach sensor,$(sensors), \
151 <sensor name="$(sensor)"/> \
155 xsltproc --output $$@ \
156 xsl/year/month.html5.xsl -
159 define view/sensor/year/month/day/html5
160 #view/$(sensor)/$(year)/$(month)/$(day)/html5: \
161 #view/$(sensor)/$(year)/$(month)/$(day).html5
168 years=$(call uniq,$(foreach rrd,$(.rrd),$(word 2,$(subst /, ,$(rrd)))))
169 months=$(foreach rrd,$(filter rrd/$(year)/%,$(.rrd)),$(basename $(word 3,$(subst /, ,$(rrd)))))
170 days=$(shell seq -w $$(date +'%d' -d '$(year)/$(month)/01 + 1 month - 1 second'))
172 month_begin=$(shell date +'%s' -d '$(year)/$(month)/01')
173 month_end=$(shell date +'%s' -d '$(year)/$(month)/01 + 1 month - 1 second')
175 day_begin=$(shell date +'%s' -d '$(year)/$(month)/$(day)')
176 day_end=$(shell date +'%s' -d '$(year)/$(month)/$(day) + 1 day - 1 second')
178 define foreach/sensor
179 .PHONY: view/$(sensor)/$(view)
180 view/$(view): view/$(sensor)/$(view)
181 $(call view/sensor/$(view))
184 define foreach/year/sensor/view
185 .PHONY: view/$(sensor)/$(year)/$(view)
186 view/$(sensor)/$(view): view/$(sensor)/$(year)/$(view)
187 $(call view/sensor/year/$(view))
190 define foreach/year/month/sensor/view
191 .PHONY: view/$(sensor)/$(year)/$(month)/$(view)
192 view/$(sensor)/$(year)/$(view): view/$(sensor)/$(year)/$(month)/$(view)
193 $(call view/sensor/year/month/$(view))
195 define foreach/year/month/view
196 .PHONY: view/$(year)/$(month)/$(view)
197 view/$(year)/$(view): view/$(year)/$(month)/$(view)
198 $(call view/year/month/$(view))
201 define foreach/year/month/day/sensor/view
202 .PHONY: view/$(sensor)/$(year)/$(month)/$(day)/$(view)
203 view/$(sensor)/$(year)/$(month)/$(view): view/$(sensor)/$(year)/$(month)/$(day)/$(view)
204 $(call view/sensor/year/month/day/$(view))
207 $(foreach sensor,$(sensors), \
208 $(foreach view,$(views), \
209 $(eval $(call foreach/sensor)) \
212 $(foreach year,$(years), \
213 $(foreach view,$(views), \
214 $(eval $(call foreach/year/view)) \
216 $(foreach sensor,$(sensors), \
217 $(foreach view,$(views), \
218 $(eval $(call foreach/year/sensor/view)) \
221 $(foreach month,$(months), \
222 $(foreach view,$(views), \
223 $(eval $(call foreach/year/month/view)) \
225 $(foreach sensor,$(sensors), \
226 $(foreach view,$(views), \
227 $(eval $(call foreach/year/month/sensor/view)) \
230 $(foreach day,$(days), \
231 $(foreach view,$(views), \
232 $(eval $(call foreach/year/month/day/view)) \
234 $(foreach sensor,$(sensors), \
235 $(foreach view,$(views), \
236 $(eval $(call foreach/year/month/day/sensor/view)) \