added NTP client functionality
This commit is contained in:
@@ -98,9 +98,9 @@ The following `deck.fs` functions are direct aliases to the corresponding `os` c
|
|||||||
- `env` = `getenv` = `os.getenv`
|
- `env` = `getenv` = `os.getenv`
|
||||||
- `rnd` = `urandom` = `os.urandom`
|
- `rnd` = `urandom` = `os.urandom`
|
||||||
|
|
||||||
### `deck.hwinfo` (WIP)
|
### `deck.hwinfo`
|
||||||
|
|
||||||
Various hardware information.
|
Various hardware information. May be expanded in the future.
|
||||||
|
|
||||||
Exports the following functions:
|
Exports the following functions:
|
||||||
|
|
||||||
@@ -120,6 +120,7 @@ Exported functions:
|
|||||||
- `ssl_context()`: get the default SSL context for wrapping in a raw socket
|
- `ssl_context()`: get the default SSL context for wrapping in a raw socket
|
||||||
- `init_socket()`: return the active reference to the `socket` library
|
- `init_socket()`: return the active reference to the `socket` library
|
||||||
- `init_requests()`: return the active reference to the `requests` library
|
- `init_requests()`: return the active reference to the `requests` library
|
||||||
|
- `init_ntp(tz=0)`: return an NTP time client instance (use the `.datetime` property of the instance to access current time and the `tz` parameter to specify the timezone offset)
|
||||||
|
|
||||||
A normal flow for instantiating a Requests library looks like this:
|
A normal flow for instantiating a Requests library looks like this:
|
||||||
|
|
||||||
@@ -258,7 +259,7 @@ The foundational module set is going to at least include high-level capabilities
|
|||||||
- date and time informaion (done),
|
- date and time informaion (done),
|
||||||
- file system manipulation (done),
|
- file system manipulation (done),
|
||||||
- text viewing and editing (done),
|
- text viewing and editing (done),
|
||||||
- device information collection (partially done),
|
- device information collection (done),
|
||||||
- chat UI creation (done).
|
- chat UI creation (done).
|
||||||
|
|
||||||
After all this is implemented, future phases may also include device-specific features like GPS, graphics, sound and touchscreen input.
|
After all this is implemented, future phases may also include device-specific features like GPS, graphics, sound and touchscreen input.
|
||||||
|
|||||||
+10
-3
@@ -12,9 +12,11 @@
|
|||||||
#
|
#
|
||||||
# Created by Luxferre in 2025, released into public domain
|
# Created by Luxferre in 2025, released into public domain
|
||||||
|
|
||||||
import os, time # standard modules
|
import os, time # standard modules
|
||||||
import wifi # CircuitPython builtins
|
import wifi # CircuitPython builtins
|
||||||
import adafruit_connection_manager, adafruit_requests # Adafruit Bundle libs
|
# Adafruit Bundle libs
|
||||||
|
import adafruit_connection_manager
|
||||||
|
import adafruit_requests, adafruit_ntp
|
||||||
|
|
||||||
def wifi_connect(ssid=None, password=None):
|
def wifi_connect(ssid=None, password=None):
|
||||||
'''
|
'''
|
||||||
@@ -71,3 +73,8 @@ def init_requests():
|
|||||||
'Instantiate a Requests library'
|
'Instantiate a Requests library'
|
||||||
return adafruit_requests.Session(init_socket(), ssl_context())
|
return adafruit_requests.Session(init_socket(), ssl_context())
|
||||||
|
|
||||||
|
def init_ntp(tz=0):
|
||||||
|
'Instantiate an NTP time client'
|
||||||
|
pool = init_socket()
|
||||||
|
return adafruit_ntp.NTP(pool, tz_offset=tz, cache_seconds=3600)
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
adafruit_connection_manager>=3.1.6
|
adafruit_connection_manager>=3.1.6
|
||||||
adafruit_requests>=4.1.15
|
adafruit_requests>=4.1.15
|
||||||
adafruit_bus_device>=5.2.14
|
|
||||||
adafruit_datetime>=1.4.4
|
adafruit_datetime>=1.4.4
|
||||||
|
adafruit_ntp>=3.3.5
|
||||||
|
adafruit_bus_device>=5.2.14
|
||||||
|
|||||||
Reference in New Issue
Block a user