Comments (4)
First, this is a beta (maybe alpha) version so far, and thus master is tracking dev and changes (aka breaks) a lot.
Second, the dependencies are not published npms. And specifically rasbus
also is a wrapper for several i2c and spi libraries. Though the lib itself just assumes the interface (duck for now, typescript later maybe)
Third, example/client is the current working app. It follows similar style used in other repo here (aka boschieu etc). The current examples focus less on creating Gpio style access (though it is stubbed in and headed in that direction as per notes etc) and more on managing the chip settings directly as a low level api.
Node, the Gpio will follow the onoff
style api and work interchangeably with it. The chip has two interrupts that can be managed via onoff
and feed back to this lib (other gpio libs should also work)
Last, the usefulness of many of the existing and target features add a complexity not found in other (all?) libraries for the mcp23 chips. And as such usefulness of such added complexity weight against any performance gains may be negligible under V8 runtimes (as examples. supporting both 8bit and 16bit poll mode, as well as the interlaced and dual-blocks addressing mode may provide little production usages ... time will tell :) )
I would be interested in any use cases / features etc you have in mind.
thank
from mcp23.
Gotcha. So is this polling-only, or is it interrupt-driven? Looking for something that doesn't eat CPU unless buttons are pressed.
from mcp23.
Full Interrupt driven event can be achieved. But support for single and no interrupts is supported.
This chip can generate interrupts on its intA and itB pins. If those are wired to a raspberry pi, a library like onoff
is need to driver those.
The intent of this library is to then provide the callbacks Mcp23.interruptA()
in order to trigger the chip read and production of software events for the corresponding Gpio/Port/Word interfaces.
The chip provides two interrupts. It is however the intent to support both independent A and B interrupts as well as the Mirrored Interrupt mode the chip supports. Also, as software fast poll example will be added when no A or B interrupt can be added and needs to be emulated.
const intA = new onoff.Gpio(INT_A_PIN_NAME, 'in', 'high');
...
Mcp23.from(bus, { ... }).then(device => {
..
intA.watch( ... (err, value) => {
...
device.interruptA();
}
const portA = device.exportPort('A'); // pins 21 - 28 on the mcp23017
// this could have also just been device.exportGpio(21, 'in', 'both'); etc
..
portA.watch( ... (err, value) => {
...
// here we write our application code specific to handling events on portA
..
The "point" of all that being that this extra abstraction allows for the use of any external library to provide the interrupt pins for the mcp23 while still providing a flexible Gpio style interface.
The expectation is that higher-level APIs will be developed atop of these structures (such as examples/client
) that abstract much of the setup process hidden. Projects like johnny-five
and other accumulate much of this dependency glue, however, many sacrifice exposing simplified API to the end user, which is for most acceptable :)
from mcp23.
Killer explanation, thank you!
from mcp23.
Related Issues (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 mcp23.