├── LICENSE
├── PiSharpSimScreenshot.png
├── README.md
├── docs
└── pictures
│ ├── Alignment.PNG
│ ├── Anonymous_led_circle_grey.jpg
│ ├── Anonymous_led_circle_red.jpg
│ ├── GpioHeader.pdn
│ ├── Header_Lines.png
│ ├── Interrupteurs.jpg
│ ├── LEDOff.png
│ ├── LEDOn.png
│ ├── PiSharpSimScreenshot.png
│ ├── SwitchOff.png
│ ├── SwitchOn.png
│ ├── headerFUll.pdn
│ ├── jean_victor_balin_unknown_red.jpg
│ └── unknown.png
└── src
├── Demos
├── LibGpioDemo1-Output
│ ├── LibGpioDemo1.sln
│ └── LibGpioDemo1
│ │ ├── LibGpioDemo1.csproj
│ │ ├── Program.cs
│ │ ├── Properties
│ │ └── AssemblyInfo.cs
│ │ └── ReferencedAssemblies
│ │ └── PiSharp.LibGpio.dll
└── LibGpioDemo2-Input
│ ├── LibGpioDemo2.sln
│ └── LibGpioDemo2
│ ├── LibGpioDemo2.csproj
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ └── ReferencedAssemblies
│ └── PiSharp.LibGpio.dll
├── PiSharp.GpioSimulator
├── FrmAbout.Designer.cs
├── FrmAbout.cs
├── FrmAbout.resx
├── GpioState.cs
├── Images
│ ├── LEDOff.png
│ ├── LEDOn.png
│ ├── SwitchOff.png
│ └── SwitchOn.png
├── Main.Designer.cs
├── Main.cs
├── Main.resx
├── PiSharp.GpioSimulator.csproj
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Simulator.cs
└── app.config
├── PiSharp.LibGpio
├── Entities
│ ├── BroadcomPinNumber.cs
│ ├── Direction.cs
│ ├── PhysicalPinNumber.cs
│ └── RaspberryPinNumber.cs
├── LibGpio.cs
├── PiSharp.LibGpio.csproj
└── Properties
│ └── AssemblyInfo.cs
├── PiSharpGpio.sln
└── PiSharpGpio
├── PiSharpGpio.csproj
├── Program.cs
├── Properties
└── AssemblyInfo.cs
└── app.config
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Andy Bradford
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/PiSharpSimScreenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/PiSharpSimScreenshot.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PiSharp
2 | Raspberry Pi GPIO Library for .NET
3 |
4 | Pi# (pronounced “Pi Sharp”) is a library to expose the GPIO functionality of the Raspberry Pi computer to the C# and Visual Basic.Net languages.
5 |
6 | Also included is the Pi# simulator which runs under Windows, OSX or Linux to allow you to develop and test GPIO based programs without a Raspberry Pi. For information on using Pi# see [Setting Up Pi Sharp](https://github.com/andycb/PiSharp/wiki/Setting-Up-Pi-Sharp)
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/docs/pictures/Alignment.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/docs/pictures/Alignment.PNG
--------------------------------------------------------------------------------
/docs/pictures/Anonymous_led_circle_grey.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/docs/pictures/Anonymous_led_circle_grey.jpg
--------------------------------------------------------------------------------
/docs/pictures/Anonymous_led_circle_red.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/docs/pictures/Anonymous_led_circle_red.jpg
--------------------------------------------------------------------------------
/docs/pictures/GpioHeader.pdn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/docs/pictures/GpioHeader.pdn
--------------------------------------------------------------------------------
/docs/pictures/Header_Lines.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/docs/pictures/Header_Lines.png
--------------------------------------------------------------------------------
/docs/pictures/Interrupteurs.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/docs/pictures/Interrupteurs.jpg
--------------------------------------------------------------------------------
/docs/pictures/LEDOff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/docs/pictures/LEDOff.png
--------------------------------------------------------------------------------
/docs/pictures/LEDOn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/docs/pictures/LEDOn.png
--------------------------------------------------------------------------------
/docs/pictures/PiSharpSimScreenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/docs/pictures/PiSharpSimScreenshot.png
--------------------------------------------------------------------------------
/docs/pictures/SwitchOff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/docs/pictures/SwitchOff.png
--------------------------------------------------------------------------------
/docs/pictures/SwitchOn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/docs/pictures/SwitchOn.png
--------------------------------------------------------------------------------
/docs/pictures/headerFUll.pdn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/docs/pictures/headerFUll.pdn
--------------------------------------------------------------------------------
/docs/pictures/jean_victor_balin_unknown_red.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/docs/pictures/jean_victor_balin_unknown_red.jpg
--------------------------------------------------------------------------------
/docs/pictures/unknown.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/docs/pictures/unknown.png
--------------------------------------------------------------------------------
/src/Demos/LibGpioDemo1-Output/LibGpioDemo1.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibGpioDemo1", "LibGpioDemo1\LibGpioDemo1.csproj", "{F866EEAC-4242-4755-A903-58E2F36403B1}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|x86 = Debug|x86
9 | Release|x86 = Release|x86
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {F866EEAC-4242-4755-A903-58E2F36403B1}.Debug|x86.ActiveCfg = Debug|x86
13 | {F866EEAC-4242-4755-A903-58E2F36403B1}.Debug|x86.Build.0 = Debug|x86
14 | {F866EEAC-4242-4755-A903-58E2F36403B1}.Release|x86.ActiveCfg = Release|x86
15 | {F866EEAC-4242-4755-A903-58E2F36403B1}.Release|x86.Build.0 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/src/Demos/LibGpioDemo1-Output/LibGpioDemo1/LibGpioDemo1.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | 8.0.30703
7 | 2.0
8 | {F866EEAC-4242-4755-A903-58E2F36403B1}
9 | Exe
10 | Properties
11 | LibGpioDemo1
12 | LibGpioDemo1
13 | v3.0
14 | 512
15 |
16 |
17 | x86
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | x86
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 | False
38 | ReferencedAssemblies\PiSharp.LibGpio.dll
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
59 |
--------------------------------------------------------------------------------
/src/Demos/LibGpioDemo1-Output/LibGpioDemo1/Program.cs:
--------------------------------------------------------------------------------
1 | namespace LibGpioDemo1
2 | {
3 | using System.Threading;
4 |
5 | // Pi# Namespaces
6 | using PiSharp.LibGpio;
7 | using PiSharp.LibGpio.Entities;
8 |
9 | class Program
10 | {
11 | static void Main(string[] args)
12 | {
13 | // Use test mode
14 | LibGpio.Gpio.TestMode = true;
15 |
16 | // Setup all pins for output (using Broadcom numbers)
17 | LibGpio.Gpio.SetupChannel(BroadcomPinNumber.Four, Direction.Output);
18 | LibGpio.Gpio.SetupChannel(BroadcomPinNumber.Seventeen, Direction.Output);
19 | LibGpio.Gpio.SetupChannel(BroadcomPinNumber.Eighteen, Direction.Output);
20 | LibGpio.Gpio.SetupChannel(BroadcomPinNumber.TwentyOne, Direction.Output);
21 | LibGpio.Gpio.SetupChannel(BroadcomPinNumber.TwentyTwo, Direction.Output);
22 | LibGpio.Gpio.SetupChannel(BroadcomPinNumber.TwentyThree, Direction.Output);
23 | LibGpio.Gpio.SetupChannel(BroadcomPinNumber.TwentyFour, Direction.Output);
24 | LibGpio.Gpio.SetupChannel(BroadcomPinNumber.TwentyFive, Direction.Output);
25 |
26 | // Loop around doing an LED chase
27 | while (true)
28 | {
29 | // Turn on
30 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.Four, true);
31 | Thread.Sleep(200);
32 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.Seventeen, true);
33 | Thread.Sleep(200);
34 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.Eighteen, true);
35 | Thread.Sleep(200);
36 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyOne, true);
37 | Thread.Sleep(200);
38 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyTwo, true);
39 | Thread.Sleep(200);
40 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyThree, true);
41 | Thread.Sleep(200);
42 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyFour, true);
43 | Thread.Sleep(200);
44 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyFive, true);
45 | Thread.Sleep(200);
46 |
47 | // Turn off
48 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.Four, false);
49 | Thread.Sleep(200);
50 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.Seventeen, false);
51 | Thread.Sleep(200);
52 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.Eighteen, false);
53 | Thread.Sleep(200);
54 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyOne, false);
55 | Thread.Sleep(200);
56 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyTwo, false);
57 | Thread.Sleep(200);
58 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyThree, false);
59 | Thread.Sleep(200);
60 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyFour, false);
61 | Thread.Sleep(200);
62 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyFive, false);
63 | Thread.Sleep(200);
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/Demos/LibGpioDemo1-Output/LibGpioDemo1/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("LibGpioDemo1")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("LibGpioDemo1")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("56506ab8-888f-469f-85d0-7907286bbbac")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Demos/LibGpioDemo1-Output/LibGpioDemo1/ReferencedAssemblies/PiSharp.LibGpio.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/src/Demos/LibGpioDemo1-Output/LibGpioDemo1/ReferencedAssemblies/PiSharp.LibGpio.dll
--------------------------------------------------------------------------------
/src/Demos/LibGpioDemo2-Input/LibGpioDemo2.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibGpioDemo2", "LibGpioDemo2\LibGpioDemo2.csproj", "{F866EEAC-4242-4755-A903-58E2F36403B1}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|x86 = Debug|x86
9 | Release|x86 = Release|x86
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {F866EEAC-4242-4755-A903-58E2F36403B1}.Debug|x86.ActiveCfg = Debug|x86
13 | {F866EEAC-4242-4755-A903-58E2F36403B1}.Debug|x86.Build.0 = Debug|x86
14 | {F866EEAC-4242-4755-A903-58E2F36403B1}.Release|x86.ActiveCfg = Release|x86
15 | {F866EEAC-4242-4755-A903-58E2F36403B1}.Release|x86.Build.0 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/src/Demos/LibGpioDemo2-Input/LibGpioDemo2/LibGpioDemo2.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | 8.0.30703
7 | 2.0
8 | {F866EEAC-4242-4755-A903-58E2F36403B1}
9 | Exe
10 | Properties
11 | LibGpioDemo2
12 | LibGpioDemo2
13 | v3.0
14 | 512
15 |
16 |
17 | x86
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | x86
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 | False
38 | ReferencedAssemblies\PiSharp.LibGpio.dll
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
59 |
--------------------------------------------------------------------------------
/src/Demos/LibGpioDemo2-Input/LibGpioDemo2/Program.cs:
--------------------------------------------------------------------------------
1 | namespace LibGpioDemo2
2 | {
3 | using System.Threading;
4 |
5 | // Pi# Namespaces
6 | using PiSharp.LibGpio;
7 | using PiSharp.LibGpio.Entities;
8 |
9 | class Program
10 | {
11 | static void Main(string[] args)
12 | {
13 | // Use test mode
14 | LibGpio.Gpio.TestMode = true;
15 |
16 | // Setup one pin for input and one for output (using Raspberry Pi numbers)
17 | LibGpio.Gpio.SetupChannel(RaspberryPinNumber.Seven, Direction.Input);
18 | LibGpio.Gpio.SetupChannel(RaspberryPinNumber.Zero, Direction.Output);
19 |
20 | // Loop around and set the value of GPIO 0 to the inverse of GPIO 7
21 | // ie. If the button is pressed, the LED will go out
22 | var oldInput = true;
23 | while (true)
24 | {
25 | var newInput = LibGpio.Gpio.ReadValue(RaspberryPinNumber.Seven);
26 | if (newInput != oldInput)
27 | {
28 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.Seventeen, !newInput);
29 | oldInput = newInput;
30 | }
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Demos/LibGpioDemo2-Input/LibGpioDemo2/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("LibGpioDemo1")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("LibGpioDemo1")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("56506ab8-888f-469f-85d0-7907286bbbac")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Demos/LibGpioDemo2-Input/LibGpioDemo2/ReferencedAssemblies/PiSharp.LibGpio.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/src/Demos/LibGpioDemo2-Input/LibGpioDemo2/ReferencedAssemblies/PiSharp.LibGpio.dll
--------------------------------------------------------------------------------
/src/PiSharp.GpioSimulator/FrmAbout.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace PiSharp.GpioSimulator
2 | {
3 | partial class FrmAbout
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.label1 = new System.Windows.Forms.Label();
32 | this.label2 = new System.Windows.Forms.Label();
33 | this.label3 = new System.Windows.Forms.Label();
34 | this.linkLabel1 = new System.Windows.Forms.LinkLabel();
35 | this.linkLabel3 = new System.Windows.Forms.LinkLabel();
36 | this.linkLabel2 = new System.Windows.Forms.LinkLabel();
37 | this.LblRasPiCredit = new System.Windows.Forms.LinkLabel();
38 | this.label4 = new System.Windows.Forms.Label();
39 | this.CmdOkay = new System.Windows.Forms.Button();
40 | this.linkLabel4 = new System.Windows.Forms.LinkLabel();
41 | this.linkLabel5 = new System.Windows.Forms.LinkLabel();
42 | this.SuspendLayout();
43 | //
44 | // label1
45 | //
46 | this.label1.AutoSize = true;
47 | this.label1.Font = new System.Drawing.Font("Arial Rounded MT Bold", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
48 | this.label1.Location = new System.Drawing.Point(12, 9);
49 | this.label1.Name = "label1";
50 | this.label1.Size = new System.Drawing.Size(341, 24);
51 | this.label1.TabIndex = 0;
52 | this.label1.Text = "Pi# Raspberry Pi GPIO Simulator";
53 | //
54 | // label2
55 | //
56 | this.label2.AutoSize = true;
57 | this.label2.Font = new System.Drawing.Font("Arial Rounded MT Bold", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
58 | this.label2.Location = new System.Drawing.Point(12, 50);
59 | this.label2.Name = "label2";
60 | this.label2.Size = new System.Drawing.Size(299, 18);
61 | this.label2.TabIndex = 1;
62 | this.label2.Text = "Copyright (C) Andrew Bradford 2012";
63 | //
64 | // label3
65 | //
66 | this.label3.AutoSize = true;
67 | this.label3.Font = new System.Drawing.Font("Arial Rounded MT Bold", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
68 | this.label3.Location = new System.Drawing.Point(13, 86);
69 | this.label3.Name = "label3";
70 | this.label3.Size = new System.Drawing.Size(459, 18);
71 | this.label3.TabIndex = 2;
72 | this.label3.Text = "Made possible through the work of the following projects:";
73 | //
74 | // linkLabel1
75 | //
76 | this.linkLabel1.AutoSize = true;
77 | this.linkLabel1.Font = new System.Drawing.Font("Arial Rounded MT Bold", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
78 | this.linkLabel1.Location = new System.Drawing.Point(12, 121);
79 | this.linkLabel1.Name = "linkLabel1";
80 | this.linkLabel1.Size = new System.Drawing.Size(498, 15);
81 | this.linkLabel1.TabIndex = 3;
82 | this.linkLabel1.TabStop = true;
83 | this.linkLabel1.Tag = "http://lwk.mjhosting.co.uk/?p=343";
84 | this.linkLabel1.Text = "LWK\'s Arduino Projects - Getting Started With Raspberry Pi GPIO and Python";
85 | this.linkLabel1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Credit_LinkClicked);
86 | //
87 | // linkLabel3
88 | //
89 | this.linkLabel3.AutoSize = true;
90 | this.linkLabel3.Font = new System.Drawing.Font("Arial Rounded MT Bold", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
91 | this.linkLabel3.Location = new System.Drawing.Point(13, 149);
92 | this.linkLabel3.Name = "linkLabel3";
93 | this.linkLabel3.Size = new System.Drawing.Size(151, 15);
94 | this.linkLabel3.TabIndex = 5;
95 | this.linkLabel3.TabStop = true;
96 | this.linkLabel3.Tag = "http://code.google.com/p/raspberry-gpio-python/";
97 | this.linkLabel3.Text = "raspberry-gpio-python";
98 | this.linkLabel3.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Credit_LinkClicked);
99 | //
100 | // linkLabel2
101 | //
102 | this.linkLabel2.AutoSize = true;
103 | this.linkLabel2.Font = new System.Drawing.Font("Arial Rounded MT Bold", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
104 | this.linkLabel2.Location = new System.Drawing.Point(13, 177);
105 | this.linkLabel2.Name = "linkLabel2";
106 | this.linkLabel2.Size = new System.Drawing.Size(120, 15);
107 | this.linkLabel2.TabIndex = 6;
108 | this.linkLabel2.TabStop = true;
109 | this.linkLabel2.Tag = "http://mono-project.com";
110 | this.linkLabel2.Text = "The Mono Project";
111 | this.linkLabel2.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Credit_LinkClicked);
112 | //
113 | // LblRasPiCredit
114 | //
115 | this.LblRasPiCredit.AutoSize = true;
116 | this.LblRasPiCredit.Font = new System.Drawing.Font("Arial Rounded MT Bold", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
117 | this.LblRasPiCredit.Location = new System.Drawing.Point(12, 205);
118 | this.LblRasPiCredit.Name = "LblRasPiCredit";
119 | this.LblRasPiCredit.Size = new System.Drawing.Size(193, 15);
120 | this.LblRasPiCredit.TabIndex = 7;
121 | this.LblRasPiCredit.TabStop = true;
122 | this.LblRasPiCredit.Tag = "http://www.raspberrypi.org/";
123 | this.LblRasPiCredit.Text = "The Raspberry Pi Foundation";
124 | this.LblRasPiCredit.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Credit_LinkClicked);
125 | //
126 | // label4
127 | //
128 | this.label4.AutoSize = true;
129 | this.label4.Location = new System.Drawing.Point(13, 262);
130 | this.label4.Name = "label4";
131 | this.label4.Size = new System.Drawing.Size(382, 13);
132 | this.label4.TabIndex = 8;
133 | this.label4.Text = "Note: No afflilication with, or endorcement of, these projects should be assumed";
134 | //
135 | // CmdOkay
136 | //
137 | this.CmdOkay.Location = new System.Drawing.Point(219, 289);
138 | this.CmdOkay.Name = "CmdOkay";
139 | this.CmdOkay.Size = new System.Drawing.Size(92, 31);
140 | this.CmdOkay.TabIndex = 9;
141 | this.CmdOkay.Text = "Okay";
142 | this.CmdOkay.UseVisualStyleBackColor = true;
143 | this.CmdOkay.Click += new System.EventHandler(this.CmdOkay_Click);
144 | //
145 | // linkLabel4
146 | //
147 | this.linkLabel4.AutoSize = true;
148 | this.linkLabel4.Font = new System.Drawing.Font("Arial Rounded MT Bold", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
149 | this.linkLabel4.Location = new System.Drawing.Point(13, 234);
150 | this.linkLabel4.Name = "linkLabel4";
151 | this.linkLabel4.Size = new System.Drawing.Size(143, 15);
152 | this.linkLabel4.TabIndex = 10;
153 | this.linkLabel4.TabStop = true;
154 | this.linkLabel4.Tag = "http://openclipart.org/";
155 | this.linkLabel4.Text = "Open Clip Art Library";
156 | //
157 | // linkLabel5
158 | //
159 | this.linkLabel5.AutoSize = true;
160 | this.linkLabel5.Font = new System.Drawing.Font("Arial Rounded MT Bold", 12F);
161 | this.linkLabel5.Location = new System.Drawing.Point(317, 50);
162 | this.linkLabel5.Name = "linkLabel5";
163 | this.linkLabel5.Size = new System.Drawing.Size(118, 18);
164 | this.linkLabel5.TabIndex = 11;
165 | this.linkLabel5.TabStop = true;
166 | this.linkLabel5.Tag = "https://pisharp.codeplex.com/license";
167 | this.linkLabel5.Text = "(Licence Info)";
168 | this.linkLabel5.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Credit_LinkClicked);
169 | //
170 | // FrmAbout
171 | //
172 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
173 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
174 | this.ClientSize = new System.Drawing.Size(548, 332);
175 | this.Controls.Add(this.linkLabel5);
176 | this.Controls.Add(this.linkLabel4);
177 | this.Controls.Add(this.CmdOkay);
178 | this.Controls.Add(this.label4);
179 | this.Controls.Add(this.LblRasPiCredit);
180 | this.Controls.Add(this.linkLabel2);
181 | this.Controls.Add(this.linkLabel3);
182 | this.Controls.Add(this.linkLabel1);
183 | this.Controls.Add(this.label3);
184 | this.Controls.Add(this.label2);
185 | this.Controls.Add(this.label1);
186 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
187 | this.MaximizeBox = false;
188 | this.MinimizeBox = false;
189 | this.Name = "FrmAbout";
190 | this.Text = "About";
191 | this.ResumeLayout(false);
192 | this.PerformLayout();
193 |
194 | }
195 |
196 | #endregion
197 |
198 | private System.Windows.Forms.Label label1;
199 | private System.Windows.Forms.Label label2;
200 | private System.Windows.Forms.Label label3;
201 | private System.Windows.Forms.LinkLabel linkLabel1;
202 | private System.Windows.Forms.LinkLabel linkLabel3;
203 | private System.Windows.Forms.LinkLabel linkLabel2;
204 | private System.Windows.Forms.LinkLabel LblRasPiCredit;
205 | private System.Windows.Forms.Label label4;
206 | private System.Windows.Forms.Button CmdOkay;
207 | private System.Windows.Forms.LinkLabel linkLabel4;
208 | private System.Windows.Forms.LinkLabel linkLabel5;
209 | }
210 | }
--------------------------------------------------------------------------------
/src/PiSharp.GpioSimulator/FrmAbout.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 | using System.Diagnostics;
10 |
11 | namespace PiSharp.GpioSimulator
12 | {
13 | public partial class FrmAbout : Form
14 | {
15 | public FrmAbout()
16 | {
17 | InitializeComponent();
18 | }
19 |
20 | private void Credit_LinkClicked(object sender, MouseEventArgs e)
21 | {
22 | Process.Start(((LinkLabel)sender).Tag.ToString());
23 | }
24 |
25 | private void CmdOkay_Click(object sender, EventArgs e)
26 | {
27 | this.Visible = false;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/PiSharp.GpioSimulator/FrmAbout.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/src/PiSharp.GpioSimulator/GpioState.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2012 Andrew Bradford
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6 | // associated documentation files (the "Software"), to deal in the Software without restriction,
7 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject
9 | // to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12 | //
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
16 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | //
18 | //-----------------------------------------------------------------------
19 |
20 | namespace PiSharp.GpioSimulator
21 | {
22 | ///
23 | /// Represents the state of a GPIO channel
24 | ///
25 | public enum GpioState
26 | {
27 | ///
28 | /// The GPIO channel has not been configured and its state is unknown
29 | ///
30 | Unknown = 0,
31 |
32 | ///
33 | /// Chanel configured as input
34 | ///
35 | Input,
36 |
37 | ///
38 | /// Chanel configures as output
39 | ///
40 | Outout
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/PiSharp.GpioSimulator/Images/LEDOff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/src/PiSharp.GpioSimulator/Images/LEDOff.png
--------------------------------------------------------------------------------
/src/PiSharp.GpioSimulator/Images/LEDOn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/src/PiSharp.GpioSimulator/Images/LEDOn.png
--------------------------------------------------------------------------------
/src/PiSharp.GpioSimulator/Images/SwitchOff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/src/PiSharp.GpioSimulator/Images/SwitchOff.png
--------------------------------------------------------------------------------
/src/PiSharp.GpioSimulator/Images/SwitchOn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andycb/PiSharp/a1728039b38ac3baacaed5d2f680a2a69cde6f88/src/PiSharp.GpioSimulator/Images/SwitchOn.png
--------------------------------------------------------------------------------
/src/PiSharp.GpioSimulator/Main.Designer.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2012 Andrew Bradford
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6 | // associated documentation files (the "Software"), to deal in the Software without restriction,
7 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject
9 | // to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12 | //
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
16 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | //
18 | //
19 | //
20 | // This file is generated by a tool and should not be edited manually
21 | //
22 | //-----------------------------------------------------------------------
23 |
24 | namespace PiSharp.GpioSimulator
25 | {
26 | partial class Main
27 | {
28 | ///
29 | /// Required designer variable.
30 | ///
31 | private System.ComponentModel.IContainer components = null;
32 |
33 | ///
34 | /// Clean up any resources being used.
35 | ///
36 | /// true if managed resources should be disposed; otherwise, false.
37 | protected override void Dispose(bool disposing)
38 | {
39 | if (disposing && (components != null))
40 | {
41 | components.Dispose();
42 | }
43 | base.Dispose(disposing);
44 | }
45 |
46 | #region Windows Form Designer generated code
47 |
48 | ///
49 | /// Required method for Designer support - do not modify
50 | /// the contents of this method with the code editor.
51 | ///
52 | private void InitializeComponent()
53 | {
54 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));
55 | this.panel1 = new System.Windows.Forms.Panel();
56 | this.Gpio4 = new System.Windows.Forms.Panel();
57 | this.Gpio17 = new System.Windows.Forms.Panel();
58 | this.Gpio18 = new System.Windows.Forms.Panel();
59 | this.Gpio24 = new System.Windows.Forms.Panel();
60 | this.Gpio22 = new System.Windows.Forms.Panel();
61 | this.Gpio21 = new System.Windows.Forms.Panel();
62 | this.Gpio23 = new System.Windows.Forms.Panel();
63 | this.Gpio25 = new System.Windows.Forms.Panel();
64 | this.label1 = new System.Windows.Forms.Label();
65 | this.label2 = new System.Windows.Forms.Label();
66 | this.label3 = new System.Windows.Forms.Label();
67 | this.label4 = new System.Windows.Forms.Label();
68 | this.label5 = new System.Windows.Forms.Label();
69 | this.label6 = new System.Windows.Forms.Label();
70 | this.label7 = new System.Windows.Forms.Label();
71 | this.label8 = new System.Windows.Forms.Label();
72 | this.label9 = new System.Windows.Forms.Label();
73 | this.label10 = new System.Windows.Forms.Label();
74 | this.label11 = new System.Windows.Forms.Label();
75 | this.label12 = new System.Windows.Forms.Label();
76 | this.label13 = new System.Windows.Forms.Label();
77 | this.label14 = new System.Windows.Forms.Label();
78 | this.label15 = new System.Windows.Forms.Label();
79 | this.label16 = new System.Windows.Forms.Label();
80 | this.label17 = new System.Windows.Forms.Label();
81 | this.label18 = new System.Windows.Forms.Label();
82 | this.label19 = new System.Windows.Forms.Label();
83 | this.label20 = new System.Windows.Forms.Label();
84 | this.label21 = new System.Windows.Forms.Label();
85 | this.label22 = new System.Windows.Forms.Label();
86 | this.label23 = new System.Windows.Forms.Label();
87 | this.label24 = new System.Windows.Forms.Label();
88 | this.label25 = new System.Windows.Forms.Label();
89 | this.label26 = new System.Windows.Forms.Label();
90 | this.label27 = new System.Windows.Forms.Label();
91 | this.LblAboutLink = new System.Windows.Forms.LinkLabel();
92 | this.SuspendLayout();
93 | //
94 | // panel1
95 | //
96 | this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
97 | | System.Windows.Forms.AnchorStyles.Right)));
98 | this.panel1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panel1.BackgroundImage")));
99 | this.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
100 | this.panel1.Location = new System.Drawing.Point(40, 133);
101 | this.panel1.Name = "panel1";
102 | this.panel1.Size = new System.Drawing.Size(751, 257);
103 | this.panel1.TabIndex = 0;
104 | //
105 | // Gpio4
106 | //
107 | this.Gpio4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
108 | this.Gpio4.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("Gpio4.BackgroundImage")));
109 | this.Gpio4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
110 | this.Gpio4.Location = new System.Drawing.Point(73, 73);
111 | this.Gpio4.Name = "Gpio4";
112 | this.Gpio4.Size = new System.Drawing.Size(55, 54);
113 | this.Gpio4.TabIndex = 1;
114 | this.Gpio4.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.Gpio_MouseDoubleClick);
115 | //
116 | // Gpio17
117 | //
118 | this.Gpio17.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
119 | this.Gpio17.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("Gpio17.BackgroundImage")));
120 | this.Gpio17.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
121 | this.Gpio17.Location = new System.Drawing.Point(172, 73);
122 | this.Gpio17.Name = "Gpio17";
123 | this.Gpio17.Size = new System.Drawing.Size(55, 54);
124 | this.Gpio17.TabIndex = 2;
125 | this.Gpio17.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.Gpio_MouseDoubleClick);
126 | //
127 | // Gpio18
128 | //
129 | this.Gpio18.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
130 | this.Gpio18.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("Gpio18.BackgroundImage")));
131 | this.Gpio18.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
132 | this.Gpio18.Location = new System.Drawing.Point(266, 73);
133 | this.Gpio18.Name = "Gpio18";
134 | this.Gpio18.Size = new System.Drawing.Size(55, 54);
135 | this.Gpio18.TabIndex = 2;
136 | this.Gpio18.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.Gpio_MouseDoubleClick);
137 | //
138 | // Gpio24
139 | //
140 | this.Gpio24.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
141 | this.Gpio24.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("Gpio24.BackgroundImage")));
142 | this.Gpio24.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
143 | this.Gpio24.Location = new System.Drawing.Point(631, 73);
144 | this.Gpio24.Name = "Gpio24";
145 | this.Gpio24.Size = new System.Drawing.Size(55, 54);
146 | this.Gpio24.TabIndex = 2;
147 | this.Gpio24.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.Gpio_MouseDoubleClick);
148 | //
149 | // Gpio22
150 | //
151 | this.Gpio22.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
152 | this.Gpio22.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("Gpio22.BackgroundImage")));
153 | this.Gpio22.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
154 | this.Gpio22.Location = new System.Drawing.Point(450, 73);
155 | this.Gpio22.Name = "Gpio22";
156 | this.Gpio22.Size = new System.Drawing.Size(55, 54);
157 | this.Gpio22.TabIndex = 2;
158 | this.Gpio22.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.Gpio_MouseDoubleClick);
159 | //
160 | // Gpio21
161 | //
162 | this.Gpio21.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
163 | this.Gpio21.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("Gpio21.BackgroundImage")));
164 | this.Gpio21.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
165 | this.Gpio21.Location = new System.Drawing.Point(359, 73);
166 | this.Gpio21.Name = "Gpio21";
167 | this.Gpio21.Size = new System.Drawing.Size(55, 54);
168 | this.Gpio21.TabIndex = 2;
169 | this.Gpio21.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.Gpio_MouseDoubleClick);
170 | //
171 | // Gpio23
172 | //
173 | this.Gpio23.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
174 | this.Gpio23.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("Gpio23.BackgroundImage")));
175 | this.Gpio23.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
176 | this.Gpio23.Location = new System.Drawing.Point(541, 73);
177 | this.Gpio23.Name = "Gpio23";
178 | this.Gpio23.Size = new System.Drawing.Size(55, 54);
179 | this.Gpio23.TabIndex = 2;
180 | this.Gpio23.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.Gpio_MouseDoubleClick);
181 | //
182 | // Gpio25
183 | //
184 | this.Gpio25.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
185 | this.Gpio25.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("Gpio25.BackgroundImage")));
186 | this.Gpio25.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
187 | this.Gpio25.Location = new System.Drawing.Point(718, 73);
188 | this.Gpio25.Name = "Gpio25";
189 | this.Gpio25.Size = new System.Drawing.Size(55, 54);
190 | this.Gpio25.TabIndex = 3;
191 | this.Gpio25.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.Gpio_MouseDoubleClick);
192 | //
193 | // label1
194 | //
195 | this.label1.AutoSize = true;
196 | this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
197 | this.label1.Location = new System.Drawing.Point(10, 9);
198 | this.label1.Name = "label1";
199 | this.label1.Size = new System.Drawing.Size(47, 13);
200 | this.label1.TabIndex = 4;
201 | this.label1.Text = "Pysical";
202 | //
203 | // label2
204 | //
205 | this.label2.AutoSize = true;
206 | this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
207 | this.label2.Location = new System.Drawing.Point(10, 27);
208 | this.label2.Name = "label2";
209 | this.label2.Size = new System.Drawing.Size(64, 13);
210 | this.label2.TabIndex = 5;
211 | this.label2.Text = "Raspberry";
212 | //
213 | // label3
214 | //
215 | this.label3.AutoSize = true;
216 | this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
217 | this.label3.Location = new System.Drawing.Point(10, 48);
218 | this.label3.Name = "label3";
219 | this.label3.Size = new System.Drawing.Size(63, 13);
220 | this.label3.TabIndex = 6;
221 | this.label3.Text = "Broadcom";
222 | //
223 | // label4
224 | //
225 | this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
226 | this.label4.AutoSize = true;
227 | this.label4.Location = new System.Drawing.Point(88, 9);
228 | this.label4.Name = "label4";
229 | this.label4.Size = new System.Drawing.Size(13, 13);
230 | this.label4.TabIndex = 7;
231 | this.label4.Text = "7";
232 | //
233 | // label5
234 | //
235 | this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
236 | this.label5.AutoSize = true;
237 | this.label5.Location = new System.Drawing.Point(187, 9);
238 | this.label5.Name = "label5";
239 | this.label5.Size = new System.Drawing.Size(19, 13);
240 | this.label5.TabIndex = 8;
241 | this.label5.Text = "11";
242 | //
243 | // label6
244 | //
245 | this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
246 | this.label6.AutoSize = true;
247 | this.label6.Location = new System.Drawing.Point(281, 9);
248 | this.label6.Name = "label6";
249 | this.label6.Size = new System.Drawing.Size(19, 13);
250 | this.label6.TabIndex = 9;
251 | this.label6.Text = "12";
252 | //
253 | // label7
254 | //
255 | this.label7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
256 | this.label7.AutoSize = true;
257 | this.label7.Location = new System.Drawing.Point(374, 9);
258 | this.label7.Name = "label7";
259 | this.label7.Size = new System.Drawing.Size(19, 13);
260 | this.label7.TabIndex = 10;
261 | this.label7.Text = "13";
262 | //
263 | // label8
264 | //
265 | this.label8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
266 | this.label8.AutoSize = true;
267 | this.label8.Location = new System.Drawing.Point(465, 9);
268 | this.label8.Name = "label8";
269 | this.label8.Size = new System.Drawing.Size(19, 13);
270 | this.label8.TabIndex = 11;
271 | this.label8.Text = "15";
272 | //
273 | // label9
274 | //
275 | this.label9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
276 | this.label9.AutoSize = true;
277 | this.label9.Location = new System.Drawing.Point(556, 9);
278 | this.label9.Name = "label9";
279 | this.label9.Size = new System.Drawing.Size(19, 13);
280 | this.label9.TabIndex = 12;
281 | this.label9.Text = "16";
282 | //
283 | // label10
284 | //
285 | this.label10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
286 | this.label10.AutoSize = true;
287 | this.label10.Location = new System.Drawing.Point(646, 9);
288 | this.label10.Name = "label10";
289 | this.label10.Size = new System.Drawing.Size(19, 13);
290 | this.label10.TabIndex = 13;
291 | this.label10.Text = "18";
292 | //
293 | // label11
294 | //
295 | this.label11.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
296 | this.label11.AutoSize = true;
297 | this.label11.Location = new System.Drawing.Point(733, 9);
298 | this.label11.Name = "label11";
299 | this.label11.Size = new System.Drawing.Size(19, 13);
300 | this.label11.TabIndex = 14;
301 | this.label11.Text = "22";
302 | //
303 | // label12
304 | //
305 | this.label12.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
306 | this.label12.AutoSize = true;
307 | this.label12.Location = new System.Drawing.Point(88, 27);
308 | this.label12.Name = "label12";
309 | this.label12.Size = new System.Drawing.Size(13, 13);
310 | this.label12.TabIndex = 15;
311 | this.label12.Text = "7";
312 | //
313 | // label13
314 | //
315 | this.label13.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
316 | this.label13.AutoSize = true;
317 | this.label13.Location = new System.Drawing.Point(187, 27);
318 | this.label13.Name = "label13";
319 | this.label13.Size = new System.Drawing.Size(13, 13);
320 | this.label13.TabIndex = 16;
321 | this.label13.Text = "0";
322 | //
323 | // label14
324 | //
325 | this.label14.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
326 | this.label14.AutoSize = true;
327 | this.label14.Location = new System.Drawing.Point(281, 27);
328 | this.label14.Name = "label14";
329 | this.label14.Size = new System.Drawing.Size(13, 13);
330 | this.label14.TabIndex = 17;
331 | this.label14.Text = "1";
332 | //
333 | // label15
334 | //
335 | this.label15.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
336 | this.label15.AutoSize = true;
337 | this.label15.Location = new System.Drawing.Point(374, 27);
338 | this.label15.Name = "label15";
339 | this.label15.Size = new System.Drawing.Size(13, 13);
340 | this.label15.TabIndex = 18;
341 | this.label15.Text = "2";
342 | //
343 | // label16
344 | //
345 | this.label16.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
346 | this.label16.AutoSize = true;
347 | this.label16.Location = new System.Drawing.Point(465, 27);
348 | this.label16.Name = "label16";
349 | this.label16.Size = new System.Drawing.Size(13, 13);
350 | this.label16.TabIndex = 19;
351 | this.label16.Text = "3";
352 | //
353 | // label17
354 | //
355 | this.label17.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
356 | this.label17.AutoSize = true;
357 | this.label17.Location = new System.Drawing.Point(556, 27);
358 | this.label17.Name = "label17";
359 | this.label17.Size = new System.Drawing.Size(13, 13);
360 | this.label17.TabIndex = 20;
361 | this.label17.Text = "4";
362 | //
363 | // label18
364 | //
365 | this.label18.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
366 | this.label18.AutoSize = true;
367 | this.label18.Location = new System.Drawing.Point(646, 27);
368 | this.label18.Name = "label18";
369 | this.label18.Size = new System.Drawing.Size(13, 13);
370 | this.label18.TabIndex = 21;
371 | this.label18.Text = "5";
372 | //
373 | // label19
374 | //
375 | this.label19.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
376 | this.label19.AutoSize = true;
377 | this.label19.Location = new System.Drawing.Point(733, 27);
378 | this.label19.Name = "label19";
379 | this.label19.Size = new System.Drawing.Size(13, 13);
380 | this.label19.TabIndex = 22;
381 | this.label19.Text = "6";
382 | //
383 | // label20
384 | //
385 | this.label20.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
386 | this.label20.AutoSize = true;
387 | this.label20.Location = new System.Drawing.Point(88, 48);
388 | this.label20.Name = "label20";
389 | this.label20.Size = new System.Drawing.Size(13, 13);
390 | this.label20.TabIndex = 23;
391 | this.label20.Text = "4";
392 | //
393 | // label21
394 | //
395 | this.label21.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
396 | this.label21.AutoSize = true;
397 | this.label21.Location = new System.Drawing.Point(187, 48);
398 | this.label21.Name = "label21";
399 | this.label21.Size = new System.Drawing.Size(19, 13);
400 | this.label21.TabIndex = 24;
401 | this.label21.Text = "17";
402 | //
403 | // label22
404 | //
405 | this.label22.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
406 | this.label22.AutoSize = true;
407 | this.label22.Location = new System.Drawing.Point(281, 48);
408 | this.label22.Name = "label22";
409 | this.label22.Size = new System.Drawing.Size(19, 13);
410 | this.label22.TabIndex = 25;
411 | this.label22.Text = "18";
412 | //
413 | // label23
414 | //
415 | this.label23.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
416 | this.label23.AutoSize = true;
417 | this.label23.Location = new System.Drawing.Point(374, 48);
418 | this.label23.Name = "label23";
419 | this.label23.Size = new System.Drawing.Size(19, 13);
420 | this.label23.TabIndex = 26;
421 | this.label23.Text = "21";
422 | //
423 | // label24
424 | //
425 | this.label24.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
426 | this.label24.AutoSize = true;
427 | this.label24.Location = new System.Drawing.Point(465, 48);
428 | this.label24.Name = "label24";
429 | this.label24.Size = new System.Drawing.Size(19, 13);
430 | this.label24.TabIndex = 27;
431 | this.label24.Text = "22";
432 | //
433 | // label25
434 | //
435 | this.label25.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
436 | this.label25.AutoSize = true;
437 | this.label25.Location = new System.Drawing.Point(556, 48);
438 | this.label25.Name = "label25";
439 | this.label25.Size = new System.Drawing.Size(19, 13);
440 | this.label25.TabIndex = 28;
441 | this.label25.Text = "23";
442 | //
443 | // label26
444 | //
445 | this.label26.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
446 | this.label26.AutoSize = true;
447 | this.label26.Location = new System.Drawing.Point(646, 48);
448 | this.label26.Name = "label26";
449 | this.label26.Size = new System.Drawing.Size(19, 13);
450 | this.label26.TabIndex = 29;
451 | this.label26.Text = "24";
452 | //
453 | // label27
454 | //
455 | this.label27.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
456 | this.label27.AutoSize = true;
457 | this.label27.Location = new System.Drawing.Point(733, 48);
458 | this.label27.Name = "label27";
459 | this.label27.Size = new System.Drawing.Size(19, 13);
460 | this.label27.TabIndex = 30;
461 | this.label27.Text = "25";
462 | //
463 | // LblAboutLink
464 | //
465 | this.LblAboutLink.AutoSize = true;
466 | this.LblAboutLink.Location = new System.Drawing.Point(0, 385);
467 | this.LblAboutLink.Name = "LblAboutLink";
468 | this.LblAboutLink.Size = new System.Drawing.Size(35, 13);
469 | this.LblAboutLink.TabIndex = 31;
470 | this.LblAboutLink.TabStop = true;
471 | this.LblAboutLink.Text = "About";
472 | this.LblAboutLink.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LblAboutLink_LinkClicked);
473 | //
474 | // Main
475 | //
476 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
477 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
478 | this.ClientSize = new System.Drawing.Size(844, 403);
479 | this.Controls.Add(this.LblAboutLink);
480 | this.Controls.Add(this.label27);
481 | this.Controls.Add(this.label26);
482 | this.Controls.Add(this.label25);
483 | this.Controls.Add(this.label24);
484 | this.Controls.Add(this.label23);
485 | this.Controls.Add(this.label22);
486 | this.Controls.Add(this.label21);
487 | this.Controls.Add(this.label20);
488 | this.Controls.Add(this.label19);
489 | this.Controls.Add(this.label18);
490 | this.Controls.Add(this.label17);
491 | this.Controls.Add(this.label16);
492 | this.Controls.Add(this.label15);
493 | this.Controls.Add(this.label14);
494 | this.Controls.Add(this.label13);
495 | this.Controls.Add(this.label12);
496 | this.Controls.Add(this.label11);
497 | this.Controls.Add(this.label10);
498 | this.Controls.Add(this.label9);
499 | this.Controls.Add(this.label8);
500 | this.Controls.Add(this.label7);
501 | this.Controls.Add(this.label6);
502 | this.Controls.Add(this.label5);
503 | this.Controls.Add(this.label4);
504 | this.Controls.Add(this.label1);
505 | this.Controls.Add(this.label3);
506 | this.Controls.Add(this.label2);
507 | this.Controls.Add(this.Gpio25);
508 | this.Controls.Add(this.panel1);
509 | this.Controls.Add(this.Gpio21);
510 | this.Controls.Add(this.Gpio18);
511 | this.Controls.Add(this.Gpio24);
512 | this.Controls.Add(this.Gpio22);
513 | this.Controls.Add(this.Gpio23);
514 | this.Controls.Add(this.Gpio17);
515 | this.Controls.Add(this.Gpio4);
516 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
517 | this.MaximizeBox = false;
518 | this.Name = "Main";
519 | this.Text = "Pi# - Raspberry Pi GPIO Simulator";
520 | this.Load += new System.EventHandler(this.Main_Load);
521 | this.ResumeLayout(false);
522 | this.PerformLayout();
523 |
524 | }
525 |
526 | #endregion
527 |
528 | private System.Windows.Forms.Panel panel1;
529 | private System.Windows.Forms.Panel Gpio4;
530 | private System.Windows.Forms.Panel Gpio17;
531 | private System.Windows.Forms.Panel Gpio18;
532 | private System.Windows.Forms.Panel Gpio24;
533 | private System.Windows.Forms.Panel Gpio22;
534 | private System.Windows.Forms.Panel Gpio21;
535 | private System.Windows.Forms.Panel Gpio23;
536 | private System.Windows.Forms.Panel Gpio25;
537 | private System.Windows.Forms.Label label1;
538 | private System.Windows.Forms.Label label2;
539 | private System.Windows.Forms.Label label3;
540 | private System.Windows.Forms.Label label4;
541 | private System.Windows.Forms.Label label5;
542 | private System.Windows.Forms.Label label6;
543 | private System.Windows.Forms.Label label7;
544 | private System.Windows.Forms.Label label8;
545 | private System.Windows.Forms.Label label9;
546 | private System.Windows.Forms.Label label10;
547 | private System.Windows.Forms.Label label11;
548 | private System.Windows.Forms.Label label12;
549 | private System.Windows.Forms.Label label13;
550 | private System.Windows.Forms.Label label14;
551 | private System.Windows.Forms.Label label15;
552 | private System.Windows.Forms.Label label16;
553 | private System.Windows.Forms.Label label17;
554 | private System.Windows.Forms.Label label18;
555 | private System.Windows.Forms.Label label19;
556 | private System.Windows.Forms.Label label20;
557 | private System.Windows.Forms.Label label21;
558 | private System.Windows.Forms.Label label22;
559 | private System.Windows.Forms.Label label23;
560 | private System.Windows.Forms.Label label24;
561 | private System.Windows.Forms.Label label25;
562 | private System.Windows.Forms.Label label26;
563 | private System.Windows.Forms.Label label27;
564 | private System.Windows.Forms.LinkLabel LblAboutLink;
565 | }
566 | }
567 |
568 |
--------------------------------------------------------------------------------
/src/PiSharp.GpioSimulator/Main.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2012 Andrew Bradford
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6 | // associated documentation files (the "Software"), to deal in the Software without restriction,
7 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject
9 | // to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12 | //
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
16 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | //
18 | //-----------------------------------------------------------------------
19 |
20 | namespace PiSharp.GpioSimulator
21 | {
22 | using System;
23 | using System.Collections.Generic;
24 | using System.Drawing;
25 | using System.IO;
26 | using System.Windows.Forms;
27 |
28 | ///
29 | /// The main simulator form
30 | ///
31 | public partial class Main : Form
32 | {
33 | ///
34 | /// Background image of a powered off LED
35 | ///
36 | private Image ledOffBitmap = new Bitmap(Path.Combine("Images", "LEDOff.png"));
37 |
38 | ///
39 | /// Background image of a lit LED
40 | ///
41 | private Image ledOnBitmap = new Bitmap(Path.Combine("Images", "LEDOn.png"));
42 |
43 | ///
44 | /// Background image of a switched off switch
45 | ///
46 | private Image switchOffBitmap = new Bitmap(Path.Combine("Images", "SwitchOff.png"));
47 |
48 | ///
49 | /// Background image of a switched on switch
50 | ///
51 | private Image switchOnBitmap = new Bitmap(Path.Combine("Images", "SwitchOn.png"));
52 |
53 | ///
54 | /// Contains the current states of the GPIO pins
55 | ///
56 | private Dictionary chanelStates = new Dictionary();
57 |
58 | ///
59 | /// Contains the file system watcher, used to detect writes the GPIO
60 | ///
61 | private FileSystemWatcher fileWatcher;
62 |
63 | ///
64 | /// Initializes a new instance of the Main class.
65 | ///
66 | public Main()
67 | {
68 | this.InitializeComponent();
69 | }
70 |
71 | ///
72 | /// Executes when the form loads
73 | ///
74 | /// The sending object
75 | /// The event arguments
76 | private void Main_Load(object sender, EventArgs e)
77 | {
78 | // Create the temp test dir is it doesn't already exist
79 | var path = this.GetGpioPath();
80 | if (!Directory.Exists(path))
81 | {
82 | Directory.CreateDirectory(path);
83 | }
84 |
85 | this.fileWatcher = new FileSystemWatcher(this.GetGpioPath());
86 | this.fileWatcher.IncludeSubdirectories = true;
87 | this.fileWatcher.Changed += this.FileChanged;
88 | this.fileWatcher.Created += this.FileChanged;
89 | this.fileWatcher.Deleted += this.FileChanged;
90 | this.fileWatcher.EnableRaisingEvents = true;
91 | }
92 |
93 | ///
94 | /// Executed when there is a detected change to the monitored folder
95 | ///
96 | /// The sending object
97 | /// The event arguments
98 | private void FileChanged(object sender, FileSystemEventArgs e)
99 | {
100 | if (e.Name.Contains("direction"))
101 | {
102 | var value = string.Empty;
103 | using (var streamReader = new StreamReader(new FileStream(e.FullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
104 | {
105 | value = streamReader.ReadToEnd();
106 | }
107 |
108 | var nameSplit = e.Name.Split(Path.DirectorySeparatorChar);
109 | var id = nameSplit[nameSplit.Length - 2];
110 |
111 | if (value == "out")
112 | {
113 | this.GetPanel(id).BackgroundImage = this.ledOffBitmap;
114 | this.ChangeState(id, GpioState.Outout);
115 | }
116 | else
117 | {
118 | this.GetPanel(id).BackgroundImage = this.switchOffBitmap;
119 | this.ChangeState(id, GpioState.Input);
120 | }
121 | }
122 |
123 | if (e.Name.Contains("value"))
124 | {
125 | var value = string.Empty;
126 | using (var streamReader = new StreamReader(new FileStream(e.FullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
127 | {
128 | value = streamReader.ReadToEnd();
129 | }
130 |
131 | var nameSplit = e.Name.Split(Path.DirectorySeparatorChar);
132 | var id = nameSplit[nameSplit.Length - 2];
133 | this.SetValue(this.GetPanel(id), value);
134 | }
135 | }
136 |
137 | ///
138 | /// Sets a simulated output to the correct value
139 | ///
140 | /// The image to change
141 | /// The value
142 | private void SetValue(Panel image, string value)
143 | {
144 | var id = image.Name.ToLower();
145 | if (this.chanelStates.ContainsKey(id) && this.chanelStates[id] != GpioState.Outout)
146 | {
147 | // Not configured as output, ignore it. This prevents the simulator changing itself when setting inputs
148 | return;
149 | }
150 |
151 | if (value == "1")
152 | {
153 | image.BackgroundImage = this.ledOnBitmap;
154 | }
155 | else
156 | {
157 | image.BackgroundImage = this.ledOffBitmap;
158 | }
159 | }
160 |
161 | ///
162 | /// Retrieves the panel represented a GPIO pin from its Broadcom ID
163 | ///
164 | /// The Broadcom ID, in form "gpio{Number}"
165 | /// The corresponding panel
166 | private Panel GetPanel(string id)
167 | {
168 | switch (id)
169 | {
170 | case "gpio4":
171 | return this.Gpio4;
172 |
173 | case "gpio17":
174 | return this.Gpio17;
175 |
176 | case "gpio18":
177 | return this.Gpio18;
178 |
179 | case "gpio21":
180 | return this.Gpio21;
181 |
182 | case "gpio22":
183 | return this.Gpio22;
184 |
185 | case "gpio23":
186 | return this.Gpio23;
187 |
188 | case "gpio24":
189 | return this.Gpio24;
190 |
191 | case "gpio25":
192 | return this.Gpio25;
193 |
194 | default:
195 | throw new ArgumentException();
196 | }
197 | }
198 |
199 | ///
200 | /// Gets the GPIO path to write to
201 | ///
202 | /// The correct path for the IO and mode
203 | private string GetGpioPath()
204 | {
205 | if (Environment.OSVersion.Platform == PlatformID.Win32NT || Environment.OSVersion.Platform == PlatformID.Win32Windows
206 | || Environment.OSVersion.Platform == PlatformID.Win32S || Environment.OSVersion.Platform == PlatformID.WinCE)
207 | {
208 | // If we're running under Windows, use a Windows format test path
209 | return "C:\\RasPiGpioTest";
210 | }
211 | else
212 | {
213 | // Otherwise use a Unix style test path
214 | return "/tmp/RasPiGpioTest";
215 | }
216 | }
217 |
218 | ///
219 | /// Runs when an icon is double clicked
220 | ///
221 | /// The sending object
222 | /// The event arguments
223 | private void Gpio_MouseDoubleClick(object sender, MouseEventArgs e)
224 | {
225 | var panel = (Panel)sender;
226 | if (panel.BackgroundImage == this.switchOffBitmap)
227 | {
228 | this.WriteInput(panel.Name, true);
229 | panel.BackgroundImage = this.switchOnBitmap;
230 | }
231 | else if (panel.BackgroundImage == this.switchOnBitmap)
232 | {
233 | this.WriteInput(panel.Name, false);
234 | panel.BackgroundImage = this.switchOffBitmap;
235 | }
236 | }
237 |
238 | ///
239 | /// Writes an output to the simulated GPIO
240 | ///
241 | /// The GPIO id
242 | /// The value to write
243 | private void WriteInput(string gpioId, bool value)
244 | {
245 | var filePath = Path.Combine(gpioId.ToLowerInvariant(), "value");
246 | using (var streamWriter = new StreamWriter(Path.Combine(this.GetGpioPath(), filePath), false))
247 | {
248 | if (value)
249 | {
250 | streamWriter.Write("1");
251 | }
252 | else
253 | {
254 | streamWriter.Write("0");
255 | }
256 | }
257 | }
258 |
259 | ///
260 | /// Changes the internal state of a GPIO channel
261 | ///
262 | /// The GPIO ID
263 | /// The state to change to
264 | private void ChangeState(string id, GpioState state)
265 | {
266 | if (this.chanelStates.ContainsKey(id))
267 | {
268 | this.chanelStates[id] = state;
269 | }
270 | else
271 | {
272 | this.chanelStates.Add(id, state);
273 | }
274 | }
275 |
276 | private void LblAboutLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
277 | {
278 | new FrmAbout().ShowDialog();
279 | }
280 | }
281 | }
282 |
--------------------------------------------------------------------------------
/src/PiSharp.GpioSimulator/PiSharp.GpioSimulator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | 8.0.30703
7 | 2.0
8 | {8EABDDC4-A226-4FFE-8FAE-520438A42DB2}
9 | WinExe
10 | Properties
11 | PiSharp.GpioSimulator
12 | PiSharp.GpioSimulator
13 | v3.5
14 | 512
15 |
16 |
17 |
18 | x86
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | x86
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | Form
47 |
48 |
49 | FrmAbout.cs
50 |
51 |
52 |
53 | Form
54 |
55 |
56 | Main.cs
57 |
58 |
59 |
60 |
61 | FrmAbout.cs
62 |
63 |
64 | Main.cs
65 |
66 |
67 | ResXFileCodeGenerator
68 | Resources.Designer.cs
69 | Designer
70 |
71 |
72 | True
73 | Resources.resx
74 | True
75 |
76 |
77 |
78 | SettingsSingleFileGenerator
79 | Settings.Designer.cs
80 |
81 |
82 | True
83 | Settings.settings
84 | True
85 |
86 |
87 |
88 |
89 | PreserveNewest
90 |
91 |
92 | PreserveNewest
93 |
94 |
95 | PreserveNewest
96 |
97 |
98 | PreserveNewest
99 |
100 |
101 |
102 |
109 |
--------------------------------------------------------------------------------
/src/PiSharp.GpioSimulator/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2012 Andrew Bradford
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6 | // associated documentation files (the "Software"), to deal in the Software without restriction,
7 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject
9 | // to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12 | //
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
16 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | //
18 | //-----------------------------------------------------------------------
19 |
20 | using System.Reflection;
21 | using System.Runtime.CompilerServices;
22 | using System.Runtime.InteropServices;
23 |
24 | // General Information about an assembly is controlled through the following
25 | // set of attributes. Change these attribute values to modify the information
26 | // associated with an assembly.
27 | [assembly: AssemblyTitle("PiSharp.GpioSimulator")]
28 | [assembly: AssemblyDescription("")]
29 | [assembly: AssemblyConfiguration("")]
30 | [assembly: AssemblyCompany("")]
31 | [assembly: AssemblyProduct("PiSharp.GpioSimulator")]
32 | [assembly: AssemblyCopyright("Copyright © 2012")]
33 | [assembly: AssemblyTrademark("")]
34 | [assembly: AssemblyCulture("")]
35 |
36 | // Setting ComVisible to false makes the types in this assembly not visible
37 | // to COM components. If you need to access a type in this assembly from
38 | // COM, set the ComVisible attribute to true on that type.
39 | [assembly: ComVisible(false)]
40 |
41 | // The following GUID is for the ID of the typelib if this project is exposed to COM
42 | [assembly: Guid("0e0b6e2f-a891-43b4-a085-9bc10f672f32")]
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/src/PiSharp.GpioSimulator/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.269
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace PiSharp.GpioSimulator.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PiSharp.GpioSimulator.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/PiSharp.GpioSimulator/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/src/PiSharp.GpioSimulator/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.269
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace PiSharp.GpioSimulator.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/PiSharp.GpioSimulator/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/PiSharp.GpioSimulator/Simulator.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2012 Andrew Bradford
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6 | // associated documentation files (the "Software"), to deal in the Software without restriction,
7 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject
9 | // to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12 | //
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
16 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | //
18 | //-----------------------------------------------------------------------
19 |
20 | namespace PiSharp.GpioSimulator
21 | {
22 | using System;
23 | using System.Windows.Forms;
24 |
25 | ///
26 | /// Program entry point
27 | ///
28 | public static class Simulator
29 | {
30 | ///
31 | /// The main entry point for the application.
32 | ///
33 | [STAThread]
34 | public static void Main()
35 | {
36 | Application.EnableVisualStyles();
37 | Application.SetCompatibleTextRenderingDefault(false);
38 | Application.Run(new Main());
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/PiSharp.GpioSimulator/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/PiSharp.LibGpio/Entities/BroadcomPinNumber.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2012 Andrew Bradford
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6 | // associated documentation files (the "Software"), to deal in the Software without restriction,
7 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject
9 | // to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12 | //
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
16 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | //
18 | //-----------------------------------------------------------------------
19 |
20 | namespace PiSharp.LibGpio.Entities
21 | {
22 | ///
23 | /// The Broadcom GPIO ID
24 | ///
25 | public enum BroadcomPinNumber
26 | {
27 | ///
28 | /// GPIO Pin 4
29 | ///
30 | Four = 4,
31 |
32 | ///
33 | /// GPIO Pin 17
34 | ///
35 | Seventeen = 17,
36 |
37 | ///
38 | /// GPIO Pin 18
39 | ///
40 | Eighteen = 18,
41 |
42 | ///
43 | /// GPIO Pin 21
44 | ///
45 | TwentyOne = 21,
46 |
47 | ///
48 | /// GPIO Pin 22
49 | ///
50 | TwentyTwo = 22,
51 |
52 | ///
53 | /// GPIO Pin 23
54 | ///
55 | TwentyThree = 23,
56 |
57 | ///
58 | /// GPIO Pin 24
59 | ///
60 | TwentyFour = 24,
61 |
62 | ///
63 | /// GPIO Pin 25
64 | ///
65 | TwentyFive = 25,
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/PiSharp.LibGpio/Entities/Direction.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2012 Andrew Bradford
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6 | // associated documentation files (the "Software"), to deal in the Software without restriction,
7 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject
9 | // to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12 | //
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
16 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | //
18 | //-----------------------------------------------------------------------
19 |
20 | namespace PiSharp.LibGpio.Entities
21 | {
22 | ///
23 | /// The GPIO direction
24 | ///
25 | public enum Direction
26 | {
27 | ///
28 | /// Configured for input
29 | ///
30 | Input,
31 |
32 | ///
33 | /// Configured for output
34 | ///
35 | Output
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/PiSharp.LibGpio/Entities/PhysicalPinNumber.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2012 Andrew Bradford
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6 | // associated documentation files (the "Software"), to deal in the Software without restriction,
7 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject
9 | // to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12 | //
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
16 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | //
18 | //-----------------------------------------------------------------------
19 |
20 | namespace PiSharp.LibGpio.Entities
21 | {
22 | ///
23 | /// The physical GPIO pin ID
24 | ///
25 | public enum PhysicalPinNumber
26 | {
27 | ///
28 | /// Invalid pin number - used to established a known invalid value to un-initialised variables.
29 | ///
30 | Undefined = 0,
31 |
32 | ///
33 | /// GPIO Pin 7
34 | ///
35 | Seven = 7,
36 |
37 | ///
38 | /// GPIO Pin 11
39 | ///
40 | Eleven = 11,
41 |
42 | ///
43 | /// GPIO Pin 12
44 | ///
45 | Twelve = 12,
46 |
47 | ///
48 | /// GPIO Pin 13
49 | ///
50 | Thirteen = 13,
51 |
52 | ///
53 | /// GPIO Pin 15
54 | ///
55 | Fifteen = 15,
56 |
57 | ///
58 | /// GPIO Pin 16
59 | ///
60 | Sixteen = 16,
61 |
62 | ///
63 | /// GPIO Pin 18
64 | ///
65 | Eighteen = 18,
66 |
67 | ///
68 | /// GPIO Pin 22
69 | ///
70 | TwentyTwo = 22
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/PiSharp.LibGpio/Entities/RaspberryPinNumber.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2012 Andrew Bradford
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6 | // associated documentation files (the "Software"), to deal in the Software without restriction,
7 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject
9 | // to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12 | //
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
16 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | //
18 | //-----------------------------------------------------------------------
19 |
20 | namespace PiSharp.LibGpio.Entities
21 | {
22 | ///
23 | /// The Raspberry Pi GPIO ID
24 | ///
25 | public enum RaspberryPinNumber
26 | {
27 | ///
28 | /// Invalid pin number - used to established a known invalid value to un-initialised variables.
29 | ///
30 | Zero = 0,
31 |
32 | ///
33 | /// GPIO Pin 1
34 | ///
35 | One,
36 |
37 | ///
38 | /// GPIO Pin 2
39 | ///
40 | Two,
41 |
42 | ///
43 | /// GPIO Pin 3
44 | ///
45 | Three,
46 |
47 | ///
48 | /// GPIO Pin 4
49 | ///
50 | Four,
51 |
52 | ///
53 | /// GPIO Pin 5
54 | ///
55 | Five,
56 |
57 | ///
58 | /// GPIO Pin 6
59 | ///
60 | Six,
61 |
62 | ///
63 | /// GPIO Pin 7
64 | ///
65 | Seven,
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/PiSharp.LibGpio/LibGpio.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2012 Andrew Bradford
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6 | // associated documentation files (the "Software"), to deal in the Software without restriction,
7 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject
9 | // to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12 | //
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
16 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | //
18 | //-----------------------------------------------------------------------
19 |
20 | namespace PiSharp.LibGpio
21 | {
22 | using System;
23 | using System.Collections.Generic;
24 | using System.Diagnostics;
25 | using System.Globalization;
26 | using System.IO;
27 |
28 | using PiSharp.LibGpio.Entities;
29 |
30 | ///
31 | /// Library for interfacing with the Raspberry Pi GPIO ports.
32 | /// This class is implemented as a singleton - no attempt should be made to instantiate it
33 | ///
34 | public class LibGpio
35 | {
36 | ///
37 | /// Stores the singleton instance of the class
38 | ///
39 | private static LibGpio instance;
40 |
41 | ///
42 | /// Stores the configured directions of the GPIO ports
43 | ///
44 | private Dictionary directions = new Dictionary();
45 |
46 | ///
47 | /// Prevents a default instance of the LibGpio class from being created.
48 | ///
49 | private LibGpio()
50 | {
51 | var gpioPath = this.GetGpioPath();
52 | if (!Directory.Exists(gpioPath))
53 | {
54 | Directory.CreateDirectory(gpioPath);
55 | }
56 | }
57 |
58 | ///
59 | /// Gets the class instance
60 | ///
61 | public static LibGpio Gpio
62 | {
63 | get
64 | {
65 | if (instance == null)
66 | {
67 | instance = new LibGpio();
68 | }
69 |
70 | return instance;
71 | }
72 | }
73 |
74 | ///
75 | /// Gets or sets a value indicating whether the library should be used in test mode.
76 | /// Note: If running under Windows or Mac OSx, test mode is assumed.
77 | ///
78 | public bool TestMode
79 | {
80 | get;
81 | set;
82 | }
83 |
84 | ///
85 | /// Closes a GPIO channel
86 | ///
87 | /// The Raspberry Pi pin number to configure
88 | public void CloseChannel(RaspberryPinNumber pinNumber)
89 | {
90 | this.CloseChannel(ConvertToBroadcom(pinNumber));
91 | }
92 |
93 | ///
94 | /// Closes a GPIO channel
95 | ///
96 | /// The physical pin number to configure
97 | public void CloseChannel(PhysicalPinNumber pinNumber)
98 | {
99 | this.CloseChannel(ConvertToBroadcom(pinNumber));
100 | }
101 |
102 | ///
103 | /// Closes a GPIO channel
104 | ///
105 | /// The Broadcom pin number to configure
106 | public void CloseChannel(BroadcomPinNumber pinNumber)
107 | {
108 | var outputName = string.Format("gpio{0}", (int)pinNumber);
109 | var gpioPath = Path.Combine(this.GetGpioPath(), outputName);
110 |
111 | if (Directory.Exists(gpioPath))
112 | {
113 | this.UnExport(pinNumber);
114 |
115 | // Sets direction back to input.
116 | this.SetDirection(pinNumber, Direction.Input);
117 | }
118 |
119 |
120 |
121 | Debug.WriteLine(string.Format("[PiSharp.LibGpio] Broadcom GPIO number '{0}', configured for use", pinNumber));
122 | }
123 |
124 | ///
125 | /// Configures a GPIO channel for use
126 | ///
127 | /// The Raspberry Pi pin number to configure
128 | /// The direction to configure the pin for
129 | public void SetupChannel(RaspberryPinNumber pinNumber, Direction direction)
130 | {
131 | this.SetupChannel(ConvertToBroadcom(pinNumber), direction);
132 | }
133 |
134 | ///
135 | /// Configures a GPIO channel for use
136 | ///
137 | /// The physical pin number to configure
138 | /// The direction to configure the pin for
139 | public void SetupChannel(PhysicalPinNumber pinNumber, Direction direction)
140 | {
141 | this.SetupChannel(ConvertToBroadcom(pinNumber), direction);
142 | }
143 |
144 | ///
145 | /// Configures a GPIO channel for use
146 | ///
147 | /// The Broadcom pin number to configure
148 | /// The direction to configure the pin for
149 | public void SetupChannel(BroadcomPinNumber pinNumber, Direction direction)
150 | {
151 | var outputName = string.Format("gpio{0}", (int)pinNumber);
152 | var gpioPath = Path.Combine(this.GetGpioPath(), outputName);
153 |
154 | // If already exported, unexport it before continuing
155 | if (Directory.Exists(gpioPath))
156 | {
157 | this.UnExport(pinNumber);
158 | }
159 |
160 | // Now export the channel
161 | this.Export(pinNumber);
162 |
163 | // Set the IO direction
164 | this.SetDirection(pinNumber, direction);
165 |
166 | Debug.WriteLine(string.Format("[PiSharp.LibGpio] Broadcom GPIO number '{0}', configured for use", pinNumber));
167 | }
168 |
169 | ///
170 | /// Outputs a value to a GPIO pin
171 | ///
172 | /// The pin number to use
173 | /// The value to output
174 | ///
175 | /// Thrown when an attempt to use an incorrectly configured channel is made
176 | ///
177 | public void OutputValue(RaspberryPinNumber pinNumber, bool value)
178 | {
179 | this.OutputValue(ConvertToBroadcom(pinNumber), value);
180 | }
181 |
182 | ///
183 | /// Outputs a value to a GPIO pin
184 | ///
185 | /// The pin number to use
186 | /// The value to output
187 | ///
188 | /// Thrown when an attempt to use an incorrectly configured channel is made
189 | ///
190 | public void OutputValue(PhysicalPinNumber pinNumber, bool value)
191 | {
192 | this.OutputValue(ConvertToBroadcom(pinNumber), value);
193 | }
194 |
195 | ///
196 | /// Outputs a value to a GPIO pin
197 | ///
198 | /// The pin number to use
199 | /// The value to output
200 | ///
201 | /// Thrown when an attempt to use an incorrectly configured channel is made
202 | ///
203 | public void OutputValue(BroadcomPinNumber pinNumber, bool value)
204 | {
205 | // Check that the output is configured
206 | if (!this.directions.ContainsKey(pinNumber))
207 | {
208 | throw new InvalidOperationException("Attempt to output value on un-configured pin");
209 | }
210 |
211 | // Check that the channel is not being used incorrectly
212 | if (this.directions[pinNumber] == Direction.Input)
213 | {
214 | throw new InvalidOperationException("Attempt to output value on pin configured for input");
215 | }
216 |
217 | var gpioId = string.Format("gpio{0}", (int)pinNumber);
218 | var filePath = Path.Combine(gpioId, "value");
219 | using (var streamWriter = new StreamWriter(Path.Combine(this.GetGpioPath(), filePath), false))
220 | {
221 | if (value)
222 | {
223 | streamWriter.Write("1");
224 | }
225 | else
226 | {
227 | streamWriter.Write("0");
228 | }
229 | }
230 |
231 | Debug.WriteLine(string.Format("[PiSharp.LibGpio] Broadcom GPIO number '{0}', outputting value '{1}'", pinNumber, value));
232 | }
233 |
234 | ///
235 | /// Reads a value form a GPIO pin
236 | ///
237 | /// The pin number to read
238 | /// The value at that pin
239 | ///
240 | /// Thrown when an attempt to use an incorrectly configured channel is made
241 | ///
242 | public bool ReadValue(RaspberryPinNumber pinNumber)
243 | {
244 | return this.ReadValue(ConvertToBroadcom(pinNumber));
245 | }
246 |
247 | ///
248 | /// Reads a value form a GPIO pin
249 | ///
250 | /// The pin number to read
251 | /// The value at that pin
252 | ///
253 | /// Thrown when an attempt to use an incorrectly configured channel is made
254 | ///
255 | public bool ReadValue(PhysicalPinNumber pinNumber)
256 | {
257 | return this.ReadValue(ConvertToBroadcom(pinNumber));
258 | }
259 |
260 | ///
261 | /// Reads a value form a GPIO pin
262 | ///
263 | /// The pin number to read
264 | /// The value at that pin
265 | ///
266 | /// Thrown when an attempt to use an incorrectly configured channel is made
267 | ///
268 | public bool ReadValue(BroadcomPinNumber pinNumber)
269 | {
270 | // Check that the output is configured
271 | if (!this.directions.ContainsKey(pinNumber))
272 | {
273 | throw new InvalidOperationException("Attempt to read value from un-configured pin");
274 | }
275 |
276 | // Check that the channel is not being used incorrectly
277 | if (this.directions[pinNumber] == Direction.Output)
278 | {
279 | throw new InvalidOperationException("Attempt to read value form pin configured for output");
280 | }
281 |
282 | var gpioId = string.Format("gpio{0}", (int)pinNumber);
283 | var filePath = Path.Combine(gpioId, "value");
284 | using (var fileStream = new FileStream(Path.Combine(this.GetGpioPath(), filePath), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
285 | {
286 | using (var streamReader = new StreamReader(fileStream))
287 | {
288 | var rawValue = streamReader.ReadToEnd().Trim();
289 | Debug.WriteLine(string.Format("[PiSharp.LibGpio] Broadcom GPIO number '{0}', has input value '{1}'", pinNumber, rawValue));
290 | if (rawValue == "1")
291 | {
292 | return true;
293 | }
294 | else
295 | {
296 | return false;
297 | }
298 | }
299 | }
300 | }
301 |
302 | ///
303 | /// Gets the Broadcom GPIO pin number form the Raspberry Pi pin number
304 | ///
305 | /// The Raspberry Pi pin number
306 | /// The equivalent Broadcom ID
307 | private static BroadcomPinNumber ConvertToBroadcom(RaspberryPinNumber pinNumber)
308 | {
309 | switch (pinNumber)
310 | {
311 | case RaspberryPinNumber.Seven:
312 | return BroadcomPinNumber.Four;
313 |
314 | case RaspberryPinNumber.Zero:
315 | return BroadcomPinNumber.Seventeen;
316 |
317 | case RaspberryPinNumber.One:
318 | return BroadcomPinNumber.Eighteen;
319 |
320 | case RaspberryPinNumber.Two:
321 | return BroadcomPinNumber.TwentyOne;
322 |
323 | case RaspberryPinNumber.Three:
324 | return BroadcomPinNumber.TwentyTwo;
325 |
326 | case RaspberryPinNumber.Four:
327 | return BroadcomPinNumber.TwentyThree;
328 |
329 | case RaspberryPinNumber.Five:
330 | return BroadcomPinNumber.TwentyFour;
331 |
332 | case RaspberryPinNumber.Six:
333 | return BroadcomPinNumber.TwentyFive;
334 |
335 | default:
336 | throw new ArgumentOutOfRangeException();
337 | }
338 | }
339 |
340 | ///
341 | /// Gets the Broadcom GPIO pin number form the physical pin number
342 | ///
343 | /// The physical pin number
344 | /// The equivalent Broadcom ID
345 | private static BroadcomPinNumber ConvertToBroadcom(PhysicalPinNumber pinNumber)
346 | {
347 | switch (pinNumber)
348 | {
349 | case PhysicalPinNumber.Seven:
350 | return BroadcomPinNumber.Four;
351 |
352 | case PhysicalPinNumber.Eleven:
353 | return BroadcomPinNumber.Seventeen;
354 |
355 | case PhysicalPinNumber.Twelve:
356 | return BroadcomPinNumber.Eighteen;
357 |
358 | case PhysicalPinNumber.Thirteen:
359 | return BroadcomPinNumber.TwentyOne;
360 |
361 | case PhysicalPinNumber.Fifteen:
362 | return BroadcomPinNumber.TwentyTwo;
363 |
364 | case PhysicalPinNumber.Sixteen:
365 | return BroadcomPinNumber.TwentyThree;
366 |
367 | case PhysicalPinNumber.Eighteen:
368 | return BroadcomPinNumber.TwentyFour;
369 |
370 | case PhysicalPinNumber.TwentyTwo:
371 | return BroadcomPinNumber.TwentyFive;
372 |
373 | default:
374 | throw new ArgumentOutOfRangeException();
375 | }
376 | }
377 |
378 | ///
379 | /// Unexports a given GPIO pin number
380 | ///
381 | /// The pin number to unexport
382 | private void UnExport(BroadcomPinNumber pinNumber)
383 | {
384 | using (var fileStream = new FileStream(Path.Combine(this.GetGpioPath(), "unexport"), FileMode.Open, FileAccess.Write, FileShare.ReadWrite))
385 | {
386 | using (var streamWriter = new StreamWriter(fileStream))
387 | {
388 | streamWriter.Write((int)pinNumber);
389 | }
390 | }
391 |
392 | Debug.WriteLine(string.Format("[PiSharp.LibGpio] Broadcom GPIO number '{0}', un-exported", pinNumber));
393 | }
394 |
395 | ///
396 | /// Exports a given GPIO pin
397 | ///
398 | /// The pin number to export
399 | private void Export(BroadcomPinNumber pinNumber)
400 | {
401 | // The simulator requires directories to be created first, but the RasPi does not and throws an exception.
402 | if (this.TestMode || Environment.OSVersion.Platform != PlatformID.Unix)
403 | {
404 | var exportDir = string.Format("gpio{0}", (int)pinNumber);
405 | var exportPath = Path.Combine(this.GetGpioPath(), exportDir);
406 | if (!Directory.Exists(exportPath))
407 | {
408 | Directory.CreateDirectory(exportPath);
409 | File.Create(Path.Combine(exportPath, "value")).Close();
410 | }
411 | }
412 |
413 | using (var fileStream = new FileStream(Path.Combine(this.GetGpioPath(), "export"), FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite))
414 | {
415 |
416 | using (var streamWriter = new StreamWriter(fileStream))
417 | {
418 | streamWriter.Write((int)pinNumber);
419 | streamWriter.Flush();
420 | }
421 | }
422 |
423 | Debug.WriteLine(string.Format("[PiSharp.LibGpio] Broadcom GPIO number '{0}', been exported", pinNumber));
424 | }
425 |
426 | ///
427 | /// Sets the direction of a GPIO channel
428 | ///
429 | /// The pin number to set the direction of
430 | /// The direction to set it to
431 | private void SetDirection(BroadcomPinNumber pinNumber, Direction direction)
432 | {
433 | var gpioId = string.Format("gpio{0}", (int)pinNumber);
434 | var filePath = Path.Combine(gpioId, "direction");
435 | using (var streamWriter = new StreamWriter(Path.Combine(this.GetGpioPath(), filePath), false))
436 | {
437 | if (direction == Direction.Input)
438 | {
439 | streamWriter.Write("in");
440 | }
441 | else
442 | {
443 | streamWriter.Write("out");
444 | }
445 | }
446 |
447 | // Internally log the direction of this pin, so we can perform safety checks later.
448 | if (this.directions.ContainsKey(pinNumber))
449 | {
450 | this.directions[pinNumber] = direction;
451 | }
452 | else
453 | {
454 | this.directions.Add(pinNumber, direction);
455 | }
456 |
457 | Debug.WriteLine(string.Format("[PiSharp.LibGpio] Broadcom GPIO number '{0}', now set to direction '{1}'", pinNumber, direction));
458 | }
459 |
460 | ///
461 | /// Gets the GPIO path to write to
462 | ///
463 | /// The correct path for the IO and mode
464 | private string GetGpioPath()
465 | {
466 | if (Environment.OSVersion.Platform == PlatformID.Win32NT || Environment.OSVersion.Platform == PlatformID.Win32Windows
467 | || Environment.OSVersion.Platform == PlatformID.Win32S || Environment.OSVersion.Platform == PlatformID.WinCE)
468 | {
469 | // If we're running under Windows, use a Windows format test path
470 | return "C:\\RasPiGpioTest";
471 | }
472 | else if (this.TestMode
473 | || Environment.OSVersion.Platform == PlatformID.MacOSX
474 | || Environment.OSVersion.Platform == PlatformID.Unix
475 | || ((int)Environment.OSVersion.Platform) == 128) // 128 is used for OSX on for .NET versions <4.0 on Mono, see https://github.com/andycb/PiSharp/issues/3
476 | {
477 | // If we're in Test mode or running on a Mac, use a Unix style test path
478 | return "/tmp/RasPiGpioTest";
479 | }
480 | else
481 | {
482 | // Otherwise use the the GPIO folder for the Raspberry Pi
483 | return "/sys/class/gpio";
484 | }
485 | }
486 | }
487 | }
488 |
--------------------------------------------------------------------------------
/src/PiSharp.LibGpio/PiSharp.LibGpio.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | 8.0.30703
7 | 2.0
8 | {2880BE93-F857-4E19-AF08-94AF812FB3A8}
9 | Library
10 | Properties
11 | PiSharp.LibGpio
12 | PiSharp.LibGpio
13 | v3.5
14 |
15 |
16 | 512
17 |
18 |
19 | x86
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | TRACE;DEBUG;GpioTestMode
25 | prompt
26 | 4
27 |
28 |
29 | x86
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
65 |
--------------------------------------------------------------------------------
/src/PiSharp.LibGpio/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2012 Andrew Bradford
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6 | // associated documentation files (the "Software"), to deal in the Software without restriction,
7 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject
9 | // to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12 | //
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
16 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | //
18 | //-----------------------------------------------------------------------
19 |
20 | using System.Reflection;
21 | using System.Runtime.CompilerServices;
22 | using System.Runtime.InteropServices;
23 |
24 | // General Information about an assembly is controlled through the following
25 | // set of attributes. Change these attribute values to modify the information
26 | // associated with an assembly.
27 | [assembly: AssemblyTitle("PiSharp.LibGpio")]
28 | [assembly: AssemblyDescription("")]
29 | [assembly: AssemblyConfiguration("")]
30 | [assembly: AssemblyCompany("")]
31 | [assembly: AssemblyProduct("PiSharp.LibGpio")]
32 | [assembly: AssemblyCopyright("Copyright © 2012")]
33 | [assembly: AssemblyTrademark("")]
34 | [assembly: AssemblyCulture("")]
35 |
36 | // Setting ComVisible to false makes the types in this assembly not visible
37 | // to COM components. If you need to access a type in this assembly from
38 | // COM, set the ComVisible attribute to true on that type.
39 | [assembly: ComVisible(false)]
40 |
41 | // The following GUID is for the ID of the typelib if this project is exposed to COM
42 | [assembly: Guid("cced25ba-9382-4784-b667-fd5486739a96")]
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/src/PiSharpGpio.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PiSharpGpio", "PiSharpGpio\PiSharpGpio.csproj", "{52B36261-BFA8-4401-A5F3-E923D54ADE1A}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PiSharp.LibGpio", "PiSharp.LibGpio\PiSharp.LibGpio.csproj", "{2880BE93-F857-4E19-AF08-94AF812FB3A8}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PiSharp.GpioSimulator", "PiSharp.GpioSimulator\PiSharp.GpioSimulator.csproj", "{8EABDDC4-A226-4FFE-8FAE-520438A42DB2}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|x86 = Debug|x86
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {52B36261-BFA8-4401-A5F3-E923D54ADE1A}.Debug|x86.ActiveCfg = Debug|x86
17 | {52B36261-BFA8-4401-A5F3-E923D54ADE1A}.Debug|x86.Build.0 = Debug|x86
18 | {52B36261-BFA8-4401-A5F3-E923D54ADE1A}.Release|x86.ActiveCfg = Release|x86
19 | {52B36261-BFA8-4401-A5F3-E923D54ADE1A}.Release|x86.Build.0 = Release|x86
20 | {2880BE93-F857-4E19-AF08-94AF812FB3A8}.Debug|x86.ActiveCfg = Debug|x86
21 | {2880BE93-F857-4E19-AF08-94AF812FB3A8}.Debug|x86.Build.0 = Debug|x86
22 | {2880BE93-F857-4E19-AF08-94AF812FB3A8}.Release|x86.ActiveCfg = Release|x86
23 | {2880BE93-F857-4E19-AF08-94AF812FB3A8}.Release|x86.Build.0 = Release|x86
24 | {8EABDDC4-A226-4FFE-8FAE-520438A42DB2}.Debug|x86.ActiveCfg = Debug|x86
25 | {8EABDDC4-A226-4FFE-8FAE-520438A42DB2}.Debug|x86.Build.0 = Debug|x86
26 | {8EABDDC4-A226-4FFE-8FAE-520438A42DB2}.Release|x86.ActiveCfg = Release|x86
27 | {8EABDDC4-A226-4FFE-8FAE-520438A42DB2}.Release|x86.Build.0 = Release|x86
28 | EndGlobalSection
29 | GlobalSection(SolutionProperties) = preSolution
30 | HideSolutionNode = FALSE
31 | EndGlobalSection
32 | EndGlobal
33 |
--------------------------------------------------------------------------------
/src/PiSharpGpio/PiSharpGpio.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | 8.0.30703
7 | 2.0
8 | {52B36261-BFA8-4401-A5F3-E923D54ADE1A}
9 | Exe
10 | Properties
11 | PiSharpGpio
12 | PiSharpGpio
13 | v3.5
14 |
15 |
16 | 512
17 |
18 |
19 | x86
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | TRACE;DEBUG;GpioTestMode
25 | prompt
26 | 4
27 |
28 |
29 | x86
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | {2880BE93-F857-4E19-AF08-94AF812FB3A8}
55 | PiSharp.LibGpio
56 |
57 |
58 |
59 |
66 |
--------------------------------------------------------------------------------
/src/PiSharpGpio/Program.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2012 Andrew Bradford
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6 | // associated documentation files (the "Software"), to deal in the Software without restriction,
7 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject
9 | // to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12 | //
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
16 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | //
18 | //-----------------------------------------------------------------------
19 |
20 | namespace PiSharpGpio
21 | {
22 | using System;
23 | using System.Threading;
24 |
25 | using PiSharp.LibGpio;
26 | using PiSharp.LibGpio.Entities;
27 |
28 | ///
29 | /// Demo program for the LibGpio library
30 | ///
31 | public class Program
32 | {
33 | ///
34 | /// Program Entry point
35 | ///
36 | public static void Main()
37 | {
38 | Console.ReadKey();
39 |
40 | LibGpio.Gpio.TestMode = true;
41 |
42 | LibGpio.Gpio.SetupChannel(BroadcomPinNumber.Eighteen, Direction.Output);
43 | LibGpio.Gpio.SetupChannel(RaspberryPinNumber.Two, Direction.Output);
44 | LibGpio.Gpio.SetupChannel(RaspberryPinNumber.Three, Direction.Output);
45 | LibGpio.Gpio.SetupChannel(RaspberryPinNumber.Four, Direction.Output);
46 | LibGpio.Gpio.SetupChannel(RaspberryPinNumber.Five, Direction.Output);
47 | LibGpio.Gpio.SetupChannel(RaspberryPinNumber.Six, Direction.Output);
48 | LibGpio.Gpio.SetupChannel(RaspberryPinNumber.Seven, Direction.Output);
49 | LibGpio.Gpio.SetupChannel(RaspberryPinNumber.Zero, Direction.Output);
50 |
51 | Console.ReadKey();
52 |
53 | for (var i = 0; i < 5; ++i)
54 | {
55 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.Four, true);
56 | Thread.Sleep(200);
57 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.Seventeen, true);
58 | Thread.Sleep(200);
59 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.Eighteen, true);
60 | Thread.Sleep(200);
61 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyOne, true);
62 | Thread.Sleep(200);
63 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyTwo, true);
64 | Thread.Sleep(200);
65 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyThree, true);
66 | Thread.Sleep(200);
67 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyFour, true);
68 | Thread.Sleep(200);
69 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyFive, true);
70 | Thread.Sleep(200);
71 |
72 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.Four, false);
73 | Thread.Sleep(200);
74 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.Seventeen, false);
75 | Thread.Sleep(200);
76 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.Eighteen, false);
77 | Thread.Sleep(200);
78 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyOne, false);
79 | Thread.Sleep(200);
80 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyTwo, false);
81 | Thread.Sleep(200);
82 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyThree, false);
83 | Thread.Sleep(200);
84 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyFour, false);
85 | Thread.Sleep(200);
86 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyFive, false);
87 | Thread.Sleep(200);
88 | }
89 |
90 | Console.ReadKey();
91 |
92 | LibGpio.Gpio.SetupChannel(RaspberryPinNumber.One, Direction.Input);
93 | LibGpio.Gpio.SetupChannel(RaspberryPinNumber.Two, Direction.Output);
94 | LibGpio.Gpio.SetupChannel(RaspberryPinNumber.Three, Direction.Input);
95 | LibGpio.Gpio.SetupChannel(RaspberryPinNumber.Four, Direction.Output);
96 | LibGpio.Gpio.SetupChannel(RaspberryPinNumber.Five, Direction.Input);
97 | LibGpio.Gpio.SetupChannel(RaspberryPinNumber.Six, Direction.Output);
98 | LibGpio.Gpio.SetupChannel(RaspberryPinNumber.Seven, Direction.Input);
99 | LibGpio.Gpio.SetupChannel(RaspberryPinNumber.Zero, Direction.Output);
100 |
101 | var oldInput = false;
102 | while (true)
103 | {
104 | var newInput = LibGpio.Gpio.ReadValue(RaspberryPinNumber.Seven);
105 | if (newInput != oldInput)
106 | {
107 | LibGpio.Gpio.OutputValue(BroadcomPinNumber.Seventeen, newInput);
108 | oldInput = newInput;
109 | }
110 | }
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/src/PiSharpGpio/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2012 Andrew Bradford
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6 | // associated documentation files (the "Software"), to deal in the Software without restriction,
7 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject
9 | // to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12 | //
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
16 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | //
18 | //-----------------------------------------------------------------------
19 |
20 | using System.Reflection;
21 | using System.Runtime.CompilerServices;
22 | using System.Runtime.InteropServices;
23 |
24 | // General Information about an assembly is controlled through the following
25 | // set of attributes. Change these attribute values to modify the information
26 | // associated with an assembly.
27 | [assembly: AssemblyTitle("PiSharpGpio")]
28 | [assembly: AssemblyDescription("")]
29 | [assembly: AssemblyConfiguration("")]
30 | [assembly: AssemblyCompany("")]
31 | [assembly: AssemblyProduct("PiSharpGpio")]
32 | [assembly: AssemblyCopyright("Copyright © 2012")]
33 | [assembly: AssemblyTrademark("")]
34 | [assembly: AssemblyCulture("")]
35 |
36 | // Setting ComVisible to false makes the types in this assembly not visible
37 | // to COM components. If you need to access a type in this assembly from
38 | // COM, set the ComVisible attribute to true on that type.
39 | [assembly: ComVisible(false)]
40 |
41 | // The following GUID is for the ID of the typelib if this project is exposed to COM
42 | [assembly: Guid("b73874f6-17ba-4a68-9749-ac6a81c1f464")]
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/src/PiSharpGpio/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------