Skip to content

Commit 002c2b5

Browse files
authored
Added board support package for Atom Lite (#71)
***NO_CI***
1 parent eeee88b commit 002c2b5

File tree

13 files changed

+659
-7
lines changed

13 files changed

+659
-7
lines changed

README.md

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ These NuGet packages provide a support for M5Stack products:
2727
- [M5StickC](https://docs.m5stack.com/en/core/m5stickc)
2828
- [M5StickCPlus](https://docs.m5stack.com/en/core/m5stickc_plus)
2929
- [M5Core2](https://docs.m5stack.com/en/core/core2)
30+
- [Atom Lite](https://docs.m5stack.com/en/core/atom_lite)
3031

3132
> 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 <https://api.nuget.org/v3/index.json> , otherwise add it.
3233
> 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.
@@ -58,6 +59,12 @@ For the M5Core2:
5859
nanoff --target M5Core2 --update --preview --serialport COM3
5960
```
6061

62+
For the M5AtomLite:
63+
64+
```shell
65+
nanoff --target ESP32_PICO --update --preview --serialport COM3
66+
```
67+
6168
> Note 3: If the `nanoff` commands fails, make sure you have followed instruction from Note 1 above.
6269
6370
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!
@@ -158,6 +165,28 @@ M5StickC.M5Button.Holding += (sender, e) =>
158165
};
159166
```
160167

168+
On the Atom Lite it's called `Button`. You can get access to the status of the button, the events and everything you need. For example:
169+
170+
```csharp
171+
M5AtomLite.Button.Press +=> (sender, e)
172+
{
173+
var color = M5AtomLite.NeoPixel.GetColor();
174+
if(color.R > 0)
175+
{
176+
M5AtomLite.NeoPixel.SetColor(Color.FromArgb(255, 0, 255, 0));
177+
}
178+
else if (color.G > 0)
179+
{
180+
M5AtomLite.NeoPixel.SetColor(Color.FromArgb(255, 0, 0, 255));
181+
}
182+
else
183+
{
184+
M5AtomLite.NeoPixel.SetColor(Color.FromArgb(255, 255, 0, 0));
185+
}
186+
};
187+
```
188+
189+
161190
> Note: The M5Core2 has touch screen and the buttons are "virtual"". See next section to see how to use them.
162191
163192
### M5Core2 touch panel and buttons
@@ -289,10 +318,10 @@ Refer to the [SerialPort documentation](https://github.com/nanoframework/System.
289318

290319
### ADC Channels
291320

292-
ADC Channels are pre setup on the M5Core, access them like this:
321+
ADC Channels are pre setup on the M5Core, M5Core2 and Atom Lite, access them like this:
293322

294323
```csharp
295-
// This will give you the ADC1 channel 7 which is on pin 35
324+
// This will give you the ADC1 channel 7 which is on pin 35 of M5Core
296325
AdcChannel myChannel = M5Core.GetAdcGpio(35);
297326
```
298327

@@ -310,7 +339,7 @@ I2cDevice myDevice = M5Core.GetGrove(0x42);
310339

311340
### SPI Device
312341

313-
The M5Core provides as well an SpiDevice:
342+
The M5Core, M5Core2 and Atom Lite provides as well an `SpiDevice`:
314343

315344
```csharp
316345
// In this case GPIO5 will be used as chip select:
@@ -328,7 +357,7 @@ var pin5 = M5StickC.GpioController.OpenPin(36, PinMode.Output);
328357

329358
### DAC
330359

331-
The M5Core 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.
360+
The M5Core, M5Core2 and Atom Lite 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.
332361

333362
### Led
334363

@@ -341,7 +370,16 @@ M5StickC.Led.Toggle();
341370

342371
### Infrared Led
343372

344-
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.
373+
The M5StickC/CPlus and M5AtomLite 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.
374+
375+
### NeoPixel
376+
377+
The M5AtomLite exposes a rgb led. You can access it thru the `NeoPixel` property:
378+
379+
```csharp
380+
// This will set NeoPixel to green:
381+
M5AtomLite.NeoPixel.SetColor(Color.Green);
382+
```
345383

346384
## Feedback and documentation
347385

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Label="Globals">
4+
<NanoFrameworkProjectSystemPath>$(MSBuildExtensionsPath)\nanoFramework\v1.0\</NanoFrameworkProjectSystemPath>
5+
</PropertyGroup>
6+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props')" />
7+
<PropertyGroup>
8+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
9+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
10+
<ProjectTypeGuids>{11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
11+
<ProjectGuid>7533c164-9d3e-461b-beed-888c91ac640b</ProjectGuid>
12+
<OutputType>Exe</OutputType>
13+
<AppDesignerFolder>Properties</AppDesignerFolder>
14+
<FileAlignment>512</FileAlignment>
15+
<RootNamespace>M5AtomLiteTestApp</RootNamespace>
16+
<AssemblyName>M5AtomLiteTestApp</AssemblyName>
17+
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
18+
</PropertyGroup>
19+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
20+
<ItemGroup>
21+
<Compile Include="Program.cs" />
22+
<Compile Include="Properties\AssemblyInfo.cs" />
23+
</ItemGroup>
24+
<ItemGroup>
25+
<ProjectReference Include="..\..\nanoFramework.M5AtomLite\nanoFramework.M5AtomLite.nfproj" />
26+
</ItemGroup>
27+
<ItemGroup>
28+
<None Include="packages.config" />
29+
</ItemGroup>
30+
<ItemGroup>
31+
<Reference Include="Iot.Device.Button, Version=0.0.0.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
32+
<HintPath>..\..\packages\nanoFramework.Iot.Device.Button.1.0.288-preview.29\lib\Iot.Device.Button.dll</HintPath>
33+
<Private>True</Private>
34+
<SpecificVersion>True</SpecificVersion>
35+
</Reference>
36+
<Reference Include="mscorlib, Version=1.12.0.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
37+
<HintPath>..\..\packages\nanoFramework.CoreLibrary.1.12.0-preview.5\lib\mscorlib.dll</HintPath>
38+
<Private>True</Private>
39+
<SpecificVersion>True</SpecificVersion>
40+
</Reference>
41+
<Reference Include="nanoFramework.Runtime.Events, Version=1.10.0.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
42+
<HintPath>..\..\packages\nanoFramework.Runtime.Events.1.10.0-preview.6\lib\nanoFramework.Runtime.Events.dll</HintPath>
43+
<Private>True</Private>
44+
<SpecificVersion>True</SpecificVersion>
45+
</Reference>
46+
<Reference Include="System.Device.Gpio, Version=1.0.3.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
47+
<HintPath>..\..\packages\nanoFramework.System.Device.Gpio.1.0.3-preview.8\lib\System.Device.Gpio.dll</HintPath>
48+
<Private>True</Private>
49+
<SpecificVersion>True</SpecificVersion>
50+
</Reference>
51+
<Reference Include="System.Drawing">
52+
<HintPath>..\..\packages\nanoFramework.System.Drawing.1.0.288-preview.20\lib\System.Drawing.dll</HintPath>
53+
</Reference>
54+
</ItemGroup>
55+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
56+
<ProjectExtensions>
57+
<ProjectCapabilities>
58+
<ProjectConfigurationsDeclaredAsItems />
59+
</ProjectCapabilities>
60+
</ProjectExtensions>
61+
</Project>

Tests/M5AtomLiteTestApp/Program.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Diagnostics;
6+
using System.Drawing;
7+
using System.Threading;
8+
using nanoFramework.M5AtomLite;
9+
10+
namespace M5AtomLiteTestApp
11+
{
12+
public class Program
13+
{
14+
public static void Main()
15+
{
16+
var button = M5AtomLite.Button;
17+
var rgb = M5AtomLite.NeoPixel;
18+
rgb.SetColor(Color.FromArgb(255, 255, 0, 0));
19+
20+
button.Press += Button_Press;
21+
22+
Debug.WriteLine("Hello from nanoFramework!");
23+
24+
Thread.Sleep(Timeout.Infinite);
25+
}
26+
27+
private static void Button_Press(object sender, EventArgs e)
28+
{
29+
var color = M5AtomLite.NeoPixel.GetColor();
30+
if(color.R > 0)
31+
{
32+
M5AtomLite.NeoPixel.SetColor(Color.FromArgb(255, 0, 255, 0));
33+
}
34+
else if (color.G > 0)
35+
{
36+
M5AtomLite.NeoPixel.SetColor(Color.FromArgb(255, 0, 0, 255));
37+
}
38+
else
39+
{
40+
M5AtomLite.NeoPixel.SetColor(Color.FromArgb(255, 255, 0, 0));
41+
}
42+
}
43+
}
44+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("CSharp.BlankApplication")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("CSharp.BlankApplication")]
13+
[assembly: AssemblyCopyright("Copyright © ")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// Version information for an assembly consists of the following four values:
23+
//
24+
// Major Version
25+
// Minor Version
26+
// Build Number
27+
// Revision
28+
//
29+
// You can specify all the values or you can default the Build and Revision Numbers
30+
// by using the '*' as shown below:
31+
// [assembly: AssemblyVersion("1.0.*")]
32+
[assembly: AssemblyVersion("1.0.0.0")]
33+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="nanoFramework.CoreLibrary" version="1.12.0-preview.5" targetFramework="netnanoframework10" />
4+
<package id="nanoFramework.Iot.Device.Button" version="1.0.288-preview.29" targetFramework="netnanoframework10" />
5+
<package id="nanoFramework.Runtime.Events" version="1.10.0-preview.6" targetFramework="netnanoframework10" />
6+
<package id="nanoFramework.System.Device.Gpio" version="1.0.3-preview.8" targetFramework="netnanoframework10" />
7+
<package id="nanoFramework.System.Drawing" version="1.0.288-preview.20" targetFramework="netnanoframework10" />
8+
</packages>

nanoFramework.M5AtomLite.nuspec

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
3+
<metadata>
4+
<id>nanoFramework.M5AtomLite</id>
5+
<version>$version$</version>
6+
<title>nanoFramework.M5AtomLite</title>
7+
<authors>nanoFramework project contributors</authors>
8+
<owners>nanoFramework,dotnetfoundation</owners>
9+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
10+
<license type="file">LICENSE.md</license>
11+
<releaseNotes>
12+
</releaseNotes>
13+
<readme>docs\README.md</readme>
14+
<developmentDependency>false</developmentDependency>
15+
<projectUrl>https://github.com/nanoframework/nanoFramework.M5Stack</projectUrl>
16+
<icon>images\nf-logo.png</icon>
17+
<repository type="git" url="https://github.com/nanoframework/nanoFramework.M5Stack" commit="$commit$" />
18+
<copyright>Copyright (c) .NET Foundation and Contributors</copyright>
19+
<description>This package includes the nanoFramework.M5AtomLite assembly for .NET nanoFramework C# projects.</description>
20+
<tags>nanoFramework C# csharp netmf netnf nanoFramework.M5AtomLite</tags>
21+
<dependencies>
22+
<dependency id="nanoFramework.CoreLibrary" version="1.12.0-preview.5" />
23+
<dependency id="nanoFramework.Hardware.Esp32" version="1.3.5-preview.6" />
24+
<dependency id="nanoFramework.Hardware.Esp32.Rmt" version="1.2.2-preview.6" />
25+
<dependency id="nanoFramework.Iot.Device.Button" version="1.0.288-preview.29" />
26+
<dependency id="nanoFramework.Runtime.Events" version="1.10.0-preview.6" />
27+
<dependency id="nanoFramework.System.Device.Gpio" version="1.0.3-preview.8" />
28+
<dependency id="nanoFramework.System.Device.Dac" version="1.4.3-preview.6" />
29+
<dependency id="nanoFramework.System.Device.Adc" version="1.0.2-preview.6" />
30+
<dependency id="nanoFramework.System.Device.I2c" version="1.0.3-preview.6" />
31+
<dependency id="nanoFramework.System.Device.Spi" version="1.0.3-preview.17" />
32+
<dependency id="nanoFramework.System.Drawing" version="1.0.288-preview.20" />
33+
</dependencies>
34+
</metadata>
35+
<files>
36+
<file src="nanoFramework.M5AtomLite\bin\Release\nanoFramework.M5AtomLite.dll" target="lib\nanoFramework.M5AtomLite.dll" />
37+
<file src="nanoFramework.M5AtomLite\bin\Release\nanoFramework.M5AtomLite.pdb" target="lib\nanoFramework.M5AtomLite.pdb" />
38+
<file src="nanoFramework.M5AtomLite\bin\Release\nanoFramework.M5AtomLite.pdbx" target="lib\nanoFramework.M5AtomLite.pdbx" />
39+
<file src="nanoFramework.M5AtomLite\bin\Release\nanoFramework.M5AtomLite.pe" target="lib\nanoFramework.M5AtomLite.pe" />
40+
<file src="nanoFramework.M5AtomLite\bin\Release\nanoFramework.M5AtomLite.xml" target="lib\nanoFramework.M5AtomLite.xml" />
41+
<file src="assets\readme.txt" target="" />
42+
<file src="README.md" target="docs\" />
43+
<file src="assets\nf-logo.png" target="images\" />
44+
<file src="LICENSE.md" target="" />
45+
</files>
46+
</package>

0 commit comments

Comments
 (0)