-
Notifications
You must be signed in to change notification settings - Fork 12
Add Ili9488 display driver #180
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
1179d72
9ded79b
d34159c
f32d4d6
c674e7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,173 @@ | ||||||
| // | ||||||
| // Copyright (c) .NET Foundation and Contributors | ||||||
| // Portions Copyright (c) Microsoft Corporation. All rights reserved. | ||||||
| // See LICENSE file in the project root for full license information. | ||||||
| // | ||||||
|
|
||||||
| namespace nanoFramework.UI.GraphicDrivers | ||||||
| { | ||||||
| /// <summary> | ||||||
| /// Managed driver for Ili9488. | ||||||
| /// </summary> | ||||||
| public static class Ili9488 | ||||||
| { | ||||||
| private static GraphicDriver _driver; | ||||||
|
|
||||||
| // Those enums are left like this to match the native side | ||||||
| private enum ILI9488_CMD | ||||||
| { | ||||||
| NOP = 0x00, | ||||||
| SOFTWARE_RESET = 0x01, | ||||||
| POWER_STATE = 0x10, | ||||||
| Sleep_Out = 0x11, | ||||||
| Noron = 0x13, | ||||||
| Invert_On = 0x21, | ||||||
| Invert_Off = 0x20, | ||||||
| Gamma_Set = 0x26, | ||||||
| Display_OFF = 0x28, | ||||||
| Display_ON = 0x29, | ||||||
| Column_Address_Set = 0x2A, | ||||||
| Page_Address_Set = 0x2B, | ||||||
| Memory_Write = 0x2C, | ||||||
| Colour_Set = 0x2D, | ||||||
| Memory_Read = 0x2E, | ||||||
| Partial_Area = 0x30, | ||||||
| Memory_Access_Control = 0x36, | ||||||
| Pixel_Format_Set = 0x3A, | ||||||
| Memory_Write_Continue = 0x3C, | ||||||
| Write_Display_Brightness = 0x51, | ||||||
| Interface_Signal_Control = 0xB0, | ||||||
| Frame_Rate_Control_Normal = 0xB1, | ||||||
| Inversion_Control = 0xB4, | ||||||
| Display_Function_Control = 0xB6, | ||||||
| Entry_Mode_Set = 0xB7, | ||||||
| Power_Control_1 = 0xC0, | ||||||
| Power_Control_2 = 0xC1, | ||||||
| VCOM_Control_1 = 0xC5, | ||||||
| VCOM_Control_2 = 0xC7, | ||||||
| External_Command = 0xC8, | ||||||
| Power_Control_A = 0xCB, | ||||||
| Power_Control_B = 0xCF, | ||||||
| Positive_Gamma_Correction = 0xE0, | ||||||
| Negative_Gamma_Correction = 0XE1, | ||||||
| Driver_Timing_Control_A = 0xE8, | ||||||
| Driver_Timing_Control_B = 0xEA, | ||||||
| Set_Image_Function = 0xE9, | ||||||
| Power_On_Sequence = 0xED, | ||||||
| Enable_3G = 0xF2, | ||||||
| Interface_Control = 0xF6, | ||||||
| Pump_Ratio_Control = 0xF7 | ||||||
| }; | ||||||
|
|
||||||
| private enum ILI9488_Orientation | ||||||
| { | ||||||
| MADCTL_MH = 0x04, // sets the Horizontal Refresh, 0=Left-Right and 1=Right-Left | ||||||
| MADCTL_ML = 0x10, // sets the Vertical Refresh, 0=Top-Bottom and 1=Bottom-Top | ||||||
| MADCTL_MV = 0x20, // sets the Row/Column Swap, 0=Normal and 1=Swapped | ||||||
| MADCTL_MX = 0x40, // sets the Column Order, 0=Left-Right and 1=Right-Left | ||||||
| MADCTL_MY = 0x80, // sets the Row Order, 0=Top-Bottom and 1=Bottom-Top | ||||||
|
|
||||||
| MADCTL_BGR = 0x08, // Blue-Green-Red pixel order | ||||||
| MADCTL_RGB = 0x00 // Red-Green-Blue pixel order | ||||||
| }; | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// Default width. Use to override the one you'll pass in the screen and add it to the driver. | ||||||
| /// </summary> | ||||||
| public static uint Width { get; } = 480; | ||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||
|
|
||||||
| /// <summary> | ||||||
| /// Default height. Use to override the one you'll pass in the screen and add it to the driver. | ||||||
| /// </summary> | ||||||
| public static uint Height { get; } = 320; | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// Gets the graphic driver for the Ili9488 display. | ||||||
| /// </summary> | ||||||
| public static GraphicDriver GraphicDriver | ||||||
| { | ||||||
| get | ||||||
| { | ||||||
| if (_driver == null) | ||||||
| { | ||||||
| _driver = new GraphicDriver() | ||||||
| { | ||||||
| MemoryWrite = (byte)ILI9488_CMD.Memory_Write, | ||||||
| SetColumnAddress = (byte)ILI9488_CMD.Column_Address_Set, | ||||||
| SetRowAddress = (byte)ILI9488_CMD.Page_Address_Set, | ||||||
| InitializationSequence = new byte[] | ||||||
| { | ||||||
| (byte)GraphicDriverCommandType.Command, 3, (byte)ILI9488_CMD.Power_Control_1, 0x17, 0x15, | ||||||
| (byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Power_Control_2, 0x41, | ||||||
| (byte)GraphicDriverCommandType.Command, 4, (byte)ILI9488_CMD.VCOM_Control_1, 0x00, 0x12, 0x80, | ||||||
| (byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Memory_Access_Control, 0x40, // 0x40 = MADCTL_MX (0x40) + MADCTL_RGB (0x00) | ||||||
| (byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Pixel_Format_Set, 0x66, // 18 bit SPI | ||||||
|
mikmog marked this conversation as resolved.
Outdated
|
||||||
| (byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Pixel_Format_Set, 0x66, // 18 bit SPI | |
| (byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Pixel_Format_Set, 0x55, // 16 bit RGB565 SPI |
Copilot
AI
Apr 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All orientation command sequences hardcode MADCTL_RGB. The PR description mentions the default is RGB but that it “can be overridden to BGR”; with the current implementation, consumers can only do that by manually editing the returned byte arrays, and the MADCTL enum is private so they can’t reuse the named constant. Consider exposing an explicit/public way to get an alternate BGR-configured GraphicDriver (or a switch/parameter) so the advertised override is straightforward and less error-prone.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,15 @@ | ||||||
| using System.Reflection; | ||||||
| using System.Runtime.InteropServices; | ||||||
|
|
||||||
| // General Information about an assembly is controlled through the following | ||||||
| // set of attributes. Change these attribute values to modify the information | ||||||
| // associated with an assembly. | ||||||
| [assembly: AssemblyTitle("nanoFramework.Graphics.Ili9488")] | ||||||
| [assembly: AssemblyCompany("nanoFramework Contributors")] | ||||||
| [assembly: AssemblyProduct("nanoFramework.System.Text")] | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect The Proposed fix-[assembly: AssemblyProduct("nanoFramework.System.Text")]
+[assembly: AssemblyProduct("nanoFramework.Graphics.Ili9488")]📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| [assembly: AssemblyCopyright("Copyright © nanoFramework Contributors 2023")] | ||||||
|
mikmog marked this conversation as resolved.
Outdated
|
||||||
|
|
||||||
| // Setting ComVisible to false makes the types in this assembly not visible | ||||||
| // to COM components. If you need to access a type in this assembly from | ||||||
| // COM, set the ComVisible attribute to true on that type. | ||||||
| [assembly: ComVisible(false)] | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing here the nbgv props and targets. Also in the reference in the packages.lock file.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you are editing feel free to include this pr, Otherwise I'll do it |
||
| <Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <PropertyGroup Label="Globals"> | ||
| <NanoFrameworkProjectSystemPath>$(MSBuildExtensionsPath)\nanoFramework\v1.0\</NanoFrameworkProjectSystemPath> | ||
| </PropertyGroup> | ||
| <Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props')" /> | ||
| <PropertyGroup> | ||
| <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
| <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
| <ProjectTypeGuids>{11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
| <ProjectGuid>1349bd64-2f76-4c99-9e3a-bf8851663c61</ProjectGuid> | ||
| <OutputType>Library</OutputType> | ||
| <AppDesignerFolder>Properties</AppDesignerFolder> | ||
| <FileAlignment>512</FileAlignment> | ||
| <RootNamespace>nanoFramework.UI.GraphicDrivers</RootNamespace> | ||
| <AssemblyName>nanoFramework.Graphics.Ili9488</AssemblyName> | ||
| <TargetFrameworkVersion>v1.0</TargetFrameworkVersion> | ||
| <DocumentationFile>bin\$(Configuration)\nanoFramework.Graphics.Ili9488.xml</DocumentationFile> | ||
| <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <SignAssembly>true</SignAssembly> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <AssemblyOriginatorKeyFile>..\..\key.snk</AssemblyOriginatorKeyFile> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <DelaySign>false</DelaySign> | ||
| </PropertyGroup> | ||
| <Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" /> | ||
| <ItemGroup> | ||
| <Compile Include="Ili9488.cs" /> | ||
| <Compile Include="Properties\AssemblyInfo.cs" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\nanoFramework.Graphics.Core\nanoFramework.Graphics.Core.nfproj" /> | ||
| <ProjectReference Include="..\..\nanoFramework.Graphics\nanoFramework.Graphics.nfproj" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <Content Include="packages.lock.json" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <None Include="packages.config" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <Reference Include="mscorlib, Version=1.17.11.0, Culture=neutral, PublicKeyToken=c07d481e9758c731"> | ||
| <HintPath>..\..\packages\nanoFramework.CoreLibrary.1.17.11\lib\mscorlib.dll</HintPath> | ||
| </Reference> | ||
| </ItemGroup> | ||
| <Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" /> | ||
| <ProjectExtensions> | ||
| <ProjectCapabilities> | ||
| <ProjectConfigurationsDeclaredAsItems /> | ||
| </ProjectCapabilities> | ||
| </ProjectExtensions> | ||
| </Project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <packages> | ||
| <package id="nanoFramework.CoreLibrary" version="1.17.11" targetFramework="netnano1.0" /> | ||
| </packages> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "version": 1, | ||
| "dependencies": { | ||
| ".NETnanoFramework,Version=v1.0": { | ||
| "nanoFramework.CoreLibrary": { | ||
| "type": "Direct", | ||
| "requested": "[1.17.11, 1.17.11]", | ||
| "resolved": "1.17.11", | ||
| "contentHash": "HezzAc0o2XrSGf85xSeD/6xsO6ohF9hX6/iMQ1IZS6Zw6umr4WfAN2Jv0BrPxkaYwzEegJxxZujkHoUIAqtOMw==" | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd"> | ||
| <metadata> | ||
| <id>nanoFramework.Graphics.Ili9488</id> | ||
| <version>$version$</version> | ||
| <title>nanoFramework.Graphics.Ili9488</title> | ||
| <authors>nanoframework</authors> | ||
| <requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
| <license type="file">LICENSE.md</license> | ||
| <releaseNotes> | ||
| </releaseNotes> | ||
| <developmentDependency>false</developmentDependency> | ||
| <readme>docs\README.md</readme> | ||
| <projectUrl>https://github.com/nanoframework/nanoFramework.Graphics</projectUrl> | ||
| <icon>images\nf-logo.png</icon> | ||
| <repository type="git" url="https://github.com/nanoframework/nanoFramework.Graphics" commit="$commit$" /> | ||
| <copyright>Copyright (c) .NET Foundation and Contributors</copyright> | ||
| <description>This package includes the nanoFramework.Graphics assembly for .NET nanoFramework C# projects. | ||
| It does embed a managed driver Ili9488. It is aimed to be used for images built with Generic Graphics driver. | ||
| This package requires a target with nanoFramework.Graphics v$nativeVersion$ (checksum $checksum$).</description> | ||
| <tags>nanoFramework C# csharp netmf netnf nanoFramework.Graphics Ili9488</tags> | ||
| <dependencies> | ||
| <dependency id="nanoFramework.CoreLibrary" version="1.17.11" /> | ||
| <dependency id="nanoFramework.ResourceManager" version="1.2.13" /> | ||
| <dependency id="nanoFramework.Runtime.Events" version="1.11.6" /> | ||
| <dependency id="nanoFramework.Runtime.Native" version="1.6.6" /> | ||
| <dependency id="nanoFramework.System.Collections" version="1.5.18" /> | ||
| </dependencies> | ||
| </metadata> | ||
| <files> | ||
| <file src="nanoFramework.Graphics.Core\bin\Release\nanoFramework.Graphics.Core.dll" target="lib\nanoFramework.Graphics.Core.dll" /> | ||
| <file src="nanoFramework.Graphics.Core\bin\Release\nanoFramework.Graphics.Core.pdb" target="lib\nanoFramework.Graphics.Core.pdb" /> | ||
| <file src="nanoFramework.Graphics.Core\bin\Release\nanoFramework.Graphics.Core.pdbx" target="lib\nanoFramework.Graphics.Core.pdbx" /> | ||
| <file src="nanoFramework.Graphics.Core\bin\Release\nanoFramework.Graphics.Core.pe" target="lib\nanoFramework.Graphics.Core.pe" /> | ||
| <file src="nanoFramework.Graphics.Core\bin\Release\nanoFramework.Graphics.Core.xml" target="lib\nanoFramework.Graphics.Core.xml" /> | ||
| <file src="nanoFramework.Graphics\bin\Release\nanoFramework.Graphics.dll" target="lib\nanoFramework.Graphics.dll" /> | ||
| <file src="nanoFramework.Graphics\bin\Release\nanoFramework.Graphics.pdb" target="lib\nanoFramework.Graphics.pdb" /> | ||
| <file src="nanoFramework.Graphics\bin\Release\nanoFramework.Graphics.pdbx" target="lib\nanoFramework.Graphics.pdbx" /> | ||
| <file src="nanoFramework.Graphics\bin\Release\nanoFramework.Graphics.pe" target="lib\nanoFramework.Graphics.pe" /> | ||
| <file src="nanoFramework.Graphics\bin\Release\nanoFramework.Graphics.xml" target="lib\nanoFramework.Graphics.xml" /> | ||
| <file src="ManagedDrivers\Ili9488\bin\Release\nanoFramework.Graphics.Ili9488.dll" target="lib\nanoFramework.Graphics.Ili9488.dll" /> | ||
| <file src="ManagedDrivers\Ili9488\bin\Release\nanoFramework.Graphics.Ili9488.pdb" target="lib\nanoFramework.Graphics.Ili9488.pdb" /> | ||
| <file src="ManagedDrivers\Ili9488\bin\Release\nanoFramework.Graphics.Ili9488.pdbx" target="lib\nanoFramework.Graphics.Ili9488.pdbx" /> | ||
| <file src="ManagedDrivers\Ili9488\bin\Release\nanoFramework.Graphics.Ili9488.pe" target="lib\nanoFramework.Graphics.Ili9488.pe" /> | ||
| <file src="ManagedDrivers\Ili9488\bin\Release\nanoFramework.Graphics.Ili9488.xml" target="lib\nanoFramework.Graphics.Ili9488.xml" /> | ||
| <file src="assets\readme.txt" target="" /> | ||
| <file src="README.md" target="docs\" /> | ||
| <file src="assets\nf-logo.png" target="images" /> | ||
| <file src="LICENSE.md" target="" /> | ||
| </files> | ||
| </package> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better move all these as proper IntelliSense comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more or less a copy paste of Ili9342 driver. Tried to keep them as identical as possible. Prepared for future refactoring. Note the enum is private and defined like this in ~all of the drivers.
Given the similarities of the Ili9xxx drivers they can probably live in the same nuget and share the enums for commands and orientation. But that's out of scope in current pr.