-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial check in of Ssd1306 binding * Reference projects * Added SPI/I2C logic * Correction for SendData * Updated links * Initial check in of Ssd1306 binding * Reference projects * Added SPI/I2C logic * Correction for SendData * Updated links * Added spacing * Added validation to arguments * Removed old command structure * Removed unneeded info in proj file * Removed SPI and added sample * Add image link * Consolidate compile files * Simplified Control byte update * Changed Value to Id * Removed unneeded validation and tests * Updated ranges * Removed unused usings * Updated tests to Facts where needed * Removed continuation bit for better separation * Added summaries * Relocated enums * Added connection type checklist * Updated based on feedback * Added basic font * Added sample to get IP address * Added range helper * Add checks based on feedback * Added check and exception * Added device to binding list
- Loading branch information
Showing
68 changed files
with
2,817 additions
and
0 deletions.
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
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,33 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace Iot.Device.Ssd1306.Command | ||
{ | ||
public class ActivateScroll : ICommand | ||
{ | ||
/// <summary> | ||
/// This command starts the motion of scrolling and should only be issued | ||
/// after the scroll setup parameters have been defined by the scrolling | ||
/// setup commands :26h/27h/29h/2Ah. The setting in the last scrolling setup | ||
/// command overwrites the setting in the previous scrolling setup commands. | ||
/// </summary> | ||
public ActivateScroll() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// The value that represents the command. | ||
/// </summary> | ||
public byte Id => 0x2F; | ||
|
||
/// <summary> | ||
/// Gets the bytes that represent the command. | ||
/// </summary> | ||
/// <returns>The bytes that represent the command.</returns> | ||
public byte[] GetBytes() | ||
{ | ||
return new byte[] { Id }; | ||
} | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
src/devices/Ssd1306/Command/ContinuousVerticalAndHorizontalScrollSetup.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,91 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
|
||
namespace Iot.Device.Ssd1306.Command | ||
{ | ||
public class ContinuousVerticalAndHorizontalScrollSetup : ICommand | ||
{ | ||
/// <summary> | ||
/// This command consists of 6 consecutive bytes to set up the continuous vertical | ||
/// scroll parameters and determines the scrolling start page, end page, scrolling | ||
/// speed and vertical scrolling offset. | ||
/// </summary> | ||
/// <param name="scrollType">Vertical/Horizontal scroll type.</param> | ||
/// <param name="startPageAddress">Start page address with a range of 0-7.</param> | ||
/// <param name="frameFrequencyType">Frame frequency type with a range of 0-7.</param> | ||
/// <param name="endPageAddress">End page address with a range of 0-7.</param> | ||
/// <param name="verticalScrollingOffset">Vertical scrolling offset with a range of 0-63.</param> | ||
public ContinuousVerticalAndHorizontalScrollSetup( | ||
VerticalHorizontalScrollType scrollType, | ||
PageAddress startPageAddress, | ||
FrameFrequencyType frameFrequencyType, | ||
PageAddress endPageAddress, | ||
byte verticalScrollingOffset) | ||
{ | ||
if (verticalScrollingOffset > 0x3F) | ||
{ | ||
throw new ArgumentException("The vertical scrolling offset is invalid.", nameof(verticalScrollingOffset)); | ||
} | ||
|
||
ScrollType = scrollType; | ||
StartPageAddress = startPageAddress; | ||
FrameFrequencyType = frameFrequencyType; | ||
EndPageAddress = endPageAddress; | ||
VerticalScrollingOffset = verticalScrollingOffset; | ||
} | ||
|
||
/// <summary> | ||
/// The value that represents the command. | ||
/// </summary> | ||
public byte Id => (byte)ScrollType; | ||
|
||
/// <summary> | ||
/// Vertical/Horizontal scroll type. | ||
/// </summary> | ||
public VerticalHorizontalScrollType ScrollType { get; } | ||
|
||
/// <summary> | ||
/// Start page address with a range of 0-7. | ||
/// </summary> | ||
public PageAddress StartPageAddress { get; } | ||
|
||
/// <summary> | ||
/// Frame frequency type with a range of 0-7. | ||
/// </summary> | ||
public FrameFrequencyType FrameFrequencyType { get; } | ||
|
||
/// <summary> | ||
/// End page address with a range of 0-7. | ||
/// </summary> | ||
public PageAddress EndPageAddress { get; } | ||
|
||
/// <summary> | ||
/// Vertical scrolling offset with a range of 0-63. | ||
/// </summary> | ||
public byte VerticalScrollingOffset { get; } | ||
|
||
/// <summary> | ||
/// Gets the bytes that represent the command. | ||
/// </summary> | ||
/// <returns>The bytes that represent the command.</returns> | ||
public byte[] GetBytes() | ||
{ | ||
return new byte[] { Id, 0x00, (byte)StartPageAddress, (byte)FrameFrequencyType, (byte)EndPageAddress, VerticalScrollingOffset }; | ||
} | ||
|
||
public enum VerticalHorizontalScrollType | ||
{ | ||
/// <summary> | ||
/// Vertical and right horizontal scroll. | ||
/// </summary> | ||
Right = 0x29, | ||
/// <summary> | ||
/// Vertical and left horizontal scroll. | ||
/// </summary> | ||
Left = 0x2A | ||
} | ||
} | ||
} |
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,31 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace Iot.Device.Ssd1306.Command | ||
{ | ||
public class DeactivateScroll : ICommand | ||
{ | ||
/// <summary> | ||
/// This command stops the motion of scrolling. After sending 2Eh command to deactivate | ||
/// the scrolling action, the ram data needs to be rewritten. | ||
/// </summary> | ||
public DeactivateScroll() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// The value that represents the command. | ||
/// </summary> | ||
public byte Id => 0x2E; | ||
|
||
/// <summary> | ||
/// Gets the bytes that represent the command. | ||
/// </summary> | ||
/// <returns>The bytes that represent the command.</returns> | ||
public byte[] GetBytes() | ||
{ | ||
return new byte[] { Id }; | ||
} | ||
} | ||
} |
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,37 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace Iot.Device.Ssd1306.Command | ||
{ | ||
public class EntireDisplayOn : ICommand | ||
{ | ||
/// <summary> | ||
/// This command turns the entire display on or off. | ||
/// </summary> | ||
/// <param name="entireDisplay">Resume to RAM content display when FALSE and turns entire dislay on when TRUE.</param> | ||
public EntireDisplayOn(bool entireDisplay) | ||
{ | ||
EntireDisplay = entireDisplay; | ||
} | ||
|
||
/// <summary> | ||
/// The value that represents the command. | ||
/// </summary> | ||
public byte Id => (byte)(EntireDisplay ? 0xA5 : 0xA4); | ||
|
||
/// <summary> | ||
/// Resume to RAM content display when FALSE and turns entire dislay on when TRUE. | ||
/// </summary> | ||
public bool EntireDisplay { get; } | ||
|
||
/// <summary> | ||
/// Gets the bytes that represent the command. | ||
/// </summary> | ||
/// <returns>The bytes that represent the command.</returns> | ||
public byte[] GetBytes() | ||
{ | ||
return new byte[] { Id }; | ||
} | ||
} | ||
} |
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,87 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace Iot.Device.Ssd1306.Command | ||
{ | ||
public enum FrameFrequencyType | ||
{ | ||
Frames2 = 0x07, | ||
Frames3 = 0x04, | ||
Frames4 = 0x05, | ||
Frames5 = 0x00, | ||
Frames25 = 0x06, | ||
Frames64 = 0x01, | ||
Frames128 = 0x02, | ||
Frames256 = 0x03 | ||
} | ||
|
||
public class HorizontalScrollSetup : ICommand | ||
{ | ||
/// <summary> | ||
/// This command consists of consecutive bytes to set up the horizontal scroll parameters | ||
/// and determines the scrolling start page, end page and scrolling speed. | ||
/// </summary> | ||
/// <param name="scrollType">Horizontal scroll type.</param> | ||
/// <param name="startPageAddress">Start page address with a range of 0-7.</param> | ||
/// <param name="frameFrequencyType">Frame frequency type with a range of 0-7.</param> | ||
/// <param name="endPageAddress">End page address with a range of 0-7.</param> | ||
public HorizontalScrollSetup( | ||
HorizontalScrollType scrollType, | ||
PageAddress startPageAddress, | ||
FrameFrequencyType frameFrequencyType, | ||
PageAddress endPageAddress) | ||
{ | ||
ScrollType = scrollType; | ||
StartPageAddress = startPageAddress; | ||
FrameFrequencyType = frameFrequencyType; | ||
EndPageAddress = endPageAddress; | ||
} | ||
|
||
/// <summary> | ||
/// The value that represents the command. | ||
/// </summary> | ||
public byte Id => (byte)ScrollType; | ||
|
||
/// <summary> | ||
/// Horizontal scroll type. | ||
/// </summary> | ||
public HorizontalScrollType ScrollType { get; } | ||
|
||
/// <summary> | ||
/// Start page address with a range of 0-7. | ||
/// </summary> | ||
public PageAddress StartPageAddress { get; } | ||
|
||
/// <summary> | ||
/// Frame frequency type with a range of 0-7. | ||
/// </summary> | ||
public FrameFrequencyType FrameFrequencyType { get; } | ||
|
||
/// <summary> | ||
/// End page address with a range of 0-7. | ||
/// </summary> | ||
public PageAddress EndPageAddress { get; } | ||
|
||
/// <summary> | ||
/// Gets the bytes that represent the command. | ||
/// </summary> | ||
/// <returns>The bytes that represent the command.</returns> | ||
public byte[] GetBytes() | ||
{ | ||
return new byte[] { Id, 0x00, (byte)StartPageAddress, (byte)FrameFrequencyType, (byte)EndPageAddress, 0x00, 0xFF }; | ||
} | ||
|
||
public enum HorizontalScrollType | ||
{ | ||
/// <summary> | ||
/// Right horizontal scroll. | ||
/// </summary> | ||
Right = 0x26, | ||
/// <summary> | ||
/// Left horizontal scroll. | ||
/// </summary> | ||
Left = 0x27 | ||
} | ||
} | ||
} |
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,20 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace Iot.Device.Ssd1306.Command | ||
{ | ||
public interface ICommand | ||
{ | ||
/// <summary> | ||
/// The value that represents the command. | ||
/// </summary> | ||
byte Id { get; } | ||
|
||
/// <summary> | ||
/// Gets the bytes that represent the command. | ||
/// </summary> | ||
/// <returns>The bytes that represent the command.</returns> | ||
byte[] GetBytes(); | ||
} | ||
} |
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,30 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace Iot.Device.Ssd1306.Command | ||
{ | ||
public class NoOperation : ICommand | ||
{ | ||
/// <summary> | ||
/// This command is a no operation command. | ||
/// </summary> | ||
public NoOperation() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// The value that represents the command. | ||
/// </summary> | ||
public byte Id => 0xE3; | ||
|
||
/// <summary> | ||
/// Gets the bytes that represent the command. | ||
/// </summary> | ||
/// <returns>The bytes that represent the command.</returns> | ||
public byte[] GetBytes() | ||
{ | ||
return new byte[] { Id }; | ||
} | ||
} | ||
} |
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,44 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace Iot.Device.Ssd1306.Command | ||
{ | ||
public class SetChargePump : ICommand | ||
{ | ||
/// <summary> | ||
/// This command controls the switching capacitor regulator circuit. | ||
/// </summary> | ||
/// <param name="enableChargePump">Determines if charge pump is enabled while the display is on.</param> | ||
public SetChargePump(bool enableChargePump = false) | ||
{ | ||
EnableChargePump = enableChargePump; | ||
} | ||
|
||
/// <summary> | ||
/// The value that represents the command. | ||
/// </summary> | ||
public byte Id => 0x8D; | ||
|
||
/// <summary> | ||
/// Determines if charge pump is enabled while the display is on. | ||
/// </summary> | ||
public bool EnableChargePump { get; } | ||
|
||
/// <summary> | ||
/// Gets the bytes that represent the command. | ||
/// </summary> | ||
/// <returns>The bytes that represent the command.</returns> | ||
public byte[] GetBytes() | ||
{ | ||
byte enableChargePump = 0x10; | ||
|
||
if (EnableChargePump) | ||
{ | ||
enableChargePump = 0x14; | ||
} | ||
|
||
return new byte[] { Id, enableChargePump }; | ||
} | ||
} | ||
} |
Oops, something went wrong.