Skip to content

Commit 1179d72

Browse files
committed
Add Ili9488 display driver
1 parent 83c4cc9 commit 1179d72

8 files changed

Lines changed: 326 additions & 0 deletions

ManagedDrivers/Ili9488/Ili9488.cs

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
//
2+
// Copyright (c) .NET Foundation and Contributors
3+
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
4+
// See LICENSE file in the project root for full license information.
5+
//
6+
7+
namespace nanoFramework.UI.GraphicDrivers
8+
{
9+
/// <summary>
10+
/// Managed driver for Ili9488.
11+
/// </summary>
12+
public static class Ili9488
13+
{
14+
private static GraphicDriver _driver;
15+
16+
// Those enums are left like this to match the native side
17+
private enum ILI9488_CMD
18+
{
19+
NOP = 0x00,
20+
SOFTWARE_RESET = 0x01,
21+
POWER_STATE = 0x10,
22+
Sleep_Out = 0x11,
23+
Noron = 0x13,
24+
Invert_On = 0x21,
25+
Invert_Off = 0x20,
26+
Gamma_Set = 0x26,
27+
Display_OFF = 0x28,
28+
Display_ON = 0x29,
29+
Column_Address_Set = 0x2A,
30+
Page_Address_Set = 0x2B,
31+
Memory_Write = 0x2C,
32+
Colour_Set = 0x2D,
33+
Memory_Read = 0x2E,
34+
Partial_Area = 0x30,
35+
Memory_Access_Control = 0x36,
36+
Pixel_Format_Set = 0x3A,
37+
Memory_Write_Continue = 0x3C,
38+
Write_Display_Brightness = 0x51,
39+
Interface_Signal_Control = 0xB0,
40+
Frame_Rate_Control_Normal = 0xB1,
41+
Inversion_Control = 0xB4,
42+
Display_Function_Control = 0xB6,
43+
Entry_Mode_Set = 0xB7,
44+
Power_Control_1 = 0xC0,
45+
Power_Control_2 = 0xC1,
46+
VCOM_Control_1 = 0xC5,
47+
VCOM_Control_2 = 0xC7,
48+
External_Command = 0xC8,
49+
Power_Control_A = 0xCB,
50+
Power_Control_B = 0xCF,
51+
Positive_Gamma_Correction = 0xE0,
52+
Negative_Gamma_Correction = 0XE1,
53+
Driver_Timing_Control_A = 0xE8,
54+
Driver_Timing_Control_B = 0xEA,
55+
Set_Image_Function = 0xE9,
56+
Power_On_Sequence = 0xED,
57+
Enable_3G = 0xF2,
58+
Interface_Control = 0xF6,
59+
Pump_Ratio_Control = 0xF7
60+
};
61+
62+
private enum ILI9488_Orientation
63+
{
64+
MADCTL_MH = 0x04, // sets the Horizontal Refresh, 0=Left-Right and 1=Right-Left
65+
MADCTL_ML = 0x10, // sets the Vertical Refresh, 0=Top-Bottom and 1=Bottom-Top
66+
MADCTL_MV = 0x20, // sets the Row/Column Swap, 0=Normal and 1=Swapped
67+
MADCTL_MX = 0x40, // sets the Column Order, 0=Left-Right and 1=Right-Left
68+
MADCTL_MY = 0x80, // sets the Row Order, 0=Top-Bottom and 1=Bottom-Top
69+
70+
MADCTL_BGR = 0x08, // Blue-Green-Red pixel order
71+
MADCTL_RGB = 0x00 // Red-Green-Blue pixel order
72+
};
73+
74+
/// <summary>
75+
/// Default width. Use to override the one you'll pass in the screen and add it to the driver.
76+
/// </summary>
77+
public static uint Width { get; } = 480;
78+
79+
/// <summary>
80+
/// Default height. Use to override the one you'll pass in the screen and add it to the driver.
81+
/// </summary>
82+
public static uint Height { get; } = 320;
83+
84+
/// <summary>
85+
/// Gets the graphic driver for the Ili9488 display.
86+
/// </summary>
87+
public static GraphicDriver GraphicDriver
88+
{
89+
get
90+
{
91+
if (_driver == null)
92+
{
93+
_driver = new GraphicDriver()
94+
{
95+
MemoryWrite = (byte)ILI9488_CMD.Memory_Write,
96+
SetColumnAddress = (byte)ILI9488_CMD.Column_Address_Set,
97+
SetRowAddress = (byte)ILI9488_CMD.Page_Address_Set,
98+
InitializationSequence = new byte[]
99+
{
100+
(byte)GraphicDriverCommandType.Command, 3, (byte)ILI9488_CMD.Power_Control_1, 0x17, 0x15,
101+
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Power_Control_2, 0x41,
102+
(byte)GraphicDriverCommandType.Command, 4, (byte)ILI9488_CMD.VCOM_Control_1, 0x00, 0x12, 0x80,
103+
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Memory_Access_Control, 0x40, // 0x40 = MADCTL_MX (0x40) + MADCTL_RGB (0x00)
104+
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Pixel_Format_Set, 0x66, // 18 bit SPI
105+
(byte)GraphicDriverCommandType.Command, 16, (byte)ILI9488_CMD.Positive_Gamma_Correction, 0x00, 0x03, 0x09, 0x08, 0x16, 0x0A, 0x3F, 0x78, 0x4C, 0x09, 0x0A, 0x08, 0x16, 0x1A, 0x0F,
106+
(byte)GraphicDriverCommandType.Command, 16, (byte)ILI9488_CMD.Negative_Gamma_Correction, 0x00, 0x16, 0x19, 0x03, 0x0F, 0x05, 0x32, 0x45, 0x46, 0x04, 0x0E, 0x0D, 0x35, 0x37, 0x0F,
107+
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Interface_Signal_Control, 0x80,
108+
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Frame_Rate_Control_Normal, 0xA0,
109+
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Inversion_Control, 0x02,
110+
(byte)GraphicDriverCommandType.Command, 4, (byte)ILI9488_CMD.Display_Function_Control, 0x02, 0x02, 0x3B,
111+
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Set_Image_Function, 0x00,
112+
(byte)GraphicDriverCommandType.Command, 5, (byte)ILI9488_CMD.Pump_Ratio_Control, 0xA9, 0x51, 0x2C, 0x82,
113+
(byte)GraphicDriverCommandType.Command, 1, (byte)ILI9488_CMD.Sleep_Out,
114+
(byte)GraphicDriverCommandType.Sleep, 12, // Sleep 120 ms
115+
(byte)GraphicDriverCommandType.Command, 1, (byte)ILI9488_CMD.Display_ON,
116+
(byte)GraphicDriverCommandType.Sleep, 20, // Sleep 200 ms
117+
(byte)GraphicDriverCommandType.Command, 1, (byte)ILI9488_CMD.NOP,
118+
(byte)GraphicDriverCommandType.Sleep, 2 // Sleep 20 ms
119+
},
120+
OrientationLandscape = new byte[]
121+
{
122+
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Memory_Access_Control,
123+
(byte)(
124+
ILI9488_Orientation.MADCTL_MX |
125+
ILI9488_Orientation.MADCTL_MY |
126+
ILI9488_Orientation.MADCTL_MV |
127+
ILI9488_Orientation.MADCTL_RGB
128+
),
129+
},
130+
OrientationLandscape180 = new byte[]
131+
{
132+
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Memory_Access_Control,
133+
(byte)(
134+
ILI9488_Orientation.MADCTL_MV |
135+
ILI9488_Orientation.MADCTL_RGB
136+
),
137+
},
138+
OrientationPortrait = new byte[]
139+
{
140+
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Memory_Access_Control,
141+
(byte)(
142+
ILI9488_Orientation.MADCTL_MX |
143+
ILI9488_Orientation.MADCTL_RGB
144+
),
145+
},
146+
OrientationPortrait180 = new byte[]
147+
{
148+
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Memory_Access_Control,
149+
(byte)(
150+
ILI9488_Orientation.MADCTL_MY |
151+
ILI9488_Orientation.MADCTL_RGB
152+
),
153+
},
154+
PowerModeNormal = new byte[]
155+
{
156+
(byte)GraphicDriverCommandType.Command, 3, (byte)ILI9488_CMD.POWER_STATE, 0x00, 0x00,
157+
},
158+
PowerModeSleep = new byte[]
159+
{
160+
(byte)GraphicDriverCommandType.Command, 3, (byte)ILI9488_CMD.POWER_STATE, 0x00, 0x01,
161+
},
162+
DefaultOrientation = DisplayOrientation.Landscape,
163+
Brightness = (byte)ILI9488_CMD.Write_Display_Brightness,
164+
SetWindowType = SetWindowType.X16bitsY16Bit,
165+
BitsPerPixel = 18
166+
};
167+
}
168+
169+
return _driver;
170+
}
171+
}
172+
}
173+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
4+
// General Information about an assembly is controlled through the following
5+
// set of attributes. Change these attribute values to modify the information
6+
// associated with an assembly.
7+
[assembly: AssemblyTitle("nanoFramework.Graphics.Ili9488")]
8+
[assembly: AssemblyCompany("nanoFramework Contributors")]
9+
[assembly: AssemblyProduct("nanoFramework.System.Text")]
10+
[assembly: AssemblyCopyright("Copyright © nanoFramework Contributors 2023")]
11+
12+
// Setting ComVisible to false makes the types in this assembly not visible
13+
// to COM components. If you need to access a type in this assembly from
14+
// COM, set the ComVisible attribute to true on that type.
15+
[assembly: ComVisible(false)]
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Label="Globals">
4+
<NanoFrameworkProjectSystemPath>$(MSBuildExtensionsPath)\nanoFramework\v1.0\</NanoFrameworkProjectSystemPath>
5+
</PropertyGroup>
6+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props')" />
7+
<PropertyGroup>
8+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
9+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
10+
<ProjectTypeGuids>{11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
11+
<ProjectGuid>1349bd64-2f76-4c99-9e3a-bf8851663c61</ProjectGuid>
12+
<OutputType>Library</OutputType>
13+
<AppDesignerFolder>Properties</AppDesignerFolder>
14+
<FileAlignment>512</FileAlignment>
15+
<RootNamespace>nanoFramework.UI.GraphicDrivers</RootNamespace>
16+
<AssemblyName>nanoFramework.Graphics.Ili9488</AssemblyName>
17+
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
18+
<DocumentationFile>bin\$(Configuration)\nanoFramework.Graphics.Ili9488.xml</DocumentationFile>
19+
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
20+
</PropertyGroup>
21+
<PropertyGroup>
22+
<SignAssembly>true</SignAssembly>
23+
</PropertyGroup>
24+
<PropertyGroup>
25+
<AssemblyOriginatorKeyFile>..\..\key.snk</AssemblyOriginatorKeyFile>
26+
</PropertyGroup>
27+
<PropertyGroup>
28+
<DelaySign>false</DelaySign>
29+
</PropertyGroup>
30+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
31+
<ItemGroup>
32+
<Compile Include="Ili9488.cs" />
33+
<Compile Include="Properties\AssemblyInfo.cs" />
34+
</ItemGroup>
35+
<ItemGroup>
36+
<ProjectReference Include="..\..\nanoFramework.Graphics.Core\nanoFramework.Graphics.Core.nfproj" />
37+
<ProjectReference Include="..\..\nanoFramework.Graphics\nanoFramework.Graphics.nfproj" />
38+
</ItemGroup>
39+
<ItemGroup>
40+
<Content Include="packages.lock.json" />
41+
</ItemGroup>
42+
<ItemGroup>
43+
<None Include="packages.config" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Reference Include="mscorlib, Version=1.17.11.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
47+
<HintPath>..\..\packages\nanoFramework.CoreLibrary.1.17.11\lib\mscorlib.dll</HintPath>
48+
</Reference>
49+
</ItemGroup>
50+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
51+
<ProjectExtensions>
52+
<ProjectCapabilities>
53+
<ProjectConfigurationsDeclaredAsItems />
54+
</ProjectCapabilities>
55+
</ProjectExtensions>
56+
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="nanoFramework.CoreLibrary" version="1.17.11" targetFramework="netnano1.0" />
4+
</packages>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": 1,
3+
"dependencies": {
4+
".NETnanoFramework,Version=v1.0": {
5+
"nanoFramework.CoreLibrary": {
6+
"type": "Direct",
7+
"requested": "[1.17.11, 1.17.11]",
8+
"resolved": "1.17.11",
9+
"contentHash": "HezzAc0o2XrSGf85xSeD/6xsO6ohF9hX6/iMQ1IZS6Zw6umr4WfAN2Jv0BrPxkaYwzEegJxxZujkHoUIAqtOMw=="
10+
}
11+
}
12+
}
13+
}

azure-pipelines.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ jobs:
8282
- template: azure-pipelines-templates/class-lib-package.yml@templates
8383
parameters:
8484
nugetPackageName: 'nanoFramework.Graphics.Ili9342'
85+
86+
- template: azure-pipelines-templates/class-lib-package.yml@templates
87+
parameters:
88+
nugetPackageName: 'nanoFramework.Graphics.Ili9488'
8589

8690
- template: azure-pipelines-templates/class-lib-package.yml@templates
8791
parameters:
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
3+
<metadata>
4+
<id>nanoFramework.Graphics.Ili9488</id>
5+
<version>$version$</version>
6+
<title>nanoFramework.Graphics.Ili9488</title>
7+
<authors>nanoframework</authors>
8+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
9+
<license type="file">LICENSE.md</license>
10+
<releaseNotes>
11+
</releaseNotes>
12+
<developmentDependency>false</developmentDependency>
13+
<readme>docs\README.md</readme>
14+
<projectUrl>https://github.com/nanoframework/nanoFramework.Graphics</projectUrl>
15+
<icon>images\nf-logo.png</icon>
16+
<repository type="git" url="https://github.com/nanoframework/nanoFramework.Graphics" commit="$commit$" />
17+
<copyright>Copyright (c) .NET Foundation and Contributors</copyright>
18+
<description>This package includes the nanoFramework.Graphics assembly for .NET nanoFramework C# projects.
19+
It does embed a managed driver Ili9488. It is aimed to be used for images built with Generic Graphics driver.
20+
This package requires a target with nanoFramework.Graphics v$nativeVersion$ (checksum $checksum$).</description>
21+
<tags>nanoFramework C# csharp netmf netnf nanoFramework.Graphics Ili9488</tags>
22+
<dependencies>
23+
<dependency id="nanoFramework.CoreLibrary" version="1.17.11" />
24+
<dependency id="nanoFramework.ResourceManager" version="1.2.13" />
25+
<dependency id="nanoFramework.Runtime.Events" version="1.11.6" />
26+
<dependency id="nanoFramework.Runtime.Native" version="1.6.6" />
27+
<dependency id="nanoFramework.System.Collections" version="1.5.18" />
28+
</dependencies>
29+
</metadata>
30+
<files>
31+
<file src="nanoFramework.Graphics.Core\bin\Release\nanoFramework.Graphics.Core.dll" target="lib\nanoFramework.Graphics.Core.dll" />
32+
<file src="nanoFramework.Graphics.Core\bin\Release\nanoFramework.Graphics.Core.pdb" target="lib\nanoFramework.Graphics.Core.pdb" />
33+
<file src="nanoFramework.Graphics.Core\bin\Release\nanoFramework.Graphics.Core.pdbx" target="lib\nanoFramework.Graphics.Core.pdbx" />
34+
<file src="nanoFramework.Graphics.Core\bin\Release\nanoFramework.Graphics.Core.pe" target="lib\nanoFramework.Graphics.Core.pe" />
35+
<file src="nanoFramework.Graphics.Core\bin\Release\nanoFramework.Graphics.Core.xml" target="lib\nanoFramework.Graphics.Core.xml" />
36+
<file src="nanoFramework.Graphics\bin\Release\nanoFramework.Graphics.dll" target="lib\nanoFramework.Graphics.dll" />
37+
<file src="nanoFramework.Graphics\bin\Release\nanoFramework.Graphics.pdb" target="lib\nanoFramework.Graphics.pdb" />
38+
<file src="nanoFramework.Graphics\bin\Release\nanoFramework.Graphics.pdbx" target="lib\nanoFramework.Graphics.pdbx" />
39+
<file src="nanoFramework.Graphics\bin\Release\nanoFramework.Graphics.pe" target="lib\nanoFramework.Graphics.pe" />
40+
<file src="nanoFramework.Graphics\bin\Release\nanoFramework.Graphics.xml" target="lib\nanoFramework.Graphics.xml" />
41+
<file src="ManagedDrivers\Ili9488\bin\Release\nanoFramework.Graphics.Ili9488.dll" target="lib\nanoFramework.Graphics.Ili9488.dll" />
42+
<file src="ManagedDrivers\Ili9488\bin\Release\nanoFramework.Graphics.Ili9488.pdb" target="lib\nanoFramework.Graphics.Ili9488.pdb" />
43+
<file src="ManagedDrivers\Ili9488\bin\Release\nanoFramework.Graphics.Ili9488.pdbx" target="lib\nanoFramework.Graphics.Ili9488.pdbx" />
44+
<file src="ManagedDrivers\Ili9488\bin\Release\nanoFramework.Graphics.Ili9488.pe" target="lib\nanoFramework.Graphics.Ili9488.pe" />
45+
<file src="ManagedDrivers\Ili9488\bin\Release\nanoFramework.Graphics.Ili9488.xml" target="lib\nanoFramework.Graphics.Ili9488.xml" />
46+
<file src="assets\readme.txt" target="" />
47+
<file src="README.md" target="docs\" />
48+
<file src="assets\nf-logo.png" target="images" />
49+
<file src="LICENSE.md" target="" />
50+
</files>
51+
</package>

0 commit comments

Comments
 (0)