Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #45

Merged
merged 4 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/Juego/Juego.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private Juego() { }

try
{
logger?.Info("Intantiating version MCP23008");
logger?.Info("Instantiating version MCP23008");
mcpVersion = new Mcp23008(i2cBus, address: 0x23);
version = mcpVersion.ReadFromPorts();
}
Expand Down
25 changes: 14 additions & 11 deletions Source/Juego/JuegoHardwareV1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public class JuegoHardwareV1 : IJuegoHardware
protected IF7FeatherMeadowDevice Device { get; }

/// <inheritdoc/>
public IGraphicsDisplay Display { get; }
public IGraphicsDisplay? Display { get; }

/// <inheritdoc/>
protected ISpiBus SpiBus { get; }
protected ISpiBus? SpiBus { get; }

/// <inheritdoc/>
public AnalogJoystick? AnalogJoystick { get; protected set; }
Expand Down Expand Up @@ -60,10 +60,10 @@ public class JuegoHardwareV1 : IJuegoHardware
public Bmi270? MotionSensor => null;

/// <inheritdoc/>
public DisplayConnector DisplayHeader => (DisplayConnector)Connectors[0];
public DisplayConnector DisplayHeader => (DisplayConnector)Connectors[0]!;

/// <inheritdoc/>
public I2cConnector Qwiic => null;
public I2cConnector? Qwiic => null;


/// <summary>
Expand Down Expand Up @@ -126,13 +126,16 @@ public JuegoHardwareV1(IF7FeatherMeadowDevice device)
var dcPort = Device.CreateDigitalOutputPort(Device.Pins.D04);
var resetPort = Device.CreateDigitalOutputPort(Device.Pins.D14);

Display = new St7789(
spiBus: SpiBus,
chipSelectPort: chipSelectPort,
dataCommandPort: dcPort,
resetPort: resetPort,
width: 240, height: 240);
Resolver.Log.Info("Display initialized");
if (SpiBus != null)
{
Display = new St7789(
spiBus: SpiBus,
chipSelectPort: chipSelectPort,
dataCommandPort: dcPort,
resetPort: resetPort,
width: 240, height: 240);
Resolver.Log.Info("Display initialized");
}

Right_UpButton = new PushButton(device.Pins.D06, ResistorMode.InternalPullDown);
Right_DownButton = new PushButton(device.Pins.D05, ResistorMode.InternalPullDown);
Expand Down
43 changes: 25 additions & 18 deletions Source/Juego/JuegoHardwareV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ public class JuegoHardwareV2 : IJuegoHardware
/// <inheritdoc/>
protected IF7CoreComputeMeadowDevice Device { get; }
/// <inheritdoc/>
protected IDigitalInterruptPort McpInterrupt_1 { get; }
protected IDigitalInterruptPort? McpInterrupt_1 { get; }
/// <inheritdoc/>
protected IDigitalInterruptPort McpInterrupt_2 { get; }
protected IDigitalInterruptPort? McpInterrupt_2 { get; }
/// <inheritdoc/>
protected IDigitalOutputPort Mcp_Reset { get; }
protected IDigitalOutputPort? Mcp_Reset { get; }
/// <inheritdoc/>
public IGraphicsDisplay Display { get; }
public IGraphicsDisplay? Display { get; }
/// <inheritdoc/>
public IDigitalOutputPort DisplayBacklightPort { get; }
public IDigitalOutputPort? DisplayBacklightPort { get; }
/// <inheritdoc/>
protected II2cBus I2cBus { get; }
/// <inheritdoc/>
protected ISpiBus SpiBus { get; }
protected ISpiBus? SpiBus { get; }
/// <inheritdoc/>
public Mcp23008 Mcp_1 { get; protected set; }
public Mcp23008? Mcp_1 { get; protected set; }
/// <inheritdoc/>
public Mcp23008 Mcp_2 { get; protected set; }
public Mcp23008? Mcp_2 { get; protected set; }
/// <inheritdoc/>
public Mcp23008 Mcp_VersionInfo { get; set; }
public Mcp23008? Mcp_VersionInfo { get; set; }
/// <inheritdoc/>
public PushButton? Right_UpButton { get; protected set; }
/// <inheritdoc/>
Expand Down Expand Up @@ -70,7 +70,7 @@ public class JuegoHardwareV2 : IJuegoHardware
public Bmi270? MotionSensor => null;

/// <inheritdoc/>
public DisplayConnector DisplayHeader => (DisplayConnector)Connectors[0];
public DisplayConnector DisplayHeader => (DisplayConnector)Connectors[0]!;

/// <inheritdoc/>
public I2cConnector? Qwiic => null;
Expand Down Expand Up @@ -174,19 +174,21 @@ public JuegoHardwareV2(IF7CoreComputeMeadowDevice device, II2cBus i2cBus)

Thread.Sleep(50);

Display = new Ili9341(
if (SpiBus != null)
{
Display = new Ili9341(
spiBus: SpiBus,
chipSelectPort: chipSelectPort,
dataCommandPort: dcPort,
resetPort: resetPort,
width: 240, height: 320)
{
SpiBusSpeed = new Frequency(48000, Frequency.UnitType.Kilohertz),
};
{
SpiBusSpeed = new Frequency(48000, Frequency.UnitType.Kilohertz),
};
((Ili9341)Display).SetRotation(RotationType._270Degrees);

((Ili9341)Display).SetRotation(RotationType._270Degrees);

Resolver.Log.Info("Display initialized");
Resolver.Log.Info("Display initialized");
}
}

if (Mcp_1 != null)
Expand Down Expand Up @@ -219,10 +221,15 @@ public JuegoHardwareV2(IF7CoreComputeMeadowDevice device, II2cBus i2cBus)
SelectButton = new PushButton(selectPort);
}
}
internal DisplayConnector CreateDisplayConnector()
internal DisplayConnector? CreateDisplayConnector()
{
Resolver.Log.Trace("Creating display connector");

if (Mcp_1 == null)
{
return null;
}

return new DisplayConnector(
"Display",
new PinMapping
Expand Down
52 changes: 30 additions & 22 deletions Source/Juego/JuegoHardwareV3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@
/// <inheritdoc/>
protected IF7CoreComputeMeadowDevice Device { get; }
/// <inheritdoc/>
protected IDigitalInterruptPort McpInterrupt_1 { get; }
protected IDigitalInterruptPort? McpInterrupt_1 { get; }
/// <inheritdoc/>
protected IDigitalInterruptPort McpInterrupt_2 { get; }
protected IDigitalInterruptPort? McpInterrupt_2 { get; }
/// <inheritdoc/>
protected IDigitalOutputPort Mcp_Reset { get; }
protected IDigitalOutputPort? Mcp_Reset { get; }
/// <inheritdoc/>
public IGraphicsDisplay Display { get; }
public IGraphicsDisplay? Display { get; }
/// <inheritdoc/>
public IDigitalOutputPort DisplayBacklightPort { get; }
public IDigitalOutputPort? DisplayBacklightPort { get; }
/// <inheritdoc/>
protected II2cBus I2cBus { get; }
/// <inheritdoc/>
protected ISpiBus SpiBus { get; }
protected ISpiBus? SpiBus { get; }
/// <inheritdoc/>
public Mcp23008 Mcp_1 { get; protected set; }
public Mcp23008? Mcp_1 { get; protected set; }
/// <inheritdoc/>
public Mcp23008 Mcp_2 { get; protected set; }
public Mcp23008? Mcp_2 { get; protected set; }
/// <inheritdoc/>
public Mcp23008 Mcp_VersionInfo { get; set; }
public Mcp23008? Mcp_VersionInfo { get; set; }
/// <inheritdoc/>
public PushButton? Right_UpButton { get; protected set; }
/// <inheritdoc/>
Expand Down Expand Up @@ -75,10 +75,10 @@
public Bmi270? MotionSensor { get; protected set; }

/// <inheritdoc/>
public DisplayConnector DisplayHeader => (DisplayConnector)Connectors[0];
public DisplayConnector DisplayHeader => (DisplayConnector)Connectors[0]!;

Check warning on line 78 in Source/Juego/JuegoHardwareV3.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.

Check warning on line 78 in Source/Juego/JuegoHardwareV3.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

/// <inheritdoc/>
public I2cConnector? Qwiic => (I2cConnector)Connectors[1];
public I2cConnector? Qwiic => (I2cConnector?)Connectors[1];

Check warning on line 81 in Source/Juego/JuegoHardwareV3.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.

/// <summary>
/// Collection of connectors on the Juego board
Expand All @@ -103,7 +103,7 @@
/// <summary>
/// Create a new Juego hardware v3 object
/// </summary>
public JuegoHardwareV3(IF7CoreComputeMeadowDevice device, II2cBus i2cBus)

Check warning on line 106 in Source/Juego/JuegoHardwareV3.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'McpInterrupt_1' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
{
Device = device;
I2cBus = i2cBus;
Expand Down Expand Up @@ -163,19 +163,22 @@

Thread.Sleep(50);

Display = new Ili9341(
spiBus: SpiBus,
chipSelectPort: chipSelectPort,
dataCommandPort: dcPort,
resetPort: resetPort,
width: 240, height: 320)
if (SpiBus != null)
{

Check warning on line 167 in Source/Juego/JuegoHardwareV3.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'spiBus' in 'Ili9341.Ili9341(ISpiBus spiBus, IDigitalOutputPort chipSelectPort, IDigitalOutputPort dataCommandPort, IDigitalOutputPort resetPort, int width, int height, ColorMode colorMode = ColorMode.Format12bppRgb444)'.
SpiBusSpeed = new Frequency(48000, Frequency.UnitType.Kilohertz),
};
Display = new Ili9341(
spiBus: SpiBus,
chipSelectPort: chipSelectPort,
dataCommandPort: dcPort,
resetPort: resetPort,
width: 240, height: 320)
{
SpiBusSpeed = new Frequency(48000, Frequency.UnitType.Kilohertz),
};

((Ili9341)Display).SetRotation(RotationType._270Degrees);
((Ili9341)Display).SetRotation(RotationType._270Degrees);

Resolver.Log.Info("Display initialized");
Resolver.Log.Info("Display initialized");
}
}

try
Expand Down Expand Up @@ -220,10 +223,15 @@
}
}

internal DisplayConnector CreateDisplayConnector()
internal DisplayConnector? CreateDisplayConnector()
{
Resolver.Log.Trace("Creating display connector");

if (Mcp_1 == null)
{
return null;
}

return new DisplayConnector(
"Display",
new PinMapping
Expand Down
8 changes: 0 additions & 8 deletions Source/Juego_Prototype/Apps/Clock/Clock.Renderer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Meadow;
using Meadow.Foundation;
using Meadow.Foundation.Displays.UI;
using Meadow.Foundation.Graphics;
using System;
Expand Down Expand Up @@ -32,16 +31,9 @@
InitMenu(gl);

return;

gl.Clear();
gl.DrawText(0, 0, "Meadow Clock");
gl.DrawText(0, 16, "v0.1.0");
gl.Show();

Thread.Sleep(500);
}

public void Update(IIOConfig ioConfig)

Check warning on line 36 in Source/Juego_Prototype/Apps/Clock/Clock.Renderer.cs

View workflow job for this annotation

GitHub Actions / build

Unreachable code detected
{
var gl = ioConfig.Graphics;

Expand Down
8 changes: 0 additions & 8 deletions Source/Juego_Prototype/Games/Lander/LanderGame.Art.cs

This file was deleted.

80 changes: 0 additions & 80 deletions Source/Juego_Prototype/Games/Lander/LanderGame.Renderer.cs

This file was deleted.

Loading
Loading