You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NOTE1: 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.
32
-
NOTE2: 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.
31
+
> 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.
32
+
> 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.
33
33
34
34
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).
35
35
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).
NOTE3: If the `nanoff` commands fails, make sure you have followed instruction from NOTE1 above.
61
+
> Note 3: If the `nanoff` commands fails, make sure you have followed instruction from Note 1 above.
62
62
63
63
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!
64
64
65
-
> 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.
65
+
> 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.
66
66
67
67
In the samples below, we'll use either M5Core or M5Stick as examples, they are all working in a very similar way.
> Note: The M5Core2 has touch screen and the buttons are "virtual"". At the time of this writing the .NET nanoFramework team is implementing and testing the touch-screen (touch-panel) functionality (will be released soon).
161
+
> Note: The M5Core2 has touch screen and the buttons are "virtual"". See next section to see how to use them.
162
+
163
+
### M5Core2 touch panel and buttons
164
+
165
+
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:
166
+
167
+
```csharp
168
+
M5Core2.InitializeScreen();
169
+
M5Core2.TouchEvent+=TouchEventCallback;
170
+
```
171
+
172
+
Here is an example on how to check if you are on a button or not and get the various elements:
if ((e.TouchEventCategory&TouchEventCategory.Moving) ==TouchEventCategory.Moving)
211
+
{
212
+
Debug.WriteLine(StrMove);
213
+
Console.Write(StrMove);
214
+
}
215
+
216
+
if ((e.TouchEventCategory&TouchEventCategory.LiftUp) ==TouchEventCategory.LiftUp)
217
+
{
218
+
Debug.WriteLine(StrLiftUp);
219
+
Console.Write(StrLiftUp);
220
+
}
221
+
222
+
if ((e.TouchEventCategory&TouchEventCategory.DoubleTouch) ==TouchEventCategory.DoubleTouch)
223
+
{
224
+
Debug.WriteLine(StrDoubleTouch);
225
+
Console.Write(StrDoubleTouch);
226
+
}
227
+
228
+
Console.WriteLine("");
229
+
Console.WriteLine("");
230
+
Console.WriteLine("");
231
+
}
232
+
```
233
+
234
+
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.
235
+
236
+
`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.
0 commit comments