-
Notifications
You must be signed in to change notification settings - Fork 70
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
Feature/amg8833 #874
Merged
Merged
Feature/amg8833 #874
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a2f0eba
Starting implementation of CP2112
ctacke 51b1fb6
more CP2112 bits
ctacke c0a5f87
working on CP2112 I2C implementation
ctacke 47bedc7
updated CP2112 assembly info
ctacke 66b7207
starting FT232 refactor
ctacke eba7582
re-doing FT232 for I2C
ctacke a71fe9b
FT232 SPI and GPIO rework
ctacke 6b65c73
FT232 GPIO updates for new driver
ctacke 41ac82f
Merge branch 'develop' into feature/ft232
ctacke b55b85e
Merge branch 'develop' into feature/cp2112
ctacke e8f039d
added native CP2112 libraries
ctacke 711dd59
trying (and failing) to get the CP2112 to do an I2CWrite
ctacke f06bf7c
Starting work on the AMG8833
ctacke fd4d7e3
Merge branch 'feature/ft232' into feature/amg8388
ctacke e76761f
Updated AMG8833 driver and sample
ctacke d00b704
start for Amg8833 for raspi
ctacke 2bd6e3f
Working on Ascii display
ctacke 2838a45
fixes for ascii driver and updates to linux sample
ctacke 70e4282
Update AsciiConsole display naming and add csproj metadata
adrianstevens d59cc7e
Cleanup
adrianstevens 46b7f18
Merge remote-tracking branch 'origin/develop' into feature/amg8388
ctacke 0105b5c
FT232 warning clean-up
ctacke 11d973a
Clean up CP2112 doc warnings
ctacke 86ad3bf
change ascii display sample to .net 7 so it will build in CI
ctacke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
89 changes: 89 additions & 0 deletions
89
...oundation.Peripherals/Displays.AsciiConsole/Driver/AsciiConsoleDisplay.CharacterBuffer.cs
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,89 @@ | ||
using Meadow.Foundation.Graphics; | ||
using Meadow.Foundation.Graphics.Buffers; | ||
using System; | ||
|
||
namespace Meadow.Foundation.Displays | ||
{ | ||
public partial class AsciiConsoleDisplay | ||
{ | ||
internal class CharacterBuffer : IPixelBuffer | ||
{ | ||
public int Width { get; } | ||
public int Height { get; } | ||
public ColorMode ColorMode => ColorMode.Format8bppGray; | ||
public int BitDepth => 6; | ||
|
||
public int ByteCount => throw new NotImplementedException(); | ||
|
||
public byte[] Buffer => throw new NotImplementedException(); | ||
|
||
private char[,] _buffer; | ||
|
||
public CharacterBuffer(int width, int height) | ||
{ | ||
Width = width; | ||
Height = height; | ||
|
||
_buffer = new char[width, height]; | ||
} | ||
|
||
public void Clear() | ||
{ | ||
Fill(Color.Black); | ||
} | ||
|
||
public void Fill(Color color) | ||
{ | ||
for (var y = 0; y < Height; y++) | ||
{ | ||
for (var x = 0; x < Width; x++) | ||
{ | ||
SetPixel(x, y, color); | ||
} | ||
} | ||
} | ||
|
||
public void Fill(int originX, int originY, int width, int height, Color color) | ||
{ | ||
for (var y = originY; y < height + originY; y++) | ||
{ | ||
for (var x = originX; x < width + originX; x++) | ||
{ | ||
SetPixel(x, y, color); | ||
} | ||
} | ||
} | ||
|
||
internal char GetPixelCharacter(int x, int y) | ||
{ | ||
return _buffer[x, y]; | ||
} | ||
|
||
public Color GetPixel(int x, int y) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void InvertPixel(int x, int y) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void SetPixel(int x, int y, Color color) | ||
{ | ||
_buffer[x, y] = ColorToCharacter(color); | ||
} | ||
|
||
public void WriteBuffer(int originX, int originY, IPixelBuffer buffer) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
private char ColorToCharacter(Color color) | ||
{ | ||
var index = (int)((color.Color8bppGray / 255d) * (_colors.Length - 1)); | ||
return _colors[index]; | ||
} | ||
} | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
Source/Meadow.Foundation.Peripherals/Displays.AsciiConsole/Driver/AsciiConsoleDisplay.cs
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,90 @@ | ||
using Meadow.Foundation.Graphics; | ||
using Meadow.Foundation.Graphics.Buffers; | ||
using System; | ||
|
||
namespace Meadow.Foundation.Displays; | ||
|
||
public partial class AsciiConsoleDisplay : IGraphicsDisplay | ||
{ | ||
private readonly CharacterBuffer _buffer; | ||
private const string _colors = " `.-':_,^=;><+!rc*/z?sLTv)J7(|Fi{C}fI31tlu[neoZ5Yxjya]2ESwqkP6h9d4VpOGbUAKXHm8RD#$Bg0MNWQ%&@"; // 92 "colors" | ||
|
||
public ColorMode ColorMode => PixelBuffer.ColorMode; | ||
|
||
public ColorMode SupportedColorModes => ColorMode.Format8bppGray; | ||
|
||
public int Width => PixelBuffer.Width; | ||
public int Height => PixelBuffer.Height; | ||
public IPixelBuffer PixelBuffer => _buffer; | ||
|
||
public AsciiConsoleDisplay(int width, int height) | ||
{ | ||
Console.Clear(); | ||
Console.SetCursorPosition(0, 0); | ||
|
||
_buffer = new CharacterBuffer(width, height); | ||
PixelBuffer.Clear(); | ||
} | ||
|
||
public void Clear(bool updateDisplay = false) | ||
{ | ||
PixelBuffer.Clear(); | ||
} | ||
|
||
public void DrawPixel(int x, int y, Color color) | ||
{ | ||
PixelBuffer.SetPixel(x, y, color); | ||
} | ||
|
||
public void DrawPixel(int x, int y, bool enabled) | ||
{ | ||
PixelBuffer.SetPixel(x, y, enabled ? Color.White : Color.Black); | ||
} | ||
|
||
public void Fill(Color fillColor, bool updateDisplay = false) | ||
{ | ||
PixelBuffer.Fill(fillColor); | ||
if (updateDisplay) | ||
{ | ||
Show(); | ||
} | ||
} | ||
|
||
public void Fill(int x, int y, int width, int height, Color fillColor) | ||
{ | ||
PixelBuffer.Fill(x, y, width, height, fillColor); | ||
} | ||
|
||
public void InvertPixel(int x, int y) | ||
{ | ||
PixelBuffer.InvertPixel(x, y); | ||
} | ||
|
||
public void Show() | ||
{ | ||
for (var y = 0; y < Height; y++) | ||
{ | ||
for (var x = 0; x < Width; x++) | ||
{ | ||
Console.SetCursorPosition(x, y); | ||
Console.Write(_buffer.GetPixelCharacter(x, y)); | ||
} | ||
} | ||
} | ||
|
||
public void Show(int left, int top, int right, int bottom) | ||
{ | ||
for (; left < right; left++) | ||
{ | ||
for (; top < bottom; top++) | ||
{ | ||
Console.SetCursorPosition(left, top); | ||
Console.Write(_buffer.GetPixelCharacter(left, top)); | ||
} | ||
} | ||
} | ||
|
||
public void WriteBuffer(int x, int y, IPixelBuffer displayBuffer) | ||
{ | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...w.Foundation.Peripherals/Displays.AsciiConsole/Driver/Meadow.Displays.AsciiConsole.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,27 @@ | ||
<Project Sdk="Meadow.Sdk/1.1.0"> | ||
<PropertyGroup> | ||
<PackageReadmeFile>Readme.md</PackageReadmeFile> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>10.0</LangVersion> | ||
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<PackageIcon>icon.png</PackageIcon> | ||
<Authors>Wilderness Labs, Inc</Authors> | ||
<TargetFramework>netstandard2.1</TargetFramework> | ||
<OutputType>Library</OutputType> | ||
<AssemblyName>AsciiConsole</AssemblyName> | ||
<Company>Wilderness Labs, Inc</Company> | ||
<PackageProjectUrl>http://developer.wildernesslabs.co/Meadow/Meadow.Foundation/</PackageProjectUrl> | ||
<PackageId>Meadow.Foundation.Displays.AsciiConsole</PackageId> | ||
<RepositoryUrl>https://github.com/WildernessLabs/Meadow.Foundation</RepositoryUrl> | ||
<PackageTags>Meadow,Meadow.Foundation,Displays,Ascii,Console</PackageTags> | ||
<Version>1.6.0.1</Version> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Description>Ascii console display</Description> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<None Include=".\Readme.md" Pack="true" PackagePath="" /> | ||
<None Include="..\..\..\icon.png" Pack="true" PackagePath="" /> | ||
<ProjectReference Include="..\..\..\Meadow.Foundation.Core\Meadow.Foundation.Core.csproj" /> | ||
</ItemGroup> | ||
</Project> |
12 changes: 12 additions & 0 deletions
12
Source/Meadow.Foundation.Peripherals/Displays.AsciiConsole/Driver/Readme.md
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 @@ | ||
# Meadow.Foundation.Displays.AsciiConsoleDisplay | ||
|
||
## How to Contribute | ||
|
||
- **Found a bug?** [Report an issue](https://github.com/WildernessLabs/Meadow_Issues/issues) | ||
- Have a **feature idea or driver request?** [Open a new feature request](https://github.com/WildernessLabs/Meadow_Issues/issues) | ||
- Want to **contribute code?** Fork the [Meadow.Foundation](https://github.com/WildernessLabs/Meadow.Foundation) repository and submit a pull request against the `develop` branch | ||
|
||
|
||
## Need Help? | ||
|
||
If you have questions or need assistance, please join the Wilderness Labs [community on Slack](http://slackinvite.wildernesslabs.co/). |
16 changes: 16 additions & 0 deletions
16
...isplays.AsciiConsole/Samples/AsciiConsoleDisplay_Sample/AsciiConsoleDisplay_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,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<AssemblyName>App</AssemblyName> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\..\Meadow.Foundation.Libraries_and_Frameworks\Graphics.MicroLayout\Driver\Graphics.MicroLayout.csproj" /> | ||
<ProjectReference Include="..\..\Driver\Meadow.Displays.AsciiConsole.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
103 changes: 103 additions & 0 deletions
103
...oundation.Peripherals/Displays.AsciiConsole/Samples/AsciiConsoleDisplay_Sample/Program.cs
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,103 @@ | ||
using Meadow; | ||
using Meadow.Foundation.Displays; | ||
using Meadow.Foundation.Graphics; | ||
using Meadow.Foundation.Graphics.MicroLayout; | ||
|
||
namespace AsciiConsoleDisplay_Sample; | ||
|
||
internal class Program | ||
{ | ||
private static void Main(string[] args) | ||
{ | ||
DrawShapes(); | ||
} | ||
|
||
private static async Task MovingBox() | ||
{ | ||
var colors = typeof(Color) | ||
.GetFields(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public) | ||
.Where(f => f.FieldType == typeof(Color)) | ||
.Select(c => (Color)c.GetValue(null)!) | ||
.ToArray(); | ||
|
||
var colorIndex = 0; | ||
var display = new AsciiConsoleDisplay(20, 15); | ||
var screen = new DisplayScreen(display); | ||
var box = new Box(0, 0, 4, 3) | ||
{ | ||
ForeColor = colors[colorIndex] | ||
}; | ||
screen.Controls.Add(box); | ||
|
||
var x = 0; | ||
var y = 0; | ||
var xdir = 1; | ||
var ydir = 1; | ||
|
||
while (true) | ||
{ | ||
screen.BeginUpdate(); | ||
box.Top = y; | ||
box.Left = x; | ||
box.ForeColor = colors[colorIndex]; | ||
screen.EndUpdate(); | ||
|
||
await Task.Delay(500); | ||
|
||
if ((x >= display.Width - 4) || (x < 0)) | ||
{ | ||
xdir *= -1; | ||
} | ||
if ((y >= display.Height - 4) || (y < 0)) | ||
{ | ||
ydir *= -1; | ||
} | ||
x += (1 * xdir); | ||
y += (1 * ydir); | ||
|
||
colorIndex++; | ||
if (colorIndex >= colors.Length) colorIndex = 0; | ||
} | ||
} | ||
|
||
private static void DrawShapes() | ||
{ | ||
var display = new AsciiConsoleDisplay(80, 60); | ||
|
||
var graphics = new MicroGraphics(display) | ||
{ | ||
IgnoreOutOfBoundsPixels = true, | ||
}; | ||
|
||
graphics.Clear(); | ||
|
||
graphics.DrawTriangle(5, 5, 30, 30, 5, 30, Color.Red, false); | ||
graphics.DrawRectangle(10, 12, 40, 20, Color.Yellow, false); | ||
graphics.DrawCircle(20, 20, 20, Color.White, false); | ||
|
||
graphics.Show(); | ||
} | ||
|
||
private static async Task CycleColors() | ||
{ | ||
var display = new AsciiConsoleDisplay(40, 30); | ||
|
||
var colors = typeof(Color).GetFields(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public).Where(c => c.FieldType == typeof(Color)); | ||
foreach (var color in colors) | ||
{ | ||
for (var x = 0; x < 16; x++) | ||
{ | ||
for (var y = 0; y < 16; y++) | ||
{ | ||
var c = (Color)color.GetValue(null)!; | ||
|
||
display.DrawPixel(x, y, c); | ||
} | ||
} | ||
|
||
display.Show(); | ||
|
||
await Task.Delay(100); | ||
} | ||
} | ||
} |
Binary file added
BIN
+634 KB
...n.Peripherals/ICs.IOExpanders.Cp2112/Data Sheets/an495-cp2112-interface-specification.pdf
Binary file not shown.
Binary file added
BIN
+862 KB
...ripherals/ICs.IOExpanders.Cp2112/Data Sheets/an496-hid-usb-to-smbus-api-specification.pdf
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldnt all these public methods have XML comments?