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)
- Up Board
- not able to run the code HOT 3
- Nanopi neo HOT 1
- New Support: Orange Pi Zero LTS HOT 1
- LED Channel as one of parameters for NeoPixel HOT 4
- Request HOT 1
- Board Request for PCA9685 on Nvidia Jetson Nano HOT 1
- New issue HOT 1
- Jetson Nano -- AttributeError: module 'adafruit_platformdetect.constants.chips' has no attribute 'JH71x0' HOT 2
- FT232H not being recognized in PowerShell HOT 4
- Issue with APDS9960 sensor on Raspberry Pi 3 Model B+ HOT 1
- Add board: BOARD=orangepi3-lts HOT 1
- ADD BANANAPI CM4 BOARD
- ADD BANANAPI CM4 BOARD SUPPORT
- DietPi - Error installing Adafruit-Blinka HOT 1
- any check scripts that should be performed before issuing a PR for adding a new board
- 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
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.