Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
| 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/) |
Expand All @@ -31,6 +33,7 @@ These NuGet packages provide a support for M5Stack products:
- [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)

Expand Down Expand Up @@ -58,7 +61,7 @@ For the M5StickCPlus:
nanoff --target M5StickCPlus --update --preview --serialport COM3
```

For the M5Core2:
For the M5Core2 and Fire:

```shell
nanoff --target M5Core2 --update --preview --serialport COM3
Expand Down Expand Up @@ -137,13 +140,13 @@ 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) =>
Expand Down Expand Up @@ -272,7 +275,7 @@ The `TouchEventCategory` enum is a flag and can combine buttons and states. The

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 M5Core.
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

Expand Down Expand Up @@ -322,7 +325,7 @@ Refer to the [SerialPort documentation](https://github.com/nanoframework/System.

### ADC Channels

ADC Channels are pre setup on the M5Core, M5Core2 and Atom Lite/Matrix, 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 of M5Core
Expand All @@ -343,7 +346,7 @@ I2cDevice myDevice = M5Core.GetGrove(0x42);

### SPI Device

The M5Core, M5Core2 and Atom Lite/Matrix 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:
Expand All @@ -352,7 +355,7 @@ SpiDevice mySpi = M5Core.GetSpiDevice(5);

### GPIO Controller

Similar as previously, you can get the `GpioController` on any of the M5Core, 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
Expand All @@ -361,7 +364,7 @@ var pin5 = M5StickC.GpioController.OpenPin(36, PinMode.Output);

### DAC

The M5Core, M5Core2 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.
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

Expand Down
110 changes: 110 additions & 0 deletions Tests/FireTestApp/FireTestApp.nfproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<NanoFrameworkProjectSystemPath>$(MSBuildExtensionsPath)\nanoFramework\v1.0\</NanoFrameworkProjectSystemPath>
</PropertyGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectTypeGuids>{11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectGuid>5ff00f7c-8ed8-4468-9959-497ce8c5b1af</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<FileAlignment>512</FileAlignment>
<RootNamespace>FiteTestApp</RootNamespace>
<AssemblyName>FiteTestApp</AssemblyName>
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
</PropertyGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\nanoFramework.Fire\nanoFramework.Fire.nfproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Iot.Device.Bmm150">
<HintPath>..\..\packages\nanoFramework.Iot.Device.Bmm150.1.0.288-preview.86\lib\Iot.Device.Bmm150.dll</HintPath>
</Reference>
<Reference Include="Iot.Device.Button">
<HintPath>..\..\packages\nanoFramework.Iot.Device.Button.1.0.288-preview.86\lib\Iot.Device.Button.dll</HintPath>
</Reference>
<Reference Include="Iot.Device.Buzzer">
<HintPath>..\..\packages\nanoFramework.Iot.Device.Buzzer.1.0.288-preview.86\lib\Iot.Device.Buzzer.dll</HintPath>
</Reference>
<Reference Include="Iot.Device.Ip5306">
<HintPath>..\..\packages\nanoFramework.Iot.Device.Ip5306.1.0.288-preview.86\lib\Iot.Device.Ip5306.dll</HintPath>
</Reference>
<Reference Include="Iot.Device.Mpu6886">
<HintPath>..\..\packages\nanoFramework.Iot.Device.Mpu6886.1.0.288-preview.86\lib\Iot.Device.Mpu6886.dll</HintPath>
</Reference>
<Reference Include="mscorlib">
<HintPath>..\..\packages\nanoFramework.CoreLibrary.1.12.0-preview.9\lib\mscorlib.dll</HintPath>
</Reference>
<Reference Include="nanoFramework.Graphics">
<HintPath>..\..\packages\nanoFramework.Graphics.1.0.2-preview.15\lib\nanoFramework.Graphics.dll</HintPath>
</Reference>
<Reference Include="nanoFramework.ResourceManager">
<HintPath>..\..\packages\nanoFramework.ResourceManager.1.1.4-preview.8\lib\nanoFramework.ResourceManager.dll</HintPath>
</Reference>
<Reference Include="nanoFramework.Runtime.Events">
<HintPath>..\..\packages\nanoFramework.Runtime.Events.1.10.0-preview.8\lib\nanoFramework.Runtime.Events.dll</HintPath>
</Reference>
<Reference Include="nanoFramework.Runtime.Native">
<HintPath>..\..\packages\nanoFramework.Runtime.Native.1.5.4-preview.5\lib\nanoFramework.Runtime.Native.dll</HintPath>
</Reference>
<Reference Include="nanoFramework.System.Collections">
<HintPath>..\..\packages\nanoFramework.System.Collections.1.4.0-preview.21\lib\nanoFramework.System.Collections.dll</HintPath>
</Reference>
<Reference Include="System.Buffers.Binary.BinaryPrimitives">
<HintPath>..\..\packages\nanoFramework.System.Buffers.Binary.BinaryPrimitives.1.0.288-preview.64\lib\System.Buffers.Binary.BinaryPrimitives.dll</HintPath>
</Reference>
<Reference Include="System.Device.Adc">
<HintPath>..\..\packages\nanoFramework.System.Device.Adc.1.0.2-preview.8\lib\System.Device.Adc.dll</HintPath>
</Reference>
<Reference Include="System.Device.Dac">
<HintPath>..\..\packages\nanoFramework.System.Device.Dac.1.4.3-preview.8\lib\System.Device.Dac.dll</HintPath>
</Reference>
<Reference Include="System.Device.Gpio">
<HintPath>..\..\packages\nanoFramework.System.Device.Gpio.1.0.3-preview.14\lib\System.Device.Gpio.dll</HintPath>
</Reference>
<Reference Include="System.Device.I2c">
<HintPath>..\..\packages\nanoFramework.System.Device.I2c.1.0.3-preview.8\lib\System.Device.I2c.dll</HintPath>
</Reference>
<Reference Include="System.Device.Model">
<HintPath>..\..\packages\nanoFramework.System.Device.Model.1.0.288-preview.64\lib\System.Device.Model.dll</HintPath>
</Reference>
<Reference Include="System.Device.Pwm">
<HintPath>..\..\packages\nanoFramework.System.Device.Pwm.1.0.1-preview.8\lib\System.Device.Pwm.dll</HintPath>
</Reference>
<Reference Include="System.Device.Spi">
<HintPath>..\..\packages\nanoFramework.System.Device.Spi.1.0.4-preview.3\lib\System.Device.Spi.dll</HintPath>
</Reference>
<Reference Include="System.Math">
<HintPath>..\..\packages\nanoFramework.System.Math.1.4.4-preview.15\lib\System.Math.dll</HintPath>
</Reference>
<Reference Include="System.Numerics">
<HintPath>..\..\packages\nanoFramework.System.Numerics.1.0.288-preview.64\lib\System.Numerics.dll</HintPath>
</Reference>
<Reference Include="UnitsNet.ElectricCurrent">
<HintPath>..\..\packages\UnitsNet.nanoFramework.ElectricCurrent.4.125.0\lib\UnitsNet.ElectricCurrent.dll</HintPath>
</Reference>
<Reference Include="UnitsNet.Frequency">
<HintPath>..\..\packages\UnitsNet.nanoFramework.Frequency.4.125.0\lib\UnitsNet.Frequency.dll</HintPath>
</Reference>
<Reference Include="UnitsNet.Temperature">
<HintPath>..\..\packages\UnitsNet.nanoFramework.Temperature.4.125.0\lib\UnitsNet.Temperature.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
<ProjectExtensions>
<ProjectCapabilities>
<ProjectConfigurationsDeclaredAsItems />
</ProjectCapabilities>
</ProjectExtensions>
</Project>
125 changes: 125 additions & 0 deletions Tests/FireTestApp/Program.cs
Original file line number Diff line number Diff line change
@@ -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);
}
Loading