Remarks
FourDigitSevenSegment | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
The following example shows how to initialize a SevenSegment display and iterates through all possible characters:
public class MeadowApp : App<F7Micro, MeadowApp>
{
FourDigitSevenSegment sevenSegment;
public MeadowApp()
{
sevenSegment = new FourDigitSevenSegment
(
portDigit1: Device.CreateDigitalOutputPort(Device.Pins.D00),
portDigit2: Device.CreateDigitalOutputPort(Device.Pins.D03),
portDigit3: Device.CreateDigitalOutputPort(Device.Pins.D04),
portDigit4: Device.CreateDigitalOutputPort(Device.Pins.D06),
portA: Device.CreateDigitalOutputPort(Device.Pins.D01),
portB: Device.CreateDigitalOutputPort(Device.Pins.D05),
portC: Device.CreateDigitalOutputPort(Device.Pins.D08),
portD: Device.CreateDigitalOutputPort(Device.Pins.D10),
portE: Device.CreateDigitalOutputPort(Device.Pins.D11),
portF: Device.CreateDigitalOutputPort(Device.Pins.D02),
portG: Device.CreateDigitalOutputPort(Device.Pins.D07),
portDecimal: Device.CreateDigitalOutputPort(Device.Pins.D09),
isCommonCathode: true
);
int number = 0;
while (true)
{
string stringNumber = number.ToString("D4");
sevenSegment.SetDisplay(stringNumber.ToCharArray());
Thread.Sleep(1000);
number++;
}
}
}
Sample projects available on GitHub
Wiring Example
To wire a Common Cathode Seven Segment Display (like the 5161AS) to your Meadow board, connect the following:
SevenSegment | Meadow Pin |
---|---|
portE | D11 |
portD | D10 |
PortDecimal | D09 |
PortC | D08 |
PortG | D07 |
PortD4 | D06 |
PortB | D05 |
PortD3 | D04 |
PortD2 | D03 |
PortF | D02 |
PortA | D01 |
PortD1 | D00 |
It should look like the following diagram:
Characteristic | Locus |
---|---|
Inheritance | System.Object > FourDigitSevenSegment |
Inherited Members | System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone() |
Namespace | Meadow.Foundation.Displays.Led |
Assembly | FourDigitSevenSegment.dll |
Syntax
public class FourDigitSevenSegment
Constructors
FourDigitSevenSegment(IDigitalOutputPort, IDigitalOutputPort, IDigitalOutputPort, IDigitalOutputPort, IDigitalOutputPort, IDigitalOutputPort, IDigitalOutputPort, IDigitalOutputPort, IDigitalOutputPort, IDigitalOutputPort, IDigitalOutputPort, IDigitalOutputPort, Boolean)
Creates a SevenSegment connected to the especified IDigitalOutputPorts
Declaration
public FourDigitSevenSegment(IDigitalOutputPort portDigit1, IDigitalOutputPort portDigit2, IDigitalOutputPort portDigit3, IDigitalOutputPort portDigit4, IDigitalOutputPort portA, IDigitalOutputPort portB, IDigitalOutputPort portC, IDigitalOutputPort portD, IDigitalOutputPort portE, IDigitalOutputPort portF, IDigitalOutputPort portG, IDigitalOutputPort portDecimal, bool isCommonCathode)
Parameters
Type | Name | Description |
---|---|---|
IDigitalOutputPort | portDigit1 | |
IDigitalOutputPort | portDigit2 | |
IDigitalOutputPort | portDigit3 | |
IDigitalOutputPort | portDigit4 | |
IDigitalOutputPort | portA | |
IDigitalOutputPort | portB | |
IDigitalOutputPort | portC | |
IDigitalOutputPort | portD | |
IDigitalOutputPort | portE | |
IDigitalOutputPort | portF | |
IDigitalOutputPort | portG | |
IDigitalOutputPort | portDecimal | |
System.Boolean | isCommonCathode |
FourDigitSevenSegment(IIODevice, IPin, IPin, IPin, IPin, IPin, IPin, IPin, IPin, IPin, IPin, IPin, IPin, Boolean)
Creates a SevenSegment connected to the especified IPins to a IODevice
Declaration
public FourDigitSevenSegment(IIODevice device, IPin pinDigit1, IPin pinDigit2, IPin pinDigit3, IPin pinDigit4, IPin pinA, IPin pinB, IPin pinC, IPin pinD, IPin pinE, IPin pinF, IPin pinG, IPin pinDecimal, bool isCommonCathode)
Parameters
Type | Name | Description |
---|---|---|
IIODevice | device | |
IPin | pinDigit1 | |
IPin | pinDigit2 | |
IPin | pinDigit3 | |
IPin | pinDigit4 | |
IPin | pinA | |
IPin | pinB | |
IPin | pinC | |
IPin | pinD | |
IPin | pinE | |
IPin | pinF | |
IPin | pinG | |
IPin | pinDecimal | |
System.Boolean | isCommonCathode |
Fields
animationThread
Declaration
protected Task animationThread
Field Value
Type | Description |
---|---|
System.Threading.Tasks.Task |
cts
Declaration
protected CancellationTokenSource cts
Field Value
Type | Description |
---|---|
System.Threading.CancellationTokenSource |
digits
Declaration
protected readonly IDigitalOutputPort[] digits
Field Value
Type | Description |
---|---|
IDigitalOutputPort[] |
sevenSegments
Declaration
protected SevenSegment[] sevenSegments
Field Value
Type | Description |
---|---|
SevenSegment[] |
Methods
SetDisplay(Char[], Int32)
Displays the especified valid character
Declaration
public void SetDisplay(char[] character, int decimalLocation = -1)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | character | |
System.Int32 | decimalLocation |
StartDisplayLoop(Char[], Int32, CancellationToken)
Declaration
protected Task StartDisplayLoop(char[] character, int decimalLocation, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | character | |
System.Int32 | decimalLocation | |
System.Threading.CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Stop()
Declaration
public void Stop()