mirror of
https://github.com/pimoroni/grow-python
synced 2025-10-25 15:19:23 +00:00
Moved monitor-and-water to advanced
This commit is contained in:
@@ -47,6 +47,7 @@ class Channel:
|
|||||||
dry_point=26.7,
|
dry_point=26.7,
|
||||||
icon=None,
|
icon=None,
|
||||||
auto_water=False,
|
auto_water=False,
|
||||||
|
enabled=False,
|
||||||
):
|
):
|
||||||
self.channel = display_channel
|
self.channel = display_channel
|
||||||
self.sensor = Moisture(sensor_channel)
|
self.sensor = Moisture(sensor_channel)
|
||||||
@@ -61,6 +62,7 @@ class Channel:
|
|||||||
self.dry_point = dry_point
|
self.dry_point = dry_point
|
||||||
self.last_dose = time.time()
|
self.last_dose = time.time()
|
||||||
self.icon = icon
|
self.icon = icon
|
||||||
|
self.enabled = enabled
|
||||||
self.alarm = False
|
self.alarm = False
|
||||||
|
|
||||||
self.sensor.set_wet_point(wet_point)
|
self.sensor.set_wet_point(wet_point)
|
||||||
@@ -91,6 +93,9 @@ class Channel:
|
|||||||
self.water_level = config.get("water_level", self.water_level)
|
self.water_level = config.get("water_level", self.water_level)
|
||||||
self.watering_delay = config.get("watering_delay", self.watering_delay)
|
self.watering_delay = config.get("watering_delay", self.watering_delay)
|
||||||
self.auto_water = config.get("auto_water", self.auto_water)
|
self.auto_water = config.get("auto_water", self.auto_water)
|
||||||
|
self.enabled = config.get("enabled", self.enabled)
|
||||||
|
self.wet_point = config.get("wet_point", self.wet_point)
|
||||||
|
self.dry_point = config.get("dry_point", self.dry_point)
|
||||||
icon = config.get("icon", None)
|
icon = config.get("icon", None)
|
||||||
if icon is not None:
|
if icon is not None:
|
||||||
self.icon = Image.open(icon)
|
self.icon = Image.open(icon)
|
||||||
@@ -99,6 +104,7 @@ class Channel:
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return """Channel: {channel}
|
return """Channel: {channel}
|
||||||
|
Enabled: {enabled}
|
||||||
Alarm level: {alarm_level}
|
Alarm level: {alarm_level}
|
||||||
Auto water: {auto_water}
|
Auto water: {auto_water}
|
||||||
Water level: {water_level}
|
Water level: {water_level}
|
||||||
@@ -126,13 +132,14 @@ Dry point: {dry_point}
|
|||||||
|
|
||||||
# Saturation amounts from each sensor
|
# Saturation amounts from each sensor
|
||||||
c = 1.0 - self.sensor.saturation
|
c = 1.0 - self.sensor.saturation
|
||||||
active = self.sensor.active
|
active = self.sensor.active and self.enabled
|
||||||
|
|
||||||
# Draw background bars
|
if active:
|
||||||
draw.rectangle(
|
# Draw background bars
|
||||||
(x, int(c * HEIGHT), x + 37, HEIGHT),
|
draw.rectangle(
|
||||||
self.indicator_color(c) if active else (229, 229, 229),
|
(x, int(c * HEIGHT), x + 37, HEIGHT),
|
||||||
)
|
self.indicator_color(c) if active else (229, 229, 229),
|
||||||
|
)
|
||||||
|
|
||||||
# Draw plant image
|
# Draw plant image
|
||||||
x -= 3
|
x -= 3
|
||||||
@@ -177,6 +184,8 @@ Dry point: {dry_point}
|
|||||||
)
|
)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
if not self.enabled:
|
||||||
|
return
|
||||||
sat = self.sensor.saturation
|
sat = self.sensor.saturation
|
||||||
if sat < self.water_level:
|
if sat < self.water_level:
|
||||||
if self.water():
|
if self.water():
|
||||||
@@ -356,6 +365,10 @@ Alarm Interval: {:.2f}s
|
|||||||
render()
|
render()
|
||||||
display.display(image.convert("RGB"))
|
display.display(image.convert("RGB"))
|
||||||
|
|
||||||
|
#w, h = image.size
|
||||||
|
#image.convert("RGB").resize((w * 4, h * 4), Image.NEAREST).save("display.png")
|
||||||
|
#break
|
||||||
|
|
||||||
if alarm_enable and alarm and time.time() - time_last_beep > alarm_interval:
|
if alarm_enable and alarm and time.time() - time_last_beep > alarm_interval:
|
||||||
piezo.beep(440, 0.1, blocking=False)
|
piezo.beep(440, 0.1, blocking=False)
|
||||||
threading.Timer(0.3, piezo.beep, args=[440, 0.1], kwargs={"blocking":False}).start()
|
threading.Timer(0.3, piezo.beep, args=[440, 0.1], kwargs={"blocking":False}).start()
|
||||||
19
examples/advanced/settings.yml
Normal file
19
examples/advanced/settings.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
channel1:
|
||||||
|
enabled: true
|
||||||
|
warn_level: 0.2
|
||||||
|
icon: icons/flat-4.png
|
||||||
|
wet_point: 2.5
|
||||||
|
dry_point: 27.6
|
||||||
|
channel2:
|
||||||
|
enabled: false
|
||||||
|
warn_level: 0.2
|
||||||
|
wet_point: 2.5
|
||||||
|
dry_point: 27.6
|
||||||
|
channel3:
|
||||||
|
enabled: false
|
||||||
|
warn_level: 0.2
|
||||||
|
wet_point: 2.5
|
||||||
|
dry_point: 27.6
|
||||||
|
general:
|
||||||
|
alarm_enable: True
|
||||||
|
alarm_interval: 10.0
|
||||||
Reference in New Issue
Block a user