Skip to content

Commit

Permalink
Merge pull request #87 from WildernessLabs/develop
Browse files Browse the repository at this point in the history
Merge to main for RC3
  • Loading branch information
jorgedevs authored Apr 2, 2023
2 parents 4f28169 + 1456318 commit 4d76b39
Show file tree
Hide file tree
Showing 66 changed files with 1,847 additions and 1,543 deletions.
66 changes: 32 additions & 34 deletions Source/Meadow.Contracts/Channelnfo/AnalogChannelInfo.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
using System;
namespace Meadow.Hardware
namespace Meadow.Hardware;

/// <summary>
/// Information about an analog channel
/// </summary>
public class AnalogChannelInfo : ChannelInfoBase, IAnalogChannelInfo
{
/// <summary>
/// Information about an analog channel
/// Whether or not the channel is capable of reading input (i.e. ADC).
/// </summary>
public class AnalogChannelInfo : ChannelInfoBase, IAnalogChannelInfo
{
/// <summary>
/// Whether or not the channel is capable of reading input (i.e. ADC).
/// </summary>
/// <value><c>true</c> if input capable; otherwise, <c>false</c>.</value>
public bool InputCapable { get; protected set; }
/// <summary>
/// Whether or not the channel is capable of writing output (i.e. DAC).
/// </summary>
/// <value><c>true</c> if output capable; otherwise, <c>false</c>.</value>
public bool OutputCapable { get; protected set; }
/// <summary>
/// Precision (in bits) of the channel
/// </summary>
public byte Precision { get; protected set; }

/// <summary>
/// Create an AnalogChannelInfo instance
/// </summary>
/// <param name="name">The channel name</param>
/// <param name="precision">The precision (in bits) of the channel</param>
/// <param name="inputCapable">Whether or not the channel is ADC capable</param>
/// <param name="outputCapable">Whether or not the channel is DAC capable</param>
public AnalogChannelInfo(string name, byte precision, bool inputCapable, bool outputCapable)
: base (name)
{
this.Precision = precision;
this.InputCapable = inputCapable;
this.OutputCapable = outputCapable;
}
/// <value><c>true</c> if input capable; otherwise, <c>false</c>.</value>
public bool InputCapable { get; protected set; }
/// <summary>
/// Whether or not the channel is capable of writing output (i.e. DAC).
/// </summary>
/// <value><c>true</c> if output capable; otherwise, <c>false</c>.</value>
public bool OutputCapable { get; protected set; }
/// <summary>
/// Precision (in bits) of the channel
/// </summary>
public byte Precision { get; protected set; }

/// <summary>
/// Create an AnalogChannelInfo instance
/// </summary>
/// <param name="name">The channel name</param>
/// <param name="precision">The precision (in bits) of the channel</param>
/// <param name="inputCapable">Whether or not the channel is ADC capable</param>
/// <param name="outputCapable">Whether or not the channel is DAC capable</param>
public AnalogChannelInfo(string name, byte precision, bool inputCapable, bool outputCapable)
: base(name)
{
this.Precision = precision;
this.InputCapable = inputCapable;
this.OutputCapable = outputCapable;
}

}
26 changes: 15 additions & 11 deletions Source/Meadow.Contracts/Channelnfo/CanChannelInfo.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
using System;
namespace Meadow.Hardware
{
public class CanChannelInfo : DigitalChannelInfoBase, ICanChannelInfo
{
public SerialDirectionType SerialDirection { get; protected set; }
namespace Meadow.Hardware;

public CanChannelInfo(string name, SerialDirectionType serialDirection)
: base(name, true, true, true, true, true, false)
{
this.SerialDirection = serialDirection;
}
/// <summary>
/// Information about a Controller Area Network (CanChannelInfo) channel
/// </summary>
public class CanChannelInfo : DigitalChannelInfoBase, ICanChannelInfo
{
/// <summary>
/// Direction
/// </summary>
public SerialDirectionType SerialDirection { get; protected set; }

public CanChannelInfo(string name, SerialDirectionType serialDirection)
: base(name, true, true, true, true, true, false)
{
this.SerialDirection = serialDirection;
}

}
46 changes: 29 additions & 17 deletions Source/Meadow.Contracts/Channelnfo/DigitalChannelInfo.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
using System;
namespace Meadow.Hardware
namespace Meadow.Hardware;

/// <summary>
/// Information about a digital channel's capabilities
/// </summary>
public class DigitalChannelInfo : DigitalChannelInfoBase
{
public class DigitalChannelInfo : DigitalChannelInfoBase
/// <summary>
/// Creates a new DigitalChannelInfo instance
/// </summary>
/// <param name="name"></param>
/// <param name="inputCapable"></param>
/// <param name="outputCapable"></param>
/// <param name="interruptCapable"></param>
/// <param name="pullDownCapable"></param>
/// <param name="pullUpCapable"></param>
/// <param name="inverseLogic"></param>
/// <param name="interruptGroup"></param>
public DigitalChannelInfo(
string name,
bool inputCapable = true,
bool outputCapable = true,
bool interruptCapable = true,
bool pullDownCapable = true,
bool pullUpCapable = true,
bool inverseLogic = false,
int? interruptGroup = null
)
: base(name, inputCapable, outputCapable, interruptCapable,
pullDownCapable, pullUpCapable, inverseLogic, interruptGroup)
{
public DigitalChannelInfo(
string name,
bool inputCapable = true,
bool outputCapable = true,
bool interruptCapable = true,
bool pullDownCapable = true,
bool pullUpCapable = true,
bool inverseLogic = false,
int? interruptGroup = null
)
: base(name, inputCapable, outputCapable, interruptCapable,
pullDownCapable, pullUpCapable, inverseLogic, interruptGroup)
{
}
}
}
81 changes: 52 additions & 29 deletions Source/Meadow.Contracts/Channelnfo/PwmChannelInfo.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,56 @@
 using System;
namespace Meadow.Hardware
namespace Meadow.Hardware;

/// <summary>
/// Information about a Pulse Width Modulation (PWM) channel
/// </summary>
public class PwmChannelInfo : DigitalChannelInfoBase, IPwmChannelInfo
{
public class PwmChannelInfo : DigitalChannelInfoBase, IPwmChannelInfo
{
public float MinimumFrequency { get; protected set; }
public float MaximumFrequency { get; protected set; }
public uint Timer { get; protected set; }
public uint TimerChannel { get; protected set; }
/// <summary>
/// The minimum pulse frequency supported by the channel
/// </summary>
public float MinimumFrequency { get; protected set; }
/// <summary>
/// The maximium pulse frequency supported by the channel
/// </summary>
public float MaximumFrequency { get; protected set; }
/// <summary>
/// Gets the OS system timer number used to drive the PWM
/// </summary>
public uint Timer { get; protected set; }
/// <summary>
/// Gets the OS timer channel used to drive the PWM
/// </summary>
public uint TimerChannel { get; protected set; }

public PwmChannelInfo(string name,
uint timer,
uint timerChannel,
float minimumFrequency = 0,
float maximumFrequency = 100000,
bool pullDownCapable = false, // does this mean anything in PWM?
bool pullUpCapable = false) // ibid
: base(
name,
inputCapable: true,
outputCapable: true,
interruptCapable: false, // ?? i mean, technically, yes, but will we have events?
pullDownCapable: pullDownCapable,
pullUpCapable: pullUpCapable,
inverseLogic: false) //TODO: switch to C# 7.2+ to get rid of trailing names
{
this.Timer = timer;
this.TimerChannel = timerChannel;
this.MinimumFrequency = minimumFrequency;
this.MaximumFrequency = maximumFrequency;
}
/// <summary>
/// Creates a PwmChannelInfo instance
/// </summary>
/// <param name="name"></param>
/// <param name="timer"></param>
/// <param name="timerChannel"></param>
/// <param name="minimumFrequency"></param>
/// <param name="maximumFrequency"></param>
/// <param name="pullDownCapable"></param>
/// <param name="pullUpCapable"></param>
public PwmChannelInfo(string name,
uint timer,
uint timerChannel,
float minimumFrequency = 0,
float maximumFrequency = 100000,
bool pullDownCapable = false, // does this mean anything in PWM?
bool pullUpCapable = false) // ibid
: base(
name,
inputCapable: true,
outputCapable: true,
interruptCapable: false, // ?? i mean, technically, yes, but will we have events?
pullDownCapable: pullDownCapable,
pullUpCapable: pullUpCapable,
inverseLogic: false) //TODO: switch to C# 7.2+ to get rid of trailing names
{
Timer = timer;
TimerChannel = timerChannel;
MinimumFrequency = minimumFrequency;
MaximumFrequency = maximumFrequency;
}
}
39 changes: 19 additions & 20 deletions Source/Meadow.Contracts/Communications/I2cChannelInfo.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
namespace Meadow.Hardware
namespace Meadow.Hardware;

//TODO: what else should this have? allowed speeds?
public class I2cChannelInfo : DigitalChannelInfoBase, II2cChannelInfo
{
//TODO: what else should this have? allowed speeds?
public class I2cChannelInfo : DigitalChannelInfoBase, II2cChannelInfo
{
public I2cChannelFunctionType ChannelFunction { get; protected set; }
public I2cChannelFunctionType ChannelFunction { get; protected set; }

public I2cChannelInfo(string name,
I2cChannelFunctionType channelFunction,
bool pullDownCapable = false,
bool pullUpCapable = false)
: base(
name,
inputCapable: true,
outputCapable: true,
interruptCapable: false, // ?? i mean, technically, yes, but will we have events?
pullDownCapable: pullDownCapable,
pullUpCapable: pullUpCapable,
inverseLogic: false) //TODO: switch to C# 7.2+ to get rid of trailing names
{
this.ChannelFunction = channelFunction;
}
public I2cChannelInfo(string name,
I2cChannelFunctionType channelFunction,
bool pullDownCapable = false,
bool pullUpCapable = false)
: base(
name,
inputCapable: true,
outputCapable: true,
interruptCapable: false, // ?? i mean, technically, yes, but will we have events?
pullDownCapable: pullDownCapable,
pullUpCapable: pullUpCapable,
inverseLogic: false) //TODO: switch to C# 7.2+ to get rid of trailing names
{
this.ChannelFunction = channelFunction;
}
}
37 changes: 18 additions & 19 deletions Source/Meadow.Contracts/Communications/SpiChannelInfo.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
namespace Meadow.Hardware
namespace Meadow.Hardware;

public class SpiChannelInfo : DigitalChannelInfoBase, ISpiChannelInfo
{
public class SpiChannelInfo : DigitalChannelInfoBase, ISpiChannelInfo
{
public SpiLineType LineTypes { get; protected set; }
public SpiLineType LineTypes { get; protected set; }

public SpiChannelInfo(string name,
SpiLineType lineTypes,
bool pullDownCapable = false,
bool pullUpCapable = false)
: base(
name,
inputCapable: true,
outputCapable: true,
interruptCapable: false, // ?? i mean, technically, yes, but will we have events?
pullDownCapable: pullDownCapable,
pullUpCapable: pullUpCapable,
inverseLogic: false) //TODO: switch to C# 7.2+ to get rid of trailing names
{
LineTypes = lineTypes;
}
public SpiChannelInfo(string name,
SpiLineType lineTypes,
bool pullDownCapable = false,
bool pullUpCapable = false)
: base(
name,
inputCapable: true,
outputCapable: true,
interruptCapable: false, // ?? i mean, technically, yes, but will we have events?
pullDownCapable: pullDownCapable,
pullUpCapable: pullUpCapable,
inverseLogic: false) //TODO: switch to C# 7.2+ to get rid of trailing names
{
LineTypes = lineTypes;
}
}
26 changes: 17 additions & 9 deletions Source/Meadow.Contracts/Enums/AntennaType.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
namespace Meadow.Hardware
namespace Meadow.Hardware;

/// <summary>
/// The types of antenna that can be selected.
/// </summary>
public enum AntennaType
{
/// <summary>
/// The types of antenna that can be selected.
/// Unknown
/// </summary>
public enum AntennaType
{
NotKnown = 0,
OnBoard = 1,
External = 2
};
}
NotKnown = 0,
/// <summary>
/// On-board antenna
/// </summary>
OnBoard = 1,
/// <summary>
/// External antenna
/// </summary>
External = 2
};
21 changes: 13 additions & 8 deletions Source/Meadow.Contracts/Enums/ByteOrder.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
namespace Meadow
namespace Meadow;

/// <summary>
/// Describes the byte ordering for muli-byte words.
/// </summary>
public enum ByteOrder
{
/// <summary>
/// Describes the byte ordering for muli-byte words.
/// Little-endian byte ordering
/// </summary>
public enum ByteOrder
{
LittleEndian,
BigEndian
};
}
LittleEndian,
/// <summary>
/// Big-endian byte ordering
/// </summary>
BigEndian
};
Loading

0 comments on commit 4d76b39

Please sign in to comment.