diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index 5ef8af20..efd5023c 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -7,8 +7,9 @@ name: Daily update dependencies on: schedule: - # At 00:00 UTC every Mon, Wed and Friday. - - cron: '00 00 * * 1,3,5' + # At 03:00 UTC daily. + # This has to run after the automated updated in IoT bindings as it depends from several bindings there. + - cron: '00 03 * * *' repository_dispatch: types: update-dependencies @@ -21,32 +22,12 @@ jobs: name: Update .NET nanoFramework dependencies timeout-minutes: 30 # Non default because this solution has lots of projects to update! runs-on: windows-latest + env: + GITHUB_TOKEN: ${{ github.token }} steps: - name: Checkout uses: actions/checkout@v2 - with: - path: main - - name: Checkout tools repo - uses: actions/checkout@v2 - with: - repository: nanoframework/nf-tools - path: tools - name: Update dependencies - run: ./github-actions/update-nf-dependencies.ps1 - working-directory: tools - - name: Create Pull Request - uses: peter-evans/create-pull-request@v3 - if: env.CREATE_PR == 'true' + uses: nanoframework/nanodu@v1 with: - title: '${{ env.PR_TITLE }}' - body: | - ${{ env.PR_MESSAGE }} - - [version update] - - ### :warning: This is an automated update. :warning: - committer: 'nfbot ' - branch: ${{ env.BRANCH_NAME }} - path: main - labels: | - Type: dependencies + solutionsToCheck: 'nanoFramework.M5Stack.sln' diff --git a/.gitignore b/.gitignore index d7dec62f..79e57d7c 100644 --- a/.gitignore +++ b/.gitignore @@ -331,3 +331,6 @@ ASALocalRun/ #SoundCloud *.sonarqube/ + +#VSCode +*.vscode/ diff --git a/AtomCommon/AtomBase.cs b/AtomCommon/AtomBase.cs new file mode 100644 index 00000000..00ae096c --- /dev/null +++ b/AtomCommon/AtomBase.cs @@ -0,0 +1,155 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Iot.Device.Button; +using nanoFramework.Hardware.Esp32; +using nanoFramework.Hardware.Esp32.Rmt; +using System; +using System.Device.Adc; +using System.Device.Dac; +using System.Device.Gpio; +using System.Device.I2c; +using System.Device.Spi; + +#if ATOM_MATRIX +namespace nanoFramework.AtomMatrix +{ + /// + /// The AtomMatrix Board. + /// + public static partial class AtomMatrix +#else +namespace nanoFramework.AtomLite +{ + /// + /// M5Stack board + /// + public static partial class AtomLite +#endif + { + private static GpioButton _button; + private static GpioController _gpio; + private static DacChannel _dac1; + private static DacChannel _dac2; + private static AdcController _adc; + private static TransmitterChannel _irLed; + + /// + /// Main button. + /// + public static GpioButton Button + { + get + { + if (_button == null) + { + _button = new(39, _gpio, false); + } + + return _button; + } + } + + /// + /// Gets the main . + /// + public static GpioController GpioController => _gpio; + + /// + /// Gets connected to GPIO 25. + /// + public static DacChannel Dac1 + { + get + { + // We are creating it on demand + if (_dac1 == null) + { + _dac1 = DacController.GetDefault().OpenChannel(0); + } + + return _dac1; + } + } + + /// + /// Gets connected to GPIO 26. + /// + public static DacChannel Dac2 + { + get + { + // We are creating it on demand + if (_dac2 == null) + { + + _dac2 = DacController.GetDefault().OpenChannel(1); + } + + return _dac2; + } + } + + /// + /// Gets an . + /// + /// The address of the on the bus. + /// The I2cDevice. + public static I2cDevice GetI2cDevice(int i2cDeviceAddress) => new(new I2cConnectionSettings(1, i2cDeviceAddress)); + + /// + /// Gets an . + /// + /// The address of the on the bus. + /// The I2cDevice. + public static I2cDevice GetGrove(int i2cDeviceAddress) => new(new I2cConnectionSettings(1, i2cDeviceAddress)); + + /// + /// Gets the infrared led as a RMT transmitter channel. + /// + public static TransmitterChannel InfraredLed + { + get + { + if (_irLed == null) + { + _irLed = new(12); + } + + return _irLed; + } + } + + /// + /// Gets an . + /// + /// The chip select of the device, needs to be any valid GPIO. + /// An SpiDevice. + public static SpiDevice GetSpiDevice(int chipSelect) => new(new SpiConnectionSettings(1, chipSelect)); + + /// + /// Gets an + /// + /// The GPIO pin number where the is connected to. + /// An AdcChannel + public static AdcChannel GetAdcGpio(int gpioNumber) + { + if (_adc == null) + { + _adc = new(); + } + + switch (gpioNumber) + { + case 33: + Configuration.SetPinFunction(12, DeviceFunction.ADC1_CH5); + return _adc.OpenChannel(5); + case 32: + Configuration.SetPinFunction(25, DeviceFunction.ADC1_CH4); + return _adc.OpenChannel(4); + default: + throw new ArgumentException(nameof(gpioNumber)); + } + } + } +} diff --git a/AtomCommon/AtomCommon.projitems b/AtomCommon/AtomCommon.projitems new file mode 100644 index 00000000..e5821777 --- /dev/null +++ b/AtomCommon/AtomCommon.projitems @@ -0,0 +1,14 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 79f09006-ab5d-4e3e-ad12-2efbee536ca9 + + + AtomCommon + + + + + \ No newline at end of file diff --git a/AtomCommon/AtomCommon.shproj b/AtomCommon/AtomCommon.shproj new file mode 100644 index 00000000..b0cec0d2 --- /dev/null +++ b/AtomCommon/AtomCommon.shproj @@ -0,0 +1,13 @@ + + + + 79f09006-ab5d-4e3e-ad12-2efbee536ca9 + 14.0 + + + + + + + + diff --git a/M5StackCommon/Console.cs b/M5StackCommon/Console.cs index 119d2419..50092815 100644 --- a/M5StackCommon/Console.cs +++ b/M5StackCommon/Console.cs @@ -3,9 +3,8 @@ using nanoFramework.Presentation.Media; using nanoFramework.UI; -using System; -namespace nanoFramework +namespace nanoFramework.M5Stack { /// /// Console class to display text on screens diff --git a/M5StackCommon/ScreenBase.cs b/M5StackCommon/ScreenBase.cs index b08b8f87..5539abf6 100644 --- a/M5StackCommon/ScreenBase.cs +++ b/M5StackCommon/ScreenBase.cs @@ -3,7 +3,6 @@ using nanoFramework.Presentation.Media; using nanoFramework.UI; -using System; using System.Device.Gpio; namespace nanoFramework.M5Stack diff --git a/README.md b/README.md index 8461cce9..8c8be5b9 100644 --- a/README.md +++ b/README.md @@ -4,56 +4,107 @@ ----- -# Welcome to the .NET **nanoFramework** M5Stack Library repository +# Welcome to the .NET **nanoFramework** M5Stack Libraries repository ## Build status | Component | Build Status | NuGet Package | |:-|---|---| -| nanoFramework.M5Stack | [![Build Status](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_apis/build/status/nanoFramework.M5Stack?repoName=nanoframework%2FnanoFramework.M5Stack&branchName=main)](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_build/latest?definitionId=52&repoName=nanoframework%2FnanoFramework.M5Stack&branchName=main) | [![NuGet](https://img.shields.io/nuget/v/nanoFramework.M5Stack.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.M5Stack/) | -| nanoFramework.M5Stack (preview) | [![Build Status](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_apis/build/status/nanoFramework.M5Stack?repoName=nanoframework%2FnanoFramework.M5Stack&branchName=develop)](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_build/latest?definitionId=52&repoName=nanoframework%2FnanoFramework.M5Stack&branchName=develop) | [![NuGet](https://img.shields.io/nuget/vpre/nanoFramework.M5Stack.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.M5Stack/) | +| nanoFramework.M5Core | [![Build Status](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_apis/build/status/nanoFramework.M5Stack?repoName=nanoframework%2FnanoFramework.M5Stack&branchName=main)](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_build/latest?definitionId=52&repoName=nanoframework%2FnanoFramework.M5Stack&branchName=main) | [![NuGet](https://img.shields.io/nuget/v/nanoFramework.M5Core.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.M5Stack/) | +| nanoFramework.M5Core (preview) | [![Build Status](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_apis/build/status/nanoFramework.M5Stack?repoName=nanoframework%2FnanoFramework.M5Stack&branchName=develop)](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_build/latest?definitionId=52&repoName=nanoframework%2FnanoFramework.M5Stack&branchName=develop) | [![NuGet](https://img.shields.io/nuget/vpre/nanoFramework.M5Core.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.M5Stack/) | | nanoFramework.M5Stick | [![Build Status](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_apis/build/status/nanoFramework.M5Stack?repoName=nanoframework%2FnanoFramework.M5Stack&branchName=main)](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_build/latest?definitionId=52&repoName=nanoframework%2FnanoFramework.M5Stack&branchName=main) | [![NuGet](https://img.shields.io/nuget/v/nanoFramework.M5StickC.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.M5StickC/) | | nanoFramework.M5Stick (preview) | [![Build Status](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_apis/build/status/nanoFramework.M5Stack?repoName=nanoframework%2FnanoFramework.M5Stack&branchName=develop)](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_build/latest?definitionId=52&repoName=nanoframework%2FnanoFramework.M5Stack&branchName=develop) | [![NuGet](https://img.shields.io/nuget/vpre/nanoFramework.M5StickC.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.M5StickC/) | | nanoFramework.M5StickCPlus | [![Build Status](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_apis/build/status/nanoFramework.M5Stack?repoName=nanoframework%2FnanoFramework.M5Stack&branchName=main)](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_build/latest?definitionId=52&repoName=nanoframework%2FnanoFramework.M5Stack&branchName=main) | [![NuGet](https://img.shields.io/nuget/v/nanoFramework.M5StickCPlus.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.M5StickCPlus/) | | nanoFramework.M5StickCPlus (preview) | [![Build Status](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_apis/build/status/nanoFramework.M5Stack?repoName=nanoframework%2FnanoFramework.M5Stack&branchName=develop)](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_build/latest?definitionId=52&repoName=nanoframework%2FnanoFramework.M5Stack&branchName=develop) | [![NuGet](https://img.shields.io/nuget/vpre/nanoFramework.M5StickCPlus.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.M5StickCPlus/) | | nanoFramework.M5Core2 | [![Build Status](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_apis/build/status/nanoFramework.M5Stack?repoName=nanoframework%2FnanoFramework.M5Stack&branchName=main)](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_build/latest?definitionId=52&repoName=nanoframework%2FnanoFramework.M5Stack&branchName=main) | [![NuGet](https://img.shields.io/nuget/v/nanoFramework.M5Core2.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.M5Core2/) | | nanoFramework.M5Core2 (preview) | [![Build Status](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_apis/build/status/nanoFramework.M5Stack?repoName=nanoframework%2FnanoFramework.M5Stack&branchName=develop)](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_build/latest?definitionId=52&repoName=nanoframework%2FnanoFramework.M5Stack&branchName=develop) | [![NuGet](https://img.shields.io/nuget/vpre/nanoFramework.M5Core2.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.M5Core2/) | +| nanoFramework.Fire | [![Build Status](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_apis/build/status/nanoFramework.M5Stack?repoName=nanoframework%2FnanoFramework.M5Stack&branchName=main)](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_build/latest?definitionId=52&repoName=nanoframework%2FnanoFramework.M5Stack&branchName=main) | [![NuGet](https://img.shields.io/nuget/v/nanoFramework.Fire.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.Fire/) | +| nanoFramework.Fire (preview) | [![Build Status](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_apis/build/status/nanoFramework.M5Stack?repoName=nanoframework%2FnanoFramework.M5Stack&branchName=develop)](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_build/latest?definitionId=52&repoName=nanoframework%2FnanoFramework.M5Stack&branchName=develop) | [![NuGet](https://img.shields.io/nuget/vpre/nanoFramework.Fire.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.Fire/) | +| nanoFramework.AtomLite | [![Build Status](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_apis/build/status/nanoFramework.M5Stack?repoName=nanoframework%2FnanoFramework.M5Stack&branchName=main)](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_build/latest?definitionId=52&repoName=nanoframework%2FnanoFramework.M5Stack&branchName=main) | [![NuGet](https://img.shields.io/nuget/v/nanoFramework.AtomLite.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.AtomLite/) | +| nanoFramework.AtomLite (preview) | [![Build Status](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_apis/build/status/nanoFramework.M5Stack?repoName=nanoframework%2FnanoFramework.M5Stack&branchName=develop)](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_build/latest?definitionId=52&repoName=nanoframework%2FnanoFramework.M5Stack&branchName=develop) | [![NuGet](https://img.shields.io/nuget/vpre/nanoFramework.AtomLite.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.AtomLite/) | +| nanoFramework.AtomMatrix | [![Build Status](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_apis/build/status/nanoFramework.M5Stack?repoName=nanoframework%2FnanoFramework.M5Stack&branchName=main)](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_build/latest?definitionId=52&repoName=nanoframework%2FnanoFramework.M5Stack&branchName=main) | [![NuGet](https://img.shields.io/nuget/v/nanoFramework.AtomMatrix.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.AtomMatrix/) | +| nanoFramework.AtomMatrix (preview) | [![Build Status](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_apis/build/status/nanoFramework.M5Stack?repoName=nanoframework%2FnanoFramework.M5Stack&branchName=develop)](https://dev.azure.com/nanoframework/nanoFramework.M5Stack/_build/latest?definitionId=52&repoName=nanoframework%2FnanoFramework.M5Stack&branchName=develop) | [![NuGet](https://img.shields.io/nuget/vpre/nanoFramework.AtomMatrix.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.AtomMatrix/) | ## Usage -Those 3 nugets provide a support for the [M5Stack](https://docs.m5stack.com/en/products?id=core), [M5StickC](https://docs.m5stack.com/en/core/m5stickc), [M5StickCPlus](https://docs.m5stack.com/en/core/m5stickc_plus) and [M5Core2](https://docs.m5stack.com/en/core/core2). +These NuGet packages provide a support for M5Stack products: -They bring support for the screens as well and require to be flashed with the proper image: +- [Core (gray) and Basic](https://docs.m5stack.com/en/products?id=core) +- [M5StickC](https://docs.m5stack.com/en/core/m5stickc) +- [M5StickCPlus](https://docs.m5stack.com/en/core/m5stickc_plus) +- [M5Core2](https://docs.m5stack.com/en/core/core2) +- [Fire](https://docs.m5stack.com/en/core/fire) +- [Atom Lite](https://docs.m5stack.com/en/core/atom_lite) +- [Atom Matrix](https://docs.m5stack.com/en/core/atom_matrix) + +> Note 1: Before trying to add NuGet packages to your projects and/or before flashing the devices (see next section) using MS Visual Studio (VS), open VS > Tools > Options > NuGet Package Manager > Package Sources and make sure that it contains an entry pointing to , otherwise add it. +> Note 2: When invoking VS > Project > Manage NuGet Packages make sure that in the Package source drop-down menu (right upper corner) "nuget.org" is selected. Also if you're using preview version the "include prerelease" checkbox should be clicked/selected as well. + +The NuGets bring support for the screens as well and require to be flashed with the proper image (using [`nanoff`](https://github.com/nanoframework/nanoFirmwareFlasher) dotnet CLI). +On the examples below replace `COM3` with the appropriate number of the COM port to which your device is connected. (on Windows you can check this in the Device Manager). + +For the M5Core: + +```shell +nanoff --target M5Core --update --preview --serialport COM3 +``` + +For the M5StickC: ```shell -# Replace the com port number by your COM port -# For the M5Stack: -nanoff --target M5Stack --update --preview --serialport COM3 -# For the M5StickC: nanoff --target M5StickC --update --preview --serialport COM3 --baud 115200 -# For the M5StickCPlus: -nanoff --target M5StickCPlus --update --preview --serialport COM3 --baud 115200 -# For the M5Core2: +``` + +For the M5StickCPlus: + +```shell +nanoff --target M5StickCPlus --update --preview --serialport COM3 +``` + +For the M5Core2 and Fire: + +```shell nanoff --target M5Core2 --update --preview --serialport COM3 ``` -Once you have the nugets, you can then enjoy accessing the screen, the accelerometer, get a Grove I2C connecter, add events on the buttons. And you don't even need to think about anything, all is done for you in the most transparent way! +For the Atom Lite and Matrix: + +```shell +nanoff --target ESP32_PICO --update --preview --serialport COM3 +``` + +> Note 3: If the `nanoff` commands fails, make sure you have followed instruction from Note 1 above. + +Once you have the NuGets, you can then enjoy accessing the screen, the accelerometer, get a Grove I2C connecter, add events on the buttons. And you don't even need to think about anything, all is done for you in the most transparent way! -> Note: All the classes that you'll have access are all using the Lazy pattern to be instantiated including the screen. This have the advantage to use as little memory and setup time as possible. +> Note 4: All the classes that you'll have access are all using the Lazy pattern to be instantiated including the screen. This have the advantage to use as little memory and setup time as possible. -In the samples below, we'll use either M5Stack, either M5Stick as examples, they are all working in a very similar way. +In the samples below, we'll use either M5Core or M5Stick as examples, they are all working in a very similar way. + +### Namespaces + +Make sure you add the proper namespaces reference to your C# program header e.g. +using nanoFramework; ### Screen -The only thing you need to do to access the screen is to initialize it: +The only thing you need to do to access the screen is to initialize it (please note that `InitializeScreen()` it's target specific) e.g.: + +For Core: + +```csharp +M5Core.InitializeScreen(); +``` + +For StickCPlus: ```csharp -M5Stack.InitializeScreen(); +M5StickCPlus.InitializeScreen(); ``` Once you've initialized it, you can access both a `Screen` static class and a `Console` static class. -THe `Screen` one brings primitives to write directly on the screen points or scare of colors as well as writing a text. +THe `Screen` one brings primitives to write directly on the screen points or scare of colours as well as writing a text. For example, you can write a blue square of 10x10 at the position 0, 0 like this: @@ -69,33 +120,33 @@ for (int i = 0; i < toSend.Length; i++) Screen.Write(0, 0, 10, 10, toSend); ``` -The Console class works in a similar way as the classic `System.Console`: +The Console class works in a similar way as the classic `System.Console`. In order to use it you have to reference it using the fully qualified name of the methods, like this: ```csharp -Console.Clear(); +nanoFramework.Console.Clear(); // Test the console display -Console.Write("This is a short text. "); -Console.ForegroundColor = Color.Red; -Console.WriteLine("This one displays in red after the previous one and is already at the next line."); -Console.BackgroundColor = Color.Yellow; -Console.ForegroundColor = Color.RoyalBlue; -Console.WriteLine("And this is blue on yellow background"); -Console.ResetColor(); -Console.CursorLeft = 0; -Console.CursorTop = 8; -Console.Write("This is white on black again and on 9th line"); +nanoFramework.Console.Write("This is a short text. "); +nanoFramework.Console.ForegroundColor = nanoFramework.Presentation.Media.Color.Red; +nanoFramework.Console.WriteLine("This one displays in red after the previous one and is already at the next line."); +nanoFramework.Console.BackgroundColor = nanoFramework.Presentation.Media.Color.Yellow; +nanoFramework.Console.ForegroundColor = nanoFramework.Presentation.Media.Color.RoyalBlue; +nanoFramework.Console.WriteLine("And this is blue on yellow background"); +nanoFramework.Console.ResetColor(); +nanoFramework.Console.CursorLeft = 0; +nanoFramework.Console.CursorTop = 8; +nanoFramework.Console.Write("This is white on black again and on 9th line"); ``` > Note: You can change the default font as well, you need to provide it as a property. The Cursor positions are calculated with the largest possible character. -M5Core2 has SPRAM, so you can get a full screen buffer as well. Refer to the [Graphics samples](https://github.com/nanoframework/Samples#graphics-for-screens) to understand all you can do with it. +M5Core2 and Fire have SPRAM, so you can get a full screen buffer as well. Refer to the [Graphics samples](https://github.com/nanoframework/Samples#graphics-for-screens) to understand all you can do with it. ### Buttons The main buttons except the power buttons are exposed. -On the M5Stack they are called `ButtonLeft`, `ButtonCenter` and `ButtonRight`. You can get access to the events as well. For example: +On the M5Stack and Fire they are called `ButtonLeft`, `ButtonCenter` and `ButtonRight`. You can get access to the events as well. For example: ```csharp M5Stack.ButtonLeft.Press += (sender, e) => @@ -122,21 +173,117 @@ M5StickC.M5Button.Holding += (sender, e) => }; ``` -> Note: The M5Core2 has touch screen and the buttons are part of it. So far .NET nanoFramework does not have the support for them and thus, they are not supported yet. PR to improve this situation welcome! +On the Atom Lite/Matrix it's called `Button`. You can get access to the status of the button, the events and everything you need. For example: + +```csharp +AtomLite.Button.Press +=> (sender, e) +{ + var color = AtomLite.NeoPixel.GetColor(); + if(color.R > 0) + { + AtomLite.NeoPixel.SetColor(Color.FromArgb(255, 0, 255, 0)); + } + else if (color.G > 0) + { + AtomLite.NeoPixel.SetColor(Color.FromArgb(255, 0, 0, 255)); + } + else + { + AtomLite.NeoPixel.SetColor(Color.FromArgb(255, 255, 0, 0)); + } +}; +``` + +> Note: The M5Core2 has touch screen and the buttons are "virtual"". See next section to see how to use them. + +### M5Core2 touch panel and buttons + +The touch panel comes with the screen. Both are initialized and activated at the same time. To get the touch events, you'll have to register to the `TouchEvent` event: + +```csharp +M5Core2.InitializeScreen(); +M5Core2.TouchEvent += TouchEventCallback; +``` + +Here is an example on how to check if you are on a button or not and get the various elements: + +```csharp +void TouchEventCallback(object sender, TouchEventArgs e) +{ + const string StrLB = "LEFT BUTTON PRESSED "; + const string StrMB = "MIDDLE BUTTON PRESSED "; + const string StrRB = "RIGHT BUTTON PRESSED "; + const string StrXY1 = "TOUCHED at X= "; + const string StrXY2 = ",Y= "; + const string StrID = ",Id= "; + const string StrDoubleTouch = "Double touch. "; + const string StrMove = "Moving... "; + const string StrLiftUp = "Lift up. "; + + Debug.WriteLine($"Touch Panel Event Received Category= {e.EventCategory} Subcategory= {e.TouchEventCategory}"); + Console.CursorLeft = 0; + Console.CursorTop = 0; + + Debug.WriteLine(StrXY1 + e.X + StrXY2 + e.Y + StrID + e.Id); + Console.WriteLine(StrXY1 + e.X + StrXY2 + e.Y + StrID + e.Id + " "); + + if ((e.TouchEventCategory & TouchEventCategory.LeftButton) == TouchEventCategory.LeftButton) + { + Debug.WriteLine(StrLB); + Console.WriteLine(StrLB); + } + else if ((e.TouchEventCategory & TouchEventCategory.MiddleButton) == TouchEventCategory.MiddleButton) + { + Debug.WriteLine(StrMB); + Console.WriteLine(StrMB); + } + else if ((e.TouchEventCategory & TouchEventCategory.RightButton) == TouchEventCategory.RightButton) + { + Debug.WriteLine(StrRB); + Console.WriteLine(StrRB); + } + + if ((e.TouchEventCategory & TouchEventCategory.Moving) == TouchEventCategory.Moving) + { + Debug.WriteLine(StrMove); + Console.Write(StrMove); + } + + if ((e.TouchEventCategory & TouchEventCategory.LiftUp) == TouchEventCategory.LiftUp) + { + Debug.WriteLine(StrLiftUp); + Console.Write(StrLiftUp); + } + + if ((e.TouchEventCategory & TouchEventCategory.DoubleTouch) == TouchEventCategory.DoubleTouch) + { + Debug.WriteLine(StrDoubleTouch); + Console.Write(StrDoubleTouch); + } + + Console.WriteLine(" "); + Console.WriteLine(" "); + Console.WriteLine(" "); +} +``` + +The `TouchEventCategory` enum is a flag and can combine buttons and states. The buttons are mutually exclusive, so you can only have the Left, Middle or Right button, the states are `Moving` and `LiftUp`. `Moving` is happening when a contact has already been made and the touch point is moving. `LiftUp` will appear when the contact is released. + +`DoubleTouch` is a specific that let you know there is another contact point happening. Each contact point will receive this flag. The event will be raised 2 times, one for each point. In a double touch context, you may not get the second point `LiftUp` event but you'll get the change with the disappearance of the DoubleTouch flag and the final `LiftUp` on the first point. ### Power management -Both M5Stack and M5StickC/CPlus are exposing their power management elements. It is not recommended to change any default value except if you know what you are doing. +The M5Core and M5StickC/CPlus are exposing their power management elements. It is not recommended to change any default value except if you know what you are doing. -Please refer to the detailed examples for the [AXP192](https://github.com/nanoframework/nanoFramework.IoT.Device/blob/develop/devices/Axp192/README.md) used in the M5StickC/CPlus; M5Core2 and [IP5306](https://github.com/nanoframework/nanoFramework.IoT.Device/blob/develop/devices/Ip5306/README.md) for the M5Stack. +Please refer to the detailed examples for the [AXP192](https://github.com/nanoframework/nanoFramework.IoT.Device/blob/develop/devices/Axp192/README.md) used in the M5StickC/CPlus; M5Core2 and [IP5306](https://github.com/nanoframework/nanoFramework.IoT.Device/blob/develop/devices/Ip5306/README.md) for the M5Core and Fire. ### Accelerometer and Gyroscope You can get access to the Accelerometer and Gyroscope like this: ```csharp -var ag = M5Stack.AccelerometerGyroscope; -// Do not move the M5Stack/M5Stick during the calibration +var ag = M5Core.AccelerometerGyroscope; +// Do not move the M5Core/M5Stick during the calibration ag.Calibrate(100); var acc = ag.GetAccelerometer(); var gyr = ag.GetGyroscope(); @@ -148,12 +295,12 @@ Refer to the [MPU6886 documentation](https://github.com/nanoframework/nanoFramew ### Magnetometer -The M5Stack has a magnetometer, you can access it as well: +The M5Core has a magnetometer, you can access it as well: ```csharp -var mag = M5Stack.Magnetometer; +var mag = M5Core.Magnetometer; // It is more than strongly recommended to calibrate the magnetometer. -// Move the M5Stack in all directions to have a proper calibration. +// Move the M5Core in all directions to have a proper calibration. mag.CalibrateMagnetometer(100); var magVal = mag.ReadMagnetometer(); Console.WriteLine($"x={magVal.X:N2} "); @@ -165,24 +312,24 @@ Console.WriteLine($"h={headDir:N2} "); ### SerialPort -The M5Stack and M5Core2 can provide a Serial Port, just get it like this: +The M5Core and M5Core2 can provide a Serial Port, just get it like this: ```csharp // You can access any of the Serial Port feature -M5Stack.SerialPort.Open(115200); +M5Core.SerialPort.Open(115200); // Do anything else you need -M5Stack.SerialPort.Close(); +M5Core.SerialPort.Close(); ``` Refer to the [SerialPort documentation](https://github.com/nanoframework/System.IO.Ports) for more information. ### ADC Channels -ADC Channels are pre setup on the M5Stack, access them like this: +ADC Channels are pre setup on the M5Core, M5Core2, Fire and Atom Lite/Matrix, access them like this: ```csharp -// This will give you the ADC1 channel 7 which is on pin 35 -AdcChannel myChannel = M5Stack.GetAdcGpio(35); +// This will give you the ADC1 channel 7 which is on pin 35 of M5Core +AdcChannel myChannel = M5Core.GetAdcGpio(35); ``` Refer to the M5Stack documentation to have the mapping of the ADC channels and the pins. @@ -193,22 +340,22 @@ You can get an I2cDevice/Grove like this: ```csharp // In this example, the I2C address of the device is 0x42: -I2cDevice myDevice = M5Stack.GetGrove(0x42); +I2cDevice myDevice = M5Core.GetGrove(0x42); // replacing GetGrove by GetI2cDevice will have the same impact ``` ### SPI Device -The M5Stack provides as well an SPiDevice: +The M5Core, M5Core2, Fire and Atom Lite/Matrix provides as well an `SpiDevice`: ```csharp // In this case GPIO5 will be used as chip select: -SpiDevice mySpi = M5Stack.GetSpiDevice(5); +SpiDevice mySpi = M5Core.GetSpiDevice(5); ``` ### GPIO Controller -Similar as previously, you can get the `GpioController` on any of the M5Stack, M5Core2 and M5StickC/CPlus: +Similar as previously, you can get the `GpioController` on any of the M5Core, M5Core2, Fire and M5StickC/CPlus: ```csharp // This will open the GPIO 36 as output @@ -217,7 +364,7 @@ var pin5 = M5StickC.GpioController.OpenPin(36, PinMode.Output); ### DAC -The M5Stack exposes 2 DAC and you can access them thru the `Dac1` and `Dac2` properties. Refer to the [DAC documentation](https://github.com/nanoframework/System.Device.Dac) for more information. +The M5Core, M5Core2, Fire and Atom Lite/Matrix exposes 2 DAC and you can access them thru the `Dac1` and `Dac2` properties. Refer to the [DAC documentation](https://github.com/nanoframework/System.Device.Dac) for more information. ### Led @@ -230,7 +377,35 @@ M5StickC.Led.Toggle(); ### Infrared Led -The M5StickC/CPlus exposes an infrared led. You can access it thru the `InfraredLed` property. This will give you a `TransmitterChannel`. Check out the [sample pack](https://github.com/nanoframework/Samples/tree/main/samples/Hardware.Esp32.Rmt) to understand how to use it. +The M5StickC/CPlus and Atom Lite/Matrix exposes an infrared led. You can access it thru the `InfraredLed` property. This will give you a `TransmitterChannel`. Check out the [sample pack](https://github.com/nanoframework/Samples/tree/main/samples/Hardware.Esp32.Rmt) to understand how to use it. + +### NeoPixel + +The Atom Lite exposes a rgb led. You can access it thru the `NeoPixel` property: + +```csharp +// This will set NeoPixel to green: +AtomLite.NeoPixel.SetColor(Color.Green); +``` + +### RGB LED matrix + +The Atom Matrix has a matrix of 25 RGB LEDs. +The position of the LEDs in the array follows their placement in the matrix, being 0 the one at the top left corner, growing left to right, top to bottom. + +You can access it thru the `LedMatrix` property, like this: + +```csharp +// This will set the RGB LED at position 0 to green +AtomMatrix.LedMatrix.SetColor(0, Color.Green); +``` + +After you're done with updating all the LEDs that you want to change, flush the updated to the LEDs, like this: + +```csharp +// This will update all RGB LED +AtomMatrix.LedMatrix.Update(); +``` ## Feedback and documentation diff --git a/Tests/AtomLiteTestApp/AtomLiteTestApp.nfproj b/Tests/AtomLiteTestApp/AtomLiteTestApp.nfproj new file mode 100644 index 00000000..bfa9b4bb --- /dev/null +++ b/Tests/AtomLiteTestApp/AtomLiteTestApp.nfproj @@ -0,0 +1,58 @@ + + + + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ + + + + Debug + AnyCPU + {11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 7533c164-9d3e-461b-beed-888c91ac640b + Exe + Properties + 512 + AtomLiteTestApp + AtomLiteTestApp + v1.0 + + + + + + + + + + + + ..\..\packages\nanoFramework.Iot.Device.Button.1.0.288-preview.99\lib\Iot.Device.Button.dll + True + + + ..\..\packages\nanoFramework.CoreLibrary.1.12.0-preview.19\lib\mscorlib.dll + True + + + ..\..\packages\nanoFramework.Runtime.Events.1.10.0-preview.13\lib\nanoFramework.Runtime.Events.dll + True + + + ..\..\packages\nanoFramework.System.Device.Gpio.1.0.3-preview.18\lib\System.Device.Gpio.dll + True + + + ..\..\packages\nanoFramework.System.Drawing.1.0.288-preview.99\lib\System.Drawing.dll + True + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests/AtomLiteTestApp/Program.cs b/Tests/AtomLiteTestApp/Program.cs new file mode 100644 index 00000000..b171eb44 --- /dev/null +++ b/Tests/AtomLiteTestApp/Program.cs @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using nanoFramework.AtomLite; +using System; +using System.Diagnostics; +using System.Drawing; +using System.Threading; + +namespace AtomLiteTestApp +{ + public class Program + { + public static void Main() + { + var button = AtomLite.Button; + var rgb = AtomLite.NeoPixel; + rgb.SetColor(Color.FromArgb(255, 255, 0, 0)); + + button.Press += Button_Press; + + Debug.WriteLine("Hello from nanoFramework!"); + + Thread.Sleep(Timeout.Infinite); + } + + private static void Button_Press(object sender, EventArgs e) + { + var color = AtomLite.NeoPixel.GetColor(); + if(color.R > 0) + { + AtomLite.NeoPixel.SetColor(Color.FromArgb(255, 0, 255, 0)); + } + else if (color.G > 0) + { + AtomLite.NeoPixel.SetColor(Color.FromArgb(255, 0, 0, 255)); + } + else + { + AtomLite.NeoPixel.SetColor(Color.FromArgb(255, 255, 0, 0)); + } + } + } +} diff --git a/Tests/M5StackTestApp/Properties/AssemblyInfo.cs b/Tests/AtomLiteTestApp/Properties/AssemblyInfo.cs similarity index 100% rename from Tests/M5StackTestApp/Properties/AssemblyInfo.cs rename to Tests/AtomLiteTestApp/Properties/AssemblyInfo.cs diff --git a/Tests/AtomLiteTestApp/packages.config b/Tests/AtomLiteTestApp/packages.config new file mode 100644 index 00000000..e8f242fb --- /dev/null +++ b/Tests/AtomLiteTestApp/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Tests/AtomMatrixTestApp/AtomMatrixTestApp.nfproj b/Tests/AtomMatrixTestApp/AtomMatrixTestApp.nfproj new file mode 100644 index 00000000..c475793b --- /dev/null +++ b/Tests/AtomMatrixTestApp/AtomMatrixTestApp.nfproj @@ -0,0 +1,58 @@ + + + + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ + + + + Debug + AnyCPU + {11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 88f1d73a-1adf-4444-a031-024e570945cc + Exe + Properties + 512 + AtomLMatrixTestApp + AtomLMatrixTestApp + v1.0 + + + + + + + + + + + + ..\..\packages\nanoFramework.Iot.Device.Button.1.0.288-preview.99\lib\Iot.Device.Button.dll + True + + + ..\..\packages\nanoFramework.CoreLibrary.1.12.0-preview.19\lib\mscorlib.dll + True + + + ..\..\packages\nanoFramework.Runtime.Events.1.10.0-preview.13\lib\nanoFramework.Runtime.Events.dll + True + + + ..\..\packages\nanoFramework.System.Device.Gpio.1.0.3-preview.18\lib\System.Device.Gpio.dll + True + + + ..\..\packages\nanoFramework.System.Drawing.1.0.288-preview.99\lib\System.Drawing.dll + True + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests/AtomMatrixTestApp/Program.cs b/Tests/AtomMatrixTestApp/Program.cs new file mode 100644 index 00000000..0f5dde9f --- /dev/null +++ b/Tests/AtomMatrixTestApp/Program.cs @@ -0,0 +1,69 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using nanoFramework.AtomMatrix; +using System; +using System.Diagnostics; +using System.Drawing; +using System.Threading; + +namespace AtomMatrixTestApp +{ + public class Program + { + private static PixelController _ledMatrix; + + public static void Main() + { + var button = AtomMatrix.Button; + + _ledMatrix = AtomMatrix.LedMatrix; + + // diagonal green line + DrawDiagonalLine(Color.Green); + Thread.Sleep(1000); + + _ledMatrix.TurnOff(); + + // diagonal blue line + DrawDiagonalLine(Color.Blue); + Thread.Sleep(1000); + + _ledMatrix.TurnOff(); + + // diagonal red line + DrawDiagonalLine(Color.Red); + Thread.Sleep(1000); + + // clear LEDs + _ledMatrix.TurnOff(); + + button.ButtonDown += Button_ButtonDown; + button.ButtonUp += Button_ButtonUp; + + Debug.WriteLine("Hello from nanoFramework!"); + + Thread.Sleep(Timeout.Infinite); + } + + private static void DrawDiagonalLine(Color color) + { + _ledMatrix.SetColor(0, color); + _ledMatrix.SetColor(5 + 1, color); + _ledMatrix.SetColor(10 + 2, color); + _ledMatrix.SetColor(15 + 3, color); + _ledMatrix.SetColor(20 + 4, color); + _ledMatrix.Update(); + } + + private static void Button_ButtonUp(object sender, EventArgs e) + { + _ledMatrix.TurnOff(); + } + + private static void Button_ButtonDown(object sender, EventArgs e) + { + _ledMatrix.FillColor(Color.Green); + } + } +} diff --git a/Tests/AtomMatrixTestApp/Properties/AssemblyInfo.cs b/Tests/AtomMatrixTestApp/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..262254df --- /dev/null +++ b/Tests/AtomMatrixTestApp/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +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("CSharp.BlankApplication")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CSharp.BlankApplication")] +[assembly: AssemblyCopyright("Copyright © ")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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)] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests/AtomMatrixTestApp/packages.config b/Tests/AtomMatrixTestApp/packages.config new file mode 100644 index 00000000..e8f242fb --- /dev/null +++ b/Tests/AtomMatrixTestApp/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Tests/M5StackTestApp/M5StackTestApp.nfproj b/Tests/FireTestApp/FireTestApp.nfproj similarity index 52% rename from Tests/M5StackTestApp/M5StackTestApp.nfproj rename to Tests/FireTestApp/FireTestApp.nfproj index 640140c4..fdd17f29 100644 --- a/Tests/M5StackTestApp/M5StackTestApp.nfproj +++ b/Tests/FireTestApp/FireTestApp.nfproj @@ -8,114 +8,122 @@ Debug AnyCPU {11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 90a94170-2c6b-4b22-baa5-8212ac22219b + 5ff00f7c-8ed8-4468-9959-497ce8c5b1af Exe Properties 512 - M5StackTestApp - M5StackTestApp + FiteTestApp + FiteTestApp v1.0 - - True - True - Resources.resx - - - ..\..\packages\nanoFramework.Iot.Device.Bmm150.1.0.260\lib\Iot.Device.Bmm150.dll + + + + + ..\..\packages\nanoFramework.Iot.Device.Bmm150.1.0.288-preview.106\lib\Iot.Device.Bmm150.dll + True + + + ..\..\packages\nanoFramework.Iot.Device.Button.1.0.288-preview.99\lib\Iot.Device.Button.dll + True + + + ..\..\packages\nanoFramework.Iot.Device.Buzzer.1.0.288-preview.103\lib\Iot.Device.Buzzer.dll + True + + + ..\..\packages\nanoFramework.Iot.Device.Ip5306.1.0.288-preview.103\lib\Iot.Device.Ip5306.dll True - - ..\..\packages\nanoFramework.Iot.Device.Button.1.0.259\lib\Iot.Device.Button.dll + + ..\..\packages\nanoFramework.Iot.Device.Mpu6886.1.0.288-preview.106\lib\Iot.Device.Mpu6886.dll True - - ..\..\packages\nanoFramework.Iot.Device.Ip5306.1.0.259\lib\Iot.Device.Ip5306.dll + + ..\..\packages\nanoFramework.CoreLibrary.1.12.0-preview.19\lib\mscorlib.dll True - - ..\..\packages\nanoFramework.Iot.Device.Mpu6886.1.0.260\lib\Iot.Device.Mpu6886.dll + + ..\..\packages\nanoFramework.Graphics.1.0.2-preview.18\lib\nanoFramework.Graphics.dll True - - ..\..\packages\nanoFramework.CoreLibrary.1.11.7\lib\mscorlib.dll + + ..\..\packages\nanoFramework.ResourceManager.1.1.4-preview.13\lib\nanoFramework.ResourceManager.dll True - - ..\..\packages\nanoFramework.Graphics.1.0.1\lib\nanoFramework.Graphics.dll + + ..\..\packages\nanoFramework.Runtime.Events.1.10.0-preview.13\lib\nanoFramework.Runtime.Events.dll True - - ..\..\packages\nanoFramework.ResourceManager.1.1.3\lib\nanoFramework.ResourceManager.dll + + ..\..\packages\nanoFramework.Runtime.Native.1.5.4-preview.10\lib\nanoFramework.Runtime.Native.dll True - - ..\..\packages\nanoFramework.Runtime.Events.1.9.2\lib\nanoFramework.Runtime.Events.dll + + ..\..\packages\nanoFramework.System.Collections.1.4.0-preview.27\lib\nanoFramework.System.Collections.dll True - - ..\..\packages\nanoFramework.Runtime.Native.1.5.2\lib\nanoFramework.Runtime.Native.dll + + ..\..\packages\nanoFramework.System.Buffers.Binary.BinaryPrimitives.1.0.288-preview.103\lib\System.Buffers.Binary.BinaryPrimitives.dll True - - ..\..\packages\nanoFramework.System.Collections.1.3.0\lib\nanoFramework.System.Collections.dll + + ..\..\packages\nanoFramework.System.Device.Adc.1.0.2-preview.13\lib\System.Device.Adc.dll True - - ..\..\packages\nanoFramework.System.Buffers.Binary.BinaryPrimitives.1.0.259\lib\System.Buffers.Binary.BinaryPrimitives.dll + + ..\..\packages\nanoFramework.System.Device.Dac.1.4.3-preview.13\lib\System.Device.Dac.dll True - - ..\..\packages\nanoFramework.System.Device.Gpio.1.0.2\lib\System.Device.Gpio.dll + + ..\..\packages\nanoFramework.System.Device.Gpio.1.0.3-preview.18\lib\System.Device.Gpio.dll True - - ..\..\packages\nanoFramework.System.Device.I2c.1.0.2\lib\System.Device.I2c.dll + + ..\..\packages\nanoFramework.System.Device.I2c.1.0.3-preview.13\lib\System.Device.I2c.dll True - - ..\..\packages\nanoFramework.System.Device.Model.1.0.259\lib\System.Device.Model.dll + + ..\..\packages\nanoFramework.System.Device.Model.1.0.288-preview.99\lib\System.Device.Model.dll True - - ..\..\packages\nanoFramework.System.Diagnostics.Stopwatch.1.0.259\lib\System.Diagnostics.Stopwatch.dll + + ..\..\packages\nanoFramework.System.Device.Pwm.1.0.1-preview.13\lib\System.Device.Pwm.dll True - - ..\..\packages\nanoFramework.System.Math.1.4.3\lib\System.Math.dll + + ..\..\packages\nanoFramework.System.Device.Spi.1.0.4-preview.11\lib\System.Device.Spi.dll True - - ..\..\packages\nanoFramework.System.Numerics.1.0.259\lib\System.Numerics.dll + + ..\..\packages\nanoFramework.System.Math.1.4.4-preview.22\lib\System.Math.dll True - - ..\..\packages\UnitsNet.nanoFramework.ElectricCurrent.4.110.0\lib\UnitsNet.ElectricCurrent.dll + + ..\..\packages\nanoFramework.System.Numerics.1.0.289-preview.1\lib\System.Numerics.dll True - - ..\..\packages\UnitsNet.nanoFramework.Temperature.4.110.0\lib\UnitsNet.Temperature.dll + + ..\..\packages\UnitsNet.nanoFramework.ElectricCurrent.4.126.0\lib\UnitsNet.ElectricCurrent.dll + True + + + ..\..\packages\UnitsNet.nanoFramework.Frequency.4.126.0\lib\UnitsNet.Frequency.dll + True + + + ..\..\packages\UnitsNet.nanoFramework.Temperature.4.126.0\lib\UnitsNet.Temperature.dll True - - - - - - - - nFResXFileCodeGenerator - Resources.Designer.cs - diff --git a/Tests/FireTestApp/Program.cs b/Tests/FireTestApp/Program.cs new file mode 100644 index 00000000..48ab90eb --- /dev/null +++ b/Tests/FireTestApp/Program.cs @@ -0,0 +1,125 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using nanoFramework.M5Stack; +using nanoFramework.Presentation.Media; +using System; +using System.Diagnostics; +using System.Numerics; +using System.Threading; +using Console = nanoFramework.M5Stack.Console; + +Debug.WriteLine("Hello from nanoFramework!"); + +Fire.InitializeScreen(); +Console.Clear(); + +// Test the console display +Console.Write("This is a short text. "); +Console.ForegroundColor = Color.Red; +Console.WriteLine("This one displays in red after the previous one and is already at the next line."); +Console.BackgroundColor = Color.Yellow; +Console.ForegroundColor = Color.RoyalBlue; +Console.WriteLine("And this is really ugly but it's like that"); +Console.ResetColor(); +Console.Write("*@$+=}"); +Console.WriteLine("*@$+=}"); +Console.WriteLine(""); +Console.WriteLine("1 line empty before"); +Console.WriteLine("Press left button to continue"); + +while (!Fire.ButtonLeft.IsPressed) +{ + Thread.Sleep(10); +} + +Console.Clear(); + +Console.WriteLine("Calibrating the accelerator, do not touch it!"); +var acc = Fire.AccelerometerGyroscope; +acc.Calibrate(100); +Console.WriteLine(""); +Console.WriteLine("Calibrating the magnetometer, please move it all around"); +var mag = Fire.Magnetometer; +mag.CalibrateMagnetometer(100); + +Fire.ButtonLeft.Press += (sender, e) => +{ + Console.ForegroundColor = Color.Yellow; + Console.CursorLeft = 0; + Console.CursorTop = 0; + Console.Write($"Left Pressed "); +}; + +Fire.ButtonCenter.Press += (sender, e) => +{ + Console.ForegroundColor = Color.Yellow; + Console.CursorLeft = 0; + Console.CursorTop = 0; + Console.Write($"Center Pressed"); +}; + +Fire.ButtonRight.Press += (sender, e) => +{ + Console.ForegroundColor = Color.Yellow; + Console.CursorLeft = 0; + Console.CursorTop = 0; + Console.Write($"Right Pressed "); +}; + +Console.Clear(); + +var power = Fire.Power; +Vector3 accVal; +Vector3 gyroVal; +Vector3 magVal; + +while (true) +{ + accVal = acc.GetAccelerometer(); + gyroVal = acc.GetGyroscope(); + magVal = mag.ReadMagnetometer(); + var headDir = Math.Atan2(magVal.X, magVal.Y) * 180.0 / Math.PI; + Console.ForegroundColor = Color.Green; + Console.CursorLeft = 0; + Console.CursorTop = 1; + Console.WriteLine("Accelerator:"); + Console.WriteLine($" x={accVal.X:N2} "); + Console.WriteLine($" y={accVal.Y:N2} "); + Console.WriteLine($" z={accVal.Z:N2} "); + Console.ForegroundColor = Color.AliceBlue; + Console.WriteLine("Gyroscope:"); + Console.WriteLine($" x={gyroVal.X:N2} "); + Console.WriteLine($" y={gyroVal.Y:N2} "); + Console.WriteLine($" z={gyroVal.Z:N2} "); + Console.ForegroundColor = Color.Coral; + Console.CursorLeft = Console.WindowWidth / 2 - 2; + Console.CursorTop = 1; + Console.Write("Magnetometer:"); + Console.CursorLeft = Console.WindowWidth / 2 - 2; + Console.CursorTop++; + Console.Write($" x={magVal.X:N2} "); + Console.CursorLeft = Console.WindowWidth / 2 - 2; + Console.CursorTop++; + Console.Write($" y={magVal.Y:N2} "); + Console.CursorLeft = Console.WindowWidth / 2 - 2; + Console.CursorTop++; + Console.Write($" z={magVal.Z:N2} "); + Console.CursorLeft = Console.WindowWidth / 2 - 2; + Console.CursorTop++; + Console.Write($" h={headDir:N2} "); + Console.ForegroundColor = Color.DarkBlue; + Console.CursorLeft = Console.WindowWidth / 2 - 2; + Console.CursorTop = 6; + Console.Write("Power:"); + Console.CursorLeft = Console.WindowWidth / 2 - 2; + Console.CursorTop++; + Console.BackgroundColor = power.IsCharging ? Color.Black : Color.Red; + Console.Write($" Charging {power.IsCharging}"); + Console.BackgroundColor = Color.Black; + Console.Write(" "); + Console.CursorLeft = Console.WindowWidth / 2 - 2; + Console.CursorTop++; + Console.Write($" Full {power.IsBatteryFull} "); + Thread.Sleep(20); +} diff --git a/Tests/FireTestApp/Properties/AssemblyInfo.cs b/Tests/FireTestApp/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..262254df --- /dev/null +++ b/Tests/FireTestApp/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +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("CSharp.BlankApplication")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CSharp.BlankApplication")] +[assembly: AssemblyCopyright("Copyright © ")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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)] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests/FireTestApp/packages.config b/Tests/FireTestApp/packages.config new file mode 100644 index 00000000..14128f13 --- /dev/null +++ b/Tests/FireTestApp/packages.config @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests/M5Core2TestApp/M5Core2TestApp.nfproj b/Tests/M5Core2TestApp/M5Core2TestApp.nfproj new file mode 100644 index 00000000..19621e8b --- /dev/null +++ b/Tests/M5Core2TestApp/M5Core2TestApp.nfproj @@ -0,0 +1,175 @@ + + + + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ + + + + Debug + AnyCPU + {11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 20266750-53f3-46d5-8626-1438ac985033 + Exe + Properties + 512 + M5Core2TestApp + M5Core2TestApp + v1.0 + $(DefineConstants);M5CORE2 + + + + + + + + + ..\..\packages\nanoFramework.Iot.Device.Axp192.1.0.288-preview.103\lib\Iot.Device.Axp192.dll + True + + + ..\..\packages\nanoFramework.Iot.Device.Bmm150.1.0.288-preview.106\lib\Iot.Device.Bmm150.dll + True + + + ..\..\packages\nanoFramework.Iot.Device.Button.1.0.288-preview.99\lib\Iot.Device.Button.dll + True + + + ..\..\packages\nanoFramework.Iot.Device.Common.NumberHelper.1.0.288-preview.99\lib\Iot.Device.Common.NumberHelper.dll + True + + + ..\..\packages\nanoFramework.Iot.Device.Mpu6886.1.0.288-preview.106\lib\Iot.Device.Mpu6886.dll + True + + + ..\..\packages\nanoFramework.Iot.Device.Rtc.1.0.288-preview.103\lib\Iot.Device.Rtc.dll + True + + + ..\..\packages\nanoFramework.CoreLibrary.1.12.0-preview.19\lib\mscorlib.dll + True + + + ..\..\packages\nanoFramework.Graphics.1.0.2-preview.18\lib\nanoFramework.Graphics.dll + True + + + ..\..\packages\nanoFramework.Hardware.Esp32.1.3.5-preview.10\lib\nanoFramework.Hardware.Esp32.dll + True + + + ..\..\packages\nanoFramework.ResourceManager.1.1.4-preview.13\lib\nanoFramework.ResourceManager.dll + True + + + ..\..\packages\nanoFramework.Runtime.Events.1.10.0-preview.13\lib\nanoFramework.Runtime.Events.dll + True + + + ..\..\packages\nanoFramework.Runtime.Native.1.5.4-preview.10\lib\nanoFramework.Runtime.Native.dll + True + + + ..\..\packages\nanoFramework.System.Collections.1.4.0-preview.27\lib\nanoFramework.System.Collections.dll + True + + + ..\..\packages\nanoFramework.System.Text.1.1.3-preview.24\lib\nanoFramework.System.Text.dll + True + + + ..\..\packages\nanoFramework.System.Buffers.Binary.BinaryPrimitives.1.0.288-preview.103\lib\System.Buffers.Binary.BinaryPrimitives.dll + True + + + ..\..\packages\nanoFramework.System.Device.Adc.1.0.2-preview.13\lib\System.Device.Adc.dll + True + + + ..\..\packages\nanoFramework.System.Device.Dac.1.4.3-preview.13\lib\System.Device.Dac.dll + True + + + ..\..\packages\nanoFramework.System.Device.Gpio.1.0.3-preview.18\lib\System.Device.Gpio.dll + True + + + ..\..\packages\nanoFramework.System.Device.I2c.1.0.3-preview.13\lib\System.Device.I2c.dll + True + + + ..\..\packages\nanoFramework.System.Device.Model.1.0.288-preview.99\lib\System.Device.Model.dll + True + + + ..\..\packages\nanoFramework.System.Device.Pwm.1.0.1-preview.13\lib\System.Device.Pwm.dll + True + + + ..\..\packages\nanoFramework.System.Device.Spi.1.0.4-preview.11\lib\System.Device.Spi.dll + True + + + ..\..\packages\nanoFramework.System.Device.WiFi.1.4.0-preview.48\lib\System.Device.WiFi.dll + True + + + ..\..\packages\nanoFramework.System.Diagnostics.Stopwatch.1.0.289-preview.60\lib\System.Diagnostics.Stopwatch.dll + True + + + ..\..\packages\nanoFramework.System.IO.Ports.1.0.3-preview.39\lib\System.IO.Ports.dll + True + + + ..\..\packages\nanoFramework.System.IO.Streams.1.0.0-preview.19\lib\System.IO.Streams.dll + True + + + ..\..\packages\nanoFramework.System.Math.1.4.4-preview.22\lib\System.Math.dll + True + + + ..\..\packages\nanoFramework.System.Net.1.8.0-preview.43\lib\System.Net.dll + True + + + ..\..\packages\nanoFramework.System.Numerics.1.0.289-preview.1\lib\System.Numerics.dll + True + + + ..\..\packages\nanoFramework.System.Threading.1.0.4-preview.23\lib\System.Threading.dll + True + + + ..\..\packages\UnitsNet.nanoFramework.ElectricCurrent.4.126.0\lib\UnitsNet.ElectricCurrent.dll + True + + + ..\..\packages\UnitsNet.nanoFramework.ElectricPotential.4.126.0\lib\UnitsNet.ElectricPotential.dll + True + + + ..\..\packages\UnitsNet.nanoFramework.Power.4.126.0\lib\UnitsNet.Power.dll + True + + + ..\..\packages\UnitsNet.nanoFramework.Temperature.4.126.0\lib\UnitsNet.Temperature.dll + True + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests/M5Core2TestApp/Program.cs b/Tests/M5Core2TestApp/Program.cs new file mode 100644 index 00000000..dcacda35 --- /dev/null +++ b/Tests/M5Core2TestApp/Program.cs @@ -0,0 +1,94 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using nanoFramework.M5Core2; +using nanoFramework.M5Stack; +using nanoFramework.Networking; +using nanoFramework.Runtime.Native; +using System; +using System.Diagnostics; +using System.Threading; +using Console = nanoFramework.M5Stack.Console; + +M5Core2.InitializeScreen(); + +Debug.WriteLine("Hello from M5Core2!"); + +const string Ssid = "SSID"; +const string Password = "YourWifiPasswordHere"; +// Give 60 seconds to the wifi join to happen +CancellationTokenSource cs = new(60000); +var success = WiFiNetworkHelper.ConnectDhcp(Ssid, Password, requiresDateTime: true, token: cs.Token); +if (!success) +{ + // Something went wrong, you can get details with the ConnectionError property: + Debug.WriteLine($"Can't connect to the network, error: {WiFiNetworkHelper.Status}"); + if (WiFiNetworkHelper.HelperException != null) + { + Debug.WriteLine($"ex: {WiFiNetworkHelper.HelperException}"); + } +} + +var mpu = M5Core2.AccelerometerGyroscope; + +M5Core2.TouchEvent += TouchEventCallback; + +Thread.Sleep(Timeout.Infinite); + +void TouchEventCallback(object sender, TouchEventArgs e) +{ + const string StrLB = "LEFT BUTTON PRESSED "; + const string StrMB = "MIDDLE BUTTON PRESSED "; + const string StrRB = "RIGHT BUTTON PRESSED "; + const string StrXY1 = "TOUCHED at X= "; + const string StrXY2 = ",Y= "; + const string StrID = ",Id= "; + const string StrDoubleTouch = "Double touch. "; + const string StrMove = "Moving... "; + const string StrLiftUp = "Lift up. "; + + Debug.WriteLine($"Touch Panel Event Received Category= {e.EventCategory} Subcategory= {e.TouchEventCategory}"); + Console.CursorLeft = 0; + Console.CursorTop = 0; + + Debug.WriteLine(StrXY1 + e.X + StrXY2 + e.Y + StrID + e.Id); + Console.WriteLine(StrXY1 + e.X + StrXY2 + e.Y + StrID + e.Id + " "); + + if ((e.TouchEventCategory & TouchEventCategory.LeftButton) == TouchEventCategory.LeftButton) + { + Debug.WriteLine(StrLB); + Console.WriteLine(StrLB); + } + else if ((e.TouchEventCategory & TouchEventCategory.MiddleButton) == TouchEventCategory.MiddleButton) + { + Debug.WriteLine(StrMB); + Console.WriteLine(StrMB); + } + else if ((e.TouchEventCategory & TouchEventCategory.RightButton) == TouchEventCategory.RightButton) + { + Debug.WriteLine(StrRB); + Console.WriteLine(StrRB); + } + + if ((e.TouchEventCategory & TouchEventCategory.Moving) == TouchEventCategory.Moving) + { + Debug.WriteLine(StrMove); + Console.Write(StrMove); + } + + if ((e.TouchEventCategory & TouchEventCategory.LiftUp) == TouchEventCategory.LiftUp) + { + Debug.WriteLine(StrLiftUp); + Console.Write(StrLiftUp); + } + + if ((e.TouchEventCategory & TouchEventCategory.DoubleTouch) == TouchEventCategory.DoubleTouch) + { + Debug.WriteLine(StrDoubleTouch); + Console.Write(StrDoubleTouch); + } + + Console.WriteLine(" "); + Console.WriteLine(" "); + Console.WriteLine(" "); +} diff --git a/Tests/M5Core2TestApp/Properties/AssemblyInfo.cs b/Tests/M5Core2TestApp/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..262254df --- /dev/null +++ b/Tests/M5Core2TestApp/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +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("CSharp.BlankApplication")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CSharp.BlankApplication")] +[assembly: AssemblyCopyright("Copyright © ")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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)] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests/M5Core2TestApp/packages.config b/Tests/M5Core2TestApp/packages.config new file mode 100644 index 00000000..28e96a72 --- /dev/null +++ b/Tests/M5Core2TestApp/packages.config @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests/M5CoreTestApp/M5CoreTestApp.nfproj b/Tests/M5CoreTestApp/M5CoreTestApp.nfproj new file mode 100644 index 00000000..d7fc5fd6 --- /dev/null +++ b/Tests/M5CoreTestApp/M5CoreTestApp.nfproj @@ -0,0 +1,143 @@ + + + + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ + + + + Debug + AnyCPU + {11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 90a94170-2c6b-4b22-baa5-8212ac22219b + Exe + Properties + 512 + M5StackTestApp + M5StackTestApp + v1.0 + + + + + + + + + ..\..\packages\nanoFramework.Iot.Device.Bmm150.1.0.288-preview.106\lib\Iot.Device.Bmm150.dll + True + + + ..\..\packages\nanoFramework.Iot.Device.Button.1.0.288-preview.99\lib\Iot.Device.Button.dll + True + + + ..\..\packages\nanoFramework.Iot.Device.Ip5306.1.0.288-preview.103\lib\Iot.Device.Ip5306.dll + True + + + ..\..\packages\nanoFramework.Iot.Device.Mpu6886.1.0.288-preview.106\lib\Iot.Device.Mpu6886.dll + True + + + ..\..\packages\nanoFramework.CoreLibrary.1.12.0-preview.19\lib\mscorlib.dll + True + + + ..\..\packages\nanoFramework.Graphics.1.0.2-preview.18\lib\nanoFramework.Graphics.dll + True + + + ..\..\packages\nanoFramework.ResourceManager.1.1.4-preview.13\lib\nanoFramework.ResourceManager.dll + True + + + ..\..\packages\nanoFramework.Runtime.Events.1.10.0-preview.13\lib\nanoFramework.Runtime.Events.dll + True + + + ..\..\packages\nanoFramework.Runtime.Native.1.5.4-preview.10\lib\nanoFramework.Runtime.Native.dll + True + + + ..\..\packages\nanoFramework.System.Collections.1.4.0-preview.27\lib\nanoFramework.System.Collections.dll + True + + + ..\..\packages\nanoFramework.System.Text.1.1.3-preview.24\lib\nanoFramework.System.Text.dll + True + + + ..\..\packages\nanoFramework.System.Buffers.Binary.BinaryPrimitives.1.0.288-preview.103\lib\System.Buffers.Binary.BinaryPrimitives.dll + True + + + ..\..\packages\nanoFramework.System.Device.Adc.1.0.2-preview.13\lib\System.Device.Adc.dll + True + + + ..\..\packages\nanoFramework.System.Device.Dac.1.4.3-preview.13\lib\System.Device.Dac.dll + True + + + ..\..\packages\nanoFramework.System.Device.Gpio.1.0.3-preview.18\lib\System.Device.Gpio.dll + True + + + ..\..\packages\nanoFramework.System.Device.I2c.1.0.3-preview.13\lib\System.Device.I2c.dll + True + + + ..\..\packages\nanoFramework.System.Device.Model.1.0.288-preview.99\lib\System.Device.Model.dll + True + + + ..\..\packages\nanoFramework.System.Device.Pwm.1.0.1-preview.13\lib\System.Device.Pwm.dll + True + + + ..\..\packages\nanoFramework.System.Device.Spi.1.0.4-preview.11\lib\System.Device.Spi.dll + True + + + ..\..\packages\nanoFramework.System.Diagnostics.Stopwatch.1.0.289-preview.60\lib\System.Diagnostics.Stopwatch.dll + True + + + ..\..\packages\nanoFramework.System.IO.Ports.1.0.3-preview.39\lib\System.IO.Ports.dll + True + + + ..\..\packages\nanoFramework.System.IO.Streams.1.0.0-preview.19\lib\System.IO.Streams.dll + True + + + ..\..\packages\nanoFramework.System.Math.1.4.4-preview.22\lib\System.Math.dll + True + + + ..\..\packages\nanoFramework.System.Numerics.1.0.289-preview.1\lib\System.Numerics.dll + True + + + ..\..\packages\UnitsNet.nanoFramework.ElectricCurrent.4.126.0\lib\UnitsNet.ElectricCurrent.dll + True + + + ..\..\packages\UnitsNet.nanoFramework.Temperature.4.126.0\lib\UnitsNet.Temperature.dll + True + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests/M5StackTestApp/Program.cs b/Tests/M5CoreTestApp/Program.cs similarity index 89% rename from Tests/M5StackTestApp/Program.cs rename to Tests/M5CoreTestApp/Program.cs index 00f42297..077e7779 100644 --- a/Tests/M5StackTestApp/Program.cs +++ b/Tests/M5CoreTestApp/Program.cs @@ -1,21 +1,17 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Device.Gpio; -using System.Diagnostics; -using System.Threading; -using M5StackTestApp; using nanoFramework.M5Stack; -using nanoFramework.UI; using nanoFramework.Presentation.Media; -using nanoFramework; +using System; +using System.Diagnostics; using System.Numerics; -using Console = nanoFramework.Console; +using System.Threading; +using Console = nanoFramework.M5Stack.Console; Debug.WriteLine("Hello from nanoFramework!"); -M5Stack.InitializeScreen(); +M5Core.InitializeScreen(); Console.Clear(); // Test the console display @@ -32,7 +28,7 @@ Console.WriteLine("1 line empty before"); Console.WriteLine("Press left button to continue"); -while (!M5Stack.ButtonLeft.IsPressed) +while (!M5Core.ButtonLeft.IsPressed) { Thread.Sleep(10); } @@ -40,14 +36,14 @@ Console.Clear(); Console.WriteLine("Calibrating the accelerator, do not touch it!"); -var acc = M5Stack.AccelerometerGyroscope; +var acc = M5Core.AccelerometerGyroscope; acc.Calibrate(100); Console.WriteLine(""); Console.WriteLine("Calibrating the magnetometer, please move it all around"); -var mag = M5Stack.Magnetometer; +var mag = M5Core.Magnetometer; mag.CalibrateMagnetometer(100); -M5Stack.ButtonLeft.Press += (sender, e) => +M5Core.ButtonLeft.Press += (sender, e) => { Console.ForegroundColor = Color.Yellow; Console.CursorLeft = 0; @@ -55,7 +51,7 @@ Console.Write($"Left Pressed "); }; -M5Stack.ButtonCenter.Press += (sender, e) => +M5Core.ButtonCenter.Press += (sender, e) => { Console.ForegroundColor = Color.Yellow; Console.CursorLeft = 0; @@ -63,7 +59,7 @@ Console.Write($"Center Pressed"); }; -M5Stack.ButtonRight.Press += (sender, e) => +M5Core.ButtonRight.Press += (sender, e) => { Console.ForegroundColor = Color.Yellow; Console.CursorLeft = 0; @@ -73,7 +69,7 @@ Console.Clear(); -var power = M5Stack.Power; +var power = M5Core.Power; Vector3 accVal; Vector3 gyroVal; Vector3 magVal; diff --git a/Tests/M5CoreTestApp/Properties/AssemblyInfo.cs b/Tests/M5CoreTestApp/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..262254df --- /dev/null +++ b/Tests/M5CoreTestApp/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +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("CSharp.BlankApplication")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CSharp.BlankApplication")] +[assembly: AssemblyCopyright("Copyright © ")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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)] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests/M5StackTestApp/Resources.Designer.cs b/Tests/M5CoreTestApp/Resources.Designer.cs similarity index 100% rename from Tests/M5StackTestApp/Resources.Designer.cs rename to Tests/M5CoreTestApp/Resources.Designer.cs diff --git a/Tests/M5StackTestApp/Resources.resx b/Tests/M5CoreTestApp/Resources.resx similarity index 100% rename from Tests/M5StackTestApp/Resources.resx rename to Tests/M5CoreTestApp/Resources.resx diff --git a/Tests/M5StackTestApp/Resources/segoeuiregular12.tinyfnt b/Tests/M5CoreTestApp/Resources/segoeuiregular12.tinyfnt similarity index 100% rename from Tests/M5StackTestApp/Resources/segoeuiregular12.tinyfnt rename to Tests/M5CoreTestApp/Resources/segoeuiregular12.tinyfnt diff --git a/Tests/M5CoreTestApp/packages.config b/Tests/M5CoreTestApp/packages.config new file mode 100644 index 00000000..2f8c366b --- /dev/null +++ b/Tests/M5CoreTestApp/packages.config @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests/M5StackTestApp/packages.config b/Tests/M5StackTestApp/packages.config deleted file mode 100644 index 75349e6d..00000000 --- a/Tests/M5StackTestApp/packages.config +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tests/M5StickTestApp/M5StickTestApp.nfproj b/Tests/M5StickTestApp/M5StickTestApp.nfproj index bdc427ec..7c8dd356 100644 --- a/Tests/M5StickTestApp/M5StickTestApp.nfproj +++ b/Tests/M5StickTestApp/M5StickTestApp.nfproj @@ -23,100 +23,100 @@ - - ..\..\packages\nanoFramework.Iot.Device.Axp192.1.0.259\lib\Iot.Device.Axp192.dll + + ..\..\packages\nanoFramework.Iot.Device.Axp192.1.0.288-preview.103\lib\Iot.Device.Axp192.dll True - - ..\..\packages\nanoFramework.Iot.Device.Button.1.0.259\lib\Iot.Device.Button.dll + + ..\..\packages\nanoFramework.Iot.Device.Button.1.0.288-preview.99\lib\Iot.Device.Button.dll True - - ..\..\packages\nanoFramework.Iot.Device.Common.NumberHelper.1.0.259\lib\Iot.Device.Common.NumberHelper.dll + + ..\..\packages\nanoFramework.Iot.Device.Common.NumberHelper.1.0.288-preview.99\lib\Iot.Device.Common.NumberHelper.dll True - - ..\..\packages\nanoFramework.Iot.Device.Mpu6886.1.0.260\lib\Iot.Device.Mpu6886.dll + + ..\..\packages\nanoFramework.Iot.Device.Mpu6886.1.0.288-preview.106\lib\Iot.Device.Mpu6886.dll True - - ..\..\packages\nanoFramework.Iot.Device.Rtc.1.0.260\lib\Iot.Device.Rtc.dll + + ..\..\packages\nanoFramework.Iot.Device.Rtc.1.0.288-preview.103\lib\Iot.Device.Rtc.dll True - - ..\..\packages\nanoFramework.CoreLibrary.1.11.7\lib\mscorlib.dll + + ..\..\packages\nanoFramework.CoreLibrary.1.12.0-preview.19\lib\mscorlib.dll True - - ..\..\packages\nanoFramework.Graphics.1.0.1\lib\nanoFramework.Graphics.dll + + ..\..\packages\nanoFramework.Graphics.1.0.2-preview.18\lib\nanoFramework.Graphics.dll True - - ..\..\packages\nanoFramework.Hardware.Esp32.1.3.4\lib\nanoFramework.Hardware.Esp32.dll + + ..\..\packages\nanoFramework.Hardware.Esp32.1.3.5-preview.10\lib\nanoFramework.Hardware.Esp32.dll True - - ..\..\packages\nanoFramework.Hardware.Esp32.Rmt.1.2.1\lib\nanoFramework.Hardware.Esp32.Rmt.dll + + ..\..\packages\nanoFramework.Hardware.Esp32.Rmt.1.2.2-preview.10\lib\nanoFramework.Hardware.Esp32.Rmt.dll True - - ..\..\packages\nanoFramework.ResourceManager.1.1.3\lib\nanoFramework.ResourceManager.dll + + ..\..\packages\nanoFramework.ResourceManager.1.1.4-preview.13\lib\nanoFramework.ResourceManager.dll True - - ..\..\packages\nanoFramework.Runtime.Events.1.9.2\lib\nanoFramework.Runtime.Events.dll + + ..\..\packages\nanoFramework.Runtime.Events.1.10.0-preview.13\lib\nanoFramework.Runtime.Events.dll True - - ..\..\packages\nanoFramework.Runtime.Native.1.5.2\lib\nanoFramework.Runtime.Native.dll + + ..\..\packages\nanoFramework.Runtime.Native.1.5.4-preview.10\lib\nanoFramework.Runtime.Native.dll True - - ..\..\packages\nanoFramework.System.Collections.1.3.0\lib\nanoFramework.System.Collections.dll + + ..\..\packages\nanoFramework.System.Collections.1.4.0-preview.27\lib\nanoFramework.System.Collections.dll True - - ..\..\packages\nanoFramework.System.Buffers.Binary.BinaryPrimitives.1.0.259\lib\System.Buffers.Binary.BinaryPrimitives.dll + + ..\..\packages\nanoFramework.System.Buffers.Binary.BinaryPrimitives.1.0.288-preview.103\lib\System.Buffers.Binary.BinaryPrimitives.dll True - - ..\..\packages\nanoFramework.System.Device.Gpio.1.0.2\lib\System.Device.Gpio.dll + + ..\..\packages\nanoFramework.System.Device.Gpio.1.0.3-preview.18\lib\System.Device.Gpio.dll True - - ..\..\packages\nanoFramework.System.Device.I2c.1.0.2\lib\System.Device.I2c.dll + + ..\..\packages\nanoFramework.System.Device.I2c.1.0.3-preview.13\lib\System.Device.I2c.dll True - - ..\..\packages\nanoFramework.System.Device.Model.1.0.259\lib\System.Device.Model.dll + + ..\..\packages\nanoFramework.System.Device.Model.1.0.288-preview.99\lib\System.Device.Model.dll True - - ..\..\packages\nanoFramework.System.Diagnostics.Stopwatch.1.0.259\lib\System.Diagnostics.Stopwatch.dll + + ..\..\packages\nanoFramework.System.Diagnostics.Stopwatch.1.0.289-preview.60\lib\System.Diagnostics.Stopwatch.dll True - - ..\..\packages\nanoFramework.System.Math.1.4.3\lib\System.Math.dll + + ..\..\packages\nanoFramework.System.Math.1.4.4-preview.22\lib\System.Math.dll True - - ..\..\packages\nanoFramework.System.Numerics.1.0.259\lib\System.Numerics.dll + + ..\..\packages\nanoFramework.System.Numerics.1.0.289-preview.1\lib\System.Numerics.dll True - - ..\..\packages\UnitsNet.nanoFramework.ElectricCurrent.4.110.0\lib\UnitsNet.ElectricCurrent.dll + + ..\..\packages\UnitsNet.nanoFramework.ElectricCurrent.4.126.0\lib\UnitsNet.ElectricCurrent.dll True - - ..\..\packages\UnitsNet.nanoFramework.ElectricPotential.4.110.0\lib\UnitsNet.ElectricPotential.dll + + ..\..\packages\UnitsNet.nanoFramework.ElectricPotential.4.126.0\lib\UnitsNet.ElectricPotential.dll True - - ..\..\packages\UnitsNet.nanoFramework.Power.4.110.0\lib\UnitsNet.Power.dll + + ..\..\packages\UnitsNet.nanoFramework.Power.4.126.0\lib\UnitsNet.Power.dll True - - ..\..\packages\UnitsNet.nanoFramework.Temperature.4.110.0\lib\UnitsNet.Temperature.dll + + ..\..\packages\UnitsNet.nanoFramework.Temperature.4.126.0\lib\UnitsNet.Temperature.dll True diff --git a/Tests/M5StickTestApp/Program.cs b/Tests/M5StickTestApp/Program.cs index ce5a0fab..87fde578 100644 --- a/Tests/M5StickTestApp/Program.cs +++ b/Tests/M5StickTestApp/Program.cs @@ -1,13 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using nanoFramework; -using nanoFramework.M5Stick; +using nanoFramework.M5Stack; using nanoFramework.Presentation.Media; using System; using System.Diagnostics; using System.Threading; -using Console = nanoFramework.Console; +using Console = nanoFramework.M5Stack.Console; Debug.WriteLine("Hello M5Stick from nanoFramework!"); diff --git a/Tests/M5StickTestApp/packages.config b/Tests/M5StickTestApp/packages.config index c2ccdc85..16ccea75 100644 --- a/Tests/M5StickTestApp/packages.config +++ b/Tests/M5StickTestApp/packages.config @@ -1,27 +1,27 @@  - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 45734425..8655d3bf 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,10 +1,28 @@ +# Copyright (c) .NET Foundation and Contributors +# See LICENSE file in the project root for full license information. + trigger: branches: - include: [main, develop, "release-*" ] + include: + - main + - develop + - release-* paths: - exclude: [README.md, LICENSE.md, NuGet.Config, .github_changelog_generator, .gitignore] + exclude: + - .github_changelog_generator + - .gitignore + - CHANGELOG.md + - CODE_OF_CONDUCT.md + - LICENSE.md + - README.md + - NuGet.Config + - assets/* + - config/* + - .github/* + tags: - include: ["v*"] + include: + - v* # PR always trigger build pr: @@ -19,14 +37,14 @@ resources: endpoint: nanoframework pool: - vmImage: 'windows-2019' + vmImage: 'windows-latest' variables: DOTNET_NOLOGO: true solution: 'nanoFramework.M5Stack.sln' buildPlatform: 'Any CPU' buildConfiguration: 'Release' - nugetPackageName: 'nanoFramework.M5Stack' + nugetPackageName: 'nanoFramework.M5Core' steps: @@ -39,7 +57,7 @@ steps: # package steps - template: azure-pipelines-templates/class-lib-package.yml@templates parameters: - nugetPackageName: 'nanoFramework.M5Stack' + nugetPackageName: 'nanoFramework.M5Core' - template: azure-pipelines-templates/class-lib-package.yml@templates parameters: @@ -53,11 +71,29 @@ steps: parameters: nugetPackageName: 'nanoFramework.M5Core2' +- template: azure-pipelines-templates/class-lib-package.yml@templates + parameters: + nugetPackageName: 'nanoFramework.AtomLite' + +- template: azure-pipelines-templates/class-lib-package.yml@templates + parameters: + nugetPackageName: 'nanoFramework.AtomMatrix' + +- template: azure-pipelines-templates/class-lib-package.yml@templates + parameters: + nugetPackageName: 'nanoFramework.Fire' + - template: azure-pipelines-templates/class-lib-publish.yml@templates # create or update GitHub release - task: GithubRelease@1 - condition: and( succeeded(), eq(variables['System.PullRequest.PullRequestId'], ''), not( startsWith(variables['Build.SourceBranch'], 'refs/tags/v') ), ne( variables['StartReleaseCandidate'], true ) ) + condition: >- + and( + succeeded(), + eq(variables['System.PullRequest.PullRequestId'], ''), + not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')), + ne(variables['StartReleaseCandidate'], true ) + ) displayName: Create/Update GitHub PREVIEW release inputs: gitHubConnection: 'github.com_nano-$(System.TeamProject)' @@ -65,7 +101,7 @@ steps: tag: v$(MY_NUGET_VERSION) title: '$(nugetPackageName) Library v$(MY_NUGET_VERSION)' releaseNotesSource: inline - releaseNotesInline: 'Check the [changelog]($(Build.Repository.Uri)/blob/$(Build.SourceBranchName)/CHANGELOG.md).

Install from NuGet


The following NuGet packages are available for download from this release:
:package: [.NET](https://www.nuget.org/packages/$(nugetPackageName)/$(MY_NUGET_VERSION)) v$(MY_NUGET_VERSION).
:package: [M5StickC](https://www.nuget.org/packages/nanoFramework.M5StickC/$(MY_NUGET_VERSION)) v$(MY_NUGET_VERSION)
:package: [M5StickCPlus](https://www.nuget.org/packages/nanoFramework.M5StickCPlus/$(MY_NUGET_VERSION)) v$(MY_NUGET_VERSION)' + releaseNotesInline: 'Check the [changelog]($(Build.Repository.Uri)/blob/$(Build.SourceBranchName)/CHANGELOG.md).

Install from NuGet


The following NuGet packages are available for download from this release:
:package: [M5Core](https://www.nuget.org/packages/M5Core/$(MY_NUGET_VERSION)) v$(MY_NUGET_VERSION).
package: [M5Core2](https://www.nuget.org/packages/M5Core2/$(MY_NUGET_VERSION)) v$(MY_NUGET_VERSION).
:package: [M5StickC](https://www.nuget.org/packages/nanoFramework.M5StickC/$(MY_NUGET_VERSION)) v$(MY_NUGET_VERSION)
:package: [M5StickCPlus](https://www.nuget.org/packages/nanoFramework.M5StickCPlus/$(MY_NUGET_VERSION)) v$(MY_NUGET_VERSION)
:package: [M5Stack Fire](https://www.nuget.org/packages/nanoFramework.Fire/$(MY_NUGET_VERSION)) v$(MY_NUGET_VERSION)' assets: '$(Build.ArtifactStagingDirectory)/$(nugetPackageName).$(MY_NUGET_VERSION).nupkg' assetUploadMode: replace isPreRelease: true @@ -73,7 +109,13 @@ steps: # create or update GitHub release ON tags from release or main branches - task: GithubRelease@1 - condition: and( succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), not(contains(variables['Build.SourceBranch'], 'preview') ), ne( variables['StartReleaseCandidate'], true ) ) + condition: >- + and( + succeeded(), + startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), + not(contains(variables['Build.SourceBranch'], 'preview')), + ne(variables['StartReleaseCandidate'], true) + ) displayName: Create/Update GitHub stable release inputs: action: edit @@ -82,7 +124,7 @@ steps: tag: v$(MY_NUGET_VERSION) title: '$(nugetPackageName) Library v$(MY_NUGET_VERSION)' releaseNotesSource: inline - releaseNotesInline: 'Check the [changelog]($(Build.Repository.Uri)/blob/$(Build.SourceBranchName)/CHANGELOG.md).

Install from NuGet


The following NuGet packages are available for download from this release:
:package: [.NET](https://www.nuget.org/packages/$(nugetPackageName)/$(MY_NUGET_VERSION)) v$(MY_NUGET_VERSION).
:package: [M5StickC](https://www.nuget.org/packages/nanoFramework.M5StickC/$(MY_NUGET_VERSION)) v$(MY_NUGET_VERSION)
:package: [M5StickCPlus](https://www.nuget.org/packages/nanoFramework.M5StickCPlus/$(MY_NUGET_VERSION)) v$(MY_NUGET_VERSION)' + releaseNotesInline: 'Check the [changelog]($(Build.Repository.Uri)/blob/$(Build.SourceBranchName)/CHANGELOG.md).

Install from NuGet


The following NuGet packages are available for download from this release:
:package: [M5Core](https://www.nuget.org/packages/M5Core/$(MY_NUGET_VERSION)) v$(MY_NUGET_VERSION).
:package: [M5Core2](https://www.nuget.org/packages/M5Core2/$(MY_NUGET_VERSION)) v$(MY_NUGET_VERSION).
:package: [M5StickC](https://www.nuget.org/packages/nanoFramework.M5StickC/$(MY_NUGET_VERSION)) v$(MY_NUGET_VERSION)
:package: [M5StickCPlus](https://www.nuget.org/packages/nanoFramework.M5StickCPlus/$(MY_NUGET_VERSION)) v$(MY_NUGET_VERSION)
:package: [M5Stack Fire](https://www.nuget.org/packages/nanoFramework.Fire/$(MY_NUGET_VERSION)) v$(MY_NUGET_VERSION)' assets: '$(Build.ArtifactStagingDirectory)/$(nugetPackageName).$(MY_NUGET_VERSION).nupkg' assetUploadMode: replace isPreRelease: false diff --git a/nanoFramework.AtomLite.nuspec b/nanoFramework.AtomLite.nuspec new file mode 100644 index 00000000..eda1c048 --- /dev/null +++ b/nanoFramework.AtomLite.nuspec @@ -0,0 +1,43 @@ + + + + nanoFramework.AtomLite + $version$ + nanoFramework.AtomLite + nanoframework + false + LICENSE.md + + + docs\README.md + false + https://github.com/nanoframework/nanoFramework.M5Stack + images\nf-logo.png + + Copyright (c) .NET Foundation and Contributors + This package includes the nanoFramework.AtomLite assembly for .NET nanoFramework C# projects. + nanoFramework C# csharp netmf netnf m5stack AtomLite + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nanoFramework.AtomLite/AtomLite.cs b/nanoFramework.AtomLite/AtomLite.cs new file mode 100644 index 00000000..8073d10f --- /dev/null +++ b/nanoFramework.AtomLite/AtomLite.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using nanoFramework.Hardware.Esp32; + +namespace nanoFramework.AtomLite +{ + /// + /// The AtomLite Board. + /// + public static partial class AtomLite + { + private static RgbLed _rgbLed; + + /// + /// RGB NeoPixel led. + /// + public static RgbLed NeoPixel + { + get + { + if (_rgbLed == null) + { + _rgbLed = new(); + } + + return _rgbLed; + } + } + + static AtomLite() + { + // Setup first the I2C bus + Configuration.SetPinFunction(32, DeviceFunction.I2C1_CLOCK); + Configuration.SetPinFunction(26, DeviceFunction.I2C1_DATA); + + // Setup buttons + _gpio = new(); + } + } +} diff --git a/nanoFramework.AtomLite/Properties/AssemblyInfo.cs b/nanoFramework.AtomLite/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..ff9e6fe7 --- /dev/null +++ b/nanoFramework.AtomLite/Properties/AssemblyInfo.cs @@ -0,0 +1,21 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +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.AtomLite")] +[assembly: AssemblyCompany("nanoFramework Contributors")] +[assembly: AssemblyCopyright("Copyright(c).NET Foundation and Contributors")] + +// 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)] + +///////////////////////////////////////////////////////////////// +// This attribute is mandatory when building Interop libraries // +// update this whenever the native assembly signature changes // +[assembly: AssemblyNativeVersion("0.0.0.0")] +///////////////////////////////////////////////////////////////// diff --git a/nanoFramework.AtomLite/RgbLed.cs b/nanoFramework.AtomLite/RgbLed.cs new file mode 100644 index 00000000..456e926a --- /dev/null +++ b/nanoFramework.AtomLite/RgbLed.cs @@ -0,0 +1,92 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using nanoFramework.Hardware.Esp32.Rmt; +using System.Drawing; + +namespace nanoFramework.AtomLite +{ + /// + /// The RGB Led controller for M5Stack Atom Lite. + /// + public class RgbLed + { + protected const int RgbLedPin = 27; + // 80MHz / 4 => min pulse 0.00us + protected const byte ClockDivider = 4; + // one pulse duration in us + protected const float MinPulse = 1000000.0f / (80000000 / ClockDivider); + + // default datasheet values + protected readonly RmtCommand OnePulse = + new RmtCommand((ushort)(0.7 / MinPulse), true, (ushort)(0.6 / MinPulse), false); + + protected readonly RmtCommand ZeroPulse = + new RmtCommand((ushort)(0.35 / MinPulse), true, (ushort)(0.8 / MinPulse), false); + + protected readonly RmtCommand ResCommand = + new RmtCommand((ushort)(25 / MinPulse), false, (ushort)(26 / MinPulse), false); + + protected Color Pixel; + private readonly int _gpioPin; + + internal RgbLed(int gpioPin = RgbLedPin) + { + _gpioPin = gpioPin; + Pixel = Color.Black; + + } + + /// + /// Sets the NeoPixel to the specified rgb color. + /// + /// The color that is used + public void SetColor(Color color) + { + Pixel = color; + Update(); + } + + /// + /// Gets the rgb color from the NeoPixel. + /// + /// The rgb color + public Color GetColor() + { + return Pixel; + } + + private void Update() + { + using (var commandList = new TransmitterChannel(_gpioPin)) + { + ConfigureTransmitter(commandList); + + SerializeColor(Pixel.G, commandList); + SerializeColor(Pixel.R, commandList); + SerializeColor(Pixel.B, commandList); + + commandList.AddCommand(ResCommand); // RET + commandList.Send(true); + } + } + + private void SerializeColor(byte b, TransmitterChannel commandList) + { + for (var i = 0; i < 8; ++i) + { + commandList.AddCommand(((b & (1u << 7)) != 0) ? OnePulse : ZeroPulse); + b <<= 1; + } + } + + protected void ConfigureTransmitter(TransmitterChannel commandList) + { + commandList.CarrierEnabled = false; + commandList.ClockDivider = ClockDivider; + commandList.SourceClock = SourceClock.APB; + commandList.IdleLevel = false; + commandList.IsChannelIdle = true; + } + } +} diff --git a/nanoFramework.M5Stack/key.snk b/nanoFramework.AtomLite/key.snk similarity index 100% rename from nanoFramework.M5Stack/key.snk rename to nanoFramework.AtomLite/key.snk diff --git a/nanoFramework.AtomLite/nanoFramework.AtomLite.nfproj b/nanoFramework.AtomLite/nanoFramework.AtomLite.nfproj new file mode 100644 index 00000000..6b54f324 --- /dev/null +++ b/nanoFramework.AtomLite/nanoFramework.AtomLite.nfproj @@ -0,0 +1,98 @@ + + + + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ + + + + Debug + AnyCPU + {11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + c20734a9-c944-4b2a-9cea-a9b3f855b132 + Library + Properties + 512 + nanoFramework.AtomLite + nanoFramework.AtomLite + v1.0 + bin\$(Configuration)\nanoFramework.AtomLite.xml + + + true + + + key.snk + + + false + + + + + + + + + + ..\packages\nanoFramework.Iot.Device.Button.1.0.288-preview.99\lib\Iot.Device.Button.dll + True + + + ..\packages\nanoFramework.CoreLibrary.1.12.0-preview.19\lib\mscorlib.dll + True + + + ..\packages\nanoFramework.Hardware.Esp32.1.3.5-preview.10\lib\nanoFramework.Hardware.Esp32.dll + True + + + ..\packages\nanoFramework.Hardware.Esp32.Rmt.1.2.2-preview.10\lib\nanoFramework.Hardware.Esp32.Rmt.dll + True + + + ..\packages\nanoFramework.Runtime.Events.1.10.0-preview.13\lib\nanoFramework.Runtime.Events.dll + True + + + ..\packages\nanoFramework.System.Device.Adc.1.0.2-preview.13\lib\System.Device.Adc.dll + True + + + ..\packages\nanoFramework.System.Device.Dac.1.4.3-preview.13\lib\System.Device.Dac.dll + True + + + ..\packages\nanoFramework.System.Device.Gpio.1.0.3-preview.18\lib\System.Device.Gpio.dll + True + + + ..\packages\nanoFramework.System.Device.I2c.1.0.3-preview.13\lib\System.Device.I2c.dll + True + + + ..\packages\nanoFramework.System.Device.Spi.1.0.4-preview.11\lib\System.Device.Spi.dll + True + + + ..\packages\nanoFramework.System.Drawing.1.0.288-preview.99\lib\System.Drawing.dll + True + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. + + + + \ No newline at end of file diff --git a/nanoFramework.AtomLite/nanoFramework.M5AtomLite.nfproj b/nanoFramework.AtomLite/nanoFramework.M5AtomLite.nfproj new file mode 100644 index 00000000..88a55094 --- /dev/null +++ b/nanoFramework.AtomLite/nanoFramework.M5AtomLite.nfproj @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/nanoFramework.AtomLite/packages.config b/nanoFramework.AtomLite/packages.config new file mode 100644 index 00000000..a13235ba --- /dev/null +++ b/nanoFramework.AtomLite/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nanoFramework.AtomMatrix.nuspec b/nanoFramework.AtomMatrix.nuspec new file mode 100644 index 00000000..36b510eb --- /dev/null +++ b/nanoFramework.AtomMatrix.nuspec @@ -0,0 +1,44 @@ + + + + nanoFramework.AtomMatrix + $version$ + nanoFramework.AtomMatrix + nanoframework + false + LICENSE.md + + + docs\README.md + false + https://github.com/nanoframework/nanoFramework.M5Stack + images\nf-logo.png + + Copyright (c) .NET Foundation and Contributors + This package includes the nanoFramework.AtomMatrix assembly for .NET nanoFramework C# projects. + nanoFramework C# csharp netmf netnf m5stack AtomMatrix + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nanoFramework.AtomMatrix/AtomMatrix.cs b/nanoFramework.AtomMatrix/AtomMatrix.cs new file mode 100644 index 00000000..248ff8a7 --- /dev/null +++ b/nanoFramework.AtomMatrix/AtomMatrix.cs @@ -0,0 +1,73 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Iot.Device.Mpu6886; +using nanoFramework.Hardware.Esp32; +using System.Device.I2c; + +namespace nanoFramework.AtomMatrix +{ + /// + /// The AtomMatrix Board. + /// + public static partial class AtomMatrix + { + /// + /// GPIO number of the neo pixel LED (from the datasheet). + /// + private const int _rgbLedGpio = 27; + private static PixelController _rgbLed; + private static Mpu6886AccelerometerGyroscope _mpu6886; + + /// + /// Gets the Accelerometer and Gyroscope. + /// + public static Mpu6886AccelerometerGyroscope AccelerometerGyroscope + { + get + { + // We do this to avoid having to load the Accelerometer if not needed or not connected + if (_mpu6886 == null) + { + _mpu6886 = new(new(new I2cConnectionSettings(1, 0x68))); + } + + return _mpu6886; + } + } + + /// + /// RGB LED matrix (WS2812C). + /// + public static PixelController LedMatrix + { + get + { + if (_rgbLed == null) + { + // instantiate a new Pixel controller, ATOM Matrix has 5x5 LEDs + _rgbLed = new PixelController(_rgbLedGpio, 5 * 5); + } + + return _rgbLed; + } + } + + static AtomMatrix() + { + // Setup first the I2C bus + Configuration.SetPinFunction(21, DeviceFunction.I2C1_CLOCK); + Configuration.SetPinFunction(25, DeviceFunction.I2C1_DATA); + + // setup the SPI bus + Configuration.SetPinFunction(19, DeviceFunction.SPI1_MOSI); + Configuration.SetPinFunction(33, DeviceFunction.SPI1_MISO); + Configuration.SetPinFunction(23, DeviceFunction.SPI1_CLOCK); + + // Setup buttons + _gpio = new(); + + LedMatrix.TurnOff(); + } + } +} diff --git a/nanoFramework.AtomMatrix/PixelController.cs b/nanoFramework.AtomMatrix/PixelController.cs new file mode 100644 index 00000000..f43e0995 --- /dev/null +++ b/nanoFramework.AtomMatrix/PixelController.cs @@ -0,0 +1,126 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using nanoFramework.Hardware.Esp32.Rmt; +using System.Drawing; + +namespace nanoFramework.AtomMatrix +{ + /// + /// Pixel controller for the WS2812C matrix. + /// + public class PixelController + { + // timming values from datasheet, considering a clock source of 80Mhz (which we have fixed in native) + internal readonly RmtCommand onePulse = new(52, true, 52, false); + + internal readonly RmtCommand zeroPulse = new(14, true, 52, false); + + internal readonly RmtCommand ResetCommand = new(1400, false, 1400, false); + internal int _gpioPin; + + /// + /// Color for the LED matrix. + /// + /// + /// Index 0 is LED at top left corner. Growing from left to right, top to bottom. + /// + public Color[] Pixels { get; set; } + + internal PixelController(int gpioPin, uint pixelCount) + { + _gpioPin = gpioPin; + + Pixels = new Color[pixelCount]; + + for (uint i = 0; i < pixelCount; ++i) + { + Pixels[i] = new Color(); + } + } + + /// + /// Set specific color (RGB Format) on pixel the given index. + /// + /// Index of the LED to set the . + /// value to set. + /// value to set. + /// value to set. + public void SetColor(short index, byte r, byte g, byte b) => Pixels[index] = Color.FromArgb(r, g, b); + + /// + /// Set specific color on LED at the given index. + /// + /// Index of the LED to set the . + /// value to set. + public void SetColor(short index, Color color) => Pixels[index] = color; + + /// + /// Update all pixels. + /// + public void Update() + { + var transmitter = new TransmitterChannel(_gpioPin); + + ConfigureTransmitter(transmitter); + + for (uint pixel = 0; pixel < Pixels.Length; pixel++) + { + SerialiseColor(Pixels[pixel].G, transmitter); + SerialiseColor(Pixels[pixel].R, transmitter); + SerialiseColor(Pixels[pixel].B, transmitter); + + transmitter.AddCommand(ResetCommand); + } + + transmitter.Send(true); + + transmitter.Dispose(); + } + + /// + /// Turn off all pixels. + /// + public void TurnOff() + { + for (uint pixel = 0; pixel < Pixels.Length; pixel++) + { + Pixels[pixel] = Color.Black; + } + + Update(); + } + + /// + /// Fill in all LEDs with a color. + /// + /// to fill in the LEDs. + public void FillColor(Color color) + { + for (uint pixel = 0; pixel < Pixels.Length; pixel++) + { + Pixels[pixel] = color; + } + + Update(); + } + + + private void SerialiseColor(byte b, TransmitterChannel transmitter) + { + for (int i = 0; i < 8; ++i) + { + transmitter.AddCommand(((b & (1u << 7)) != 0) ? onePulse : zeroPulse); + b <<= 1; + } + } + + private void ConfigureTransmitter(TransmitterChannel transmitter) + { + transmitter.CarrierEnabled = false; + // this value for the clock divider considers a clock source of 80MHz which is what we have fixed in native + transmitter.ClockDivider = 2; + transmitter.IdleLevel = false; + } + } +} \ No newline at end of file diff --git a/nanoFramework.AtomMatrix/Properties/AssemblyInfo.cs b/nanoFramework.AtomMatrix/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..1d51b733 --- /dev/null +++ b/nanoFramework.AtomMatrix/Properties/AssemblyInfo.cs @@ -0,0 +1,15 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +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.AtomMatrix")] +[assembly: AssemblyCompany("nanoFramework Contributors")] +[assembly: AssemblyCopyright("Copyright(c).NET Foundation and Contributors")] + +// 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/nanoFramework.AtomMatrix/key.snk b/nanoFramework.AtomMatrix/key.snk new file mode 100644 index 00000000..67c9bb0a Binary files /dev/null and b/nanoFramework.AtomMatrix/key.snk differ diff --git a/nanoFramework.AtomMatrix/nanoFramework.AtomMatrix.nfproj b/nanoFramework.AtomMatrix/nanoFramework.AtomMatrix.nfproj new file mode 100644 index 00000000..85a52ac2 --- /dev/null +++ b/nanoFramework.AtomMatrix/nanoFramework.AtomMatrix.nfproj @@ -0,0 +1,123 @@ + + + + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ + + + + Debug + AnyCPU + {11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + c47be27b-028d-493a-85dd-7d5c24ee6eb7 + Library + Properties + 512 + nanoFramework.AtomMatrix + nanoFramework.AtomMatrix + $(DefineConstants);ATOM_MATRIX + v1.0 + bin\$(Configuration)\nanoFramework.AtomMatrix.xml + + + true + + + key.snk + + + false + + + + + + + + + + ..\packages\nanoFramework.Iot.Device.Button.1.0.288-preview.99\lib\Iot.Device.Button.dll + True + + + ..\packages\nanoFramework.Iot.Device.Mpu6886.1.0.288-preview.106\lib\Iot.Device.Mpu6886.dll + True + + + ..\packages\nanoFramework.CoreLibrary.1.12.0-preview.19\lib\mscorlib.dll + True + + + ..\packages\nanoFramework.Hardware.Esp32.1.3.5-preview.10\lib\nanoFramework.Hardware.Esp32.dll + True + + + ..\packages\nanoFramework.Hardware.Esp32.Rmt.1.2.2-preview.10\lib\nanoFramework.Hardware.Esp32.Rmt.dll + True + + + ..\packages\nanoFramework.Runtime.Events.1.10.0-preview.13\lib\nanoFramework.Runtime.Events.dll + True + + + ..\packages\nanoFramework.System.Buffers.Binary.BinaryPrimitives.1.0.288-preview.103\lib\System.Buffers.Binary.BinaryPrimitives.dll + True + + + ..\packages\nanoFramework.System.Device.Adc.1.0.2-preview.13\lib\System.Device.Adc.dll + True + + + ..\packages\nanoFramework.System.Device.Dac.1.4.3-preview.13\lib\System.Device.Dac.dll + True + + + ..\packages\nanoFramework.System.Device.Gpio.1.0.3-preview.18\lib\System.Device.Gpio.dll + True + + + ..\packages\nanoFramework.System.Device.I2c.1.0.3-preview.13\lib\System.Device.I2c.dll + True + + + ..\packages\nanoFramework.System.Device.Model.1.0.288-preview.99\lib\System.Device.Model.dll + True + + + ..\packages\nanoFramework.System.Device.Spi.1.0.4-preview.11\lib\System.Device.Spi.dll + True + + + ..\packages\nanoFramework.System.Drawing.1.0.288-preview.99\lib\System.Drawing.dll + True + + + ..\packages\nanoFramework.System.Math.1.4.4-preview.22\lib\System.Math.dll + True + + + ..\packages\nanoFramework.System.Numerics.1.0.289-preview.1\lib\System.Numerics.dll + True + + + ..\packages\UnitsNet.nanoFramework.Temperature.4.126.0\lib\UnitsNet.Temperature.dll + True + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. + + + + \ No newline at end of file diff --git a/nanoFramework.AtomMatrix/packages.config b/nanoFramework.AtomMatrix/packages.config new file mode 100644 index 00000000..f07750dd --- /dev/null +++ b/nanoFramework.AtomMatrix/packages.config @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nanoFramework.Fire.nuspec b/nanoFramework.Fire.nuspec new file mode 100644 index 00000000..7fb5fd66 --- /dev/null +++ b/nanoFramework.Fire.nuspec @@ -0,0 +1,49 @@ + + + + nanoFramework.Fire + $version$ + nanoFramework.Fire + nanoframework + false + LICENSE.md + + + docs\README.md + false + https://github.com/nanoframework/nanoFramework.M5Stack + images\nf-logo.png + + Copyright (c) .NET Foundation and Contributors + This package includes the nanoFramework.Fire assembly for .NET nanoFramework C# projects. + nanoFramework C# csharp netmf netnf m5stack Fire + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nanoFramework.Fire/Fire.cs b/nanoFramework.Fire/Fire.cs new file mode 100644 index 00000000..753860fc --- /dev/null +++ b/nanoFramework.Fire/Fire.cs @@ -0,0 +1,212 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Iot.Device.Button; +using Iot.Device.Buzzer; +using Iot.Device.Ip5306; +using nanoFramework.Fire; +using nanoFramework.Hardware.Esp32; +using System; +using System.Device.Adc; +using System.Device.I2c; +using UnitsNet; + +namespace nanoFramework.M5Stack +{ + /// + /// Fire board + /// + public static partial class Fire + { + private static readonly Ip5306 _power; + private static GpioButton _left; + private static GpioButton _center; + private static GpioButton _right; + private static Buzzer _buzzer; + + #region properties + + /// + /// Left button. + /// + public static GpioButton ButtonLeft + { + get + { + if (_left == null) + { + _left = new(39, _gpio, false); + } + + return _left; + } + } + + /// + /// Center button. + /// + public static GpioButton ButtonCenter + { + get + { + if (_center == null) + { + _center = new(38, _gpio, false); + } + + return _center; + } + } + + /// + /// Right button. + /// + public static GpioButton ButtonRight + { + get + { + if (_right == null) + { + _right = new(37, _gpio, false); + } + + return _right; + } + } + + /// + /// Gets the power management of the M5 Stack. + /// + /// Please make sure to read the documentation before adjusting any element. + public static Ip5306 Power { get => _power; } + + /// + /// Gets the Buzzer. + /// + public static Buzzer Buzzer + { + get + { + // We do this in case you prefer to use the DAC channels which are using the same pins + if (_buzzer == null) + { + // Setup buzzer + Configuration.SetPinFunction(25, DeviceFunction.PWM1); + _buzzer = new(25); + } + + return _buzzer; + } + } + + #endregion + + /// + /// Gets the screen. + /// + /// The screen initialization takes a little bit of time, if you need the screen consider using it as early as possible in your code. + public static void InitializeScreen() + { + // If the screen is not needed, it's not going to be created + // Note: initialization may take a little bit of time + if (_screen == null) + { + _screen = new(); + Console.Font = Resource.GetFont(Resource.FontResources.consolas_regular_16); + } + } + + static Fire() + { + // Setup first the I2C bus + Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK); + Configuration.SetPinFunction(21, DeviceFunction.I2C1_DATA); + // Same for PortA than for the internal one + _portANumber = 1; + + // Create the energy management device + I2cDevice i2c = new(new I2cConnectionSettings(1, Ip5306.SecondaryI2cAddress)); + _power = new(i2c); + + // Configuration for M5Stack + _power.ButtonOffEnabled = true; + _power.BoostOutputEnabled = false; + _power.AutoPowerOnEnabled = true; + _power.ChargerEnabled = true; + _power.BoostEnabled = true; + _power.LowPowerOffEnabled = true; + _power.FlashLightBehavior = ButtonPress.Doubleclick; + _power.SwitchOffBoostBehavior = ButtonPress.LongPress; + _power.BoostWhenVinUnpluggedEnabled = true; + _power.ChargingUnderVoltage = ChargingUnderVoltage.V4_55; + _power.ChargingLoopSelection = ChargingLoopSelection.Vin; + _power.ChargingCurrent = ElectricCurrent.FromMilliamperes(2250); + _power.ConstantChargingVoltage = ConstantChargingVoltage.Vm28; + _power.ChargingCuttOffVoltage = ChargingCutOffVoltage.V4_17; + _power.LightDutyShutdownTime = LightDutyShutdownTime.S32; + _power.ChargingCutOffCurrent = ChargingCutOffCurrent.C500mA; + _power.ChargingCuttOffVoltage = ChargingCutOffVoltage.V4_2; + + // Setup buttons + _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); + + // Second serial port + Configuration.SetPinFunction(16, DeviceFunction.COM2_RX); + Configuration.SetPinFunction(17, DeviceFunction.COM2_TX); + } + + /// + /// Gets an ADC channel + /// + /// The GPIO pin number + /// An AdcChannel + public static AdcChannel GetAdcGpio(int gpioNumber) + { + if (_adc == null) + { + _adc = new(); + } + + switch (gpioNumber) + { + case 35: + Configuration.SetPinFunction(35, DeviceFunction.ADC1_CH7); + return _adc.OpenChannel(7); + case 36: + Configuration.SetPinFunction(36, DeviceFunction.ADC1_CH0); + return _adc.OpenChannel(0); + case 2: + Configuration.SetPinFunction(2, DeviceFunction.ADC1_CH12); + return _adc.OpenChannel(12); + case 12: + Configuration.SetPinFunction(12, DeviceFunction.ADC1_CH15); + return _adc.OpenChannel(15); + case 15: + Configuration.SetPinFunction(15, DeviceFunction.ADC1_CH13); + return _adc.OpenChannel(13); + case 25: + Configuration.SetPinFunction(25, DeviceFunction.ADC1_CH18); + return _adc.OpenChannel(18); + case 26: + Configuration.SetPinFunction(26, DeviceFunction.ADC1_CH19); + return _adc.OpenChannel(19); + case 13: + Configuration.SetPinFunction(13, DeviceFunction.ADC1_CH14); + return _adc.OpenChannel(14); + case 0: + Configuration.SetPinFunction(0, DeviceFunction.ADC1_CH11); + return _adc.OpenChannel(11); + case 34: + Configuration.SetPinFunction(34, DeviceFunction.ADC1_CH6); + return _adc.OpenChannel(6); + default: + throw new ArgumentException(nameof(gpioNumber)); + } + } + } +} diff --git a/nanoFramework.Fire/Properties/AssemblyInfo.cs b/nanoFramework.Fire/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..5d0ff917 --- /dev/null +++ b/nanoFramework.Fire/Properties/AssemblyInfo.cs @@ -0,0 +1,8 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("nanoFramework.Fire")] +[assembly: AssemblyCompany("nanoFramework Contributors")] +[assembly: AssemblyProduct("nanoFramework.Fire")] +[assembly: AssemblyCopyright("Copyright (c) .NET Foundation and Contributors")] diff --git a/nanoFramework.M5Stack/Resource.Designer.cs b/nanoFramework.Fire/Resource.Designer.cs similarity index 91% rename from nanoFramework.M5Stack/Resource.Designer.cs rename to nanoFramework.Fire/Resource.Designer.cs index afe41a7e..e7061d2f 100644 --- a/nanoFramework.M5Stack/Resource.Designer.cs +++ b/nanoFramework.Fire/Resource.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace nanoFramework.M5Stack +namespace nanoFramework.Fire { internal partial class Resource @@ -20,7 +20,7 @@ internal static System.Resources.ResourceManager ResourceManager { if ((Resource.manager == null)) { - Resource.manager = new System.Resources.ResourceManager("nanoFramework.M5Stack.Resource", typeof(Resource).Assembly); + Resource.manager = new System.Resources.ResourceManager("nanoFramework.Fire.Resource", typeof(Resource).Assembly); } return Resource.manager; } diff --git a/nanoFramework.M5Stack/Resource.resx b/nanoFramework.Fire/Resource.resx similarity index 98% rename from nanoFramework.M5Stack/Resource.resx rename to nanoFramework.Fire/Resource.resx index 7761daa3..0c6a0dd1 100644 --- a/nanoFramework.M5Stack/Resource.resx +++ b/nanoFramework.Fire/Resource.resx @@ -119,6 +119,6 @@ - Resources\consolas_regular_16.tinyfnt;System.Byte[], mscorlib, Version=1.10.5.4, Culture=neutral, PublicKeyToken=c07d481e9758c731 + Resources\consolas_regular_16.tinyfnt;System.Byte[], mscorlib, Version=1.12.0.0, Culture=neutral, PublicKeyToken=c07d481e9758c731 \ No newline at end of file diff --git a/nanoFramework.M5Stack/Resources/consolas_regular_16.tinyfnt b/nanoFramework.Fire/Resources/consolas_regular_16.tinyfnt similarity index 100% rename from nanoFramework.M5Stack/Resources/consolas_regular_16.tinyfnt rename to nanoFramework.Fire/Resources/consolas_regular_16.tinyfnt diff --git a/nanoFramework.M5Stack/Screen.cs b/nanoFramework.Fire/Screen.cs similarity index 92% rename from nanoFramework.M5Stack/Screen.cs rename to nanoFramework.Fire/Screen.cs index dfa40e0f..4c74ea9e 100644 --- a/nanoFramework.M5Stack/Screen.cs +++ b/nanoFramework.Fire/Screen.cs @@ -26,7 +26,11 @@ public Screen() return; } +#if M5CORE2 || FIRE + MemoryAllocationBitmap = 2 * 1024 * 1024; +#else MemoryAllocationBitmap = 1024; +#endif BackLightPin = 32; Controller = new(); Controller.OpenPin(BackLightPin, PinMode.Output); diff --git a/nanoFramework.Fire/nanoFramework.Fire.nfproj b/nanoFramework.Fire/nanoFramework.Fire.nfproj new file mode 100644 index 00000000..7aed581e --- /dev/null +++ b/nanoFramework.Fire/nanoFramework.Fire.nfproj @@ -0,0 +1,171 @@ + + + + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ + + + + Debug + AnyCPU + {11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 2550d7fc-bba7-4173-9071-8606dd600a2c + Library + Properties + 512 + nanoFramework.Fire + nanoFramework.Fire + v1.0 + $(DefineConstants);FIRE + bin\$(Configuration)\nanoFramework.Fire.xml + + + + + + + True + True + Resource.resx + + + + + + ..\packages\nanoFramework.Iot.Device.Bmm150.1.0.288-preview.106\lib\Iot.Device.Bmm150.dll + True + + + ..\packages\nanoFramework.Iot.Device.Button.1.0.288-preview.99\lib\Iot.Device.Button.dll + True + + + ..\packages\nanoFramework.Iot.Device.Buzzer.1.0.288-preview.103\lib\Iot.Device.Buzzer.dll + True + + + ..\packages\nanoFramework.Iot.Device.Ip5306.1.0.288-preview.103\lib\Iot.Device.Ip5306.dll + True + + + ..\packages\nanoFramework.Iot.Device.Mpu6886.1.0.288-preview.106\lib\Iot.Device.Mpu6886.dll + True + + + ..\packages\nanoFramework.CoreLibrary.1.12.0-preview.19\lib\mscorlib.dll + True + + + ..\packages\nanoFramework.Graphics.1.0.2-preview.18\lib\nanoFramework.Graphics.dll + True + + + ..\packages\nanoFramework.Hardware.Esp32.1.3.5-preview.10\lib\nanoFramework.Hardware.Esp32.dll + True + + + ..\packages\nanoFramework.ResourceManager.1.1.4-preview.13\lib\nanoFramework.ResourceManager.dll + True + + + ..\packages\nanoFramework.Runtime.Events.1.10.0-preview.13\lib\nanoFramework.Runtime.Events.dll + True + + + ..\packages\nanoFramework.Runtime.Native.1.5.4-preview.10\lib\nanoFramework.Runtime.Native.dll + True + + + ..\packages\nanoFramework.System.Collections.1.4.0-preview.27\lib\nanoFramework.System.Collections.dll + True + + + ..\packages\nanoFramework.System.Text.1.1.3-preview.24\lib\nanoFramework.System.Text.dll + True + + + ..\packages\nanoFramework.System.Buffers.Binary.BinaryPrimitives.1.0.288-preview.103\lib\System.Buffers.Binary.BinaryPrimitives.dll + True + + + ..\packages\nanoFramework.System.Device.Adc.1.0.2-preview.13\lib\System.Device.Adc.dll + True + + + ..\packages\nanoFramework.System.Device.Dac.1.4.3-preview.13\lib\System.Device.Dac.dll + True + + + ..\packages\nanoFramework.System.Device.Gpio.1.0.3-preview.18\lib\System.Device.Gpio.dll + True + + + ..\packages\nanoFramework.System.Device.I2c.1.0.3-preview.13\lib\System.Device.I2c.dll + True + + + ..\packages\nanoFramework.System.Device.Model.1.0.288-preview.99\lib\System.Device.Model.dll + True + + + ..\packages\nanoFramework.System.Device.Pwm.1.0.1-preview.13\lib\System.Device.Pwm.dll + True + + + ..\packages\nanoFramework.System.Device.Spi.1.0.4-preview.11\lib\System.Device.Spi.dll + True + + + ..\packages\nanoFramework.System.IO.Ports.1.0.3-preview.39\lib\System.IO.Ports.dll + True + + + ..\packages\nanoFramework.System.IO.Streams.1.0.0-preview.19\lib\System.IO.Streams.dll + True + + + ..\packages\nanoFramework.System.Math.1.4.4-preview.22\lib\System.Math.dll + True + + + ..\packages\nanoFramework.System.Numerics.1.0.289-preview.1\lib\System.Numerics.dll + True + + + ..\packages\UnitsNet.nanoFramework.ElectricCurrent.4.126.0\lib\UnitsNet.ElectricCurrent.dll + True + + + ..\packages\UnitsNet.nanoFramework.Frequency.4.126.0\lib\UnitsNet.Frequency.dll + True + + + ..\packages\UnitsNet.nanoFramework.Temperature.4.126.0\lib\UnitsNet.Temperature.dll + True + + + + + + + + + nFResXFileCodeGenerator + Resource.Designer.cs + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. + + + + \ No newline at end of file diff --git a/nanoFramework.Fire/packages.config b/nanoFramework.Fire/packages.config new file mode 100644 index 00000000..942fcaf3 --- /dev/null +++ b/nanoFramework.Fire/packages.config @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nanoFramework.M5Core.nuspec b/nanoFramework.M5Core.nuspec new file mode 100644 index 00000000..b309437f --- /dev/null +++ b/nanoFramework.M5Core.nuspec @@ -0,0 +1,51 @@ + + + + nanoFramework.M5Core + $version$ + nanoFramework.M5Core + nanoframework + false + LICENSE.md + + + docs\README.md + false + https://github.com/nanoframework/nanoFramework.M5Stack + images\nf-logo.png + + Copyright (c) .NET Foundation and Contributors + This package includes the nanoFramework.M5Core assembly for .NET nanoFramework C# projects. + nanoFramework C# csharp netmf netnf m5stack M5Core + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nanoFramework.M5Stack/M5Stack.cs b/nanoFramework.M5Core/M5Core.cs similarity index 96% rename from nanoFramework.M5Stack/M5Stack.cs rename to nanoFramework.M5Core/M5Core.cs index 9307818a..ea4a32bf 100644 --- a/nanoFramework.M5Stack/M5Stack.cs +++ b/nanoFramework.M5Core/M5Core.cs @@ -4,25 +4,18 @@ using Iot.Device.Button; using Iot.Device.Buzzer; using Iot.Device.Ip5306; -using Iot.Device.Magnetometer; -using Iot.Device.Mpu6886; using nanoFramework.Hardware.Esp32; -using nanoFramework.UI; using System; -using System.Device.Dac; -using System.Device.Gpio; +using System.Device.Adc; using System.Device.I2c; -using System.Device.Spi; -using System.IO.Ports; using UnitsNet; -using System.Device.Adc; namespace nanoFramework.M5Stack { /// /// M5Stack board /// - public static partial class M5Stack + public static partial class M5Core { private static Ip5306 _power; private static Buzzer _buzzer; @@ -110,7 +103,11 @@ public static void InitializeScreen() if (_screen == null) { _screen = new(); +#if M5CORE2 Console.Font = Resource.GetFont(Resource.FontResources.consolas_regular_16); +#else + Console.Font = ResourceCore.GetFont(ResourceCore.FontResources.consolas_regular_16); +#endif } } @@ -120,13 +117,15 @@ public static void InitializeScreen() /// Please make sure to read the documentation before adjusting any element. public static Ip5306 Power { get => _power; } - #endregion +#endregion - static M5Stack() + static M5Core() { // Setup first the I2C bus Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK); Configuration.SetPinFunction(21, DeviceFunction.I2C1_DATA); + // Same for PortA than for the internal one + _portANumber = 1; // Create the energy management device I2cDevice i2c = new(new I2cConnectionSettings(1, Ip5306.SecondaryI2cAddress)); diff --git a/nanoFramework.M5Stack/Properties/AssemblyInfo.cs b/nanoFramework.M5Core/Properties/AssemblyInfo.cs similarity index 100% rename from nanoFramework.M5Stack/Properties/AssemblyInfo.cs rename to nanoFramework.M5Core/Properties/AssemblyInfo.cs diff --git a/nanoFramework.M5Core/ResourceCore.Designer.cs b/nanoFramework.M5Core/ResourceCore.Designer.cs new file mode 100644 index 00000000..7edece38 --- /dev/null +++ b/nanoFramework.M5Core/ResourceCore.Designer.cs @@ -0,0 +1,38 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace nanoFramework.M5Stack +{ + + internal partial class ResourceCore + { + private static System.Resources.ResourceManager manager; + internal static System.Resources.ResourceManager ResourceManager + { + get + { + if ((ResourceCore.manager == null)) + { + ResourceCore.manager = new System.Resources.ResourceManager("nanoFramework.M5Core.ResourceCore", typeof(ResourceCore).Assembly); + } + return ResourceCore.manager; + } + } + internal static nanoFramework.UI.Font GetFont(ResourceCore.FontResources id) + { + return ((nanoFramework.UI.Font)(nanoFramework.Runtime.Native.ResourceUtility.GetObject(ResourceManager, id))); + } + [System.SerializableAttribute()] + internal enum FontResources : short + { + consolas_regular_16 = 10023, + } + } +} diff --git a/nanoFramework.M5Core/ResourceCore.resx b/nanoFramework.M5Core/ResourceCore.resx new file mode 100644 index 00000000..df7451a4 --- /dev/null +++ b/nanoFramework.M5Core/ResourceCore.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + Resources\consolas_regular_16.tinyfnt;System.Byte[], mscorlib, Version=1.11.7.2, Culture=neutral, PublicKeyToken=c07d481e9758c731 + + \ No newline at end of file diff --git a/nanoFramework.M5Core/Resources/consolas_regular_16.tinyfnt b/nanoFramework.M5Core/Resources/consolas_regular_16.tinyfnt new file mode 100644 index 00000000..2331827a Binary files /dev/null and b/nanoFramework.M5Core/Resources/consolas_regular_16.tinyfnt differ diff --git a/nanoFramework.M5Core/Screen.cs b/nanoFramework.M5Core/Screen.cs new file mode 100644 index 00000000..4c74ea9e --- /dev/null +++ b/nanoFramework.M5Core/Screen.cs @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using nanoFramework.UI; +using System.Device.Gpio; + +namespace nanoFramework.M5Stack +{ + /// + /// M5 Stack screen class + /// + public class Screen : ScreenBase + { + private const int ChipSelect = 14; + private const int DataCommand = 27; + private const int Reset = 33; + private static bool _isInitialized = false; + + /// + /// Initializes the screen + /// + public Screen() + { + if (_isInitialized) + { + return; + } + +#if M5CORE2 || FIRE + MemoryAllocationBitmap = 2 * 1024 * 1024; +#else + MemoryAllocationBitmap = 1024; +#endif + BackLightPin = 32; + 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); + _isInitialized = true; + } + } +} diff --git a/nanoFramework.M5Core/key.snk b/nanoFramework.M5Core/key.snk new file mode 100644 index 00000000..67c9bb0a Binary files /dev/null and b/nanoFramework.M5Core/key.snk differ diff --git a/nanoFramework.M5Stack/nanoFramework.M5Stack.nfproj b/nanoFramework.M5Core/nanoFramework.M5Core.nfproj similarity index 60% rename from nanoFramework.M5Stack/nanoFramework.M5Stack.nfproj rename to nanoFramework.M5Core/nanoFramework.M5Core.nfproj index f3e30a86..398da2d3 100644 --- a/nanoFramework.M5Stack/nanoFramework.M5Stack.nfproj +++ b/nanoFramework.M5Core/nanoFramework.M5Core.nfproj @@ -11,11 +11,11 @@ {2c78d035-dbda-4c38-ab58-8adc22d763c3} Library 512 - nanoFramework.M5Stack - nanoFramework.M5Stack + nanoFramework.M5Core + nanoFramework.M5Core v1.0 True - bin\$(Configuration)\nanoFramework.M5Stack.xml + bin\$(Configuration)\nanoFramework.M5Core.xml true @@ -33,12 +33,12 @@ - + - + True True - Resource.resx + ResourceCore.resx @@ -48,124 +48,129 @@ - - ..\packages\nanoFramework.Iot.Device.Bmm150.1.0.260\lib\Iot.Device.Bmm150.dll + + ..\packages\nanoFramework.Iot.Device.Bmm150.1.0.288-preview.106\lib\Iot.Device.Bmm150.dll True - - ..\packages\nanoFramework.Iot.Device.Button.1.0.259\lib\Iot.Device.Button.dll + + ..\packages\nanoFramework.Iot.Device.Button.1.0.288-preview.99\lib\Iot.Device.Button.dll True - - ..\packages\nanoFramework.Iot.Device.Buzzer.1.0.260\lib\Iot.Device.Buzzer.dll + + ..\packages\nanoFramework.Iot.Device.Buzzer.1.0.288-preview.103\lib\Iot.Device.Buzzer.dll True - - ..\packages\nanoFramework.Iot.Device.Ip5306.1.0.259\lib\Iot.Device.Ip5306.dll + + ..\packages\nanoFramework.Iot.Device.Ip5306.1.0.288-preview.103\lib\Iot.Device.Ip5306.dll True - - ..\packages\nanoFramework.Iot.Device.Mpu6886.1.0.260\lib\Iot.Device.Mpu6886.dll + + ..\packages\nanoFramework.Iot.Device.Mpu6886.1.0.288-preview.106\lib\Iot.Device.Mpu6886.dll True - - ..\packages\nanoFramework.CoreLibrary.1.11.7\lib\mscorlib.dll + + ..\packages\nanoFramework.CoreLibrary.1.12.0-preview.19\lib\mscorlib.dll True - - ..\packages\nanoFramework.Graphics.1.0.1\lib\nanoFramework.Graphics.dll + + ..\packages\nanoFramework.Graphics.1.0.2-preview.18\lib\nanoFramework.Graphics.dll True - - ..\packages\nanoFramework.Hardware.Esp32.1.3.4\lib\nanoFramework.Hardware.Esp32.dll + + ..\packages\nanoFramework.Hardware.Esp32.1.3.5-preview.10\lib\nanoFramework.Hardware.Esp32.dll True - - ..\packages\nanoFramework.ResourceManager.1.1.3\lib\nanoFramework.ResourceManager.dll + + ..\packages\nanoFramework.ResourceManager.1.1.4-preview.13\lib\nanoFramework.ResourceManager.dll True - - ..\packages\nanoFramework.Runtime.Events.1.9.2\lib\nanoFramework.Runtime.Events.dll + + ..\packages\nanoFramework.Runtime.Events.1.10.0-preview.13\lib\nanoFramework.Runtime.Events.dll True - - ..\packages\nanoFramework.Runtime.Native.1.5.2\lib\nanoFramework.Runtime.Native.dll + + ..\packages\nanoFramework.Runtime.Native.1.5.4-preview.10\lib\nanoFramework.Runtime.Native.dll True - - ..\packages\nanoFramework.System.Collections.1.3.0\lib\nanoFramework.System.Collections.dll + + ..\packages\nanoFramework.System.Collections.1.4.0-preview.27\lib\nanoFramework.System.Collections.dll True - - ..\packages\nanoFramework.System.Buffers.Binary.BinaryPrimitives.1.0.259\lib\System.Buffers.Binary.BinaryPrimitives.dll + + ..\packages\nanoFramework.System.Text.1.1.3-preview.24\lib\nanoFramework.System.Text.dll True - - ..\packages\nanoFramework.System.Device.Adc.1.0.1\lib\System.Device.Adc.dll + + ..\packages\nanoFramework.System.Buffers.Binary.BinaryPrimitives.1.0.288-preview.103\lib\System.Buffers.Binary.BinaryPrimitives.dll True - - ..\packages\nanoFramework.System.Device.Dac.1.4.2\lib\System.Device.Dac.dll + + ..\packages\nanoFramework.System.Device.Adc.1.0.2-preview.13\lib\System.Device.Adc.dll True - - ..\packages\nanoFramework.System.Device.Gpio.1.0.2\lib\System.Device.Gpio.dll + + ..\packages\nanoFramework.System.Device.Dac.1.4.3-preview.13\lib\System.Device.Dac.dll True - - ..\packages\nanoFramework.System.Device.I2c.1.0.2\lib\System.Device.I2c.dll + + ..\packages\nanoFramework.System.Device.Gpio.1.0.3-preview.18\lib\System.Device.Gpio.dll True - - ..\packages\nanoFramework.System.Device.Model.1.0.259\lib\System.Device.Model.dll + + ..\packages\nanoFramework.System.Device.I2c.1.0.3-preview.13\lib\System.Device.I2c.dll True - - ..\packages\nanoFramework.System.Device.Pwm.1.0.0\lib\System.Device.Pwm.dll + + ..\packages\nanoFramework.System.Device.Model.1.0.288-preview.99\lib\System.Device.Model.dll True - - ..\packages\nanoFramework.System.Device.Spi.1.0.2\lib\System.Device.Spi.dll + + ..\packages\nanoFramework.System.Device.Pwm.1.0.1-preview.13\lib\System.Device.Pwm.dll True - - ..\packages\nanoFramework.System.Diagnostics.Stopwatch.1.0.259\lib\System.Diagnostics.Stopwatch.dll + + ..\packages\nanoFramework.System.Device.Spi.1.0.4-preview.11\lib\System.Device.Spi.dll True - - ..\packages\nanoFramework.System.IO.Ports.1.0.2\lib\System.IO.Ports.dll + + ..\packages\nanoFramework.System.Diagnostics.Stopwatch.1.0.289-preview.60\lib\System.Diagnostics.Stopwatch.dll True - - ..\packages\nanoFramework.System.Math.1.4.3\lib\System.Math.dll + + ..\packages\nanoFramework.System.IO.Ports.1.0.3-preview.39\lib\System.IO.Ports.dll True - - ..\packages\nanoFramework.System.Numerics.1.0.259\lib\System.Numerics.dll + + ..\packages\nanoFramework.System.IO.Streams.1.0.0-preview.19\lib\System.IO.Streams.dll True - - ..\packages\UnitsNet.nanoFramework.ElectricCurrent.4.110.0\lib\UnitsNet.ElectricCurrent.dll + + ..\packages\nanoFramework.System.Math.1.4.4-preview.22\lib\System.Math.dll True - - ..\packages\UnitsNet.nanoFramework.Frequency.4.110.0\lib\UnitsNet.Frequency.dll + + ..\packages\nanoFramework.System.Numerics.1.0.289-preview.1\lib\System.Numerics.dll True - - ..\packages\UnitsNet.nanoFramework.Temperature.4.110.0\lib\UnitsNet.Temperature.dll + + ..\packages\UnitsNet.nanoFramework.ElectricCurrent.4.126.0\lib\UnitsNet.ElectricCurrent.dll + True + + + ..\packages\UnitsNet.nanoFramework.Frequency.4.126.0\lib\UnitsNet.Frequency.dll + True + + + ..\packages\UnitsNet.nanoFramework.Temperature.4.126.0\lib\UnitsNet.Temperature.dll True - + nFResXFileCodeGenerator - Resource.Designer.cs + ResourceCore.Designer.cs - - - diff --git a/nanoFramework.M5Core/packages.config b/nanoFramework.M5Core/packages.config new file mode 100644 index 00000000..9889c92e --- /dev/null +++ b/nanoFramework.M5Core/packages.config @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nanoFramework.M5Core2.nuspec b/nanoFramework.M5Core2.nuspec index a041aa44..4f7dce4b 100644 --- a/nanoFramework.M5Core2.nuspec +++ b/nanoFramework.M5Core2.nuspec @@ -1,11 +1,10 @@ - + nanoFramework.M5Core2 $version$ nanoFramework.M5Core2 - nanoFramework project contributors - nanoFramework,dotnetfoundation + nanoframework false LICENSE.md @@ -17,37 +16,29 @@ Copyright (c) .NET Foundation and Contributors This package includes the nanoFramework.M5Core2 assembly for .NET nanoFramework C# projects. - nanoFramework C# csharp netmf netnf nanoFramework.M5Core2 + nanoFramework C# csharp netmf netnf m5stack M5Core2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/nanoFramework.M5Core2/M5Core2.cs b/nanoFramework.M5Core2/M5Core2.cs index 7fe76dbd..b6a11c58 100644 --- a/nanoFramework.M5Core2/M5Core2.cs +++ b/nanoFramework.M5Core2/M5Core2.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using Iot.Device.Axp192; +using Iot.Device.Ft6xx6x; using Iot.Device.Rtc; using nanoFramework.Hardware.Esp32; using nanoFramework.M5Core2; @@ -9,16 +10,37 @@ using System; using System.Device.Adc; using System.Device.I2c; +using System.Device.Gpio; using UnitsNet; +using System.Threading; +using nanoFramework.Runtime.Events; namespace nanoFramework.M5Stack { public static partial class M5Core2 { + private const int TouchPinInterrupt = 39; private static Pcf8563 _rtc; private static Axp192 _power; private static bool _powerLed; private static bool _vibrate; + private static Ft6xx6x _touchController; + private static Thread _callbackThread; + private static CancellationTokenSource _cancelThread; + private static CancellationTokenSource _startThread; + private static Point _lastPoint; + + /// + /// Touch event handler for the touch event. + /// + /// The sender object. + /// The touch event argument. + public delegate void TouchEventHandler(object sender, TouchEventArgs e); + + /// + /// Touch event handler. + /// + public static event TouchEventHandler TouchEvent; /// /// Gets the power management of the M5Core2. @@ -60,6 +82,22 @@ public static bool Vibrate } } + /// + /// Gets the touch controller. + /// + public static Ft6xx6x TouchController + { + get + { + if (_touchController == null) + { + InitializeScreen(); + } + + return _touchController; + } + } + /// /// Gets the screen. /// @@ -72,9 +110,114 @@ public static void InitializeScreen() { _screen = new(); Console.Font = Resource.GetFont(Resource.FontResources.consolas_regular_16); + _touchController = new(I2cDevice.Create(new I2cConnectionSettings(1, Ft6xx6x.DefaultI2cAddress))); + _touchController.SetInterruptMode(false); + _lastPoint = new(); + _cancelThread = new(); + _startThread = new(); + _callbackThread = new(ThreadTouchCallback); + _callbackThread.Start(); + _gpio.OpenPin(TouchPinInterrupt, PinMode.Input); + _gpio.RegisterCallbackForPinValueChangedEvent(TouchPinInterrupt, PinEventTypes.Rising | PinEventTypes.Falling, TouchCallback); } } + private static void TouchCallback(object sender, PinValueChangedEventArgs pinValueChangedEventArgs) + { + if (pinValueChangedEventArgs.ChangeType == PinEventTypes.Falling) + { + _cancelThread = new(); + _startThread.Cancel(); + } + else + { + _startThread = new(); + _cancelThread.Cancel(); + var point = _touchController.GetPoint(true); + if ((_lastPoint.X != point.X) && (_lastPoint.Y != point.Y)) + { + _lastPoint = point; + var touchCategory = CheckIfInButtons(point.X, point.Y, TouchEventCategory.Unknown) | TouchEventCategory.LiftUp; + TouchEvent?.Invoke(_touchController, new TouchEventArgs() { TimeStamp = DateTime.UtcNow, EventCategory = EventCategory.Touch, TouchEventCategory = touchCategory, X = point.X, Y = point.Y, Id = point.TouchId }); + } + } + } + + private static void ThreadTouchCallback() + { + start: + while (!_startThread.IsCancellationRequested) + { + _startThread.Token.WaitHandle.WaitOne(1000, true); + } + + int touchNumber; + TouchEventCategory touchCategory; + do + { + touchNumber = _touchController.GetNumberPoints(); + if (touchNumber == 1) + { + var point = _touchController.GetPoint(true); + _lastPoint = point; + touchCategory = CheckIfInButtons(point.X, point.Y, TouchEventCategory.Unknown); + touchCategory = point.Event == Event.Contact ? touchCategory | TouchEventCategory.Moving : touchCategory; + TouchEvent?.Invoke(_touchController, new TouchEventArgs() { TimeStamp = DateTime.UtcNow, EventCategory = EventCategory.Touch, TouchEventCategory = touchCategory, X = point.X, Y = point.Y, Id = point.TouchId }); + } + else if (touchNumber == 2) + { + var dp = _touchController.GetDoublePoints(); + touchCategory = CheckIfInButtons(dp.Point1.X, dp.Point1.Y, TouchEventCategory.DoubleTouch); + touchCategory = dp.Point1.Event == Event.Contact ? touchCategory | TouchEventCategory.Moving : touchCategory; + TouchEvent?.Invoke(_touchController, new TouchEventArgs() { TimeStamp = DateTime.UtcNow, EventCategory = EventCategory.Touch, TouchEventCategory = touchCategory, X = dp.Point1.X, Y = dp.Point1.Y, Id = dp.Point1.TouchId }); + touchCategory = CheckIfInButtons(dp.Point2.X, dp.Point2.Y, TouchEventCategory.DoubleTouch); + touchCategory = dp.Point2.Event == Event.Contact ? touchCategory | TouchEventCategory.Moving : touchCategory; + TouchEvent?.Invoke(_touchController, new TouchEventArgs() { TimeStamp = DateTime.UtcNow, EventCategory = EventCategory.Touch, TouchEventCategory = touchCategory, X = dp.Point2.X, Y = dp.Point2.Y, Id = dp.Point2.TouchId }); + } + + // This is necessary to give time to the touch sensor + // In theory, the wait should be calculated with the period + _cancelThread.Token.WaitHandle.WaitOne(10, true); + } while (!_cancelThread.IsCancellationRequested); + + // If both token are cancelled, we exit. This is in case this won't become static and will have a dispose. + // Now, with the current logic, it will always run. + if (!(_cancelThread.IsCancellationRequested && _startThread.IsCancellationRequested)) + { + goto start; + } + } + + private static TouchEventCategory CheckIfInButtons(int x, int y, TouchEventCategory touchCategory) + { + // Positions of the buttons on the X axis + const int XLeft = 83; + const int XMiddle = 182; + const int XRight = 271; + // On the Y one (same for all + const int YButtons = 263; + // The delta in pixel for the button size + const int DeltaPixel = 24; + // Check if we are in Y + if ((y <= YButtons + DeltaPixel) && (y >= YButtons - DeltaPixel)) + { + if ((x <= XLeft + DeltaPixel) && (x >= XLeft - DeltaPixel)) + { + touchCategory |= TouchEventCategory.LeftButton; + } + else if ((x <= XMiddle + DeltaPixel) && (x >= XMiddle - DeltaPixel)) + { + touchCategory |= TouchEventCategory.MiddleButton; + } + else if ((x <= XRight + DeltaPixel) && (x >= XRight - DeltaPixel)) + { + touchCategory |= TouchEventCategory.RightButton; + } + } + + return touchCategory; + } + static M5Core2() { // Setup first the I2C bus @@ -110,7 +253,7 @@ static M5Core2() _power.BatteryTemperatureMonitoring = true; _power.AdcPinCurrentSetting = AdcPinCurrentSetting.AlwaysOn; // Set ADC1 Enable - _power.AdcPinEnabled= AdcPinEnabled.All; + _power.AdcPinEnabled = AdcPinEnabled.All; // Switch on the power led PowerLed = true; // Set GPIO4 as output (rest LCD) @@ -121,7 +264,7 @@ static M5Core2() _power.SetBatteryHighTemperatureThreshold(ElectricPotential.FromVolts(3.2256)); // Enable bat detection _power.SetShutdownBatteryDetectionControl(false, true, ShutdownBatteryPinFunction.HighResistance, true, ShutdownBatteryTiming.S2); - // Set Power off voltage 3.0v + // Set Power off voltage 3.0v _power.VoffVoltage = VoffVoltage.V3_0; // This part of the code will handle the button behavior _power.EnableButtonPressed(ButtonPressed.LongPressed | ButtonPressed.ShortPressed); @@ -144,6 +287,12 @@ static M5Core2() Configuration.SetPinFunction(13, DeviceFunction.COM2_RX); Configuration.SetPinFunction(14, DeviceFunction.COM2_TX); + // 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; + // Setup the time if any _rtc = new Pcf8563(I2cDevice.Create(new I2cConnectionSettings(1, Pcf8563.DefaultI2cAddress))); diff --git a/nanoFramework.M5Core2/Resource.Designer.cs b/nanoFramework.M5Core2/Resource.Designer.cs index f4bb8be6..089cf1fb 100644 --- a/nanoFramework.M5Core2/Resource.Designer.cs +++ b/nanoFramework.M5Core2/Resource.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace nanoFramework.M5Core2 +namespace nanoFramework.M5Stack { internal partial class Resource diff --git a/nanoFramework.M5Core2/Screen.cs b/nanoFramework.M5Core2/Screen.cs index 223d24b0..20a177d9 100644 --- a/nanoFramework.M5Core2/Screen.cs +++ b/nanoFramework.M5Core2/Screen.cs @@ -8,7 +8,7 @@ using System.Threading; using UnitsNet; -namespace nanoFramework.M5Core2 +namespace nanoFramework.M5Stack { /// /// M5Core2 screen class @@ -27,7 +27,7 @@ public class Screen : ScreenBase /// public Screen() { - if(_isInitialized) + if (_isInitialized) { return; } diff --git a/nanoFramework.M5Core2/TouchEventArgs.cs b/nanoFramework.M5Core2/TouchEventArgs.cs new file mode 100644 index 00000000..04e00184 --- /dev/null +++ b/nanoFramework.M5Core2/TouchEventArgs.cs @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using nanoFramework.Runtime.Events; +using System; + +namespace nanoFramework.M5Core2 +{ + /// + /// Touch event arguments + /// + public class TouchEventArgs : EventArgs + { + /// + /// Gets or sets the touch event sub category. + /// + public TouchEventCategory TouchEventCategory { get; set; } + + /// + /// Gets or sets the event category. + /// + public EventCategory EventCategory { get; set; } + + /// + /// Gets or sets the coordinates of the point X. + /// + public int X { get; set; } + + /// + /// Gets or sets the coordinates of the point Y. + /// + public int Y { get; set; } + + /// + /// Gets or sets the contacty point Id. This is useful in a multi point context. + /// + public byte Id { get; set; } + + /// + /// Gets or sets the time stamp. + /// + public DateTime TimeStamp { get; set; } + } +} diff --git a/nanoFramework.M5Core2/TouchEventCategory.cs b/nanoFramework.M5Core2/TouchEventCategory.cs new file mode 100644 index 00000000..8c2c40a9 --- /dev/null +++ b/nanoFramework.M5Core2/TouchEventCategory.cs @@ -0,0 +1,35 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; + +namespace nanoFramework.M5Core2 +{ + /// + /// Sub event touch catgory + /// + [Flags] + public enum TouchEventCategory + { + /// Unknown + Unknown = 0b0000_0000, + + /// Left Button + LeftButton = 0b0000_0001, + + /// Middle Button + MiddleButton = 0b0000_0010, + + /// Right Button + RightButton = 0b0000_0100, + + /// Double Touch + DoubleTouch = 0b0000_1000, + + /// Moving + Moving = 0b0001_0000, + + /// Lift Up + LiftUp = 0b0010_0000, + } +} diff --git a/nanoFramework.M5Core2/nanoFramework.M5Core2.nfproj b/nanoFramework.M5Core2/nanoFramework.M5Core2.nfproj index b9d348c4..ad9cabc0 100644 --- a/nanoFramework.M5Core2/nanoFramework.M5Core2.nfproj +++ b/nanoFramework.M5Core2/nanoFramework.M5Core2.nfproj @@ -15,11 +15,12 @@ nanoFramework.M5Core2 nanoFramework.M5Core2 v1.0 - $(DefineConstants);M5CORE + $(DefineConstants);M5CORE2 bin\$(Configuration)\nanoFramework.M5Core2.xml + @@ -28,122 +29,139 @@ Resource.resx + - - ..\packages\nanoFramework.Iot.Device.Axp192.1.0.259\lib\Iot.Device.Axp192.dll + + ..\packages\nanoFramework.Iot.Device.Axp192.1.0.288-preview.103\lib\Iot.Device.Axp192.dll True - - ..\packages\nanoFramework.Iot.Device.Bmm150.1.0.260\lib\Iot.Device.Bmm150.dll + + ..\packages\nanoFramework.Iot.Device.Bmm150.1.0.288-preview.106\lib\Iot.Device.Bmm150.dll True - - ..\packages\nanoFramework.Iot.Device.Button.1.0.259\lib\Iot.Device.Button.dll + + ..\packages\nanoFramework.Iot.Device.Button.1.0.288-preview.99\lib\Iot.Device.Button.dll True - - ..\packages\nanoFramework.Iot.Device.Common.NumberHelper.1.0.259\lib\Iot.Device.Common.NumberHelper.dll + + ..\packages\nanoFramework.Iot.Device.Common.NumberHelper.1.0.288-preview.99\lib\Iot.Device.Common.NumberHelper.dll True - - ..\packages\nanoFramework.Iot.Device.Mpu6886.1.0.260\lib\Iot.Device.Mpu6886.dll + + ..\packages\nanoFramework.Iot.Device.Ft6xx6x.1.0.21-preview.102\lib\Iot.Device.Ft6xx6x.dll True - - ..\packages\nanoFramework.Iot.Device.Rtc.1.0.260\lib\Iot.Device.Rtc.dll + + ..\packages\nanoFramework.Iot.Device.Mpu6886.1.0.288-preview.106\lib\Iot.Device.Mpu6886.dll True - - ..\packages\nanoFramework.CoreLibrary.1.11.7\lib\mscorlib.dll + + ..\packages\nanoFramework.Iot.Device.Rtc.1.0.288-preview.103\lib\Iot.Device.Rtc.dll True - - ..\packages\nanoFramework.Graphics.1.0.1\lib\nanoFramework.Graphics.dll + + ..\packages\nanoFramework.CoreLibrary.1.12.0-preview.19\lib\mscorlib.dll True - - ..\packages\nanoFramework.Hardware.Esp32.1.3.4\lib\nanoFramework.Hardware.Esp32.dll + + ..\packages\nanoFramework.Graphics.1.0.2-preview.18\lib\nanoFramework.Graphics.dll True - - ..\packages\nanoFramework.ResourceManager.1.1.3\lib\nanoFramework.ResourceManager.dll + + ..\packages\nanoFramework.Hardware.Esp32.1.3.5-preview.10\lib\nanoFramework.Hardware.Esp32.dll True - - ..\packages\nanoFramework.Runtime.Events.1.9.2\lib\nanoFramework.Runtime.Events.dll + + ..\packages\nanoFramework.ResourceManager.1.1.4-preview.13\lib\nanoFramework.ResourceManager.dll True - - ..\packages\nanoFramework.Runtime.Native.1.5.2\lib\nanoFramework.Runtime.Native.dll + + ..\packages\nanoFramework.Runtime.Events.1.10.0-preview.13\lib\nanoFramework.Runtime.Events.dll True - - ..\packages\nanoFramework.System.Collections.1.3.0\lib\nanoFramework.System.Collections.dll + + ..\packages\nanoFramework.Runtime.Native.1.5.4-preview.10\lib\nanoFramework.Runtime.Native.dll True - - ..\packages\nanoFramework.System.Buffers.Binary.BinaryPrimitives.1.0.259\lib\System.Buffers.Binary.BinaryPrimitives.dll + + ..\packages\nanoFramework.System.Collections.1.4.0-preview.27\lib\nanoFramework.System.Collections.dll True - - ..\packages\nanoFramework.System.Device.Adc.1.0.1\lib\System.Device.Adc.dll + + ..\packages\nanoFramework.System.Text.1.1.3-preview.24\lib\nanoFramework.System.Text.dll True - - ..\packages\nanoFramework.System.Device.Dac.1.4.2\lib\System.Device.Dac.dll + + ..\packages\nanoFramework.System.Buffers.Binary.BinaryPrimitives.1.0.288-preview.103\lib\System.Buffers.Binary.BinaryPrimitives.dll True - - ..\packages\nanoFramework.System.Device.Gpio.1.0.2\lib\System.Device.Gpio.dll + + ..\packages\nanoFramework.System.Device.Adc.1.0.2-preview.13\lib\System.Device.Adc.dll True - - ..\packages\nanoFramework.System.Device.I2c.1.0.2\lib\System.Device.I2c.dll + + ..\packages\nanoFramework.System.Device.Dac.1.4.3-preview.13\lib\System.Device.Dac.dll True - - ..\packages\nanoFramework.System.Device.Model.1.0.259\lib\System.Device.Model.dll + + ..\packages\nanoFramework.System.Device.Gpio.1.0.3-preview.18\lib\System.Device.Gpio.dll True - - ..\packages\nanoFramework.System.Device.Pwm.1.0.0\lib\System.Device.Pwm.dll + + ..\packages\nanoFramework.System.Device.I2c.1.0.3-preview.13\lib\System.Device.I2c.dll True - - ..\packages\nanoFramework.System.Device.Spi.1.0.2\lib\System.Device.Spi.dll + + ..\packages\nanoFramework.System.Device.Model.1.0.288-preview.99\lib\System.Device.Model.dll True - - ..\packages\nanoFramework.System.Diagnostics.Stopwatch.1.0.259\lib\System.Diagnostics.Stopwatch.dll + + ..\packages\nanoFramework.System.Device.Pwm.1.0.1-preview.13\lib\System.Device.Pwm.dll True - - ..\packages\nanoFramework.System.IO.Ports.1.0.2\lib\System.IO.Ports.dll + + ..\packages\nanoFramework.System.Device.Spi.1.0.4-preview.11\lib\System.Device.Spi.dll True - - ..\packages\nanoFramework.System.Math.1.4.3\lib\System.Math.dll + + ..\packages\nanoFramework.System.Diagnostics.Stopwatch.1.0.289-preview.60\lib\System.Diagnostics.Stopwatch.dll True - - ..\packages\nanoFramework.System.Numerics.1.0.259\lib\System.Numerics.dll + + ..\packages\nanoFramework.System.IO.Ports.1.0.3-preview.39\lib\System.IO.Ports.dll True - - ..\packages\UnitsNet.nanoFramework.ElectricCurrent.4.110.0\lib\UnitsNet.ElectricCurrent.dll + + ..\packages\nanoFramework.System.IO.Streams.1.0.0-preview.19\lib\System.IO.Streams.dll True - - ..\packages\UnitsNet.nanoFramework.ElectricPotential.4.110.0\lib\UnitsNet.ElectricPotential.dll + + ..\packages\nanoFramework.System.Math.1.4.4-preview.22\lib\System.Math.dll True - - ..\packages\UnitsNet.nanoFramework.Power.4.110.0\lib\UnitsNet.Power.dll + + ..\packages\nanoFramework.System.Numerics.1.0.289-preview.1\lib\System.Numerics.dll True - - ..\packages\UnitsNet.nanoFramework.Temperature.4.110.0\lib\UnitsNet.Temperature.dll + + ..\packages\nanoFramework.System.Threading.1.0.4-preview.23\lib\System.Threading.dll + True + + + ..\packages\UnitsNet.nanoFramework.ElectricCurrent.4.126.0\lib\UnitsNet.ElectricCurrent.dll + True + + + ..\packages\UnitsNet.nanoFramework.ElectricPotential.4.126.0\lib\UnitsNet.ElectricPotential.dll + True + + + ..\packages\UnitsNet.nanoFramework.Power.4.126.0\lib\UnitsNet.Power.dll + True + + + ..\packages\UnitsNet.nanoFramework.Temperature.4.126.0\lib\UnitsNet.Temperature.dll True @@ -166,4 +184,11 @@ + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. + + + \ No newline at end of file diff --git a/nanoFramework.M5Core2/packages.config b/nanoFramework.M5Core2/packages.config index 0e1e6b28..ec41005b 100644 --- a/nanoFramework.M5Core2/packages.config +++ b/nanoFramework.M5Core2/packages.config @@ -1,32 +1,37 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nanoFramework.M5Stack.nuspec b/nanoFramework.M5Stack.nuspec deleted file mode 100644 index 8eb44e53..00000000 --- a/nanoFramework.M5Stack.nuspec +++ /dev/null @@ -1,62 +0,0 @@ - - - - nanoFramework.M5Stack - $version$ - nanoFramework.M5Stack - nanoFramework project contributors - nanoFramework,dotnetfoundation - false - LICENSE.md - - - docs\README.md - false - https://github.com/nanoframework/nanoFramework.M5Stack - images\nf-logo.png - - Copyright (c) .NET Foundation and Contributors - This package includes the nanoFramework.M5Stack assembly for .NET nanoFramework C# projects. - nanoFramework C# csharp netmf netnf nanoFramework.M5Stack - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/nanoFramework.M5Stack.sln b/nanoFramework.M5Stack.sln index fd7e9d04..95a330a1 100644 --- a/nanoFramework.M5Stack.sln +++ b/nanoFramework.M5Stack.sln @@ -1,20 +1,22 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31729.503 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32126.317 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "nanoFramework.M5Stack", "nanoFramework.M5Stack\nanoFramework.M5Stack.nfproj", "{2C78D035-DBDA-4C38-AB58-8ADC22D763C3}" +Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "nanoFramework.M5Core", "nanoFramework.M5Core\nanoFramework.M5Core.nfproj", "{2C78D035-DBDA-4C38-AB58-8ADC22D763C3}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0A689EB3-86E0-448E-99F4-3D644EC3D8C5}" ProjectSection(SolutionItems) = preProject + nanoFramework.AtomLite.nuspec = nanoFramework.AtomLite.nuspec + nanoFramework.AtomMatrix.nuspec = nanoFramework.AtomMatrix.nuspec + nanoFramework.M5Core.nuspec = nanoFramework.M5Core.nuspec nanoFramework.M5Core2.nuspec = nanoFramework.M5Core2.nuspec - nanoFramework.M5Stack.nuspec = nanoFramework.M5Stack.nuspec nanoFramework.M5StickC.nuspec = nanoFramework.M5StickC.nuspec nanoFramework.M5StickCPlus.nuspec = nanoFramework.M5StickCPlus.nuspec NuGet.Config = NuGet.Config version.json = version.json EndProjectSection EndProject -Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "M5StackTestApp", "Tests\M5StackTestApp\M5StackTestApp.nfproj", "{90A94170-2C6B-4B22-BAA5-8212AC22219B}" +Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "M5CoreTestApp", "Tests\M5CoreTestApp\M5CoreTestApp.nfproj", "{90A94170-2C6B-4B22-BAA5-8212AC22219B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{5972CDE6-43B4-42F0-9276-6B70B7EF6437}" EndProject @@ -30,15 +32,32 @@ Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "M5StickTestApp", "Tests\M5S EndProject Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "nanoFramework.M5Core2", "nanoFramework.M5Core2\nanoFramework.M5Core2.nfproj", "{08C2EFD2-2812-456E-9D27-606AE88B3C1B}" EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "nanoFramework.M5StackCore", "nanoFramework.M5StackCore\nanoFramework.M5StackCore.shproj", "{11C92E50-70F6-473B-91F8-488AC7E4C39D}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared projects", "Shared projects", "{FFF3F871-7600-480E-B378-95AD0F9FC0F1}" EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "nanoFramework.M5StackCore", "nanoFramework.M5StackCore\nanoFramework.M5StackCore.shproj", "{E2A94F3C-EE7F-4075-A98A-A19CABE82C0F}" +EndProject +Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "M5Core2TestApp", "Tests\M5Core2TestApp\M5Core2TestApp.nfproj", "{20266750-53F3-46D5-8626-1438AC985033}" +EndProject +Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "nanoFramework.AtomLite", "nanoFramework.AtomLite\nanoFramework.AtomLite.nfproj", "{C20734A9-C944-4B2A-9CEA-A9B3F855B132}" +EndProject +Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "AtomLiteTestApp", "Tests\AtomLiteTestApp\AtomLiteTestApp.nfproj", "{7533C164-9D3E-461B-BEED-888C91AC640B}" +EndProject +Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "nanoFramework.AtomMatrix", "nanoFramework.AtomMatrix\nanoFramework.AtomMatrix.nfproj", "{C47BE27B-028D-493A-85DD-7D5C24EE6EB7}" +EndProject +Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "AtomMatrixTestApp", "Tests\AtomMatrixTestApp\AtomMatrixTestApp.nfproj", "{88F1D73A-1ADF-4444-A031-024E570945CC}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "AtomCommon", "AtomCommon\AtomCommon.shproj", "{79F09006-AB5D-4E3E-AD12-2EFBEE536CA9}" +EndProject +Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "FireTestApp", "Tests\FireTestApp\FireTestApp.nfproj", "{5FF00F7C-8ED8-4468-9959-497CE8C5B1AF}" +EndProject +Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "nanoFramework.Fire", "nanoFramework.Fire\nanoFramework.Fire.nfproj", "{2550D7FC-BBA7-4173-9071-8606DD600A2C}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution M5StackCommon\M5StackCommon.projitems*{00e23322-2401-4087-abae-24f90c8a0422}*SharedItemsImports = 13 - nanoFramework.M5StackCore\nanoFramework.M5StackCore.projitems*{11c92e50-70f6-473b-91f8-488ac7e4c39d}*SharedItemsImports = 13 nanoFramework.M5StickCommon\nanoFramework.M5StickCommon.projitems*{1f49b255-573d-4d02-87da-08c4a95744b0}*SharedItemsImports = 13 + AtomCommon\AtomCommon.projitems*{79f09006-ab5d-4e3e-ad12-2efbee536ca9}*SharedItemsImports = 13 + nanoFramework.M5StackCore\nanoFramework.M5StackCore.projitems*{e2a94f3c-ee7f-4075-a98a-a19cabe82c0f}*SharedItemsImports = 13 EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -81,6 +100,48 @@ Global {08C2EFD2-2812-456E-9D27-606AE88B3C1B}.Release|Any CPU.ActiveCfg = Release|Any CPU {08C2EFD2-2812-456E-9D27-606AE88B3C1B}.Release|Any CPU.Build.0 = Release|Any CPU {08C2EFD2-2812-456E-9D27-606AE88B3C1B}.Release|Any CPU.Deploy.0 = Release|Any CPU + {20266750-53F3-46D5-8626-1438AC985033}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {20266750-53F3-46D5-8626-1438AC985033}.Debug|Any CPU.Build.0 = Debug|Any CPU + {20266750-53F3-46D5-8626-1438AC985033}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {20266750-53F3-46D5-8626-1438AC985033}.Release|Any CPU.ActiveCfg = Release|Any CPU + {20266750-53F3-46D5-8626-1438AC985033}.Release|Any CPU.Build.0 = Release|Any CPU + {20266750-53F3-46D5-8626-1438AC985033}.Release|Any CPU.Deploy.0 = Release|Any CPU + {C20734A9-C944-4B2A-9CEA-A9B3F855B132}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C20734A9-C944-4B2A-9CEA-A9B3F855B132}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C20734A9-C944-4B2A-9CEA-A9B3F855B132}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {C20734A9-C944-4B2A-9CEA-A9B3F855B132}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C20734A9-C944-4B2A-9CEA-A9B3F855B132}.Release|Any CPU.Build.0 = Release|Any CPU + {C20734A9-C944-4B2A-9CEA-A9B3F855B132}.Release|Any CPU.Deploy.0 = Release|Any CPU + {7533C164-9D3E-461B-BEED-888C91AC640B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7533C164-9D3E-461B-BEED-888C91AC640B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7533C164-9D3E-461B-BEED-888C91AC640B}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {7533C164-9D3E-461B-BEED-888C91AC640B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7533C164-9D3E-461B-BEED-888C91AC640B}.Release|Any CPU.Build.0 = Release|Any CPU + {7533C164-9D3E-461B-BEED-888C91AC640B}.Release|Any CPU.Deploy.0 = Release|Any CPU + {C47BE27B-028D-493A-85DD-7D5C24EE6EB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C47BE27B-028D-493A-85DD-7D5C24EE6EB7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C47BE27B-028D-493A-85DD-7D5C24EE6EB7}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {C47BE27B-028D-493A-85DD-7D5C24EE6EB7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C47BE27B-028D-493A-85DD-7D5C24EE6EB7}.Release|Any CPU.Build.0 = Release|Any CPU + {C47BE27B-028D-493A-85DD-7D5C24EE6EB7}.Release|Any CPU.Deploy.0 = Release|Any CPU + {88F1D73A-1ADF-4444-A031-024E570945CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {88F1D73A-1ADF-4444-A031-024E570945CC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {88F1D73A-1ADF-4444-A031-024E570945CC}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {88F1D73A-1ADF-4444-A031-024E570945CC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {88F1D73A-1ADF-4444-A031-024E570945CC}.Release|Any CPU.Build.0 = Release|Any CPU + {88F1D73A-1ADF-4444-A031-024E570945CC}.Release|Any CPU.Deploy.0 = Release|Any CPU + {5FF00F7C-8ED8-4468-9959-497CE8C5B1AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5FF00F7C-8ED8-4468-9959-497CE8C5B1AF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5FF00F7C-8ED8-4468-9959-497CE8C5B1AF}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {5FF00F7C-8ED8-4468-9959-497CE8C5B1AF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5FF00F7C-8ED8-4468-9959-497CE8C5B1AF}.Release|Any CPU.Build.0 = Release|Any CPU + {5FF00F7C-8ED8-4468-9959-497CE8C5B1AF}.Release|Any CPU.Deploy.0 = Release|Any CPU + {2550D7FC-BBA7-4173-9071-8606DD600A2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2550D7FC-BBA7-4173-9071-8606DD600A2C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2550D7FC-BBA7-4173-9071-8606DD600A2C}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {2550D7FC-BBA7-4173-9071-8606DD600A2C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2550D7FC-BBA7-4173-9071-8606DD600A2C}.Release|Any CPU.Build.0 = Release|Any CPU + {2550D7FC-BBA7-4173-9071-8606DD600A2C}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -90,7 +151,12 @@ Global {00E23322-2401-4087-ABAE-24F90C8A0422} = {FFF3F871-7600-480E-B378-95AD0F9FC0F1} {1F49B255-573D-4D02-87DA-08C4A95744B0} = {FFF3F871-7600-480E-B378-95AD0F9FC0F1} {48E3FD52-1D13-422D-AF3F-B6AEA2C72800} = {5972CDE6-43B4-42F0-9276-6B70B7EF6437} - {11C92E50-70F6-473B-91F8-488AC7E4C39D} = {FFF3F871-7600-480E-B378-95AD0F9FC0F1} + {E2A94F3C-EE7F-4075-A98A-A19CABE82C0F} = {FFF3F871-7600-480E-B378-95AD0F9FC0F1} + {20266750-53F3-46D5-8626-1438AC985033} = {5972CDE6-43B4-42F0-9276-6B70B7EF6437} + {7533C164-9D3E-461B-BEED-888C91AC640B} = {5972CDE6-43B4-42F0-9276-6B70B7EF6437} + {88F1D73A-1ADF-4444-A031-024E570945CC} = {5972CDE6-43B4-42F0-9276-6B70B7EF6437} + {79F09006-AB5D-4E3E-AD12-2EFBEE536CA9} = {FFF3F871-7600-480E-B378-95AD0F9FC0F1} + {5FF00F7C-8ED8-4468-9959-497CE8C5B1AF} = {5972CDE6-43B4-42F0-9276-6B70B7EF6437} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DD82D7FF-B798-48A4-8506-2FBA0001D32F} diff --git a/nanoFramework.M5Stack/packages.config b/nanoFramework.M5Stack/packages.config deleted file mode 100644 index 6812470c..00000000 --- a/nanoFramework.M5Stack/packages.config +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/nanoFramework.M5StackCore/M5StackBase.cs b/nanoFramework.M5StackCore/M5CoreBase.cs similarity index 90% rename from nanoFramework.M5StackCore/M5StackBase.cs rename to nanoFramework.M5StackCore/M5CoreBase.cs index 57fa2093..fcdb5dce 100644 --- a/nanoFramework.M5StackCore/M5StackBase.cs +++ b/nanoFramework.M5StackCore/M5CoreBase.cs @@ -1,27 +1,32 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using Iot.Device.Magnetometer; +using Iot.Device.Mpu6886; using System.Device.Adc; using System.Device.Dac; using System.Device.Gpio; using System.Device.I2c; using System.Device.Spi; using System.IO.Ports; -using Iot.Device.Magnetometer; -using Iot.Device.Mpu6886; namespace nanoFramework.M5Stack { -#if M5CORE +#if M5CORE2 /// /// M5Core2 board /// public static partial class M5Core2 +#elif FIRE + /// + /// Fire board + /// + public static partial class Fire #else /// /// M5Stack board /// - public static partial class M5Stack + public static partial class M5Core #endif { private static Bmm150 _bmm150; @@ -29,13 +34,10 @@ public static partial class M5Stack private static GpioController _gpio; private static DacChannel _dac1; private static DacChannel _dac2; -#if M5CORE - private static nanoFramework.M5Core2.Screen _screen; -#else - private static nanoFramework.M5Stack.Screen _screen; -#endif + private static Screen _screen; private static SerialPort _serialPort; private static AdcController _adc; + private static int _portANumber; /// /// Gets the Magnetometer. @@ -64,7 +66,7 @@ public static Mpu6886AccelerometerGyroscope AccelerometerGyroscope // We do this to avoid having to load the Accelerometer if not needed or not connected if (_mpu6886 == null) { - _mpu6886 = new(GetI2cDevice(0x68)); + _mpu6886 = new(new(new I2cConnectionSettings(1, 0x68))); } return _mpu6886; @@ -117,14 +119,14 @@ public static DacChannel Dac2 /// /// The I2C device address on the bus. /// The I2cDevice. - public static I2cDevice GetI2cDevice(int i2cDeviceAddress) => new(new I2cConnectionSettings(1, i2cDeviceAddress)); + public static I2cDevice GetI2cDevice(int i2cDeviceAddress) => new(new I2cConnectionSettings(_portANumber, i2cDeviceAddress)); /// /// Gets an I2C device. /// /// The I2C device address on the bus. /// The I2cDevice. - public static I2cDevice GetGrove(int i2cDeviceAddress) => new(new I2cConnectionSettings(1, i2cDeviceAddress)); + public static I2cDevice GetGrove(int i2cDeviceAddress) => new(new I2cConnectionSettings(_portANumber, i2cDeviceAddress)); /// /// Gets an SPI Device. diff --git a/nanoFramework.M5StackCore/nanoFramework.M5StackCore.projitems b/nanoFramework.M5StackCore/nanoFramework.M5StackCore.projitems index 473608c8..ea096b96 100644 --- a/nanoFramework.M5StackCore/nanoFramework.M5StackCore.projitems +++ b/nanoFramework.M5StackCore/nanoFramework.M5StackCore.projitems @@ -9,6 +9,6 @@ nanoFramework.M5StackCore - + \ No newline at end of file diff --git a/nanoFramework.M5StackCore/nanoFramework.M5StackCore.shproj b/nanoFramework.M5StackCore/nanoFramework.M5StackCore.shproj index 52733168..a496ce4b 100644 --- a/nanoFramework.M5StackCore/nanoFramework.M5StackCore.shproj +++ b/nanoFramework.M5StackCore/nanoFramework.M5StackCore.shproj @@ -1,7 +1,7 @@ - 11c92e50-70f6-473b-91f8-488ac7e4c39d + {E2A94F3C-EE7F-4075-A98A-A19CABE82C0F} 14.0 @@ -10,4 +10,4 @@ - + \ No newline at end of file diff --git a/nanoFramework.M5StickC.nuspec b/nanoFramework.M5StickC.nuspec index 51f3cf5b..fe1b08c9 100644 --- a/nanoFramework.M5StickC.nuspec +++ b/nanoFramework.M5StickC.nuspec @@ -1,11 +1,10 @@ - + nanoFramework.M5StickC $version$ nanoFramework.M5StickC - nanoFramework project contributors - nanoFramework,dotnetfoundation + nanoframework false LICENSE.md @@ -17,32 +16,21 @@ Copyright (c) .NET Foundation and Contributors This package includes the nanoFramework.M5StickC assembly for .NET nanoFramework C# projects. - nanoFramework C# csharp netmf netnf nanoFramework.M5StickC + nanoFramework C# csharp netmf netnf m5stack M5StickC - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/nanoFramework.M5StickC/M5StickC.cs b/nanoFramework.M5StickC/M5StickC.cs index 47a3b23f..8e490ecd 100644 --- a/nanoFramework.M5StickC/M5StickC.cs +++ b/nanoFramework.M5StickC/M5StickC.cs @@ -1,9 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; - -namespace nanoFramework.M5Stick +namespace nanoFramework.M5Stack { public static partial class M5StickC { diff --git a/nanoFramework.M5StickC/nanoFramework.M5StickC.nfproj b/nanoFramework.M5StickC/nanoFramework.M5StickC.nfproj index 6a3a21d7..119bf603 100644 --- a/nanoFramework.M5StickC/nanoFramework.M5StickC.nfproj +++ b/nanoFramework.M5StickC/nanoFramework.M5StickC.nfproj @@ -29,100 +29,100 @@ - - ..\packages\nanoFramework.Iot.Device.Axp192.1.0.259\lib\Iot.Device.Axp192.dll + + ..\packages\nanoFramework.Iot.Device.Axp192.1.0.288-preview.103\lib\Iot.Device.Axp192.dll True - - ..\packages\nanoFramework.Iot.Device.Button.1.0.259\lib\Iot.Device.Button.dll + + ..\packages\nanoFramework.Iot.Device.Button.1.0.288-preview.99\lib\Iot.Device.Button.dll True - - ..\packages\nanoFramework.Iot.Device.Common.NumberHelper.1.0.259\lib\Iot.Device.Common.NumberHelper.dll + + ..\packages\nanoFramework.Iot.Device.Common.NumberHelper.1.0.288-preview.99\lib\Iot.Device.Common.NumberHelper.dll True - - ..\packages\nanoFramework.Iot.Device.Mpu6886.1.0.260\lib\Iot.Device.Mpu6886.dll + + ..\packages\nanoFramework.Iot.Device.Mpu6886.1.0.288-preview.106\lib\Iot.Device.Mpu6886.dll True - - ..\packages\nanoFramework.Iot.Device.Rtc.1.0.260\lib\Iot.Device.Rtc.dll + + ..\packages\nanoFramework.Iot.Device.Rtc.1.0.288-preview.103\lib\Iot.Device.Rtc.dll True - - ..\packages\nanoFramework.CoreLibrary.1.11.7\lib\mscorlib.dll + + ..\packages\nanoFramework.CoreLibrary.1.12.0-preview.19\lib\mscorlib.dll True - - ..\packages\nanoFramework.Graphics.1.0.1\lib\nanoFramework.Graphics.dll + + ..\packages\nanoFramework.Graphics.1.0.2-preview.18\lib\nanoFramework.Graphics.dll True - - ..\packages\nanoFramework.Hardware.Esp32.1.3.4\lib\nanoFramework.Hardware.Esp32.dll + + ..\packages\nanoFramework.Hardware.Esp32.1.3.5-preview.10\lib\nanoFramework.Hardware.Esp32.dll True - - ..\packages\nanoFramework.Hardware.Esp32.Rmt.1.2.1\lib\nanoFramework.Hardware.Esp32.Rmt.dll + + ..\packages\nanoFramework.Hardware.Esp32.Rmt.1.2.2-preview.10\lib\nanoFramework.Hardware.Esp32.Rmt.dll True - - ..\packages\nanoFramework.ResourceManager.1.1.3\lib\nanoFramework.ResourceManager.dll + + ..\packages\nanoFramework.ResourceManager.1.1.4-preview.13\lib\nanoFramework.ResourceManager.dll True - - ..\packages\nanoFramework.Runtime.Events.1.9.2\lib\nanoFramework.Runtime.Events.dll + + ..\packages\nanoFramework.Runtime.Events.1.10.0-preview.13\lib\nanoFramework.Runtime.Events.dll True - - ..\packages\nanoFramework.Runtime.Native.1.5.2\lib\nanoFramework.Runtime.Native.dll + + ..\packages\nanoFramework.Runtime.Native.1.5.4-preview.10\lib\nanoFramework.Runtime.Native.dll True - - ..\packages\nanoFramework.System.Collections.1.3.0\lib\nanoFramework.System.Collections.dll + + ..\packages\nanoFramework.System.Collections.1.4.0-preview.27\lib\nanoFramework.System.Collections.dll True - - ..\packages\nanoFramework.System.Buffers.Binary.BinaryPrimitives.1.0.259\lib\System.Buffers.Binary.BinaryPrimitives.dll + + ..\packages\nanoFramework.System.Buffers.Binary.BinaryPrimitives.1.0.288-preview.103\lib\System.Buffers.Binary.BinaryPrimitives.dll True - - ..\packages\nanoFramework.System.Device.Gpio.1.0.2\lib\System.Device.Gpio.dll + + ..\packages\nanoFramework.System.Device.Gpio.1.0.3-preview.18\lib\System.Device.Gpio.dll True - - ..\packages\nanoFramework.System.Device.I2c.1.0.2\lib\System.Device.I2c.dll + + ..\packages\nanoFramework.System.Device.I2c.1.0.3-preview.13\lib\System.Device.I2c.dll True - - ..\packages\nanoFramework.System.Device.Model.1.0.259\lib\System.Device.Model.dll + + ..\packages\nanoFramework.System.Device.Model.1.0.288-preview.99\lib\System.Device.Model.dll True - - ..\packages\nanoFramework.System.Diagnostics.Stopwatch.1.0.259\lib\System.Diagnostics.Stopwatch.dll + + ..\packages\nanoFramework.System.Diagnostics.Stopwatch.1.0.289-preview.60\lib\System.Diagnostics.Stopwatch.dll True - - ..\packages\nanoFramework.System.Math.1.4.3\lib\System.Math.dll + + ..\packages\nanoFramework.System.Math.1.4.4-preview.22\lib\System.Math.dll True - - ..\packages\nanoFramework.System.Numerics.1.0.259\lib\System.Numerics.dll + + ..\packages\nanoFramework.System.Numerics.1.0.289-preview.1\lib\System.Numerics.dll True - - ..\packages\UnitsNet.nanoFramework.ElectricCurrent.4.110.0\lib\UnitsNet.ElectricCurrent.dll + + ..\packages\UnitsNet.nanoFramework.ElectricCurrent.4.126.0\lib\UnitsNet.ElectricCurrent.dll True - - ..\packages\UnitsNet.nanoFramework.ElectricPotential.4.110.0\lib\UnitsNet.ElectricPotential.dll + + ..\packages\UnitsNet.nanoFramework.ElectricPotential.4.126.0\lib\UnitsNet.ElectricPotential.dll True - - ..\packages\UnitsNet.nanoFramework.Power.4.110.0\lib\UnitsNet.Power.dll + + ..\packages\UnitsNet.nanoFramework.Power.4.126.0\lib\UnitsNet.Power.dll True - - ..\packages\UnitsNet.nanoFramework.Temperature.4.110.0\lib\UnitsNet.Temperature.dll + + ..\packages\UnitsNet.nanoFramework.Temperature.4.126.0\lib\UnitsNet.Temperature.dll True diff --git a/nanoFramework.M5StickC/packages.config b/nanoFramework.M5StickC/packages.config index b51a9e94..4d98f150 100644 --- a/nanoFramework.M5StickC/packages.config +++ b/nanoFramework.M5StickC/packages.config @@ -1,28 +1,28 @@  - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - + + + + \ No newline at end of file diff --git a/nanoFramework.M5StickCPlus.nuspec b/nanoFramework.M5StickCPlus.nuspec index 40a55a0b..fe2fd41c 100644 --- a/nanoFramework.M5StickCPlus.nuspec +++ b/nanoFramework.M5StickCPlus.nuspec @@ -1,11 +1,10 @@ - + nanoFramework.M5StickCPlus $version$ nanoFramework.M5StickCPlus - nanoFramework project contributors - nanoFramework,dotnetfoundation + nanoframework false LICENSE.md @@ -17,34 +16,24 @@ Copyright (c) .NET Foundation and Contributors This package includes the nanoFramework.M5StickCPlus assembly for .NET nanoFramework C# projects. - nanoFramework C# csharp netmf netnf nanoFramework.M5StickCPlus + nanoFramework C# csharp netmf netnf m5stack M5StickCPlus - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/nanoFramework.M5StickCPlus/M5StickCPlus.cs b/nanoFramework.M5StickCPlus/M5StickCPlus.cs index b803fd08..e2e3b82e 100644 --- a/nanoFramework.M5StickCPlus/M5StickCPlus.cs +++ b/nanoFramework.M5StickCPlus/M5StickCPlus.cs @@ -3,9 +3,8 @@ using Iot.Device.Buzzer; using nanoFramework.Hardware.Esp32; -using System; -namespace nanoFramework.M5Stick +namespace nanoFramework.M5Stack { public static partial class M5StickCPlus { diff --git a/nanoFramework.M5StickCPlus/nanoFramework.M5StickCPlus.nfproj b/nanoFramework.M5StickCPlus/nanoFramework.M5StickCPlus.nfproj index 4f1c6d4b..f35b06be 100644 --- a/nanoFramework.M5StickCPlus/nanoFramework.M5StickCPlus.nfproj +++ b/nanoFramework.M5StickCPlus/nanoFramework.M5StickCPlus.nfproj @@ -28,112 +28,112 @@ - - ..\packages\nanoFramework.Iot.Device.Axp192.1.0.259\lib\Iot.Device.Axp192.dll + + ..\packages\nanoFramework.Iot.Device.Axp192.1.0.288-preview.103\lib\Iot.Device.Axp192.dll True - - ..\packages\nanoFramework.Iot.Device.Button.1.0.259\lib\Iot.Device.Button.dll + + ..\packages\nanoFramework.Iot.Device.Button.1.0.288-preview.99\lib\Iot.Device.Button.dll True - - ..\packages\nanoFramework.Iot.Device.Buzzer.1.0.260\lib\Iot.Device.Buzzer.dll + + ..\packages\nanoFramework.Iot.Device.Buzzer.1.0.288-preview.103\lib\Iot.Device.Buzzer.dll True - - ..\packages\nanoFramework.Iot.Device.Common.NumberHelper.1.0.259\lib\Iot.Device.Common.NumberHelper.dll + + ..\packages\nanoFramework.Iot.Device.Common.NumberHelper.1.0.288-preview.99\lib\Iot.Device.Common.NumberHelper.dll True - - ..\packages\nanoFramework.Iot.Device.Mpu6886.1.0.260\lib\Iot.Device.Mpu6886.dll + + ..\packages\nanoFramework.Iot.Device.Mpu6886.1.0.288-preview.106\lib\Iot.Device.Mpu6886.dll True - - ..\packages\nanoFramework.Iot.Device.Rtc.1.0.260\lib\Iot.Device.Rtc.dll + + ..\packages\nanoFramework.Iot.Device.Rtc.1.0.288-preview.103\lib\Iot.Device.Rtc.dll True - - ..\packages\nanoFramework.CoreLibrary.1.11.7\lib\mscorlib.dll + + ..\packages\nanoFramework.CoreLibrary.1.12.0-preview.19\lib\mscorlib.dll True - - ..\packages\nanoFramework.Graphics.1.0.1\lib\nanoFramework.Graphics.dll + + ..\packages\nanoFramework.Graphics.1.0.2-preview.18\lib\nanoFramework.Graphics.dll True - - ..\packages\nanoFramework.Hardware.Esp32.1.3.4\lib\nanoFramework.Hardware.Esp32.dll + + ..\packages\nanoFramework.Hardware.Esp32.1.3.5-preview.10\lib\nanoFramework.Hardware.Esp32.dll True - - ..\packages\nanoFramework.Hardware.Esp32.Rmt.1.2.1\lib\nanoFramework.Hardware.Esp32.Rmt.dll + + ..\packages\nanoFramework.Hardware.Esp32.Rmt.1.2.2-preview.10\lib\nanoFramework.Hardware.Esp32.Rmt.dll True - - ..\packages\nanoFramework.ResourceManager.1.1.3\lib\nanoFramework.ResourceManager.dll + + ..\packages\nanoFramework.ResourceManager.1.1.4-preview.13\lib\nanoFramework.ResourceManager.dll True - - ..\packages\nanoFramework.Runtime.Events.1.9.2\lib\nanoFramework.Runtime.Events.dll + + ..\packages\nanoFramework.Runtime.Events.1.10.0-preview.13\lib\nanoFramework.Runtime.Events.dll True - - ..\packages\nanoFramework.Runtime.Native.1.5.2\lib\nanoFramework.Runtime.Native.dll + + ..\packages\nanoFramework.Runtime.Native.1.5.4-preview.10\lib\nanoFramework.Runtime.Native.dll True - - ..\packages\nanoFramework.System.Collections.1.3.0\lib\nanoFramework.System.Collections.dll + + ..\packages\nanoFramework.System.Collections.1.4.0-preview.27\lib\nanoFramework.System.Collections.dll True - - ..\packages\nanoFramework.System.Buffers.Binary.BinaryPrimitives.1.0.259\lib\System.Buffers.Binary.BinaryPrimitives.dll + + ..\packages\nanoFramework.System.Buffers.Binary.BinaryPrimitives.1.0.288-preview.103\lib\System.Buffers.Binary.BinaryPrimitives.dll True - - ..\packages\nanoFramework.System.Device.Gpio.1.0.2\lib\System.Device.Gpio.dll + + ..\packages\nanoFramework.System.Device.Gpio.1.0.3-preview.18\lib\System.Device.Gpio.dll True - - ..\packages\nanoFramework.System.Device.I2c.1.0.2\lib\System.Device.I2c.dll + + ..\packages\nanoFramework.System.Device.I2c.1.0.3-preview.13\lib\System.Device.I2c.dll True - - ..\packages\nanoFramework.System.Device.Model.1.0.259\lib\System.Device.Model.dll + + ..\packages\nanoFramework.System.Device.Model.1.0.288-preview.99\lib\System.Device.Model.dll True - - ..\packages\nanoFramework.System.Device.Pwm.1.0.0\lib\System.Device.Pwm.dll + + ..\packages\nanoFramework.System.Device.Pwm.1.0.1-preview.13\lib\System.Device.Pwm.dll True - - ..\packages\nanoFramework.System.Diagnostics.Stopwatch.1.0.259\lib\System.Diagnostics.Stopwatch.dll + + ..\packages\nanoFramework.System.Diagnostics.Stopwatch.1.0.289-preview.60\lib\System.Diagnostics.Stopwatch.dll True - - ..\packages\nanoFramework.System.Math.1.4.3\lib\System.Math.dll + + ..\packages\nanoFramework.System.Math.1.4.4-preview.22\lib\System.Math.dll True - - ..\packages\nanoFramework.System.Numerics.1.0.259\lib\System.Numerics.dll + + ..\packages\nanoFramework.System.Numerics.1.0.289-preview.1\lib\System.Numerics.dll True - - ..\packages\UnitsNet.nanoFramework.ElectricCurrent.4.110.0\lib\UnitsNet.ElectricCurrent.dll + + ..\packages\UnitsNet.nanoFramework.ElectricCurrent.4.126.0\lib\UnitsNet.ElectricCurrent.dll True - - ..\packages\UnitsNet.nanoFramework.ElectricPotential.4.110.0\lib\UnitsNet.ElectricPotential.dll + + ..\packages\UnitsNet.nanoFramework.ElectricPotential.4.126.0\lib\UnitsNet.ElectricPotential.dll True - - ..\packages\UnitsNet.nanoFramework.Frequency.4.110.0\lib\UnitsNet.Frequency.dll + + ..\packages\UnitsNet.nanoFramework.Frequency.4.126.0\lib\UnitsNet.Frequency.dll True - - ..\packages\UnitsNet.nanoFramework.Power.4.110.0\lib\UnitsNet.Power.dll + + ..\packages\UnitsNet.nanoFramework.Power.4.126.0\lib\UnitsNet.Power.dll True - - ..\packages\UnitsNet.nanoFramework.Temperature.4.110.0\lib\UnitsNet.Temperature.dll + + ..\packages\UnitsNet.nanoFramework.Temperature.4.126.0\lib\UnitsNet.Temperature.dll True diff --git a/nanoFramework.M5StickCPlus/packages.config b/nanoFramework.M5StickCPlus/packages.config index 896effc6..5a6ec355 100644 --- a/nanoFramework.M5StickCPlus/packages.config +++ b/nanoFramework.M5StickCPlus/packages.config @@ -1,31 +1,31 @@  - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + \ No newline at end of file diff --git a/nanoFramework.M5StickCommon/M5StickCBase.cs b/nanoFramework.M5StickCommon/M5StickCBase.cs index eb1e0156..0de77c7e 100644 --- a/nanoFramework.M5StickCommon/M5StickCBase.cs +++ b/nanoFramework.M5StickCommon/M5StickCBase.cs @@ -17,7 +17,7 @@ #else using nanoFramework.M5StickCPlus; #endif -namespace nanoFramework.M5Stick +namespace nanoFramework.M5Stack { /// /// The base class for both M5STickC and M5StickCPlus diff --git a/nanoFramework.M5StickCommon/Screen.cs b/nanoFramework.M5StickCommon/Screen.cs index 1ba22a2e..37b7e039 100644 --- a/nanoFramework.M5StickCommon/Screen.cs +++ b/nanoFramework.M5StickCommon/Screen.cs @@ -4,11 +4,9 @@ using Iot.Device.Axp192; using nanoFramework.M5Stack; using nanoFramework.UI; -using System; -using System.Device.Gpio; using UnitsNet; -namespace nanoFramework.M5Stick +namespace nanoFramework.M5Stack { /// /// M5 Stack screen class diff --git a/version.json b/version.json index 9d90e37b..62f8dd88 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.0.0", + "version": "1.0.1-preview.{height}", "assemblyVersion": { "precision": "revision" },