diff --git a/.github/workflows/develop-ci.yml b/.github/workflows/develop-ci.yml
index 30456a6..5a88e6a 100644
--- a/.github/workflows/develop-ci.yml
+++ b/.github/workflows/develop-ci.yml
@@ -3,7 +3,6 @@ name: Develop Build
on:
workflow_dispatch:
pull_request:
- push:
branches: [ develop ]
jobs:
@@ -65,7 +64,6 @@ jobs:
uses: actions/checkout@v3
with:
path: Juego
- ref: develop
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
diff --git a/.github/workflows/main-ci.yml b/.github/workflows/main-ci.yml
index 955bcfa..8f3f4f1 100644
--- a/.github/workflows/main-ci.yml
+++ b/.github/workflows/main-ci.yml
@@ -3,6 +3,7 @@ name: Main Build
on:
workflow_dispatch:
pull_request:
+ push:
branches: [ main ]
jobs:
@@ -16,6 +17,7 @@ jobs:
uses: actions/checkout@v3
with:
path: Juego
+ ref: main
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
diff --git a/Source/Juego/Juego.cs b/Source/Juego/Juego.cs
index f8687e9..7ddb663 100644
--- a/Source/Juego/Juego.cs
+++ b/Source/Juego/Juego.cs
@@ -1,6 +1,7 @@
using Meadow;
using Meadow.Foundation.Audio;
using Meadow.Foundation.ICs.IOExpanders;
+using Meadow.Hardware;
using Meadow.Logging;
using System;
@@ -18,7 +19,7 @@ private Juego() { }
///
public static IJuegoHardware? Create()
{
- IJuegoHardware? hardware;
+ IJuegoHardware? hardware = null;
Logger? logger = Resolver.Log;
logger?.Debug("Initializing Juego...");
@@ -40,23 +41,52 @@ private Juego() { }
}
else if (device is IF7CoreComputeMeadowDevice { } ccm)
{
+ II2cBus i2cBus;
+ Mcp23008? mcpVersion = null;
+ byte version = 0;
+
+ PiezoSpeaker? leftSpeaker = null;
+ PiezoSpeaker? rightSpeaker = null;
+
try
{
+ logger?.Info("Instantiating speakers");
// hack for PWM init bug .... move back into the hardware classes once it's fixed
- var leftSpeaker = new PiezoSpeaker(ccm.Pins.PB8);
- var rightSpeaker = new PiezoSpeaker(ccm.Pins.PB9);
-
- var i2cBus = ccm.CreateI2cBus(busSpeed: Meadow.Hardware.I2cBusSpeed.FastPlus);
- logger?.Info("I2C Bus instantiated");
-
- var mcpVersion = new Mcp23008(i2cBus, address: 0x23);
+ leftSpeaker = new PiezoSpeaker(ccm.Pins.PB8);
+ rightSpeaker = new PiezoSpeaker(ccm.Pins.PB9);
+ }
+ catch
+ {
+ logger?.Info("Failed to instantiate speakers");
+ }
- logger?.Trace("McpVersion up");
- var version = mcpVersion.ReadFromPorts();
+ try
+ {
+ logger?.Info("Intantiating I2C Bus");
+ i2cBus = ccm.CreateI2cBus(busSpeed: I2cBusSpeed.FastPlus);
+ }
+ catch
+ {
+ logger?.Info("Failed to instantiate I2C Bus");
+ logger?.Info("Cannot instantiate Juego hardware");
+ return null;
+ }
- logger?.Info($"Hardware version is {version}");
+ try
+ {
+ logger?.Info("Intantiating version MCP23008");
+ mcpVersion = new Mcp23008(i2cBus, address: 0x23);
+ version = mcpVersion.ReadFromPorts();
+ }
+ catch
+ {
+ logger?.Info("Failed to instantiate version MCP23008");
+ }
- if (version >= JuegoHardwareV3.MinimumHardareVersion)
+ try
+ {
+ if (mcpVersion != null &&
+ version >= JuegoHardwareV3.MinimumHardareVersion)
{
logger?.Info("Instantiating Juego v3 hardware");
hardware = new JuegoHardwareV3(ccm, i2cBus)
@@ -71,22 +101,17 @@ private Juego() { }
logger?.Info("Instantiating Juego v2 hardware");
hardware = new JuegoHardwareV2(ccm, i2cBus)
{
- Mcp_VersionInfo = mcpVersion,
+ Mcp_VersionInfo = mcpVersion!,
LeftSpeaker = leftSpeaker,
RightSpeaker = rightSpeaker,
};
}
}
- catch (Exception e)
+ catch
{
- logger?.Debug($"Failed to create McpVersion: {e.Message}");
- hardware = null;
+ logger?.Info("Failed to instantiate Juego hardware");
}
}
- else
- {
- throw new NotSupportedException();
- }
return hardware;
}
diff --git a/Source/Juego/Juego.csproj b/Source/Juego/Juego.csproj
index f7b4097..3e6d1b1 100644
--- a/Source/Juego/Juego.csproj
+++ b/Source/Juego/Juego.csproj
@@ -11,7 +11,7 @@
Meadow.Juego
https://github.com/WildernessLabs/Meadow.ProjectLab
Meadow.Juego, Meadow, Juego
- 0.96.0
+ 1.7.0
true
Convenience library for the Meadow Juego family of boards
enable
@@ -24,10 +24,10 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/Source/Juego/JuegoHardwareV3.cs b/Source/Juego/JuegoHardwareV3.cs
index 9d8b030..feddc66 100644
--- a/Source/Juego/JuegoHardwareV3.cs
+++ b/Source/Juego/JuegoHardwareV3.cs
@@ -110,37 +110,6 @@ public JuegoHardwareV3(IF7CoreComputeMeadowDevice device, II2cBus i2cBus)
Resolver.Log.Info("Initialize hardware...");
- // DEV NOTE: **ALWAYS** Set up PWMs first - Nuttx PWM driver will step on pin configs otherwise
- /* try // code left intentionally, restore once the PWM bug is fixed
- {
- LeftSpeaker = new PiezoSpeaker(device.Pins.PB8); //D03
- }
- catch (Exception e)
- {
- Resolver.Log.Error($"Err Left Speaker: {e.Message}");
- }
-
- try
- {
- RightSpeaker = new PiezoSpeaker(device.Pins.PB9); //D04
- }
- catch (Exception e)
- {
- Resolver.Log.Error($"Err Right Speaker: {e.Message}");
- } */
-
- /*
- try
- {
- I2cBus = Device.CreateI2cBus(busSpeed: I2cBusSpeed.FastPlus);
- Resolver.Log.Info("I2C initialized");
- }
- catch (Exception e)
- {
- Resolver.Log.Error($"Err initializing I2C Bus: {e.Message}");
- }
- */
-
try
{
Mcp_Reset = Device.CreateDigitalOutputPort(Device.Pins.PA10, true);
diff --git a/Source/Juego_Demo/DisplayController.cs b/Source/Juego_Demo/DisplayController.cs
index 2a32630..8dea4c9 100644
--- a/Source/Juego_Demo/DisplayController.cs
+++ b/Source/Juego_Demo/DisplayController.cs
@@ -1,4 +1,5 @@
-using Meadow.Foundation;
+using Meadow;
+using Meadow.Foundation;
using Meadow.Foundation.Graphics;
using Meadow.Units;
diff --git a/Source/Juego_Demo/MeadowApp.cs b/Source/Juego_Demo/MeadowApp.cs
index 9a923fa..5d13936 100644
--- a/Source/Juego_Demo/MeadowApp.cs
+++ b/Source/Juego_Demo/MeadowApp.cs
@@ -20,6 +20,11 @@ public override Task Initialize()
juego = Juego.Create();
+ if (juego == null)
+ {
+ return Task.FromException(new Exception("Juego hardware not found"));
+ }
+
if (juego.Display is { } display)
{
displayController = new DisplayController(display);
diff --git a/Source/Juego_Prototype/Games/Lander/LanderGame.Renderer.cs b/Source/Juego_Prototype/Games/Lander/LanderGame.Renderer.cs
index 4953257..b6cea15 100644
--- a/Source/Juego_Prototype/Games/Lander/LanderGame.Renderer.cs
+++ b/Source/Juego_Prototype/Games/Lander/LanderGame.Renderer.cs
@@ -1,6 +1,4 @@
-using System;
-using Meadow.Foundation;
-using Meadow.Foundation.Audio;
+using Meadow;
using Meadow.Foundation.Graphics;
namespace Juego.Games
@@ -9,7 +7,7 @@ public partial class LanderGame
{
readonly byte cellSize = 8;
- DrawPixelDel DrawPixel;
+ readonly DrawPixelDel DrawPixel;
public void Init(MicroGraphics gl)
{
@@ -34,7 +32,7 @@ public void Update(IIOConfig ioConfig)
void DrawBackground(MicroGraphics graphics)
{
-
+
}
void DrawLives(MicroGraphics graphics)
@@ -46,7 +44,7 @@ void DrawLives(MicroGraphics graphics)
void DrawPixel1x(int x, int y, bool colored, MicroGraphics graphics, Color color)
{
- graphics.DrawPixel(x, y, colored?color:Color.Black);
+ graphics.DrawPixel(x, y, colored ? color : Color.Black);
}
void DrawPixel2x(int x, int y, bool colored, MicroGraphics graphics)
diff --git a/Source/Juego_Prototype/Juego_Prototype.csproj b/Source/Juego_Prototype/Juego_Prototype.csproj
index bb962e4..2f8fd19 100644
--- a/Source/Juego_Prototype/Juego_Prototype.csproj
+++ b/Source/Juego_Prototype/Juego_Prototype.csproj
@@ -16,12 +16,12 @@
-
-
-
-
-
-
+
+
+
+
+
+