Skip to content

Commit 8176e15

Browse files
author
Pierrick C
committed
Updated example after pylint checks
*No space allowed around keyword argument assignment *Multiple import + comments
1 parent d05929b commit 8176e15

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

examples/time_source.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
import busio, board, time, rtc
1+
# Simple script using GPS timestamps as RTC time source
2+
# The GPS timestamps are available without a fix and keep the track of
3+
# time while there is powersource (ie coin cell battery)
4+
5+
import time
6+
import board
7+
import rtc
8+
import busio
29
import adafruit_gps
310

4-
uart = busio.UART(board.TX, board.RX, baudrate = 9600, timeout=3000)
11+
uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=3000)
512

613
gps = adafruit_gps.GPS(uart, debug=False)
714
gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
@@ -18,20 +25,25 @@
1825
current = time.monotonic()
1926
if current - last_print >= 1.0:
2027
last_print = current
28+
# Time & date from GPS informations
2129
print('Fix timestamp: {:02}/{:02}/{} {:02}:{:02}:{:02}'.format(
2230
gps.timestamp_utc.tm_mon, # Grab parts of the time from the
2331
gps.timestamp_utc.tm_mday, # struct_time object that holds
2432
gps.timestamp_utc.tm_year, # the fix time. Note you might
2533
gps.timestamp_utc.tm_hour, # not get all data like year, day,
2634
gps.timestamp_utc.tm_min, # month!
2735
gps.timestamp_utc.tm_sec))
36+
37+
#Time & date from internal RTC
2838
print('RTC timestamp: {:02}/{:02}/{} {:02}:{:02}:{:02}'.format(
2939
rtc.RTC.datetime.tm_mon,
3040
rtc.RTC.datetime.tm_mday,
3141
rtc.RTC.datetime.tm_year,
3242
rtc.RTC.datetime.tm_hour,
3343
rtc.RTC.datetime.tm_min,
3444
rtc.RTC.datetime.tm_sec))
45+
46+
#Time & date from time.localtime() function
3547
local_time = time.localtime()
3648
print("Local time: {:02}/{:02}/{} {:02}:{:02}:{:02}".format(
3749
local_time.tm_mon,

0 commit comments

Comments
 (0)