-
Notifications
You must be signed in to change notification settings - Fork 69
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 #602 from WildernessLabs/sh110x
Update SH1106 to SH110x and add SH1107 display driver
- Loading branch information
Showing
20 changed files
with
4,016 additions
and
120 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
File renamed without changes.
Binary file added
BIN
+496 KB
Source/Meadow.Foundation.Peripherals/Displays.Sh110x/Datasheet/SH1107.pdf
Binary file not shown.
8 changes: 4 additions & 4 deletions
8
...lays.Sh1106/Driver/Displays.Sh1106.csproj → ...lays.Sh110x/Driver/Displays.Sh110x.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
92 changes: 92 additions & 0 deletions
92
Source/Meadow.Foundation.Peripherals/Displays.Sh110x/Driver/Drivers/Sh1106.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,92 @@ | ||
using Meadow.Hardware; | ||
using System.Threading; | ||
|
||
namespace Meadow.Foundation.Displays | ||
{ | ||
/// <summary> | ||
/// Represents the Sh1106 family of displays | ||
/// </summary> | ||
public class Sh1106 : Sh110x | ||
{ | ||
/// <summary> | ||
/// Create a new Sh1106 object | ||
/// </summary> | ||
/// <param name="i2cBus">I2C bus connected to display</param> | ||
/// <param name="address">I2C address</param> | ||
/// <param name="width">Display width in pixels</param> | ||
/// <param name="height">Display height in pixels</param> | ||
public Sh1106(II2cBus i2cBus, byte address, int width, int height) | ||
: base(i2cBus, address, width, height) | ||
{ } | ||
|
||
/// <summary> | ||
/// Create a new Sh1106 object | ||
/// </summary> | ||
/// <param name="spiBus">SPI bus connected to display</param> | ||
/// <param name="chipSelectPin">Chip select pin</param> | ||
/// <param name="dcPin">Data command pin</param> | ||
/// <param name="resetPin">Reset pin</param> | ||
/// <param name="width">Display width in pixels</param> | ||
/// <param name="height">Display height in pixels</param> | ||
public Sh1106(ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin, int width = 128, int height = 64) | ||
: base(spiBus, chipSelectPin, dcPin, resetPin, width, height) | ||
{ } | ||
|
||
/// <summary> | ||
/// Create a new Sh1106 display object | ||
/// </summary> | ||
/// <param name="spiBus">SPI bus connected to display</param> | ||
/// <param name="chipSelectPort">Chip select output port</param> | ||
/// <param name="dataCommandPort">Data command output port</param> | ||
/// <param name="resetPort">Reset output port</param> | ||
/// <param name="width">Display width in pixels</param> | ||
/// <param name="height">Display height in pixels</param> | ||
public Sh1106(ISpiBus spiBus, | ||
IDigitalOutputPort chipSelectPort, | ||
IDigitalOutputPort dataCommandPort, | ||
IDigitalOutputPort resetPort, | ||
int width = 128, int height = 64) | ||
: base(spiBus, chipSelectPort, dataCommandPort, resetPort, width, height) | ||
{ } | ||
|
||
/// <summary> | ||
/// Initialize the Sh1106 | ||
/// </summary> | ||
protected override void Initialize() | ||
{ | ||
Reset(); | ||
|
||
SendCommand(DisplayCommand.DisplayOff); | ||
SendCommand(DisplayCommand.SetDisplayClockDiv); | ||
SendCommand(0x80); | ||
|
||
SendCommand(DisplayCommand.MultiplexModeSet); | ||
SendCommand(DisplayCommand.MultiplexDataSet); | ||
|
||
SendCommand(DisplayCommand.SetDisplayOffset); | ||
SendCommand((byte)0); | ||
|
||
SendCommand(DisplayCommand.DisplayStartLine); | ||
|
||
SendCommand(DisplayCommand.SegInvNormal); | ||
SendCommand(0xC0); | ||
|
||
SendCommand(DisplayCommand.SetComPins); | ||
SendCommand(0x12); | ||
|
||
SendCommand(DisplayCommand.SetContrast); | ||
SendCommand(0x0F); | ||
|
||
SendCommand(0x30); | ||
SendCommand(DisplayCommand.DisplayOnResume); | ||
|
||
SendCommand(DisplayCommand.SetDisplayClockDiv); | ||
SendCommand(0xF0); | ||
|
||
SendCommand(DisplayCommand.DisplayVideoNormal); | ||
|
||
Thread.Sleep(100); | ||
SendCommand(DisplayCommand.DisplayOn); | ||
} | ||
} | ||
} |
105 changes: 105 additions & 0 deletions
105
Source/Meadow.Foundation.Peripherals/Displays.Sh110x/Driver/Drivers/Sh1107.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,105 @@ | ||
using Meadow.Hardware; | ||
using System.Threading; | ||
|
||
namespace Meadow.Foundation.Displays | ||
{ | ||
/// <summary> | ||
/// Represents the Sh1107 family of displays | ||
/// </summary> | ||
public class Sh1107 : Sh110x | ||
{ | ||
/// <summary> | ||
/// Create a new Sh1107 object | ||
/// </summary> | ||
/// <param name="i2cBus">I2C bus connected to display</param> | ||
/// <param name="address">I2C address</param> | ||
/// <param name="width">Display width in pixels</param> | ||
/// <param name="height">Display height in pixels</param> | ||
public Sh1107(II2cBus i2cBus, byte address, int width = 128, int height = 128) | ||
: base(i2cBus, address, width, height) | ||
{ } | ||
|
||
/// <summary> | ||
/// Create a new Sh1107 object | ||
/// </summary> | ||
/// <param name="spiBus">SPI bus connected to display</param> | ||
/// <param name="chipSelectPin">Chip select pin</param> | ||
/// <param name="dcPin">Data command pin</param> | ||
/// <param name="resetPin">Reset pin</param> | ||
/// <param name="width">Display width in pixels</param> | ||
/// <param name="height">Display height in pixels</param> | ||
public Sh1107(ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin, int width = 128, int height = 128) | ||
: base(spiBus, chipSelectPin, dcPin, resetPin, width, height) | ||
{ } | ||
|
||
/// <summary> | ||
/// Create a new Sh1107 display object | ||
/// </summary> | ||
/// <param name="spiBus">SPI bus connected to display</param> | ||
/// <param name="chipSelectPort">Chip select output port</param> | ||
/// <param name="dataCommandPort">Data command output port</param> | ||
/// <param name="resetPort">Reset output port</param> | ||
/// <param name="width">Display width in pixels</param> | ||
/// <param name="height">Display height in pixels</param> | ||
public Sh1107(ISpiBus spiBus, | ||
IDigitalOutputPort chipSelectPort, | ||
IDigitalOutputPort dataCommandPort, | ||
IDigitalOutputPort resetPort, | ||
int width = 128, int height = 128) | ||
: base(spiBus, chipSelectPort, dataCommandPort, resetPort, width, height) | ||
{ } | ||
|
||
/// <summary> | ||
/// Initialize the Sh1107 | ||
/// </summary> | ||
protected override void Initialize() | ||
{ | ||
SendCommand(DisplayCommand.DisplayOff); | ||
SendCommand(DisplayCommand.SetDisplayClockDiv); | ||
SendCommand(0x51); | ||
|
||
SendCommand(DisplayCommand.SetContrast); | ||
SendCommand(0x4F); | ||
|
||
SendCommand(DisplayCommand.DCDC); | ||
SendCommand(0x8A); | ||
|
||
SendCommand(DisplayCommand.SetSegmentRemap); | ||
SendCommand(DisplayCommand.ComScanInc); | ||
|
||
SendCommand(DisplayCommand.DisplayStartLine); | ||
SendCommand((byte)0); | ||
|
||
SendCommand(DisplayCommand.SegInvNormal); | ||
SendCommand(0xC0); | ||
|
||
SendCommand(DisplayCommand.SetPrecharge); | ||
SendCommand(0x22); | ||
|
||
SendCommand(DisplayCommand.SetVComDetect); | ||
SendCommand(0x35); | ||
|
||
SendCommand(DisplayCommand.DisplayOnResume); | ||
SendCommand(DisplayCommand.DisplayVideoNormal); | ||
|
||
if (Width == 128 && Height == 128) | ||
{ | ||
SendCommand(DisplayCommand.SetDisplayOffset); | ||
SendCommand((byte)0x00); | ||
SendCommand(DisplayCommand.MultiplexModeSet); | ||
SendCommand(0x07F); | ||
} | ||
else | ||
{ | ||
SendCommand(DisplayCommand.SetDisplayOffset); | ||
SendCommand(0x60); | ||
SendCommand(DisplayCommand.MultiplexModeSet); | ||
SendCommand(DisplayCommand.MultiplexDataSet); | ||
} | ||
|
||
Thread.Sleep(100); | ||
|
||
SendCommand(DisplayCommand.DisplayOn); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.