diff --git a/ManagedDrivers/Ili9488/Ili9488.cs b/ManagedDrivers/Ili9488/Ili9488.cs new file mode 100644 index 0000000..35409a2 --- /dev/null +++ b/ManagedDrivers/Ili9488/Ili9488.cs @@ -0,0 +1,172 @@ +// +// 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 +{ + /// + /// Managed driver for Ili9488. + /// + 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 + }; + + /// + /// Default width. Use to override the one you'll pass in the screen and add it to the driver. + /// + public static uint Width { get; } = 480; + + /// + /// Default height. Use to override the one you'll pass in the screen and add it to the driver. + /// + public static uint Height { get; } = 320; + + /// + /// Gets the graphic driver for the Ili9488 display. + /// + 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.Pixel_Format_Set, 0x66, // 18 bit SPI + (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 + ), + }, + 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; + } + } + } +} diff --git a/ManagedDrivers/Ili9488/Properties/AssemblyInfo.cs b/ManagedDrivers/Ili9488/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f5f235b --- /dev/null +++ b/ManagedDrivers/Ili9488/Properties/AssemblyInfo.cs @@ -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")] +[assembly: AssemblyCopyright("Copyright © nanoFramework Contributors 2026")] + +// 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)] diff --git a/ManagedDrivers/Ili9488/nanoFramework.Graphics.Ili9488.nfproj b/ManagedDrivers/Ili9488/nanoFramework.Graphics.Ili9488.nfproj new file mode 100644 index 0000000..b0c40c3 --- /dev/null +++ b/ManagedDrivers/Ili9488/nanoFramework.Graphics.Ili9488.nfproj @@ -0,0 +1,56 @@ + + + + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ + + + + Debug + AnyCPU + {11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 1349bd64-2f76-4c99-9e3a-bf8851663c61 + Library + Properties + 512 + nanoFramework.UI.GraphicDrivers + nanoFramework.Graphics.Ili9488 + v1.0 + bin\$(Configuration)\nanoFramework.Graphics.Ili9488.xml + true + + + true + + + ..\..\key.snk + + + false + + + + + + + + + + + + + + + + + + + ..\..\packages\nanoFramework.CoreLibrary.1.17.11\lib\mscorlib.dll + + + + + + + + + \ No newline at end of file diff --git a/ManagedDrivers/Ili9488/packages.config b/ManagedDrivers/Ili9488/packages.config new file mode 100644 index 0000000..ddcc0ba --- /dev/null +++ b/ManagedDrivers/Ili9488/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ManagedDrivers/Ili9488/packages.lock.json b/ManagedDrivers/Ili9488/packages.lock.json new file mode 100644 index 0000000..2652a80 --- /dev/null +++ b/ManagedDrivers/Ili9488/packages.lock.json @@ -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==" + } + } + } +} \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index cdf4c44..4ec781e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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: diff --git a/nanoFramework.Graphics.Ili9488.nuspec b/nanoFramework.Graphics.Ili9488.nuspec new file mode 100644 index 0000000..7013388 --- /dev/null +++ b/nanoFramework.Graphics.Ili9488.nuspec @@ -0,0 +1,51 @@ + + + + nanoFramework.Graphics.Ili9488 + $version$ + nanoFramework.Graphics.Ili9488 + nanoframework + false + LICENSE.md + + + false + docs\README.md + https://github.com/nanoframework/nanoFramework.Graphics + images\nf-logo.png + + Copyright (c) .NET Foundation and Contributors + 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$). + nanoFramework C# csharp netmf netnf nanoFramework.Graphics Ili9488 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nanoFramework.Graphics.sln b/nanoFramework.Graphics.sln index d4cb30a..216a357 100644 --- a/nanoFramework.Graphics.sln +++ b/nanoFramework.Graphics.sln @@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution nanoFramework.Graphics.Gc9A01.nuspec = nanoFramework.Graphics.Gc9A01.nuspec nanoFramework.Graphics.Ili9341.nuspec = nanoFramework.Graphics.Ili9341.nuspec nanoFramework.Graphics.Ili9342.nuspec = nanoFramework.Graphics.Ili9342.nuspec + nanoFramework.Graphics.Ili9488.nuspec = nanoFramework.Graphics.Ili9488.nuspec nanoFramework.Graphics.nuspec = nanoFramework.Graphics.nuspec nanoFramework.Graphics.Otm8009A.nuspec = nanoFramework.Graphics.Otm8009A.nuspec nanoFramework.Graphics.Ssd1306.nuspec = nanoFramework.Graphics.Ssd1306.nuspec @@ -33,6 +34,8 @@ Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "nanoFramework.Graphics.Ili9 EndProject Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "nanoFramework.Graphics.Ili9342", "ManagedDrivers\Ili9342\nanoFramework.Graphics.Ili9342.nfproj", "{C7F4B4DB-EFB0-4073-96A7-E9AE94AD4700}" EndProject +Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "nanoFramework.Graphics.Ili9488", "ManagedDrivers\Ili9488\nanoFramework.Graphics.Ili9488.nfproj", "{1349BD64-2F76-4C99-9E3A-BF8851663C61}" +EndProject Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "nanoFramework.Graphics.Otm8009A", "ManagedDrivers\Otm8009A\nanoFramework.Graphics.Otm8009A.nfproj", "{4D12DF89-2227-4A78-97B1-FDBB17CDBB1E}" EndProject Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "nanoFramework.Graphics.Ssd1306", "ManagedDrivers\Ssd1306\nanoFramework.Graphics.Ssd1306.nfproj", "{61918B13-7E23-4567-8A4B-FE1F0248D0ED}" @@ -83,6 +86,12 @@ Global {C7F4B4DB-EFB0-4073-96A7-E9AE94AD4700}.Release|Any CPU.ActiveCfg = Release|Any CPU {C7F4B4DB-EFB0-4073-96A7-E9AE94AD4700}.Release|Any CPU.Build.0 = Release|Any CPU {C7F4B4DB-EFB0-4073-96A7-E9AE94AD4700}.Release|Any CPU.Deploy.0 = Release|Any CPU + {1349BD64-2F76-4C99-9E3A-BF8851663C61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1349BD64-2F76-4C99-9E3A-BF8851663C61}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1349BD64-2F76-4C99-9E3A-BF8851663C61}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {1349BD64-2F76-4C99-9E3A-BF8851663C61}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1349BD64-2F76-4C99-9E3A-BF8851663C61}.Release|Any CPU.Build.0 = Release|Any CPU + {1349BD64-2F76-4C99-9E3A-BF8851663C61}.Release|Any CPU.Deploy.0 = Release|Any CPU {4D12DF89-2227-4A78-97B1-FDBB17CDBB1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4D12DF89-2227-4A78-97B1-FDBB17CDBB1E}.Debug|Any CPU.Build.0 = Debug|Any CPU {4D12DF89-2227-4A78-97B1-FDBB17CDBB1E}.Debug|Any CPU.Deploy.0 = Debug|Any CPU @@ -128,6 +137,7 @@ Global {E8DACCD0-2EED-4455-ADFD-CF015F598E9F} = {B56DBFF9-1C54-4D42-8DC7-B6E35FE56268} {A6CFF866-FD75-400E-BF20-9D2FBC3DCC3E} = {B56DBFF9-1C54-4D42-8DC7-B6E35FE56268} {C7F4B4DB-EFB0-4073-96A7-E9AE94AD4700} = {B56DBFF9-1C54-4D42-8DC7-B6E35FE56268} + {1349BD64-2F76-4C99-9E3A-BF8851663C61} = {B56DBFF9-1C54-4D42-8DC7-B6E35FE56268} {4D12DF89-2227-4A78-97B1-FDBB17CDBB1E} = {B56DBFF9-1C54-4D42-8DC7-B6E35FE56268} {61918B13-7E23-4567-8A4B-FE1F0248D0ED} = {B56DBFF9-1C54-4D42-8DC7-B6E35FE56268} {EDE1D4FC-4F60-41E2-B3CC-A0671662A3C8} = {B56DBFF9-1C54-4D42-8DC7-B6E35FE56268}