Comments (3)
Whats the specific problem? Is it time.monotonic
?
Is it possible to always do the monkey patch on import of blinka?
from adafruit_blinka.
Definitely an option, but tradeoffs.
Other than this monkey-patch, you don't have to import adafruit_blinka in your source at all, as it is seamlessly imported by the circuitpython-compatibility modules (digitalio etc.). You don't need to know when in the sequence to import it, and you can't really get it wrong.
However, once there is a need to monkey-patch, you need to be sure you have explicitly called on adafruit_blinka before any other imports might access monkey-patched modules. Waiting on import from a dependent library is likely too late in the sequence. So this issue will need to be documented fairly well and can't be implicit.
Once we are committed that it's not implicit and authors have to trigger the monkey-patch, we have the freedom to expose explicit and selective monkey-patching. This helps us avoid automatically and monolithically load all the compatibility implementations you aren't using the moment you use any adafruit_blinka at all. This could be critical given the very low memory ceilings on the target platforms.
For example we could advise something like...
from adafruit_blinka import compatibility
compatibility("time", "adafruit_register")
import time
import adafruit_register
As regards time, I needed time.monotonic() since utime.ticks_ms() and friends couldn't be cross-platform, and adafruit_gps needed struct_time. See https://github.com/cefn/Adafruit_Micropython_Blinka/blob/master/src/adafruit_blinka/agnostic/time.py for a quick hack which worked for adafruit_gps and for testing#await_true() at least.
from adafruit_blinka.
Your example looks reasonable to me. Monkey-patching is ok by me on an as-needed basis.
Thanks for the in-depth explanation.
from adafruit_blinka.
Related Issues (20)
- Adafruit-PlatformDetect version 3.66.0 was unable to identify the board HOT 3
- Cant find the board HOT 6
- Some microcontroller definitions may be incorrect.
- libgpiod_pin_1_x.py does not detect internal pulldowns HOT 1
- GT911 touch sensor support for Adafruit Blinka HOT 7
- adafruit-circuitpython-motor fails with "RuntimeError: Cannot determine SOC peripheral base address" on Raspberry Pi 5 HOT 12
- Adafruit-Adafruit-PlatformDetect version 3.69.0 was unable to identify the board HOT 13
- Adafruit-PlatformDetect version 3.69.0 was unable to identify the board HOT 2
- support for NXP i.MX 8M PLUS HOT 3
- pip try to install sysv-ipc on Windows HOT 26
- It is no longer possible to install from 8.44.0. HOT 4
- Getting error in WCMCU-200 I2c to USB Adapter
- Add New Board adafruit FT232H Breakout for adafruit-blinka HOT 3
- Add Orange Pi AIPro
- Remove dependency to numpy HOT 2
- RPi GPIO is not support for Pi 5 any more, why merge pi5 with pi4 under board? HOT 3
- BananaPI F2P
- Maker Pi RP 2040 not supported. HOT 4
- Raspberry pi zero W board issue HOT 2
- [Suggestion] Find incompatibilities w.r.t. CircuitPython implementation HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adafruit_blinka.