Skip to content

Commit

Permalink
Merge pull request #198 from WildernessLabs/v1.9.0
Browse files Browse the repository at this point in the history
Release 1.9.0
  • Loading branch information
jorgedevs authored Feb 27, 2024
2 parents d3ddb7a + 4c3c8c2 commit 3e690a4
Show file tree
Hide file tree
Showing 24 changed files with 508 additions and 46 deletions.
11 changes: 9 additions & 2 deletions Source/Meadow.Contracts/Enums/WakeSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@
/// </summary>
public enum WakeSource
{
/// <summary>
/// The reason for wake in undetermined.
/// </summary>
/// <remarks>
/// This is typically only returned when the device has never been in sleep mode
/// </remarks>
Unknown = 0,
/// <summary>
/// The device has resumed due to an elapsed timer
/// </summary>
Timer,
Timer = 1,
/// <summary>
/// The device has resumed due to an interrupt
/// </summary>
Interrupt
Interrupt = 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public interface IPinDefinitions : IEnumerable<IPin>
/// <summary>
/// Retrieves a pin from <see cref="AllPins"/> by Name or Key
/// </summary>
IPin this[string name]
public IPin this[string name]
{
get => AllPins.FirstOrDefault(p =>
string.Compare(p.Name, name, true) == 0
Expand Down
2 changes: 1 addition & 1 deletion Source/Meadow.Contracts/Hardware/DigitalPortResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public DigitalPortResult(DigitalState newState, DigitalState? oldState)
/// </summary>
public TimeSpan? Delta
{
get => New.Time - Old?.Time;
get => TimeSpan.FromMilliseconds(New.Time - Old?.Time ?? 0);
}
}
}
7 changes: 3 additions & 4 deletions Source/Meadow.Contracts/Hardware/DigitalState.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
namespace Meadow.Hardware
namespace Meadow.Hardware
{
/// <summary>
/// Represents a snapshot of the state of a digital port at a given time.
Expand All @@ -14,14 +13,14 @@ public struct DigitalState
/// <summary>
/// The time at the event or notification.
/// </summary>
public DateTime Time { get; set; }
public int Time { get; set; }

/// <summary>
/// Creates an instance of a DigitalState
/// </summary>
/// <param name="state"></param>
/// <param name="time"></param>
public DigitalState(bool state, DateTime time)
public DigitalState(bool state, int time)
{
State = state;
Time = time;
Expand Down
3 changes: 2 additions & 1 deletion Source/Meadow.Contracts/Hardware/IMeadowDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public interface IMeadowDevice :
/// <summary>
/// Method called by the Core stack to initialize the IMeadowDevice
/// </summary>
void Initialize();
/// <param name="detectedPlatform">The MeadowPlatform that core detected the application is running on</param>
void Initialize(MeadowPlatform detectedPlatform);

/// <summary>
/// Retrieves battery info about the current IMeadowDevice
Expand Down
47 changes: 27 additions & 20 deletions Source/Meadow.Contracts/Hardware/INtpClient.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
using System;
using System.Threading.Tasks;

namespace Meadow
namespace Meadow;

/// <summary>
/// Delegate representing a time changed event handler.
/// </summary>
/// <param name="utcTime">The updated UTC time.</param>
public delegate void TimeChangedEventHandler(DateTime utcTime);

/// <summary>
/// Interface for a Network Time Protocol (NTP) client object.
/// </summary>
public interface INtpClient
{
/// <summary>
/// Delegate representing a time changed event handler.
/// Event called when the time is changed.
/// </summary>
/// <param name="utcTime">The updated UTC time.</param>
public delegate void TimeChangedEventHandler(DateTime utcTime);
event TimeChangedEventHandler TimeChanged;

/// <summary>
/// Interface for a Network Time Protocol (NTP) client object.
/// Gets a value indicating whether the NTP client is enabled.
/// </summary>
public interface INtpClient
{
/// <summary>
/// Event called when the time is changed.
/// </summary>
event TimeChangedEventHandler TimeChanged;
bool Enabled { get; }

/// <summary>
/// Gets a value indicating whether the NTP client is enabled.
/// </summary>
bool Enabled { get; }
/// <summary>
/// Gets or sets the poll period for NTP synchronization.
/// </summary>
TimeSpan PollPeriod { get; set; }

/// <summary>
/// Gets or sets the poll period for NTP synchronization.
/// </summary>
TimeSpan PollPeriod { get; set; }
}
/// <summary>
/// Start an NTP time synchronization
/// </summary>
/// <param name="ntpServer">An optional NTP server address. If null, the device will use the platform-configured NTP server address</param>
/// <returns><b>true</b> if successful, otherwise <b>false</b></returns>
Task<bool> Synchronize(string? ntpServer = null);
}
2 changes: 1 addition & 1 deletion Source/Meadow.Contracts/Hardware/IPowerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface IPowerController
/// <summary>
/// Event called after waking from sleep mode.
/// </summary>
event PowerTransitionHandler AfterWake;
event EventHandler<WakeSource> AfterWake;

/// <summary>
/// Resets the device.
Expand Down
16 changes: 13 additions & 3 deletions Source/Meadow.Contracts/Hardware/MeadowPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ public enum MeadowPlatform
F7CoreComputeV2 = 3,

/// <summary>
/// Meadow for Linux
/// Meadow on an embedded Linux platform
/// </summary>
MeadowForLinux,
EmbeddedLinux,

/// <summary>
/// Meadow on a desktop Linux platform
/// </summary>
DesktopLinux,

/// <summary>
/// Meadow Simulation Platform
Expand All @@ -38,6 +43,11 @@ public enum MeadowPlatform
/// <summary>
/// Windows Host OS
/// </summary>
Windows
Windows,

/// <summary>
/// OSX Host OS
/// </summary>
OSX,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Net;

namespace Meadow.Hardware;

/// <summary>
/// Data relating to a Ethernet connection.
/// </summary>
public class EthernetNetworkConnectionEventArgs : NetworkConnectionEventArgs
{
/// <summary>
/// Construct a EthernetNetworkConnectionEventArgs request.
/// </summary>
/// <param name="ipAddress">IP address of the device.</param>
/// <param name="subnet">Subnet of the device.</param>
/// <param name="gateway">Gateway address of the device.</param>
public EthernetNetworkConnectionEventArgs(IPAddress ipAddress, IPAddress subnet, IPAddress gateway)
: base(ipAddress, subnet, gateway)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ namespace Meadow.Hardware;
/// Delegate containing information about a network disconnection event
/// </summary>
/// <param name="sender"></param>
public delegate void NetworkDisconnectionHandler(INetworkAdapter sender);
/// <param name="args"></param>
public delegate void NetworkDisconnectionHandler(INetworkAdapter sender, NetworkDisconnectionEventArgs args);

/// <summary>
/// Delegate containing information about a network error event.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;

namespace Meadow.Hardware;

/// <summary>
/// Data relating to a WiFi disconnect event.
/// </summary>
public class NetworkDisconnectionEventArgs : EventArgs
{
/// <summary>
/// Date and time the event was generated.
/// </summary>
public DateTime When { get; private set; }

/// <summary>
/// Disconnect reason
/// </summary>
public string Reason { get; }

/// <summary>
/// Construct a NetworkDisconnectionEventArgs object.
/// </summary>
public NetworkDisconnectionEventArgs(string reason)
{
When = DateTime.UtcNow;
Reason = reason;
}
}
2 changes: 0 additions & 2 deletions Source/Meadow.Contracts/ISleepAwarePeripheral.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ public interface ISleepAwarePeripheral
/// Called before the platform goes into Sleep state
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public Task BeforeSleep(CancellationToken cancellationToken);

/// <summary>
/// Called after the platform returns to Wake state
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public Task AfterWake(CancellationToken cancellationToken);
}
6 changes: 3 additions & 3 deletions Source/Meadow.Contracts/Meadow.Contracts.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Meadow.Sdk/1.1.0">
<PropertyGroup>
<Version>1.8.0</Version>
<Version>1.9.0</Version>
<TargetFramework>netstandard2.1</TargetFramework>
<OutputType>Library</OutputType>
<AssemblyName>Meadow.Contracts</AssemblyName>
Expand All @@ -26,7 +26,7 @@
<None Include="icon.png" Link="icon.png" Pack="true" PackagePath="" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Meadow.Logging" Version="1.8.0" />
<PackageReference Include="Meadow.Units" Version="1.8.0" />
<PackageReference Include="Meadow.Logging" Version="1.9.0" />
<PackageReference Include="Meadow.Units" Version="1.9.0" />
</ItemGroup>
</Project>
63 changes: 63 additions & 0 deletions Source/Meadow.Contracts/Peripherals/Displays/ColorMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;

namespace Meadow.Peripherals.Displays;

/// <summary>
/// Enum for Display color mode, defines bit depth and RGB order
/// </summary>
[Flags]
public enum ColorMode : int
{
/// <summary>
/// 1-bit color
/// </summary>
Format1bpp = 1 << 0,
/// <summary>
/// 2-bit color
/// </summary>
Format2bpp = 1 << 1,
/// <summary>
/// 4-bit grayscale
/// </summary>
Format4bppGray = 1 << 2,
/// <summary>
/// 4-bit grayscale
/// </summary>
Format4bppIndexed = 1 << 3,
/// <summary>
/// 8-bit grayscale
/// </summary>
Format8bppGray = 1 << 4,
/// <summary>
/// 8-bit color
/// </summary>
Format8bppRgb332 = 1 << 5,
/// <summary>
/// 12-bit color
/// </summary>
Format12bppRgb444 = 1 << 6,
/// <summary>
/// 15-bit color
/// </summary>
Format16bppRgb555 = 1 << 7,
/// <summary>
/// 16-bit color
/// </summary>
Format16bppRgb565 = 1 << 8,
/// <summary>
/// 18-bit color
/// </summary>
Format18bppRgb666 = 1 << 9,
/// <summary>
/// 24-bit color
/// </summary>
Format24bppRgb888 = 1 << 10,
/// <summary>
/// 24-bit color
/// </summary>
Format24bppGrb888 = 1 << 11,
/// <summary>
/// 32-bit color
/// </summary>
Format32bppRgba8888 = 1 << 12,
}
Loading

0 comments on commit 3e690a4

Please sign in to comment.