macetech / centipede Goto Github PK
View Code? Open in Web Editor NEWArduino library for the Centipede Shield MCP23017 I/O expander by macetech
License: MIT License
Arduino library for the Centipede Shield MCP23017 I/O expander by macetech
License: MIT License
I need to call digitalWrite (or maybe another new method) to say:
I don't care of the desired value, just read the current value and flip (invert) it.
AFAIK digitalRead can't be really used, as we speak about output pin, and in any case it will waste time for nothing.
Anyhow, the goal should be pretty much easy with the current code, as digitalWrite call WriteRegisterPin, which already read the port status and do bitwise operation.
In detail,
Currently, the WriteRegisterPin method take in input level
to decide how to change the bit for the port, read, change and write the port back.
Seems to me that is possible to pass level
with any int
value, only 0 will have a different behavior than others.
level is taken, in example, from CS.digitalWrite without checking the value as well (AFAIK Arduino digitalWrite do the same just with uint8_t in place of int: https://github.com/arduino/ArduinoCore-avr/blob/9f8d27f09f3bbd1da1374b5549a82bda55d45d44/cores/arduino/wiring_digital.c#L156 ).
Eg i can set "6" as value, and it will be considered != 0.
Here the snippet
Lines 85 to 98 in 11bda08
So my idea is to
So as logic it could be like:
if (level == 2) { // this is just a sample, likely a switch/case would be more appropriate
// ^= -> XOR bitwise
// << -> left shift
CSDataArray[0] ^= ~(1 << regpin);
}
flipDigitalWrite
, or just having a new value passed to digitalWrite?Thank you very much,
Daniele
A few of the references to the Wire library are outdated in language, generating a few errors. Updated:
EDIT: undefined byte type seems to have been on my end.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.