Skip to content

Commit 9e662ec

Browse files
author
Eric Bézine
committed
Added .gitattributes and fixed files corruption
1 parent b945ebd commit 9e662ec

23 files changed

+1027
-2036
lines changed

.gitattributes

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
*.sln merge=union
7+
*.csproj merge=union
8+
*.vbproj merge=union
9+
*.fsproj merge=union
10+
*.dbproj merge=union
11+
12+
# Standard to msysgit
13+
*.doc diff=astextplain
14+
*.DOC diff=astextplain
15+
*.docx diff=astextplain
16+
*.DOCX diff=astextplain
17+
*.dot diff=astextplain
18+
*.DOT diff=astextplain
19+
*.pdf diff=astextplain
20+
*.PDF diff=astextplain
21+
*.rtf diff=astextplain
22+
*.RTF diff=astextplain

.gitignore

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
1-
<<<<<<< HEAD
2-
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
3-
bin
4-
obj
5-
6-
# mstest test results
7-
TestResults
8-
9-
# user files
10-
=======
11-
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
12-
bin
13-
obj
14-
15-
# mstest test results
16-
TestResults
17-
18-
# user files
19-
>>>>>>> Initial Import
20-
**.user
1+
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
2+
bin
3+
obj
4+
5+
# mstest test results
6+
TestResults
7+
8+
# user files
9+
**.user
10+
**.suo

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
<h1>Raspberry# IO</h1>
2-
3-
<h2>Introduction</h2>
4-
Raspberry# IO is a .NET/Mono IO Library for Raspberry Pi.
5-
6-
Development is in a preliminary stage, project structure is subject to frequent changes.
7-
Raspberry# IO currently support basic GPIO input/output.
8-
9-
Support for extended IO (such as support for I2C peripherals).
10-
11-
<h2>Features</h2>
12-
Raspberry# IO provides a convenient way to use Raspberry Pi GPIO, while using .NET concepts, syntax and case.
13-
14-
<ul>
15-
<li>Support for both memory (through libBCM2835 library) and file (native) access to GPIO</li>
16-
<li>Support for processor and connector pin addressing</li>
17-
<li>Support aliasing of pins for better customizing</li>
18-
<li>Support both Raspberry B rev1 and rev2 pins mapping, as well as rev2 P5 connector</li>
19-
<li>Easy-of-use, declarative configuration of pins</li>
20-
<li>Support event firing when an input pin status change</li>
21-
<li>Controlled use of resources using a IDisposable component</li>
1+
<h1>Raspberry# IO</h1>
2+
3+
<h2>Introduction</h2>
4+
Raspberry# IO is a .NET/Mono IO Library for Raspberry Pi.
5+
6+
Development is in a preliminary stage, project structure is subject to frequent changes.
7+
Raspberry# IO currently support basic GPIO input/output.
8+
9+
Support for extended IO (such as support for I2C peripherals).
10+
11+
<h2>Features</h2>
12+
Raspberry# IO provides a convenient way to use Raspberry Pi GPIO, while using .NET concepts, syntax and case.
13+
14+
<ul>
15+
<li>Support for both memory (through libBCM2835 library) and file (native) access to GPIO</li>
16+
<li>Support for processor and connector pin addressing</li>
17+
<li>Support aliasing of pins for better customizing</li>
18+
<li>Support both Raspberry B rev1 and rev2 pins mapping, as well as rev2 P5 connector</li>
19+
<li>Easy-of-use, declarative configuration of pins</li>
20+
<li>Support event firing when an input pin status change</li>
21+
<li>Controlled use of resources using a IDisposable component</li>
2222
</ul>

Raspberry.IO.Console/Program.cs

Lines changed: 98 additions & 199 deletions
Original file line numberDiff line numberDiff line change
@@ -1,199 +1,98 @@
1-
<<<<<<< HEAD
2-
using System;
3-
using System.Linq;
4-
using System.Threading;
5-
using Raspberry.IO.GeneralPurpose;
6-
7-
namespace Raspberry.IO.Console
8-
{
9-
class Program
10-
{
11-
private class Status
12-
{
13-
public Connection Connection { get; set; }
14-
public int Current { get; set; }
15-
public bool Descending { get; set; }
16-
}
17-
18-
static void Main(string[] args)
19-
{
20-
var driverName = args.SkipWhile(a => a != "-driver").Skip(1).DefaultIfEmpty("memory").First();
21-
22-
IConnectionDriver driver;
23-
switch(driverName)
24-
{
25-
case "memory":
26-
driver = new ConnectionMemoryDriver();
27-
break;
28-
case "file":
29-
driver = new ConnectionFileDriver();
30-
break;
31-
default:
32-
throw new InvalidOperationException("Unsupported driver");
33-
}
34-
35-
var speed = args.SkipWhile(a => a != "-speed").Skip(1).Select(int.Parse).DefaultIfEmpty(250).First();
36-
37-
var mainboard = Mainboard.Current;
38-
System.Console.WriteLine("Running on Raspberry firmware rev{0}, board rev{1}, processor {2}", mainboard.FirmwareRevision, mainboard.BoardRevision, mainboard.Processor);
39-
System.Console.WriteLine("Using {0} driver, frequency {1:0.##}hz", driverName, 1000.0 / speed);
40-
41-
var pins = new PinConfiguration[]
42-
{
43-
ConnectorPin.P1Pin26.Output().Named("Led1").Active(),
44-
ConnectorPin.P1Pin24.Output().Named("Led2"),
45-
ConnectorPin.P1Pin22.Output().Named("Led3").Active(),
46-
ConnectorPin.P1Pin15.Output().Named("Led4"),
47-
ConnectorPin.P1Pin13.Output().Named("Led5").Active(),
48-
ConnectorPin.P1Pin11.Output().Named("Led6"),
49-
ConnectorPin.P1Pin3.Input().Reversed()
50-
};
51-
52-
using (var connection = new Connection(driver, pins))
53-
{
54-
var status = new Status { Connection = connection };
55-
56-
connection.InputPinChanged += delegate(object sender, PinStatusEventArgs pinStatusEventArgs)
57-
{
58-
System.Console.WriteLine("[{0:HH:mm:ss}] Pin {1}: {2}", DateTime.UtcNow, (int)pinStatusEventArgs.Pin.Pin, pinStatusEventArgs.IsActive);
59-
if (pinStatusEventArgs.IsActive)
60-
status.Descending = !status.Descending;
61-
};
62-
63-
using (new Timer(Animate, status, 0, speed))
64-
System.Console.ReadLine();
65-
}
66-
}
67-
68-
private static void Animate(object state)
69-
{
70-
var status = (Status) state;
71-
72-
var connection = status.Connection;
73-
var i = status.Current;
74-
75-
connection["Led1"] = (i == 0);
76-
connection["Led2"] = (i == 1);
77-
connection["Led3"] = (i == 2);
78-
connection["Led4"] = (i == 3);
79-
connection["Led5"] = (i == 4);
80-
connection["Led6"] = (i == 5);
81-
82-
if (!status.Descending)
83-
status.Current = (i + 1) % 6;
84-
else
85-
status.Current = (6 + (i - 1)) % 6;
86-
87-
/*
88-
connection["Led1"] = (i & 0x1) == 0x1;
89-
connection["Led2"] = (i & 0x20) == 0x20;
90-
connection["Led3"] = (i & 0x4) == 0x4;
91-
connection["Led4"] = (i & 0x10) == 0x10;
92-
connection["Led5"] = (i & 0x8) == 0x8;
93-
connection["Led6"] = (i & 0x40) == 0x40;
94-
95-
status.Current = (i + 1) % 0x40;
96-
*/
97-
}
98-
}
99-
}
100-
=======
101-
using System;
102-
using System.Linq;
103-
using System.Threading;
104-
using Raspberry.IO.GeneralPurpose;
105-
106-
namespace Raspberry.IO.Console
107-
{
108-
class Program
109-
{
110-
private class Status
111-
{
112-
public Connection Connection { get; set; }
113-
public int Current { get; set; }
114-
public bool Descending { get; set; }
115-
}
116-
117-
static void Main(string[] args)
118-
{
119-
var driverName = args.SkipWhile(a => a != "-driver").Skip(1).DefaultIfEmpty("memory").First();
120-
121-
IConnectionDriver driver;
122-
switch(driverName)
123-
{
124-
case "memory":
125-
driver = new ConnectionMemoryDriver();
126-
break;
127-
case "file":
128-
driver = new ConnectionFileDriver();
129-
break;
130-
default:
131-
throw new InvalidOperationException("Unsupported driver");
132-
}
133-
134-
var speed = args.SkipWhile(a => a != "-speed").Skip(1).Select(int.Parse).DefaultIfEmpty(250).First();
135-
136-
var mainboard = Mainboard.Current;
137-
System.Console.WriteLine("Running on Raspberry firmware rev{0}, board rev{1}, processor {2}", mainboard.FirmwareRevision, mainboard.BoardRevision, mainboard.Processor);
138-
System.Console.WriteLine("Using {0} driver, frequency {1:0.##}hz", driverName, 1000.0 / speed);
139-
140-
var pins = new PinConfiguration[]
141-
{
142-
ConnectorPin.P1Pin26.Output().Named("Led1").Active(),
143-
ConnectorPin.P1Pin24.Output().Named("Led2"),
144-
ConnectorPin.P1Pin22.Output().Named("Led3").Active(),
145-
ConnectorPin.P1Pin15.Output().Named("Led4"),
146-
ConnectorPin.P1Pin13.Output().Named("Led5").Active(),
147-
ConnectorPin.P1Pin11.Output().Named("Led6"),
148-
ConnectorPin.P1Pin3.Input().Reversed()
149-
};
150-
151-
using (var connection = new Connection(driver, pins))
152-
{
153-
var status = new Status { Connection = connection };
154-
155-
connection.InputPinChanged += delegate(object sender, PinStatusEventArgs pinStatusEventArgs)
156-
{
157-
System.Console.WriteLine("[{0:HH:mm:ss}] Pin {1}: {2}", DateTime.UtcNow, (int)pinStatusEventArgs.Pin.Pin, pinStatusEventArgs.IsActive);
158-
if (pinStatusEventArgs.IsActive)
159-
status.Descending = !status.Descending;
160-
};
161-
162-
using (new Timer(Animate, status, 0, speed))
163-
System.Console.ReadLine();
164-
}
165-
}
166-
167-
private static void Animate(object state)
168-
{
169-
var status = (Status) state;
170-
171-
var connection = status.Connection;
172-
var i = status.Current;
173-
174-
connection["Led1"] = (i == 0);
175-
connection["Led2"] = (i == 1);
176-
connection["Led3"] = (i == 2);
177-
connection["Led4"] = (i == 3);
178-
connection["Led5"] = (i == 4);
179-
connection["Led6"] = (i == 5);
180-
181-
if (!status.Descending)
182-
status.Current = (i + 1) % 6;
183-
else
184-
status.Current = (6 + (i - 1)) % 6;
185-
186-
/*
187-
connection["Led1"] = (i & 0x1) == 0x1;
188-
connection["Led2"] = (i & 0x20) == 0x20;
189-
connection["Led3"] = (i & 0x4) == 0x4;
190-
connection["Led4"] = (i & 0x10) == 0x10;
191-
connection["Led5"] = (i & 0x8) == 0x8;
192-
connection["Led6"] = (i & 0x40) == 0x40;
193-
194-
status.Current = (i + 1) % 0x40;
195-
*/
196-
}
197-
}
198-
}
199-
>>>>>>> Initial Import
1+
using System;
2+
using System.Linq;
3+
using System.Threading;
4+
using Raspberry.IO.GeneralPurpose;
5+
6+
namespace Raspberry.IO.Console
7+
{
8+
class Program
9+
{
10+
private class Status
11+
{
12+
public Connection Connection { get; set; }
13+
public int Current { get; set; }
14+
public bool Descending { get; set; }
15+
}
16+
17+
static void Main(string[] args)
18+
{
19+
var driverName = args.SkipWhile(a => a != "-driver").Skip(1).DefaultIfEmpty("memory").First();
20+
21+
IConnectionDriver driver;
22+
switch(driverName)
23+
{
24+
case "memory":
25+
driver = new ConnectionMemoryDriver();
26+
break;
27+
case "file":
28+
driver = new ConnectionFileDriver();
29+
break;
30+
default:
31+
throw new InvalidOperationException("Unsupported driver");
32+
}
33+
34+
var speed = args.SkipWhile(a => a != "-speed").Skip(1).Select(int.Parse).DefaultIfEmpty(250).First();
35+
36+
var mainboard = Mainboard.Current;
37+
System.Console.WriteLine("Running on Raspberry firmware rev{0}, board rev{1}, processor {2}", mainboard.FirmwareRevision, mainboard.BoardRevision, mainboard.Processor);
38+
System.Console.WriteLine("Using {0} driver, frequency {1:0.##}hz", driverName, 1000.0 / speed);
39+
40+
var pins = new PinConfiguration[]
41+
{
42+
ConnectorPin.P1Pin26.Output().Named("Led1").Active(),
43+
ConnectorPin.P1Pin24.Output().Named("Led2"),
44+
ConnectorPin.P1Pin22.Output().Named("Led3").Active(),
45+
ConnectorPin.P1Pin15.Output().Named("Led4"),
46+
ConnectorPin.P1Pin13.Output().Named("Led5").Active(),
47+
ConnectorPin.P1Pin11.Output().Named("Led6"),
48+
ConnectorPin.P1Pin3.Input().Reversed()
49+
};
50+
51+
using (var connection = new Connection(driver, pins))
52+
{
53+
var status = new Status { Connection = connection };
54+
55+
connection.InputPinChanged += delegate(object sender, PinStatusEventArgs pinStatusEventArgs)
56+
{
57+
System.Console.WriteLine("[{0:HH:mm:ss}] Pin {1}: {2}", DateTime.UtcNow, (int)pinStatusEventArgs.Pin.Pin, pinStatusEventArgs.IsActive);
58+
if (pinStatusEventArgs.IsActive)
59+
status.Descending = !status.Descending;
60+
};
61+
62+
using (new Timer(Animate, status, 0, speed))
63+
System.Console.ReadLine();
64+
}
65+
}
66+
67+
private static void Animate(object state)
68+
{
69+
var status = (Status) state;
70+
71+
var connection = status.Connection;
72+
var i = status.Current;
73+
74+
connection["Led1"] = (i == 0);
75+
connection["Led2"] = (i == 1);
76+
connection["Led3"] = (i == 2);
77+
connection["Led4"] = (i == 3);
78+
connection["Led5"] = (i == 4);
79+
connection["Led6"] = (i == 5);
80+
81+
if (!status.Descending)
82+
status.Current = (i + 1) % 6;
83+
else
84+
status.Current = (6 + (i - 1)) % 6;
85+
86+
/*
87+
connection["Led1"] = (i & 0x1) == 0x1;
88+
connection["Led2"] = (i & 0x20) == 0x20;
89+
connection["Led3"] = (i & 0x4) == 0x4;
90+
connection["Led4"] = (i & 0x10) == 0x10;
91+
connection["Led5"] = (i & 0x8) == 0x8;
92+
connection["Led6"] = (i & 0x40) == 0x40;
93+
94+
status.Current = (i + 1) % 0x40;
95+
*/
96+
}
97+
}
98+
}

0 commit comments

Comments
 (0)