From 01aa1fe8d55761c274b411c5ed864ba267e036d2 Mon Sep 17 00:00:00 2001 From: Zoe Pfister <zoe.pfister@student.uibk.ac.at> Date: Thu, 8 Sep 2022 11:31:34 +0200 Subject: [PATCH] force manual setting of RTCTime for testing --- host/fipy/lib/rtc_time.py | 21 ++++++++++++++------- host/fipy/main.py | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/host/fipy/lib/rtc_time.py b/host/fipy/lib/rtc_time.py index c957d2f..d57b394 100644 --- a/host/fipy/lib/rtc_time.py +++ b/host/fipy/lib/rtc_time.py @@ -3,14 +3,19 @@ from machine import RTC class RTCTime: - def __init__( - self, - main_ntp_server: str = "pool.ntp.org", - backup_ntp_server: str = "time.nist.gov", - update_interval_seconds: int = 3600, - ): + # def __init__( + # self, + # main_ntp_server: str = "pool.ntp.org", + # backup_ntp_server: str = "time.nist.gov", + # update_interval_seconds: int = 3600, + # ): + # self.rtc = RTC() + # self._setup_ntp(main_ntp_server, backup_ntp_server, update_interval_seconds) + + + def __init__(self, datetime): self.rtc = RTC() - self._setup_ntp(main_ntp_server, backup_ntp_server, update_interval_seconds) + self.rtc.init(datetime) def _setup_ntp( self, main_ntp_server: str, backup_ntp_server: str, update_interval_seconds: int @@ -21,6 +26,8 @@ class RTCTime: print(self.rtc.synced()) sleep(1) + + def get_time(self): return self.rtc.now() diff --git a/host/fipy/main.py b/host/fipy/main.py index 4f51b3d..9e65d65 100644 --- a/host/fipy/main.py +++ b/host/fipy/main.py @@ -43,7 +43,7 @@ data.send( ) # data.disconnect() -rtc_time = RTCTime() +rtc_time = RTCTime((2014, 5, 1, 4, 13, 0, 0, 0)) # w = WLAN() # ESPNOW.init() -- GitLab