Skip to content
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

Namespace, API and XML cleanup #416

Merged
merged 5 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions Source/Meadow.Foundation.Core/Displays/IGraphicsDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public interface IGraphicsDisplay
public int Height { get; }

/// <summary>
/// Provide a buffer that matches this display's color depth, height, and width.
/// Provide a buffer that matches this display's color depth, height, and width
/// This should be the buffer that is sent to the device when Show is called
/// </summary>
public IPixelBuffer PixelBuffer { get; }
Expand All @@ -39,7 +39,7 @@ public interface IGraphicsDisplay
public Color DisabledColor => Color.Black;

/// <summary>
/// Transfer the contents of the buffer to the display.
/// Transfer the contents of the buffer to the display
/// </summary>
public void Show();

Expand All @@ -50,49 +50,49 @@ public interface IGraphicsDisplay
public void Show(int left, int top, int right, int bottom);

/// <summary>
/// Clear the display.
/// Clear the display
/// </summary>
/// <param name="updateDisplay">Update the dipslay once the buffer has been cleared when true.</param>
/// <param name="updateDisplay">Update the dipslay once the buffer has been cleared when true</param>
public void Clear(bool updateDisplay = false);

/// <summary>
/// Clear the display.
/// Clear the display
/// </summary>
/// <param name="fillColor">The color used to fill the display buffer.</param>
/// <param name="updateDisplay">Update the dipslay once the buffer has been cleared when true.</param>
/// <param name="fillColor">The color used to fill the display buffer</param>
/// <param name="updateDisplay">Update the dipslay once the buffer has been cleared when true</param>
public void Fill(Color fillColor, bool updateDisplay = false);

/// <summary>
/// Clear the display.
/// </summary>
/// <param name="x">x position</param>
/// <param name="y">y postion</param>
/// <param name="width">width to fill</param>
/// <param name="height">height to fill</param>
/// <param name="fillColor">The color used to fill the display buffer.</param>
/// <param name="x">x position in pixels</param>
/// <param name="y">y position in pixels</param>
/// <param name="width">width to fill in pixels</param>
/// <param name="height">height to fill in pixels</param>
/// <param name="fillColor">The color used to fill the display buffer</param>
public abstract void Fill(int x, int y, int width, int height, Color fillColor);

/// <summary>
/// Draw a single pixel at the specified color
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="color">The Meadow.Foundation color of the pixel</param>
/// <param name="x">x position in pixels</param>
/// <param name="y">y position in pixels</param>
/// <param name="color">The Meadow Foundation color of the pixel</param>
public abstract void DrawPixel(int x, int y, Color color);

/// <summary>
/// Enable or disable a single pixel (used for 1bpp displays)
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="colored"></param>
public abstract void DrawPixel(int x, int y, bool colored);
/// <param name="x">x position in pixels</param>
/// <param name="y">y position in pixels</param>
/// <param name="enabled">On if true, off if false</param>
public abstract void DrawPixel(int x, int y, bool enabled);

/// <summary>
/// Invert the color of a single pixel
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="x">x position in pixels</param>
/// <param name="y">y position in pixels</param>
public abstract void InvertPixel(int x, int y);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ public Buffer1bpp(int width, int height, int pageSize)
}

/// <summary>
/// Is the pixel colored for a given location
/// Is the pixel on / enabled for a given location
/// </summary>
/// <param name="x">x location in pixels</param>
/// <param name="y">y location in pixels</param>
/// <returns>true if pixel is set / colored</returns>
/// <returns>true if pixel is set / enabled</returns>
public virtual bool GetPixelIsEnabled(int x, int y)
{
var index = (y >> 8) * Width + x;
Expand All @@ -84,12 +84,12 @@ public override Color GetPixel(int x, int y)
/// </summary>
/// <param name="x">x position in pixels from left</param>
/// <param name="y">y position in pixels from top</param>
/// <param name="colored">is pixel colored (on)</param>
public virtual void SetPixel(int x, int y, bool colored)
/// <param name="enabled">is pixel enabled (on)</param>
public virtual void SetPixel(int x, int y, bool enabled)
{
var index = (y >> 3) * Width + x; //divide by 8

if (colored)
if (enabled)
{
Buffer[index] = (byte)(Buffer[index] | (byte)(1 << (y % 8)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Buffer1bppV(int width, int height, int pageSize)
/// </summary>
/// <param name="x">x location in pixels</param>
/// <param name="y">y location in pixels</param>
/// <returns>true if pixel is set / colored</returns>
/// <returns>true if pixel is set / enabled</returns>
public override bool GetPixelIsEnabled(int x, int y)
{
return (Buffer[(x + y * Width) / 8] & (0x80 >> (x % 8))) != 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@
{
public partial class MicroGraphics
{
public void DrawPath(GraphicsPath path, bool colored)
/// <summary>
/// Draw a graphics path
/// </summary>
/// <param name="path">The path</param>
/// <param name="enabled">Should pixels be enabled (on) or disabled (off)</param>
public void DrawPath(GraphicsPath path, bool enabled)
{
DrawPath(path, (colored ? Color.White : Color.Black));
DrawPath(path, (enabled ? Color.White : Color.Black));
}

/// <summary>
/// Draw a graphics path
/// </summary>
/// <param name="path">The path</param>
/// <param name="color">The color to draw the path</param>
public void DrawPath(GraphicsPath path, Color color)
{
//simple for now
for (int i = 0; i < path.PointCount; i++)
{
if (path.PathActions[i].Verb == VerbType.Move || i == 0)
Expand All @@ -25,4 +34,4 @@ public void DrawPath(GraphicsPath path, Color color)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ public void DrawPixel(int x, int y, Color color)
/// <summary>
/// Draw pixel at location
/// </summary>
/// <param name="x">x position</param>
/// <param name="y">y position</param>
/// <param name="colored">Is pixel colored - on/off</param>
/// <param name="x">x position in pixels</param>
/// <param name="y">y position in pixels</param>
/// <param name="enabled">True = turn on pixel, false = turn off pixel</param>

public void DrawPixel(int x, int y, bool colored)
public void DrawPixel(int x, int y, bool enabled)
{
var index = x % 8;

Expand All @@ -89,7 +89,7 @@ public void DrawPixel(int x, int y, bool colored)
return;
}

if (colored)
if (enabled)
{
buffer[display, index] = (byte)(buffer[display, index] | (byte)(1 << (y % 8)));
}
Expand All @@ -102,8 +102,8 @@ public void DrawPixel(int x, int y, bool colored)
/// <summary>
/// Invert pixel at location (toggle on/off)
/// </summary>
/// <param name="x">x position</param>
/// <param name="y">y position</param>
/// <param name="x">x position in pixels</param>
/// <param name="y">y position in pixels</param>
public void InvertPixel(int x, int y)
{
var index = x % 8;
Expand Down Expand Up @@ -153,8 +153,8 @@ public void Fill(int x, int y, int width, int height, Color fillColor)
/// <summary>
/// Draw buffer at location
/// </summary>
/// <param name="x">x position</param>
/// <param name="y">y position</param>
/// <param name="x">x position in pixels</param>
/// <param name="y">y position in pixels</param>
/// <param name="displayBuffer">buffer to draw</param>
public void WriteBuffer(int x, int y, IPixelBuffer displayBuffer)
{ //need to refactor to use a proper buffer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,31 @@ public void Clear(bool updateDisplay = false)
}

/// <summary>
/// Coordinates start with index 0
/// Draw pixel at location
/// </summary>
/// <param name="x">Abscissa of the pixel to the set / reset.</param>
/// <param name="y">Ordinate of the pixel to the set / reset.</param>
/// <param name="colored">True = turn on pixel, false = turn off pixel</param>
public void DrawPixel(int x, int y, bool colored)
/// <param name="x">x position in pixels</param>
/// <param name="y">y position in pixels</param>
/// <param name="enabled">True = turn on pixel, false = turn off pixel</param>
public void DrawPixel(int x, int y, bool enabled)
{
imageBuffer.SetPixel(x, y, colored);
imageBuffer.SetPixel(x, y, enabled);
}

/// <summary>
/// Invert pixel at a location
/// </summary>
/// <param name="x">x position in pixels</param>
/// <param name="y">y position in pixels</param>
public void InvertPixel(int x, int y)
{
imageBuffer.InvertPixel(x, y);
}

/// <summary>
/// Coordinates start with index 0
/// Draw pixel at location
/// </summary>
/// <param name="x">Abscissa of the pixel to the set / reset.</param>
/// <param name="y">Ordinate of the pixel to the set / reset.</param>
/// <param name="x">x position in pixels</param>
/// <param name="y">y position in pixels</param>
/// <param name="color">any value other than black will make the pixel visible</param>
public void DrawPixel(int x, int y, Color color)
{
Expand All @@ -167,11 +172,14 @@ public void Show()
}

public void Show(int left, int top, int right, int bottom)
{
//ToDo implement partial screen updates for PCD8544
{ //ToDo implement partial screen updates for PCD8544
Show();
}

/// <summary>
/// Invert the entire display
/// </summary>
/// <param name="inverse">Invert if true, normal if false</param>
public void InvertDisplay(bool inverse)
{
IsDisplayInverted = inverse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,25 +118,5 @@ private void InitSSD1306(DisplayType displayType)
Contrast = 0xff;
StopScrolling();
}

public override void Fill(Color clearColor, bool updateDisplay = false)
{
imageBuffer.Clear(clearColor.Color1bpp);

if(updateDisplay)
{
Show();
}
}

public override void Fill(int x, int y, int width, int height, Color color)
{
imageBuffer.Fill(x, y, width, height, color);
}

public override void WriteBuffer(int x, int y, IPixelBuffer displayBuffer)
{
imageBuffer.WriteBuffer(x, y, displayBuffer);
}
}
}
Loading