-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed error with clock returning None. Resolved LED blinking issue, a…
…dded Blinks for indication when not plugged in to PC. TODO: - Find a way of sending a Feed manually - FInd a way of getting the next feed time and using it to trigger the next feed.
- Loading branch information
Showing
6 changed files
with
82 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
import utime | ||
import ntptime | ||
import time | ||
from Pico_pins import PicoPins | ||
|
||
class Clock: | ||
def __init__(self): | ||
self.current_datetime = utime.localtime() | ||
self.update_clock() | ||
self.pins = PicoPins() | ||
|
||
def update_clock(self): | ||
ntptime.host = "ntp1.npl.co.uk" | ||
ntptime.settime() | ||
self.year, self.month, self.day, self.hour, self.minute, self.second, _, _ = self.current_datetime | ||
time.sleep(0.5) | ||
self.current_datetime = utime.localtime() | ||
time.sleep(0.5) | ||
self.hour, self.minute = f"{self.current_datetime[3] +1 :02d}", f"{self.current_datetime[4]:02d}" | ||
self.year, self.month, self.day, _, _, self.seconds, _, _ = self.current_datetime | ||
|
||
def current_clock(self, param): | ||
self.update_clock() | ||
if param == 'date': | ||
return f"{self.year}-{self.month}-{self.day}" | ||
date = f"{self.year}-{self.month}-{self.day}" | ||
return date | ||
elif param == 'time': | ||
return f"{self.hour}:{self.minute}:{self.second}" | ||
time = f"{self.hour}:{self.minute}" | ||
return time | ||
elif param == 'last_feed_time': | ||
time = f"{self.hour}:{self.minute}:{self.seconds}" | ||
return time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters