Comments (4)
I can work on this if this project is still in development?
from simplegpio.
Gross. Literally just toggling really fast. https://github.com/larsks/raspberry-gpio-python-code/blob/6d62222bd5384eb2dc2ed13065ea28dcb506cc67/source/soft_pwm.c#L90-L114
from simplegpio.
The .NET IOT device bindings library has a software PWM implementation that we can wrap.
A quick demo found that the high precision setting is needed for smooth (aka not stepped) transitions and to prevent flickering, but this pins a high priority thread at 100%. That means full RGB LED control would use 75% of a Raspberry Pi's CPU.
60Hz seems acceptable from a visual standpoint, though we may want to double that to 120Hz for those with acute vision, if going with high precision; without high precision, 120Hz flickers.
using System.Device.Pwm.Drivers;
var running = true;
var pwm = new SoftwarePwmChannel(26, 1, 0, true);
pwm.Start();
while (running)
{
var key = Console.ReadKey();
switch (key.Key)
{
case ConsoleKey.UpArrow:
pwm.DutyCycle += 0.01;
break;
case ConsoleKey.DownArrow:
pwm.DutyCycle -= 0.01;
break;
case ConsoleKey.RightArrow:
pwm.Frequency += 1;
break;
case ConsoleKey.LeftArrow:
pwm.Frequency -= 1;
break;
case ConsoleKey.Q:
running = false;
break;
}
Console.WriteLine($"On: {pwm.DutyCycle:P0} % / Freq: {pwm.Frequency,10} Hz");
}
pwm.Stop();
Console.WriteLine("Done!");
pwm.Dispose();
from simplegpio.
Implemented in v2.0-beta.2
via IPinInterface.Strength
-- docs and helpers coming by v2.0 final
from simplegpio.
Related Issues (14)
- Windows support HOT 2
- Add GPIO components HOT 1
- Add new boards HOT 1
- Fix input caching
- Add reactivity
- Add SPI/I2C/UART compatibility HOT 4
- Use new /dev/gpiomem interface HOT 3
- Add register-backed components
- Add advanced bus components
- Add more colors to RGB LED component HOT 8
- Support more complex hardware wanted? (e.g. MFRC522 RFID Reader) HOT 5
- Does it support arm? HOT 1
- Can I adapt to BananaPi? 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 simplegpio.