Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 173 additions & 0 deletions ManagedDrivers/Ili9488/Ili9488.cs
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
Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Author

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.

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;
Comment thread
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
Comment thread
mikmog marked this conversation as resolved.
Outdated
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initialization config sets Pixel_Format_Set to 0x66 (18-bit) and the driver later reports BitsPerPixel=18. Most existing managed drivers configure 16-bit RGB565 (0x55), and DisplayControl.BitsPerPixel is documented as “Currently 16 bits in RGB565 format” (nanoFramework.Graphics/Primitive/DisplayControl.cs). Unless the native generic driver explicitly supports 18-bit transfers (including pixel packing/conversion), this mismatch can break rendering (misaligned pixel data). Consider switching to 16-bit mode (0x55) + BitsPerPixel=16, or clearly documenting/ensuring the required 18-bit pixel pipeline end-to-end.

Suggested change
(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 uses AI. Check for mistakes.
(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,
(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,
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Interface_Signal_Control, 0x80,
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Frame_Rate_Control_Normal, 0xA0,
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Inversion_Control, 0x02,
(byte)GraphicDriverCommandType.Command, 4, (byte)ILI9488_CMD.Display_Function_Control, 0x02, 0x02, 0x3B,
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Set_Image_Function, 0x00,
(byte)GraphicDriverCommandType.Command, 5, (byte)ILI9488_CMD.Pump_Ratio_Control, 0xA9, 0x51, 0x2C, 0x82,
(byte)GraphicDriverCommandType.Command, 1, (byte)ILI9488_CMD.Sleep_Out,
(byte)GraphicDriverCommandType.Sleep, 12, // Sleep 120 ms
(byte)GraphicDriverCommandType.Command, 1, (byte)ILI9488_CMD.Display_ON,
(byte)GraphicDriverCommandType.Sleep, 20, // Sleep 200 ms
(byte)GraphicDriverCommandType.Command, 1, (byte)ILI9488_CMD.NOP,
(byte)GraphicDriverCommandType.Sleep, 2 // Sleep 20 ms
},
OrientationLandscape = new byte[]
{
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Memory_Access_Control,
(byte)(
ILI9488_Orientation.MADCTL_MX |
ILI9488_Orientation.MADCTL_MY |
ILI9488_Orientation.MADCTL_MV |
ILI9488_Orientation.MADCTL_RGB
),
},
OrientationLandscape180 = new byte[]
{
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Memory_Access_Control,
(byte)(
ILI9488_Orientation.MADCTL_MV |
ILI9488_Orientation.MADCTL_RGB
),
},
OrientationPortrait = new byte[]
{
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Memory_Access_Control,
(byte)(
ILI9488_Orientation.MADCTL_MX |
ILI9488_Orientation.MADCTL_RGB
),
},
OrientationPortrait180 = new byte[]
{
(byte)GraphicDriverCommandType.Command, 2, (byte)ILI9488_CMD.Memory_Access_Control,
(byte)(
ILI9488_Orientation.MADCTL_MY |
ILI9488_Orientation.MADCTL_RGB
),
},
Comment on lines +119 to +152
Copy link

Copilot AI Apr 10, 2026

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.

Copilot uses AI. Check for mistakes.
PowerModeNormal = new byte[]
{
(byte)GraphicDriverCommandType.Command, 3, (byte)ILI9488_CMD.POWER_STATE, 0x00, 0x00,
},
PowerModeSleep = new byte[]
{
(byte)GraphicDriverCommandType.Command, 3, (byte)ILI9488_CMD.POWER_STATE, 0x00, 0x01,
},
DefaultOrientation = DisplayOrientation.Landscape,
Brightness = (byte)ILI9488_CMD.Write_Display_Brightness,
SetWindowType = SetWindowType.X16bitsY16Bit,
BitsPerPixel = 18
};
}

return _driver;
}
}
}
}
15 changes: 15 additions & 0 deletions ManagedDrivers/Ili9488/Properties/AssemblyInfo.cs
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")]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Incorrect AssemblyProduct value - copy-paste error.

The AssemblyProduct attribute references an unrelated product. It should match this assembly's product name.

Proposed fix
-[assembly: AssemblyProduct("nanoFramework.System.Text")]
+[assembly: AssemblyProduct("nanoFramework.Graphics.Ili9488")]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
[assembly: AssemblyProduct("nanoFramework.System.Text")]
[assembly: AssemblyProduct("nanoFramework.Graphics.Ili9488")]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ManagedDrivers/Ili9488/Properties/AssemblyInfo.cs` at line 9, The
AssemblyProduct attribute in AssemblyInfo.cs is incorrect (copy-paste); update
the AssemblyProduct attribute value so it matches this assembly's product name
by replacing the current "nanoFramework.System.Text" string in the [assembly:
AssemblyProduct(...)] attribute with the correct product name for the
ManagedDrivers.Ili9488 assembly (edit the AssemblyProduct attribute in
AssemblyInfo.cs to the proper product identifier).

[assembly: AssemblyCopyright("Copyright © nanoFramework Contributors 2023")]
Comment thread
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)]
56 changes: 56 additions & 0 deletions ManagedDrivers/Ili9488/nanoFramework.Graphics.Ili9488.nfproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.
I can see these are missing on the other drivers too. I'm submitting a PR with a fix for those.

Copy link
Copy Markdown
Author

@mikmog mikmog Apr 9, 2026

Choose a reason for hiding this comment

The 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>
4 changes: 4 additions & 0 deletions ManagedDrivers/Ili9488/packages.config
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>
13 changes: 13 additions & 0 deletions ManagedDrivers/Ili9488/packages.lock.json
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=="
}
}
}
}
4 changes: 4 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ jobs:
- template: azure-pipelines-templates/class-lib-package.yml@templates
parameters:
nugetPackageName: 'nanoFramework.Graphics.Ili9342'

- template: azure-pipelines-templates/class-lib-package.yml@templates
parameters:
nugetPackageName: 'nanoFramework.Graphics.Ili9488'

- template: azure-pipelines-templates/class-lib-package.yml@templates
parameters:
Expand Down
51 changes: 51 additions & 0 deletions nanoFramework.Graphics.Ili9488.nuspec
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>
Loading
Loading