Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Commit 64f2578

Browse files
author
Catalin Ioana
committed
lib/pycoproc: corrected pytrack/pysense calibrate_rtc function, pulses have to be waited 20msec
1 parent 57a4665 commit 64f2578

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/pycoproc/pycoproc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,15 @@ def calibrate_rtc(self):
232232
self._write(bytes([CMD_CALIBRATE]), wait=False)
233233
self.i2c.deinit()
234234
Pin('P21', mode=Pin.IN)
235-
pulses = pycom.pulses_get('P21', 50)
235+
pulses = pycom.pulses_get('P21', 20000)
236236
self.i2c.init(mode=I2C.MASTER, pins=(self.sda, self.scl))
237+
period = 0
237238
try:
238239
period = pulses[2][1] - pulses[0][1]
239240
except:
240241
pass
241242
if period > 0:
242-
self.clk_cal_factor = (EXP_RTC_PERIOD / period) * (1000 / 1024)
243+
self.clk_cal_factor = ((EXP_RTC_PERIOD * 1.0) / period) * (1000.0 / 1024.0)
243244

244245
def button_pressed(self):
245246
button = self.peek_memory(PORTA_ADDR) & (1 << 3)

0 commit comments

Comments
 (0)