Skip to content

Commit 617bf6d

Browse files
authored
Merge pull request #14 from krittick/master
made printing to console optional when set_time() fails.
2 parents 4fe52c4 + dc1b297 commit 617bf6d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

adafruit_ntp.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,17 @@ class NTP:
4848
This module does not handle daylight savings or local time.
4949
5050
:param adafruit_esp32spi esp: ESP32SPI object.
51+
:param bool debug: Set to True to output set_time() failures to console
5152
"""
5253

53-
def __init__(self, esp):
54+
def __init__(self, esp, debug=False):
5455
# Verify ESP32SPI module
5556
if "ESP_SPIcontrol" in str(type(esp)):
5657
self._esp = esp
5758
else:
5859
raise TypeError("Provided object is not an ESP_SPIcontrol object.")
5960
self.valid_time = False
61+
self.debug = debug
6062

6163
def set_time(self, tz_offset=0):
6264
"""Fetches and sets the microcontroller's current time
@@ -73,5 +75,6 @@ def set_time(self, tz_offset=0):
7375
rtc.RTC().datetime = now
7476
self.valid_time = True
7577
except ValueError as error:
76-
print(str(error))
78+
if self.debug:
79+
print(str(error))
7780
return

0 commit comments

Comments
 (0)