-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from WildernessLabs/adrian-altair
Altair 8800 Retro click driver + sample
- Loading branch information
Showing
7 changed files
with
258 additions
and
4 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
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, | ||
} | ||
} | ||
} |
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,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]; | ||
} | ||
} | ||
} |
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,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> | ||
<ProjectReference Include="..\..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\ICs.IOExpanders.As1115\Driver\ICs.IOExpanders.As1115.csproj" /> | ||
</ItemGroup> | ||
</Project> |
12 changes: 12 additions & 0 deletions
12
Source/C8800Retro/Sample/C8800Retro_Sample/C8800Retro_Sample.csproj
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,12 @@ | ||
<Project Sdk="Meadow.Sdk/1.1.0"> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.1</TargetFramework> | ||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> | ||
<OutputType>Library</OutputType> | ||
<AssemblyName>App</AssemblyName> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\..\..\Meadow.Core\source\Meadow.F7\Meadow.F7.csproj" /> | ||
<ProjectReference Include="..\..\Driver\C8800Retro.csproj" /> | ||
</ItemGroup> | ||
</Project> |
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,57 @@ | ||
using Meadow; | ||
using Meadow.Devices; | ||
using Meadow.Foundation; | ||
using Meadow.Foundation.Graphics; | ||
using Meadow.Foundation.mikroBUS.Displays; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace C8800Retro_Sample | ||
{ | ||
// Change F7FeatherV2 to F7FeatherV1 for V1.x boards | ||
public class MeadowApp : App<F7FeatherV2> | ||
{ | ||
//<!=SNIP=> | ||
|
||
C8800Retro altair; | ||
|
||
MicroGraphics graphics; | ||
|
||
public override Task Initialize() | ||
{ | ||
Console.WriteLine("Initializing ..."); | ||
|
||
altair = new C8800Retro(Device, Device.CreateI2cBus(), Device.Pins.D03); | ||
|
||
var button1B = altair.GetButton(C8800Retro.ButtonColumn._1, C8800Retro.ButtonRow.B); | ||
button1B.Clicked += Button1B_Clicked; | ||
|
||
graphics = new MicroGraphics(altair) | ||
{ | ||
CurrentFont = new Font4x8(), | ||
}; | ||
|
||
return base.Initialize(); | ||
} | ||
|
||
private void Button1B_Clicked(object sender, EventArgs e) | ||
{ | ||
Console.WriteLine("Button 1B clicked"); | ||
} | ||
|
||
public override async Task Run() | ||
{ | ||
altair.EnableBlink(true, true); | ||
|
||
graphics.Clear(); | ||
graphics.DrawText(0, 0, "MF", Color.White); | ||
graphics.Show(); | ||
|
||
await Task.Delay(6000); | ||
|
||
altair.EnableBlink(false); | ||
} | ||
|
||
//<!=SNOP=> | ||
} | ||
} |
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