Skip to content

Commit 8ca6173

Browse files
committed
add a reasonable default for cache_offset to all examples
1 parent d121428 commit 8ca6173

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Usage Example
7070
wifi.radio.connect(wifi_ssid, wifi_password)
7171
7272
pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
73-
ntp = adafruit_ntp.NTP(pool, tz_offset=0)
73+
ntp = adafruit_ntp.NTP(pool, tz_offset=0, cache_offset=3600)
7474
7575
while True:
7676
print(ntp.datetime)

examples/ntp_connection_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# get the socket pool from connection manager
3434
socket = adafruit_connection_manager.get_radio_socketpool(radio)
3535

36-
# adjust tz_offset for locale...
37-
ntp = adafruit_ntp.NTP(socket, tz_offset=-5)
36+
# adjust tz_offset for locale, only ping NTP server every hour
37+
ntp = adafruit_ntp.NTP(socket, tz_offset=-5, cache_seconds=3600)
3838

3939
print(ntp.datetime)

examples/ntp_cpython.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import adafruit_ntp
1010

1111
# Don't use tz_offset kwarg with CPython because it will adjust automatically.
12-
ntp = adafruit_ntp.NTP(socket)
12+
ntp = adafruit_ntp.NTP(socket, cache_seconds=3600)
1313

1414
while True:
1515
print(ntp.datetime)

examples/ntp_set_rtc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
wifi.radio.connect(secrets["ssid"], secrets["password"])
2222

2323
pool = socketpool.SocketPool(wifi.radio)
24-
ntp = adafruit_ntp.NTP(pool, tz_offset=0)
24+
ntp = adafruit_ntp.NTP(pool, tz_offset=0, cache_seconds=3600)
2525

2626
# NOTE: This changes the system time so make sure you aren't assuming that time
2727
# doesn't jump.

examples/ntp_simpletest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
wifi.radio.connect(secrets["ssid"], secrets["password"])
2121

2222
pool = socketpool.SocketPool(wifi.radio)
23-
ntp = adafruit_ntp.NTP(pool, tz_offset=0)
23+
ntp = adafruit_ntp.NTP(pool, tz_offset=0, cache_offset=3600)
2424

2525
while True:
2626
print(ntp.datetime)

0 commit comments

Comments
 (0)