Skip to content

Commit 02b69ce

Browse files
Update README with missing new info
1 parent 0f0587d commit 02b69ce

File tree

3 files changed

+67
-8
lines changed

3 files changed

+67
-8
lines changed

Examples/Components/DotMatrix/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
Pin1 = pi.GPIO5, Pin2 = pi.GPIO7, Pin3 = pi.GPIO12, Pin4 = pi.GPIO13, Pin5 = pi.GPIO8, Pin6 = pi.GPIO15, Pin7 = pi.GPIO6, Pin8 = pi.GPIO3,
1111

1212
//columns
13-
Pin9 = pi.GPIO1, Pin10 = pi.GPIO14, Pin11 = pi.GPIO16, Pin12 = pi.GPIO4, Pin13 = pi.GPIO11, Pin14 = pi.GPIO2, Pin15 = pi.GPIO17, Pin16 = pi.GPIO18 }
13+
Pin9 = pi.GPIO1, Pin10 = pi.GPIO14, Pin11 = pi.GPIO16, Pin12 = pi.GPIO4, Pin13 = pi.GPIO11, Pin14 = pi.GPIO2, Pin15 = pi.GPIO17, Pin16 = pi.GPIO18
14+
}
1415
);
1516

1617
matrix.SetAllRows(PowerValue.Off);

README.md

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,24 @@ Alternatively, you can toggle power a set number of times by passing in a number
104104
redLED.Toggle(2, 3);
105105
```
106106

107+
### Pulse Width Modulation
108+
109+
Pins can have their "strength" set using Pulse Width Modulation (PWM) via the `Strength` property on the pin:
110+
```C#
111+
var led = pi.Pin18;
112+
led.Strength = 50; //valid range: 0-100
113+
```
114+
115+
There are also several helper methods to make smooth transitions easier:
116+
```C#
117+
led.FadeIn(TimeSpan.FromSeconds(1));
118+
led.FadeOut(TimeSpan.FromSeconds(2));
119+
led.FadeTo(50,TimeSpan.FromSeconds(0.5));
120+
121+
led.Pulse(TimeSpan.FromSeconds(1));
122+
led.Pulse(50, TimeSpan.FromSeconds(1));
123+
```
124+
107125
## What about inputs?
108126

109127
Input components such as buttons can be declared the same way as output components, and the `Power` and `Voltage` can be read from the new variable:
@@ -153,18 +171,24 @@ var greenPin = pi.Pin16;
153171
var bluePin = pi.Pin18;
154172

155173
var rgbLED = new RGBLED(redPin, greenPin, bluePin);
174+
```
156175

176+
Colors can then be set using the `SetColor()` method:
177+
```C#
157178
rgbLED.SetColor(Color.Red);
158-
rgbLED.SetColor(Color.Orange);
159179
rgbLED.SetColor(Color.Yellow);
160-
rgbLED.SetColor(Color.Green);
161-
rgbLED.SetColor(Color.Cyan);
162-
rgbLED.SetColor(Color.Blue);
163180
rgbLED.SetColor(Color.Purple);
164-
rgbLED.SetColor(Color.White);
165-
rgbLED.SetColor(Color.Black); //same as rgbLED.TurnOff();
166181
```
167182

183+
Several helpers also exist:
184+
```C#
185+
rgbLED.FadeTo(Color.White, TimeSpan.FromSeconds(1));
186+
rgbLED.Pulse(Color.Green, TimeSpan.FromSeconds(0.5));
187+
rgbLED.TurnOff(); // same as rgbLED.SetColor(Color.Black);
188+
```
189+
190+
See [the example](Examples/Components/RGBLED/Program.cs) for more details.
191+
168192
### Rotary Encoder
169193

170194
Rotary encoders have actions that can be performed when the dial is turned.
@@ -177,6 +201,8 @@ dial.OnDecrease(() => Console.WriteLine("down"));
177201

178202
Built-in button functionality is not yet supported.
179203

204+
See [the example](Examples/Components/RotartEncoder/Program.cs) for more details.
205+
180206
### Seven-Segment Display
181207

182208
Seven-segment displays are currently supported for direct connections to GPIO pins (support for shift register input coming soon) and can be passed a character (all ASCII letters, numbers, and several other symbols)
@@ -219,6 +245,34 @@ var custom = new PowerSet
219245
display.SetPowerValues(custom);
220246
```
221247

248+
See [the example](Examples/Components/SevenSegmentDisplay/Program.cs) for more details.
249+
250+
### Dot Matrix Display
251+
252+
The dot matrix display required 16 inputs, one for each row and one for each column. Like the seven segment display, these are initialized via a `PinSet`, with pins numbered counter-clockwise starting from the bottom left:
253+
```C#
254+
var set = new DotMatrix.PinSet
255+
{
256+
//rows
257+
Pin1 = pi.GPIO5, Pin2 = pi.GPIO7, Pin3 = pi.GPIO12, Pin4 = pi.GPIO13, Pin5 = pi.GPIO8, Pin6 = pi.GPIO15, Pin7 = pi.GPIO6, Pin8 = pi.GPIO3,
258+
259+
//columns
260+
Pin9 = pi.GPIO1, Pin10 = pi.GPIO14, Pin11 = pi.GPIO16, Pin12 = pi.GPIO4, Pin13 = pi.GPIO11, Pin14 = pi.GPIO2, Pin15 = pi.GPIO17, Pin16 = pi.GPIO18
261+
};
262+
var matrix = new DotMatrix(set);
263+
```
264+
265+
You can then set rows or columns individually or all together:
266+
```C#
267+
matrix.SetAllRows(PowerValue.On);
268+
matrix.SetAllColumns(PowerValue.Off);
269+
270+
matrix.SetRows(new DotMatrix.PowerSet { ... });
271+
matrix.SetColumns(new DotMatrix.PowerSet { ... });
272+
```
273+
274+
See [the example](Examples/Components/DotMatrix/Program.cs) for more details.
275+
222276
### Bidirectional Motor
223277

224278
The wiring required to safely run a motor is rather complicated. The code, however, can be quite eloquent. The `Motor` component assumes an L293D-compatible driver.
@@ -248,6 +302,8 @@ If using all 4 inputs on a single driver, declare another `Motor` to handle inpu
248302

249303
To drive a single-direction motor (by only having input 1 connected), simply pass `null` as the `counterclockwisePin` to the `Motor` constructor. Counterclockwise methods are not expected to function under this condition.
250304

305+
See [the example](Examples/Components/Motor/Program.cs) for more details.
306+
251307
### Shift Register
252308

253309
A shift register allows you to control more outputs than you have inputs. The `ShiftRegister` component abstracts the implementation details of the 595-style integrated circuit away, so you can simply send the data you want as a `byte`!
@@ -288,6 +344,8 @@ outputPin.Spike();
288344

289345
Similar to the `Motor` component, the `enabled` and `clear` parameters are optional; if you choose to have the register always on/enabled by connecting it to the 3.3 or 5V rail, set the first param to `null`. If you never need to clear, and that pin is also connected to 3.3 or 5V, just leave the last param out.
290346

347+
See [the example](Examples/Components/ShiftRegister/Program.cs) for more details.
348+
291349
## "Wow, this is great! How can I help?"
292350

293351
First, thank you for your enthusiasm! I'd love feedback on how you felt using this. If you had an awesome experience, let me know on [Twitter](https://twitter.com/intent/tweet?text=.@stevedesmond_ca&hashtags=SimpleGPIO). If you had any problems, feel free to [file an issue](https://github.com/stevedesmond-ca/SimpleGPIO/issues/new).

SimpleGPIO/SimpleGPIO.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<Version>2.0.0-beta.5</Version>
3+
<Version>2.0.0</Version>
44
<TargetFramework>net6.0</TargetFramework>
55
<OutputType>Library</OutputType>
66
<LangVersion>latest</LangVersion>

0 commit comments

Comments
 (0)