-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding support for more complex App types
- Loading branch information
Showing
4 changed files
with
222 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
namespace Meadow; | ||
|
||
using System; | ||
|
||
|
||
/// <summary> | ||
/// Provides a base implementation for the Meadow App. Use this | ||
/// class for Meadow applications to get strongly-typed access to the current | ||
/// device information. | ||
/// </summary> | ||
public abstract class App<D> : AppBase | ||
where D : class, IMeadowDevice | ||
{ | ||
/// <summary> | ||
/// The root Device interface | ||
/// </summary> | ||
public static D Device { get; protected set; } = default!; | ||
|
||
/// <summary> | ||
/// Base constructor for the App class | ||
/// </summary> | ||
public App() | ||
{ | ||
Device = MeadowOS.CurrentDevice as D ?? throw new ArgumentException($"Current device is not {typeof(D).Name}"); // 'D' is guaranteed to be initialized and the same type | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override void InvokeOnMainThread(Action<object?> action, object? state = null) | ||
{ | ||
switch (Device.Information.Platform) | ||
{ | ||
// ExecutionContext in Mono on the F7 isn't fully working - but we also don't worry about a MainThread there either | ||
case Hardware.MeadowPlatform.F7FeatherV1: | ||
case Hardware.MeadowPlatform.F7FeatherV2: | ||
case Hardware.MeadowPlatform.F7CoreComputeV2: | ||
action.Invoke(state); | ||
break; | ||
default: | ||
base.InvokeOnMainThread(action, state); | ||
break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Meadow; | ||
|
||
/// <summary> | ||
/// Provides a base implementation for the Meadow App. Use this | ||
/// class for Meadow applications to get strongly-typed access to the current | ||
/// device information. | ||
/// </summary> | ||
/// <typeparam name="D">The type of the IMeadowDevice this app targets</typeparam> | ||
/// <typeparam name="P">The type of the IMeadowAppEmbeddedHardwareProvider to create</typeparam> | ||
/// <typeparam name="H">The type of the IMeadowAppEmbeddedHardware the Provider will return</typeparam> | ||
public abstract class App<D, P, H> : AppBase | ||
where D : class, IMeadowDevice | ||
where P : IMeadowAppEmbeddedHardwareProvider<H> | ||
Check failure on line 13 in source/Meadow.Core/Bases/App_D_P_H.cs GitHub Actions / build
|
||
where H : IMeadowAppEmbeddedHardware | ||
Check failure on line 14 in source/Meadow.Core/Bases/App_D_P_H.cs GitHub Actions / build
|
||
{ | ||
/// <summary> | ||
/// The instance if the IMeadowAppEmbeddedHardware on which the stack is running | ||
/// </summary> | ||
public static H Hardware { get; internal set; } = default!; | ||
} |
Oops, something went wrong.