Browse Source

Added monkeypatch for time.struct_time dependency of adafruit_gps.

master^2
Cefn Hoile 3 years ago
parent
commit
b76e7eb3ac
2 changed files with 17 additions and 0 deletions
  1. +5
    -0
      src/adafruit_blinka/__init__.py
  2. +12
    -0
      src/adafruit_blinka/time.py

+ 5
- 0
src/adafruit_blinka/__init__.py View File

@ -54,3 +54,8 @@ class Lockable(ContextManaged):
self._locked = False
else:
raise ValueError("Not locked")
def patch_system():
import sys
from adafruit_blinka import time
sys.modules['time'] = time

+ 12
- 0
src/adafruit_blinka/time.py View File

@ -0,0 +1,12 @@
from time import sleep
from ucollections import namedtuple
_struct_time = namedtuple("struct_time", ("tm_year", "tm_mon", "tm_mday", "tm_hour", "tm_min", "tm_sec", "tm_wday", "tm_yday", "tm_isdst"))
def marshal_time(tm_year, tm_mon, tm_mday, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=-1, tm_yday=-1, tm_isdst=-1):
_struct_time(tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday, tm_yday, tm_isdst)
def struct_time(t):
return marshal_time(*t)
#TODO implement time.monotonic based on ticks_ms

Loading…
Cancel
Save