Comments (8)
I suppose that the motivation around this is to be able to write a software-based SPI, I2C or PWM protocol?
from iot.
This could benefit within for the bit-banging and protocols, as well. I initialing was thinking for areas like registers, latches, etc. where you sometimes need a to just clock a few times. This would help instead of having to create a bunch of for loops in the future.
An example, that comes to mind... in my senior college project, I interfaced a microcontroller to pull button status out of an N64 controller. The interface was set up in a way where there were X number of bytes somewhere within a range of bytes. The only way to get the info was by an individual data pin. So instead of have to for loop High/Low (or Low/High based on pin state) a number times... I could just say .Clock(1, X) to get me to where the bits started showing up on the data pin.
from iot.
What does X
and 1 stand for in your example? In my mind, this method should take in a pinNumber, a double of frequency, and perhaps the number of cycles you want to send the signal.
from iot.
See original comment above for entire example. 1 represented the clkPin and X represents the number of times to clock.
I agree with you on the state issue (from #107) so the signature of method would have to change. Maybe something like...
int clkPin = 1;
int numberOfClocks = 5;
PinValue idlePinValue = PinValue.High;
controller.Clock(clkPin, numberOfClocks, idlePinValue);
One problem with this is the clkPin Value would already have to be at idlePinValue before calling as it could (1) miss the initial transition or (2) accidentally create an addition clock signal.
from iot.
Won't you also need some sort of parameter to define frequency in case the clock signals have to have some sort of delay between each other?
from iot.
Yup, that was for question 1.
- Should there be a time interval argument to toggle state (understanding this isn't going to be accurate)?
So the Clock method would be something like below. NOTE: I just threw in the frequency/delay argument, but more thinking is needed (e.g. Optional, default value, etc.).
public void Clock(int clkPin, int numberOfClocks, PinValue idlePinValue, int clockDelay)
{
for(int clockCnt = 0; clockCnt < numberOfClocks; clockCnt++)
{
Thread.Sleep(clockDelay);
if(idlePinValue == PinValue.Low)
{
_controller.Write(clkPin, PinValue.High);
}
else
{
_controller.Write(clkPin, PinValue.Low);
}
Thread.Sleep(clockDelay);
_controller.Write(clkPin, idlePinValue); // Go back to initial idle value.
}
}
from iot.
I'm not sure this would have enough value in order to have it on our main library API. On the other hand, if more than one device binding needs this, I would be ok if a method like this lives under src/devices/Common and have those bindings that need it to optionally call into this method. If we do want that, this could live in a class like GpioControllerExtensions.cs which looked something like:
public static class GpioControllerExtensions
{
public static void Clock(this IGpioController controller, int clckPin, int numberOfClocks, PinValue idlePinValue, int clockDelay);
}
from iot.
This is another one of those "nice to haves", but not needed. I've only come up with one binding that would need and that small amount of code could reside in its own API. I'll close for now.
from iot.
Related Issues (20)
- Update Raspberry Pi samples suggesting modifying config.txt settings HOT 5
- Unable to set pin mode on pi5 HOT 4
- Breaking change: Y2038 support for .NET Arm32 HOT 1
- arix.local HOT 1
- Misleading XML summary for ButtonBase.IsPressed HOT 1
- TM16xx is very unstable - shows strange characters most of the time HOT 7
- GPIO input gives segmentation fault on BeagleBone Black in v3.1.0 HOT 20
- Implement Raspberry5Driver and board HOT 1
- Add support for SPI devices that use separate GPIO outputs for Data/Command and Reset HOT 4
- If using gpio on an arm Linux system. How do I make things displayed on the interface? HOT 2
- Unable to get consistent manual exposures HOT 7
- PinNumberingScheme.Board is broken HOT 2
- SPI communication on RPI5 is possibly broken
- ButtonBase.IsPressed not properly initialized HOT 1
- Investigate protocol: matter HOT 3
- Cargo causes GpioController to hang on Raspberry Pi 5 Bookworm HOT 31
- CONTRIBUTING documentation is way out of date HOT 3
- GrovePi device binding fails to read sensor values HOT 4
- SPI_Mcp3008CanRead is frequently failing on CI HOT 1
- Planned breaking changes for v4.0
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 iot.