-
Notifications
You must be signed in to change notification settings - Fork 68
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 #908 from WildernessLabs/feature/ft23xx
Feature/ft23xx
- Loading branch information
Showing
41 changed files
with
1,849 additions
and
2,979 deletions.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
...Meadow.Foundation.Libraries_and_Frameworks/Graphics.MicroLayout/Driver/Controls/Circle.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,93 @@ | ||
namespace Meadow.Foundation.Graphics.MicroLayout; | ||
|
||
public struct Coordinate2D | ||
{ | ||
public int X { get; set; } | ||
public int Y { get; set; } | ||
} | ||
|
||
/// <summary> | ||
/// Represents a circle in the user interface. | ||
/// </summary> | ||
public class Circle : ThemedControl | ||
{ | ||
private Color _foreColor; | ||
|
||
/// <summary> | ||
/// Gets or sets a value indicating whether the Circle is filled with the foreground color. | ||
/// </summary> | ||
public bool IsFilled { get; set; } = true; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="Circle"/> class with the specified dimensions. | ||
/// </summary> | ||
/// <param name="centerX">The X coordinate of the circles's center.</param> | ||
/// <param name="centerY">The Y coordinate of the circles's center.</param> | ||
/// <param name="radius">The radius of the circle.</param> | ||
public Circle(int centerX, int centerY, int radius) | ||
: base(centerX - radius, centerY - radius, radius * 2, radius * 2) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="Circle"/> class with the specified dimensions. | ||
/// </summary> | ||
/// <param name="center">The coordinate of the circles's center.</param> | ||
/// <param name="radius">The radius of the circle.</param> | ||
public Circle(Coordinate2D center, int radius) | ||
: base(center.X - radius, center.Y - radius, radius * 2, radius * 2) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Applies the specified display theme to the Circle. | ||
/// </summary> | ||
/// <param name="theme">The display theme to apply.</param> | ||
public override void ApplyTheme(DisplayTheme theme) | ||
{ | ||
if (theme != null) | ||
{ | ||
if (theme.ForegroundColor != null) this.ForeColor = theme.ForegroundColor.Value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the foreground color of the Circle. | ||
/// </summary> | ||
public Color ForeColor | ||
{ | ||
get => _foreColor; | ||
set => SetInvalidatingProperty(ref _foreColor, value); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the foreground color of the Circle. | ||
/// </summary> | ||
public int Radius | ||
{ | ||
get => Width / 2; | ||
set | ||
{ | ||
// keep centered | ||
var coeff = (value > Radius) ? -1 : 1; | ||
var offset = value - Radius; | ||
|
||
Width = value * 2; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Draws the Circle on the specified <see cref="MicroGraphics"/> surface. | ||
/// </summary> | ||
/// <param name="graphics">The <see cref="MicroGraphics"/> surface to draw the Circle on.</param> | ||
protected override void OnDraw(MicroGraphics graphics) | ||
{ | ||
if (ForeColor != Color.Transparent) | ||
{ | ||
var radius = (Right - Left) / 2; | ||
var centerX = Left + radius; | ||
var centerY = Top + radius; | ||
graphics.DrawCircle(centerX, centerY, radius, ForeColor, IsFilled); | ||
} | ||
} | ||
} |
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
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
29 changes: 29 additions & 0 deletions
29
Source/Meadow.Foundation.Peripherals/ICs.IOExpanders.Ft232h/Driver/Ft2232Expander.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,29 @@ | ||
using Meadow.Hardware; | ||
using System; | ||
|
||
namespace Meadow.Foundation.ICs.IOExpanders; | ||
|
||
public class Ft2232Expander : FtdiExpander | ||
{ | ||
internal Ft2232Expander() | ||
{ | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override II2cBus CreateI2cBus(int channel = 0, I2cBusSpeed busSpeed = I2cBusSpeed.Standard) | ||
{ | ||
// TODO: depends on part | ||
// TODO: make sure no SPI is in use | ||
var bus = new Ft23xxxI2cBus(this, busSpeed); | ||
bus.Configure(); | ||
return bus; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override ISpiBus CreateSpiBus(int channel, SpiClockConfiguration configuration) | ||
{ | ||
// TODO: make sure no SPI is in use | ||
|
||
throw new NotSupportedException(); | ||
} | ||
} |
64 changes: 0 additions & 64 deletions
64
Source/Meadow.Foundation.Peripherals/ICs.IOExpanders.Ft232h/Driver/Ft232DigitalOutputPort.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.