Skip to content

Commit

Permalink
Merge pull request #898 from WildernessLabs/tft_set_color
Browse files Browse the repository at this point in the history
Add ability to change color mode
  • Loading branch information
jorgedevs authored Feb 6, 2024
2 parents 407f1e1 + d58b2b6 commit dade741
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,24 @@ public TftSpiBase(ISpiBus spiBus,
CreateBuffer(colorMode, nativeWidth = width, nativeHeight = height);
}

/// <summary>
/// Set color mode for the display
/// </summary>
/// <param name="colorMode"></param>
/// <exception cref="ArgumentException">throw if the color mode isn't supported by the display</exception>
public virtual void SetColorMode(ColorMode colorMode)
{
if (IsColorTypeSupported(colorMode) == false)
{
throw new ArgumentException($"color mode {colorMode} not supported");
}

if (imageBuffer.ColorMode != colorMode)
{
CreateBuffer(colorMode, Width, Height);
}
}

/// <summary>
/// Is the color mode supported on this display
/// </summary>
Expand Down

0 comments on commit dade741

Please sign in to comment.