Skip to content

Commit

Permalink
Merge pull request #4 from WildernessLabs/adrian-altair
Browse files Browse the repository at this point in the history
Altair 8800 Retro click driver + sample
  • Loading branch information
jorgedevs authored Aug 15, 2022
2 parents e6f2006 + fcebd24 commit 79dd39d
Show file tree
Hide file tree
Showing 7 changed files with 258 additions and 4 deletions.
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>
<ProjectReference Include="..\..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\ICs.IOExpanders.As1115\Driver\ICs.IOExpanders.As1115.csproj" />
</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>
<ProjectReference Include="..\..\..\..\..\Meadow.Core\source\Meadow.F7\Meadow.F7.csproj" />
<ProjectReference Include="..\..\Driver\C8800Retro.csproj" />
</ItemGroup>
</Project>
57 changes: 57 additions & 0 deletions Source/C8800Retro/Sample/C8800Retro_Sample/MeadowApp.cs
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=>
}
}
4 changes: 0 additions & 4 deletions Source/CButton/Driver/CButton.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,5 @@
</PropertyGroup>
<ItemGroup>
<None Include="..\..\icon.png" Pack="true" PackagePath="" />
<!--<PackageReference Include="Meadow.Foundation.Sensors.Hid.As5013" Version="0.*" />-->
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Sensors.Hid.As5013\Driver\Sensors.Hid.As5013.csproj" />
</ItemGroup>
</Project>
32 changes: 32 additions & 0 deletions Source/mikroBUS.sln
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sensors.Hid.As5013", "..\..
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sensors.Atmospheric.Sht4x", "..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Sensors.Atmospheric.Sht4x\Driver\Sensors.Atmospheric.Sht4x.csproj", "{C26B7D6B-5766-4980-A848-57AE5B0FD526}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "C8800Retro", "C8800Retro", "{E6434FCF-518A-4DBD-B0A9-8925531B197E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sample", "Sample", "{63BB747B-FF3D-4254-9C71-05181739DEA5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "C8800Retro", "C8800Retro\Driver\C8800Retro.csproj", "{43BEE007-0FED-4477-806E-28F12C7DDC85}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "C8800Retro_Sample", "C8800Retro\Sample\C8800Retro_Sample\C8800Retro_Sample.csproj", "{D127DA01-C3B0-49CA-A964-CDEAFF7BFE5E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICs.IOExpanders.As1115", "..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\ICs.IOExpanders.As1115\Driver\ICs.IOExpanders.As1115.csproj", "{8910659A-1D9B-4CF5-A9FF-08C212A33DA1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -167,6 +177,24 @@ Global
{C26B7D6B-5766-4980-A848-57AE5B0FD526}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C26B7D6B-5766-4980-A848-57AE5B0FD526}.Release|Any CPU.Build.0 = Release|Any CPU
{C26B7D6B-5766-4980-A848-57AE5B0FD526}.Release|Any CPU.Deploy.0 = Release|Any CPU
{43BEE007-0FED-4477-806E-28F12C7DDC85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43BEE007-0FED-4477-806E-28F12C7DDC85}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43BEE007-0FED-4477-806E-28F12C7DDC85}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{43BEE007-0FED-4477-806E-28F12C7DDC85}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43BEE007-0FED-4477-806E-28F12C7DDC85}.Release|Any CPU.Build.0 = Release|Any CPU
{43BEE007-0FED-4477-806E-28F12C7DDC85}.Release|Any CPU.Deploy.0 = Release|Any CPU
{D127DA01-C3B0-49CA-A964-CDEAFF7BFE5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D127DA01-C3B0-49CA-A964-CDEAFF7BFE5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D127DA01-C3B0-49CA-A964-CDEAFF7BFE5E}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{D127DA01-C3B0-49CA-A964-CDEAFF7BFE5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D127DA01-C3B0-49CA-A964-CDEAFF7BFE5E}.Release|Any CPU.Build.0 = Release|Any CPU
{D127DA01-C3B0-49CA-A964-CDEAFF7BFE5E}.Release|Any CPU.Deploy.0 = Release|Any CPU
{8910659A-1D9B-4CF5-A9FF-08C212A33DA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8910659A-1D9B-4CF5-A9FF-08C212A33DA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8910659A-1D9B-4CF5-A9FF-08C212A33DA1}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{8910659A-1D9B-4CF5-A9FF-08C212A33DA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8910659A-1D9B-4CF5-A9FF-08C212A33DA1}.Release|Any CPU.Build.0 = Release|Any CPU
{8910659A-1D9B-4CF5-A9FF-08C212A33DA1}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -194,6 +222,10 @@ Global
{D54B1A5E-F66F-42E3-A735-E3EE25309491} = {CA8BDDA7-1C38-469D-9701-096872CD7E72}
{685A1261-40F6-4266-B09A-60AB20722C85} = {CA8BDDA7-1C38-469D-9701-096872CD7E72}
{C26B7D6B-5766-4980-A848-57AE5B0FD526} = {CA8BDDA7-1C38-469D-9701-096872CD7E72}
{63BB747B-FF3D-4254-9C71-05181739DEA5} = {E6434FCF-518A-4DBD-B0A9-8925531B197E}
{43BEE007-0FED-4477-806E-28F12C7DDC85} = {E6434FCF-518A-4DBD-B0A9-8925531B197E}
{D127DA01-C3B0-49CA-A964-CDEAFF7BFE5E} = {63BB747B-FF3D-4254-9C71-05181739DEA5}
{8910659A-1D9B-4CF5-A9FF-08C212A33DA1} = {CA8BDDA7-1C38-469D-9701-096872CD7E72}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BF2FC8CE-57C6-468C-B82D-D8204E6D9360}
Expand Down

0 comments on commit 79dd39d

Please sign in to comment.