diff --git a/Source/C8800Retro/Driver/C8800Retro.Enums.cs b/Source/C8800Retro/Driver/C8800Retro.Enums.cs new file mode 100644 index 0000000..fe7477f --- /dev/null +++ b/Source/C8800Retro/Driver/C8800Retro.Enums.cs @@ -0,0 +1,51 @@ +namespace Meadow.Foundation.mikroBUS.Displays +{ + public partial class C8800Retro + { + /// + /// Button array columns (1-4) + /// + public enum ButtonColumn + { + /// + /// Button column 1 + /// + _1, + /// + /// Button column 2 + /// + _2, + /// + /// Button column 3 + /// + _3, + /// + /// Button column 4 + /// + _4, + } + + /// + /// Button array rows (A-D) + /// + public enum ButtonRow + { + /// + /// Button row A + /// + A, + /// + /// Button row B + /// + B, + /// + /// Button row C + /// + C, + /// + /// Button row D + /// + D, + } + } +} \ No newline at end of file diff --git a/Source/C8800Retro/Driver/C8800Retro.cs b/Source/C8800Retro/Driver/C8800Retro.cs new file mode 100644 index 0000000..f14e4ad --- /dev/null +++ b/Source/C8800Retro/Driver/C8800Retro.cs @@ -0,0 +1,82 @@ +using Meadow.Foundation.ICs.IOExpanders; +using Meadow.Hardware; +using Meadow.Peripherals.Sensors.Buttons; + +namespace Meadow.Foundation.mikroBUS.Displays +{ + /// + /// Represents a mikroBUS Altair 8800 Retro click board + /// + public partial class C8800Retro : As1115 + { + /// + /// Creates an Altair 8800 retro click board object + /// + /// The Meadow device + /// The I2C bus + /// The interrupt pin + /// The I2C address + public C8800Retro(IMeadowDevice device, II2cBus i2cBus, IPin buttonInterruptPin, byte address = 0) + : base(device, i2cBus, buttonInterruptPin, address) + { + } + + /// + /// Get the button for a given row and column + /// + /// The column of the button (1-4) + /// The row of the button (A-D) + /// The IButton object + 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]; + } + } +} \ No newline at end of file diff --git a/Source/C8800Retro/Driver/C8800Retro.csproj b/Source/C8800Retro/Driver/C8800Retro.csproj new file mode 100644 index 0000000..950d0ab --- /dev/null +++ b/Source/C8800Retro/Driver/C8800Retro.csproj @@ -0,0 +1,24 @@ + + + true + icon.png + Wilderness Labs, Inc + netstandard2.1 + Library + C8800Retro + Wilderness Labs, Inc + http://developer.wildernesslabs.co/Meadow/Meadow.Foundation/ + Meadow.Foundation.mikroBUS.Sensors.Buttons.C8800Retro + https://github.com/WildernessLabs/Meadow.Foundation + Meadow, Meadow.Foundation, altair, as1115, retro, MikroBus, Mikroe, MikroElectronika, buttons, leds, led driver, keyscan + 0.1.0 + true + MikroElectronika Altair 8800 I2C led driver and keyscan MikroBus retro click board + + + + + + + + diff --git a/Source/C8800Retro/Sample/C8800Retro_Sample/C8800Retro_Sample.csproj b/Source/C8800Retro/Sample/C8800Retro_Sample/C8800Retro_Sample.csproj new file mode 100644 index 0000000..8bbe995 --- /dev/null +++ b/Source/C8800Retro/Sample/C8800Retro_Sample/C8800Retro_Sample.csproj @@ -0,0 +1,12 @@ + + + netstandard2.1 + true + Library + App + + + + + + \ No newline at end of file diff --git a/Source/C8800Retro/Sample/C8800Retro_Sample/MeadowApp.cs b/Source/C8800Retro/Sample/C8800Retro_Sample/MeadowApp.cs new file mode 100644 index 0000000..035c911 --- /dev/null +++ b/Source/C8800Retro/Sample/C8800Retro_Sample/MeadowApp.cs @@ -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 + { + // + + 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); + } + + // + } +} \ No newline at end of file diff --git a/Source/CButton/Driver/CButton.csproj b/Source/CButton/Driver/CButton.csproj index cc1dea0..c4d56d1 100644 --- a/Source/CButton/Driver/CButton.csproj +++ b/Source/CButton/Driver/CButton.csproj @@ -17,9 +17,5 @@ - - - - diff --git a/Source/mikroBUS.sln b/Source/mikroBUS.sln index 4839cb8..6f7593f 100644 --- a/Source/mikroBUS.sln +++ b/Source/mikroBUS.sln @@ -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 @@ -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 @@ -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}