diff --git a/M5StackCommon/Core2ToughCommon.cs b/M5StackCommon/Core2ToughCommon.cs index c5ca9388..1e080255 100644 --- a/M5StackCommon/Core2ToughCommon.cs +++ b/M5StackCommon/Core2ToughCommon.cs @@ -406,16 +406,11 @@ static Tough() #endif - // Setup SPI1 + // Setup SPI2 (LCD and SD Card) Configuration.SetPinFunction(23, DeviceFunction.SPI1_MOSI); Configuration.SetPinFunction(38, DeviceFunction.SPI1_MISO); Configuration.SetPinFunction(18, DeviceFunction.SPI1_CLOCK); - // Setup the screen with SP2 and SD Card - Configuration.SetPinFunction(23, DeviceFunction.SPI2_MOSI); - Configuration.SetPinFunction(38, DeviceFunction.SPI2_MISO); - Configuration.SetPinFunction(18, DeviceFunction.SPI2_CLOCK); - // Second serial port Configuration.SetPinFunction(13, DeviceFunction.COM2_RX); Configuration.SetPinFunction(14, DeviceFunction.COM2_TX); @@ -423,6 +418,7 @@ static Tough() // Setup second I2C bus (port A) Configuration.SetPinFunction(33, DeviceFunction.I2C2_CLOCK); Configuration.SetPinFunction(32, DeviceFunction.I2C2_DATA); + // The portA is the second I2C _portANumber = 2; diff --git a/M5StackCommon/Screen.cs b/M5StackCommon/Screen.cs index d31dc314..4bb8ca7e 100644 --- a/M5StackCommon/Screen.cs +++ b/M5StackCommon/Screen.cs @@ -70,7 +70,23 @@ public Screen(int memoryBitMapAllocation = DefaultMemoryAllocationBitmap) #endif // Create the screen - DisplayControl.Initialize(new SpiConfiguration(2, ChipSelect, DataCommand, Reset, BackLightPin), new ScreenConfiguration(0, 0, 320, 240), (uint)MemoryAllocationBitmap); + var displaySpiConfig = new SpiConfiguration( + 1, + ChipSelect, + DataCommand, + Reset, + BackLightPin); + + var screenConfig = new ScreenConfiguration( + 0, + 0, + 320, + 240); + + _ = DisplayControl.Initialize( + displaySpiConfig, + screenConfig, + (uint)MemoryAllocationBitmap); // set initial value for brightness BrightnessPercentage = DefaultScreenBrightness; diff --git a/nanoFramework.Fire/Fire.cs b/nanoFramework.Fire/Fire.cs index 9102d3a8..8e67d69a 100644 --- a/nanoFramework.Fire/Fire.cs +++ b/nanoFramework.Fire/Fire.cs @@ -170,9 +170,9 @@ static Fire() _gpio = new(); // Config GPIOs for SPI (screen and SD Card) - Configuration.SetPinFunction(23, DeviceFunction.SPI2_MOSI); - Configuration.SetPinFunction(19, DeviceFunction.SPI2_MISO); - Configuration.SetPinFunction(18, DeviceFunction.SPI2_CLOCK); + Configuration.SetPinFunction(23, DeviceFunction.SPI1_MOSI); + Configuration.SetPinFunction(19, DeviceFunction.SPI1_MISO); + Configuration.SetPinFunction(18, DeviceFunction.SPI1_CLOCK); // Second serial port Configuration.SetPinFunction(16, DeviceFunction.COM2_RX); diff --git a/nanoFramework.Fire/Screen.cs b/nanoFramework.Fire/Screen.cs index b2440354..5de511fa 100644 --- a/nanoFramework.Fire/Screen.cs +++ b/nanoFramework.Fire/Screen.cs @@ -37,7 +37,25 @@ public Screen(int memoryBitMapAllocation = DefaultMemoryAllocationBitmap) Controller = new(); Controller.OpenPin(BackLightPin, PinMode.Output); Enabled = true; - DisplayControl.Initialize(new SpiConfiguration(2, ChipSelect, DataCommand, Reset, BackLightPin), new ScreenConfiguration(0, 0, 320, 240), (uint)MemoryAllocationBitmap); + + var displaySpiConfig = new SpiConfiguration( + 1, + ChipSelect, + DataCommand, + Reset, + BackLightPin); + + var screenConfig = new ScreenConfiguration( + 0, + 0, + 320, + 240); + + _ = DisplayControl.Initialize( + displaySpiConfig, + screenConfig, + (uint)MemoryAllocationBitmap); + _isInitialized = true; } } diff --git a/nanoFramework.M5Core/M5Core.cs b/nanoFramework.M5Core/M5Core.cs index c9c22af4..7fdbebc3 100644 --- a/nanoFramework.M5Core/M5Core.cs +++ b/nanoFramework.M5Core/M5Core.cs @@ -155,9 +155,9 @@ static M5Core() _gpio = new(); // Config GPIOs for SPI (screen and SD Card) - Configuration.SetPinFunction(23, DeviceFunction.SPI2_MOSI); - Configuration.SetPinFunction(19, DeviceFunction.SPI2_MISO); - Configuration.SetPinFunction(18, DeviceFunction.SPI2_CLOCK); + Configuration.SetPinFunction(23, DeviceFunction.SPI1_MOSI); + Configuration.SetPinFunction(19, DeviceFunction.SPI1_MISO); + Configuration.SetPinFunction(18, DeviceFunction.SPI1_CLOCK); // Second serial port Configuration.SetPinFunction(16, DeviceFunction.COM2_RX); diff --git a/nanoFramework.M5Core/Screen.cs b/nanoFramework.M5Core/Screen.cs index 46a55c3f..3d8bea6a 100644 --- a/nanoFramework.M5Core/Screen.cs +++ b/nanoFramework.M5Core/Screen.cs @@ -37,7 +37,25 @@ public Screen(int memoryBitMapAllocation = DefaultMemoryAllocationBitmap) Controller = new(); Controller.OpenPin(BackLightPin, PinMode.Output); Enabled = true; - DisplayControl.Initialize(new SpiConfiguration(2, ChipSelect, DataCommand, Reset, BackLightPin), new ScreenConfiguration(0, 0, 320, 240), (uint)MemoryAllocationBitmap); + + var displaySpiConfig = new SpiConfiguration( + 1, + ChipSelect, + DataCommand, + Reset, + BackLightPin); + + var screenConfig = new ScreenConfiguration( + 0, + 0, + 320, + 240); + + _ = DisplayControl.Initialize( + displaySpiConfig, + screenConfig, + (uint)MemoryAllocationBitmap); + _isInitialized = true; } } diff --git a/nanoFramework.M5StickCommon/M5StickCBase.cs b/nanoFramework.M5StickCommon/M5StickCBase.cs index fcfc2709..f73d6e5c 100644 --- a/nanoFramework.M5StickCommon/M5StickCBase.cs +++ b/nanoFramework.M5StickCommon/M5StickCBase.cs @@ -185,10 +185,10 @@ static M5StickCPlus() Configuration.SetPinFunction(32, DeviceFunction.I2C2_DATA); // Set the pins for the screen - Configuration.SetPinFunction(15, DeviceFunction.SPI2_MOSI); - Configuration.SetPinFunction(13, DeviceFunction.SPI2_CLOCK); + Configuration.SetPinFunction(15, DeviceFunction.SPI1_MOSI); + Configuration.SetPinFunction(13, DeviceFunction.SPI1_CLOCK); // This is not used but must be defined - Configuration.SetPinFunction(4, DeviceFunction.SPI2_MISO); + Configuration.SetPinFunction(4, DeviceFunction.SPI1_MISO); // Setup the time if any _rtc = new Pcf8563(I2cDevice.Create(new I2cConnectionSettings(1, Pcf8563.DefaultI2cAddress))); diff --git a/nanoFramework.M5StickCommon/Screen.cs b/nanoFramework.M5StickCommon/Screen.cs index 015521df..499a2855 100644 --- a/nanoFramework.M5StickCommon/Screen.cs +++ b/nanoFramework.M5StickCommon/Screen.cs @@ -39,15 +39,42 @@ public Screen(int memoryBitMapAllocation = DefaultMemoryAllocationBitmap) MemoryAllocationBitmap = memoryBitMapAllocation; // Not used in Stick versions, AXP is doing this BackLightPin = -1; + #if M5STICKC _power = M5StickC.Power; - DisplayControl.Initialize(new SpiConfiguration(2, ChipSelect, DataCommand, Reset, BackLightPin), new ScreenConfiguration(26, 1, 80, 160), (uint)MemoryAllocationBitmap); #else _power = M5StickCPlus.Power; - DisplayControl.Initialize(new SpiConfiguration(2, ChipSelect, DataCommand, Reset, BackLightPin), new ScreenConfiguration(52, 40, 135, 240), (uint)MemoryAllocationBitmap); #endif + + var displaySpiConfig = new SpiConfiguration( + 1, + ChipSelect, + DataCommand, + Reset, + BackLightPin); + +#if M5STICKC + var screenConfig = new ScreenConfiguration( + 26, + 1, + 80, + 160); +#else + var screenConfig = new ScreenConfiguration( + 52, + 40, + 135, + 240); +#endif + + _ = DisplayControl.Initialize( + displaySpiConfig, + screenConfig, + (uint)MemoryAllocationBitmap); + // Enable the screen Enabled = true; + // For M5Stick, values from 2.6 to 3V are working fine LuminosityPercentage = 100; _power.EnableLDO3(true); diff --git a/version.json b/version.json index 403e94fb..f59e911b 100644 --- a/version.json +++ b/version.json @@ -1,13 +1,13 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.0", + "version": "1.1", "assemblyVersion": { "precision": "revision" }, "semVer1NumericIdentifierPadding": 3, "nuGetPackageVersion": { "semVer": 2.0, - "precision": "revision" + "precision": "build" }, "publicReleaseRefSpec": [ "^refs/heads/main$",