Skip to content

Commit

Permalink
Merge pull request #6 from WildernessLabs/develop
Browse files Browse the repository at this point in the history
Update to RC1
  • Loading branch information
adrianstevens authored Nov 3, 2022
2 parents 05eb685 + 730efd9 commit 359465b
Show file tree
Hide file tree
Showing 28 changed files with 473 additions and 138 deletions.
36 changes: 25 additions & 11 deletions Source/C16x9/Driver/C16x9.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ public class C16x9 : IGraphicsDisplay

readonly IDigitalOutputPort onOffPort;

readonly IDisplayBuffer displayBuffer;
/// <summary>
/// The buffer to hold the display data
/// </summary>
public IPixelBuffer PixelBuffer { get; protected set; }

/// <summary>
/// Color mode of display
Expand Down Expand Up @@ -70,7 +73,7 @@ public C16x9(IDigitalOutputPort onOffPort, II2cBus i2cBus, byte address = (byte)
iS31FL3731 = new Is31fl3731(i2cBus, address);
iS31FL3731.Initialize();

displayBuffer = new BufferGray8(Width, Height);
PixelBuffer = new BufferGray8(Width, Height);

//enable the display
this.onOffPort.State = true;
Expand Down Expand Up @@ -100,7 +103,7 @@ public C16x9(IMeadowDevice device, IPin onOffPin, II2cBus i2cBus) :
/// <param name="updateDisplay"></param>
public void Clear(bool updateDisplay = false)
{
displayBuffer.Clear();
PixelBuffer.Clear();

if (updateDisplay == true)
{
Expand All @@ -122,7 +125,7 @@ public void DrawPixel(int x, int y, Color color)
{ return; }
}

displayBuffer.SetPixel(x, y, color);
PixelBuffer.SetPixel(x, y, color);
}

/// <summary>
Expand All @@ -143,9 +146,9 @@ public void DrawPixel(int x, int y, bool colored)
/// <param name="y">y location in pixels</param>
public void InvertPixel(int x, int y)
{
var brightness = 255 - displayBuffer.GetPixel(x, y).Color8bppGray;
var brightness = 255 - PixelBuffer.GetPixel(x, y).Color8bppGray;

displayBuffer.SetPixel(x, y, new Color(brightness, brightness, brightness));
PixelBuffer.SetPixel(x, y, new Color(brightness, brightness, brightness));
}

/// <summary>
Expand All @@ -154,9 +157,9 @@ public void InvertPixel(int x, int y)
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="displayBuffer"></param>
public void DrawBuffer(int x, int y, IDisplayBuffer displayBuffer)
public void DrawBuffer(int x, int y, IPixelBuffer displayBuffer)
{
this.displayBuffer.WriteBuffer(x, y, displayBuffer);
this.PixelBuffer.WriteBuffer(x, y, displayBuffer);
}

/// <summary>
Expand All @@ -166,7 +169,7 @@ public void DrawBuffer(int x, int y, IDisplayBuffer displayBuffer)
/// <param name="updateDisplay"></param>
public void Fill(Color clearColor, bool updateDisplay = false)
{
displayBuffer.Fill(clearColor);
PixelBuffer.Fill(clearColor);

if(updateDisplay)
{
Expand All @@ -184,7 +187,7 @@ public void Fill(Color clearColor, bool updateDisplay = false)
/// <param name="fillColor"></param>
public void Fill(int x, int y, int width, int height, Color fillColor)
{
displayBuffer.Fill(fillColor, x, y, width, height);
PixelBuffer.Fill(x, y, width, height, fillColor);
}

/// <summary>
Expand All @@ -199,7 +202,7 @@ public void Show()
{
for(int y = 0; y < Height; y++)
{
iS31FL3731.SetLedPwm(frame, (byte)(x + y * Width), displayBuffer.GetPixel(x, y).Color8bppGray);
iS31FL3731.SetLedPwm(frame, (byte)(x + y * Width), PixelBuffer.GetPixel(x, y).Color8bppGray);
}
}

Expand All @@ -226,5 +229,16 @@ public void Show(byte frame)
{
iS31FL3731.DisplayFrame(frame);
}

/// <summary>
/// Write an external buffer to the display buffer
/// </summary>
/// <param name="x">X postion to write buffer in pixels</param>
/// <param name="y">Y postion to write buffer in pixels</param>
/// <param name="buffer">The buffer to write</param>
public void WriteBuffer(int x, int y, IPixelBuffer buffer)
{
PixelBuffer.WriteBuffer(x, y, buffer);
}
}
}
9 changes: 6 additions & 3 deletions Source/C16x9/Driver/C16x9.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
<Description>MikroElectronika I2C 16x9 Click LED board</Description>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\icon.png" Pack="true" PackagePath="" />
<PackageReference Include="Meadow.Foundation" Version="0.*" />
<None Include="..\..\icon.png" Pack="true" PackagePath="" />
<!--<PackageReference Include="Meadow.Foundation.Displays.MicroGraphics" Version="0.*" />
<PackageReference Include="Meadow.Foundation.ICs.IOExpanders.Is31fl3731" Version="0.*" />-->
</ItemGroup>
<ItemGroup>
<PackageReference Include="Meadow.Foundation.Displays.MicroGraphics" Version="0.*" />
<PackageReference Include="Meadow.Foundation.ICs.IOExpanders.Is31fl3731" Version="0.*" />
</ItemGroup>
</Project>
</Project>
4 changes: 2 additions & 2 deletions Source/C16x9/Sample/C16x9G_Sample/C16x9_Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<OutputType>Exe</OutputType>
<OutputType>Library</OutputType>
<AssemblyName>App</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Meadow.F7" Version="0.*" />
<ProjectReference Include="..\..\Driver\C16x9.csproj" />
<PackageReference Include="Meadow.Foundation.mikroBUS.Displays.C16x9" Version="0.*" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Source/C16x9/Sample/C16x9G_Sample/MeadowApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace C16x9_Sample
{
// Change F7FeatherV2 to F7FeatherV1 for V1.x boards
public class MeadowApp : App<F7FeatherV2, MeadowApp>
public class MeadowApp : App<F7FeatherV2>
{
//<!=SNIP=>

Expand Down
19 changes: 0 additions & 19 deletions Source/C16x9/Sample/C16x9G_Sample/Program.cs

This file was deleted.

51 changes: 51 additions & 0 deletions Source/C8800Retro/Driver/C8800Retro.Enums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
namespace Meadow.Foundation.mikroBUS.Displays
{
public partial class C8800Retro
{
/// <summary>
/// Button array columns (1-4)
/// </summary>
public enum ButtonColumn
{
/// <summary>
/// Button column 1
/// </summary>
_1,
/// <summary>
/// Button column 2
/// </summary>
_2,
/// <summary>
/// Button column 3
/// </summary>
_3,
/// <summary>
/// Button column 4
/// </summary>
_4,
}

/// <summary>
/// Button array rows (A-D)
/// </summary>
public enum ButtonRow
{
/// <summary>
/// Button row A
/// </summary>
A,
/// <summary>
/// Button row B
/// </summary>
B,
/// <summary>
/// Button row C
/// </summary>
C,
/// <summary>
/// Button row D
/// </summary>
D,
}
}
}
82 changes: 82 additions & 0 deletions Source/C8800Retro/Driver/C8800Retro.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using Meadow.Foundation.ICs.IOExpanders;
using Meadow.Hardware;
using Meadow.Peripherals.Sensors.Buttons;

namespace Meadow.Foundation.mikroBUS.Displays
{
/// <summary>
/// Represents a mikroBUS Altair 8800 Retro click board
/// </summary>
public partial class C8800Retro : As1115
{
/// <summary>
/// Creates an Altair 8800 retro click board object
/// </summary>
/// <param name="device">The Meadow device</param>
/// <param name="i2cBus">The I2C bus</param>
/// <param name="buttonInterruptPin">The interrupt pin</param>
/// <param name="address">The I2C address</param>
public C8800Retro(IMeadowDevice device, II2cBus i2cBus, IPin buttonInterruptPin, byte address = 0)
: base(device, i2cBus, buttonInterruptPin, address)
{
}

/// <summary>
/// Get the button for a given row and column
/// </summary>
/// <param name="column">The column of the button (1-4)</param>
/// <param name="row">The row of the button (A-D)</param>
/// <returns>The IButton object</returns>
public IButton GetButton(ButtonColumn column, ButtonRow row)
{
KeyScanButtonType buttonType = KeyScanButtonType.None;

if(row == ButtonRow.A)
{
buttonType = column switch
{
ButtonColumn._1 => KeyScanButtonType.Button1,
ButtonColumn._2 => KeyScanButtonType.Button2,
ButtonColumn._3 => KeyScanButtonType.Button3,
ButtonColumn._4 => KeyScanButtonType.Button4,
_ => KeyScanButtonType.None
};
}
if (row == ButtonRow.B)
{
buttonType = column switch
{
ButtonColumn._1 => KeyScanButtonType.Button5,
ButtonColumn._2 => KeyScanButtonType.Button6,
ButtonColumn._3 => KeyScanButtonType.Button7,
ButtonColumn._4 => KeyScanButtonType.Button8,
_ => KeyScanButtonType.None
};
}
if (row == ButtonRow.C)
{
buttonType = column switch
{
ButtonColumn._1 => KeyScanButtonType.Button9,
ButtonColumn._2 => KeyScanButtonType.Button10,
ButtonColumn._3 => KeyScanButtonType.Button11,
ButtonColumn._4 => KeyScanButtonType.Button12,
_ => KeyScanButtonType.None
};
}
if (row == ButtonRow.D)
{
buttonType = column switch
{
ButtonColumn._1 => KeyScanButtonType.Button13,
ButtonColumn._2 => KeyScanButtonType.Button14,
ButtonColumn._3 => KeyScanButtonType.Button15,
ButtonColumn._4 => KeyScanButtonType.Button16,
_ => KeyScanButtonType.None
};
}

return KeyScanButtons[buttonType];
}
}
}
24 changes: 24 additions & 0 deletions Source/C8800Retro/Driver/C8800Retro.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Meadow.Sdk/1.1.0">
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageIcon>icon.png</PackageIcon>
<Authors>Wilderness Labs, Inc</Authors>
<TargetFramework>netstandard2.1</TargetFramework>
<OutputType>Library</OutputType>
<AssemblyName>C8800Retro</AssemblyName>
<Company>Wilderness Labs, Inc</Company>
<PackageProjectUrl>http://developer.wildernesslabs.co/Meadow/Meadow.Foundation/</PackageProjectUrl>
<PackageId>Meadow.Foundation.mikroBUS.Sensors.Buttons.C8800Retro</PackageId>
<RepositoryUrl>https://github.com/WildernessLabs/Meadow.Foundation</RepositoryUrl>
<PackageTags>Meadow, Meadow.Foundation, altair, as1115, retro, MikroBus, Mikroe, MikroElectronika, buttons, leds, led driver, keyscan</PackageTags>
<Version>0.1.0</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>MikroElectronika Altair 8800 I2C led driver and keyscan MikroBus retro click board</Description>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\icon.png" Pack="true" PackagePath="" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Meadow.Foundation.ICs.IOExpanders.As1115" Version="0.*" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Meadow.Sdk/1.1.0">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<OutputType>Library</OutputType>
<AssemblyName>App</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Meadow.F7" Version="0.*" />
<PackageReference Include="Meadow.Foundation.mikroBUS.Sensors.Buttons.C8800Retro" Version="0.*" />
</ItemGroup>
</Project>
Loading

0 comments on commit 359465b

Please sign in to comment.