first commit
This commit is contained in:
commit
a5a0434432
1126 changed files with 439481 additions and 0 deletions
31
Software/CSharp/GrovePi/Sensors/RealTimeClock.cs
Normal file
31
Software/CSharp/GrovePi/Sensors/RealTimeClock.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
|
||||
namespace GrovePi.Sensors
|
||||
{
|
||||
public interface IRealTimeClock
|
||||
{
|
||||
byte[] Read();
|
||||
}
|
||||
|
||||
internal class RealTimeClock : IRealTimeClock
|
||||
{
|
||||
private const byte CommandAddress = 30;
|
||||
private readonly GrovePi _device;
|
||||
private readonly Pin _pin;
|
||||
|
||||
internal RealTimeClock(GrovePi device, Pin pin)
|
||||
{
|
||||
if (device == null) throw new ArgumentNullException(nameof(device));
|
||||
_device = device;
|
||||
_pin = pin;
|
||||
}
|
||||
|
||||
public byte[] Read()
|
||||
{
|
||||
var buffer = new[] {CommandAddress, (byte) _pin, Constants.Unused, Constants.Unused};
|
||||
_device.DirectAccess.Write(buffer);
|
||||
_device.DirectAccess.Read(buffer);
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue