### Install Meadow Project Templates Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/MCUs/Project_Lab/index.md Use the .NET command-line interface to install the official Wilderness Labs Meadow project templates, which provide starting points for different Meadow application types. ```console dotnet new install WildernessLabs.Meadow.Template ``` -------------------------------- ### Control LED with PWM using Meadow.Foundation C# Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow.Foundation/Getting_Started/index.md Initializes a PwmLed driver on pin D13 with a specified forward voltage and starts a pulsing effect. Requires the Meadow.Foundation.Leds library. ```C# using Meadow; using Meadow.Devices; using Meadow.Foundation.Leds; namespace HelloPulsy { // Change F7FeatherV2 to F7FeatherV1 for V1.x boards public class MeadowApp : App { PwmLed pwmLed; public override Task Initialize() { pwmLed = new PwmLed(Device.Pins.D13, TypicalForwardVoltage.Blue); return base.Initialize(); } public override Task Run() { // pulse the LED pwmLed.StartPulse(); return base.Run(); } } } ``` -------------------------------- ### Create New Meadow.Linux Console App (Bash) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Linux/index.md Creates a new .NET console application directory and navigates into it. This serves as the starting point for a Meadow.Linux project. ```bash dotnet new console --output MeadowLinuxSampleApp cd MeadowLinuxSampleApp ``` -------------------------------- ### Navigate to DocFX Directory and Serve Site Source: https://github.com/wildernesslabs/documentation/blob/develop/docfx/README.md Changes the current directory to 'docfx' and then runs the docfx command to build and serve the documentation site locally. The '--serve' flag starts a web server. ```bash cd docfx docfx docfx.json --serve ``` -------------------------------- ### Run Meadow.Blazor Application (Command) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Blazor/index.md Runs the built Meadow.Blazor application using the .NET CLI, starting the Blazor Server and the Meadow application. ```command dotnet run ``` -------------------------------- ### Installing .NET 7 SDK on Raspberry Pi OS (Bash) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Linux/index.md Downloads and executes the .NET install script to install the .NET 7 SDK on a Linux machine, specifically targeting Raspberry Pi OS as an example. Requires `wget` and `sudo`. ```bash wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh sudo chmod +x ./dotnet-install.sh ./dotnet-install.sh --channel 7.0 ``` -------------------------------- ### Build Meadow.Windows Application (Command Line) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Windows/index.md Builds the Meadow.Windows application project using the .NET SDK, compiling the source code and resolving dependencies. ```command dotnet build ``` -------------------------------- ### Basic MeadowApp Structure - Meadow Core-Compute - C# Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Hardware/Reference/Meadow_Hardware/Getting_Started_Core-Compute_Module/index.md This snippet shows the fundamental structure of a Meadow application targeting the F7CoreComputeV2 module. It includes the `Initialize` method for setting up peripherals and the `Run` method for the main application logic. Both methods print a message to the console. ```C# using Meadow; using Meadow.Devices; using Meadow.Foundation.Leds; using System; using System.Threading.Tasks; namespace HelloMeadow { // Change F7FeatherV2 or F7FeatherV1 for Feather boards public class MeadowApp : App { public override Task Run() { Console.WriteLine("Run..."); return base.Run(); } public async override Task Initialize() { Console.WriteLine("Initialize..."); await base.Initialize(); } } } ``` -------------------------------- ### Netduino Deployment and Debug Output Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Netduino/Getting_Started/index.md This snippet shows the expected console output during the deployment process to the Netduino device from the IDE (Xamarin Studio in this case) and the subsequent debug messages printed by the running application's infinite loop. ```text Deploy: Deploying assemblies to device Deploy: Deploying assemblies for a total size of 560 bytes Deploy: Assemblies successfully deployed to device. ... Looping0 Looping1 Looping2 Looping3 ``` -------------------------------- ### Install Meadow.CLI using dotnet tool Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Tools/Meadow_CLI/index.md Installs the Meadow.CLI global tool from NuGet using the .NET SDK command. This command is used for initial setup on Windows, macOS, and Linux. ```console dotnet tool install WildernessLabs.Meadow.CLI --global ``` -------------------------------- ### Run Meadow.Windows Application (Command Line) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Windows/index.md Executes the built Meadow.Windows application on the Windows development machine. ```command dotnet run ``` -------------------------------- ### Netduino Blink LED Application (C#) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Netduino/Getting_Started/index.md This C# code implements a simple application for Netduino using the .NET Micro Framework. It configures an OutputPort for the onboard LED pin, then enters an infinite loop to toggle the LED state with a 250ms delay and print loop progress to the debug output. ```C# using System; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using System.Threading; using SecretLabs.NETMF.Hardware.Netduino; namespace NetduinoBlink { public class Program { public static void Main() { // configure an output port for us to "write" to the LED OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); // note that if we didn't have the SecretLabs.NETMF.Hardware.Netduino DLL, we could also manually access it this way: //OutputPort led = new OutputPort(Cpu.Pin.GPIO_Pin10, false); int i = 0; while (true) { led.Write(true); // turn on the LED Thread.Sleep(250); // sleep for 250ms led.Write(false); // turn off the LED Thread.Sleep(250); // sleep for 250ms Debug.Print ("Looping" + i); i++; } } } } ``` -------------------------------- ### Add Meadow.Windows NuGet Package (Command Line) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Windows/index.md Adds the Meadow.Windows NuGet package to the project, providing the necessary libraries and device abstraction to run Meadow applications on Windows. ```command dotnet add package Meadow.Windows ``` -------------------------------- ### Verify Meadow Project Template Installation (Console) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/MCUs/Project_Lab_Cellular/index.md Shows the expected output after successfully installing the Meadow project templates, listing the available templates with their short names, languages, and tags. ```console The following template packages will be installed: WildernessLabs.Meadow.Template Success: WildernessLabs.Meadow.Template installed the following templates: Template Name Short Name Language Tags ----------------------- ------------------ -------------- ------------------- Meadow Core-Compute App meadow-ccm [C#],F#,VB.NET Meadow/Console Meadow Desktop App meadow-desktop [C#] Meadow/Console Meadow F7 Feather App meadow-feather [C#],F#,VB.NET Meadow/Console Meadow Jetson Nano App meadow-jetson-nano [C#] Meadow/Console Meadow Library meadow-library [C#],F#,VB.NET Meadow/Library Meadow Project Lab App meadow-project-lab [C#] Meadow/Console Meadow Raspberry Pi App meadow-rpi [C#] Meadow/Console Meadow reTerminal App meadow-reterminal [C#] Meadow/Console Meadow StartKit App meadow-startkit [C#] Meadow/App/StartKit ``` -------------------------------- ### Blinking LED with Meadow.Foundation - Meadow Core-Compute - C# Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Hardware/Reference/Meadow_Hardware/Getting_Started_Core-Compute_Module/index.md This snippet extends the basic Meadow application structure to control an external LED. It initializes an `Led` object connected to pin D14 in the `Initialize` method and starts a blinking pattern with specified on/off times in the `Run` method using the Meadow.Foundation library. Requires an LED connected to pin D14 and GND. ```C# using Meadow; using Meadow.Devices; using Meadow.Foundation.Leds; using System; using System.Threading.Tasks; namespace HelloMeadow { // Change F7FeatherV2 or F7FeatherV1 for Feather boards public class MeadowApp : App { Led led; public override Task Run() { Console.WriteLine("Run..."); led.StartBlink(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(0.5)); return base.Run(); } public async override Task Initialize() { Console.WriteLine("Initialize..."); led = new Led(Device.CreateDigitalOutputPort(Device.Pins.D14)); await base.Initialize(); } } } ``` -------------------------------- ### Create New Blazor Server App (Command) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Blazor/index.md Creates a new Blazor Server project named 'MeadowBlazorSampleApp' and navigates into the newly created project directory using the .NET CLI. ```command dotnet new blazorserver -n MeadowBlazorSampleApp cd MeadowBlazorSampleApp ``` -------------------------------- ### Netduino Network Initialization, HTTP Client, and LED Blink Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Samples/Netduino/WebRequest/index.md The main program initializes an 'App' instance which handles network setup and a web request. It then enters a loop to blink the onboard LED while the app is running. The 'App' class contains methods to find network interfaces, check and acquire an IP address (supporting DHCP), and execute an HTTP GET request to a specified URL. This requires the .NET Micro Framework and Netduino-specific libraries. ```C# using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware.Netduino; using System; using System.Threading; using System.Net; using System.IO; using Microsoft.SPOT; using Microsoft.SPOT.Net.NetworkInformation; namespace Blinky { public class Program { public static void Main() { App app = new App (); app.Run (); OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); while (app.IsRunning) { led.Write(true); // turn on the LED Thread.Sleep(250); // sleep for 250ms led.Write(false); // turn off the LED Thread.Sleep(250); // sleep for 250ms } Debug.Print ("App finished."); Debug.Print ("I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhäuser Gate. All those moments will be lost in time, like tears in rain."); Debug.Print ("Time to die."); } } public class App { NetworkInterface[] _interfaces; public bool IsRunning { get; set; } public void Run() { this.IsRunning = true; bool goodToGo = InitializeNetwork (); if (goodToGo) { MakeWebRequest ("http://google.com"); } this.IsRunning = false; } protected bool InitializeNetwork() { if (Microsoft.SPOT.Hardware.SystemInfo.SystemID.SKU == 3) { Debug.Print("Wireless tests run only on Device"); return false; } Debug.Print("Getting all the network interfaces."); _interfaces = NetworkInterface.GetAllNetworkInterfaces(); // debug output ListNetworkInterfaces (); // loop through each network interface foreach (var net in _interfaces) { // debug out ListNetworkInfo (net); switch (net.NetworkInterfaceType) { case (NetworkInterfaceType.Ethernet): Debug.Print ("Found Ethernet Interface"); break; case (NetworkInterfaceType.Wireless80211): Debug.Print ("Found 802.11 WiFi Interface"); break; case (NetworkInterfaceType.Unknown): Debug.Print ("Found Unknown Interface"); break; } // check for an IP address, try to get one if it's empty return CheckIPAddress (net); } // if we got here, should be false. return false; } protected void MakeWebRequest(string url) { var httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.Method = "GET"; var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var result = streamReader.ReadToEnd(); Debug.Print("this is what we got from " + url + ": " + result); } } protected bool CheckIPAddress (NetworkInterface net) { int timeout = 10000; // timeout, in milliseconds to wait for an IP. 10,000 = 10 seconds // check to see if the IP address is empty (0.0.0.0). IPAddress.Any is 0.0.0.0. if (net.IPAddress == IPAddress.Any.ToString()) { Debug.Print ("No IP Address"); if (net.IsDhcpEnabled) { Debug.Print ("DHCP is enabled, attempting to get an IP Address"); // ask for an IP address from DHCP [note this is a static, not sure which network interface it would act on] int sleepInterval = 10; int maxIntervalCount = timeout / sleepInterval; int count = 0; while (IPAddress.GetDefaultLocalAddress () == IPAddress.Any && count < maxIntervalCount) { Debug.Print ("Sleep while obtaining an IP"); Thread.Sleep (10); count++; }; // if we got here, we either timed out or got an address, so let's find out. if (net.IPAddress == IPAddress.Any.ToString()) { Debug.Print ("Failed to get an IP Address in the allotted time."); return false; } Debug.Print ("Got IP Address: " + net.IPAddress.ToString ()); return true; } } // if we got here, we either already had an IP or DHCP was not enabled. if (net.IPAddress != IPAddress.Any.ToString()) { Debug.Print ("Already has an IP Address: " + net.IPAddress.ToString ()); return true; } // if we got here, we didn't have an IP and DHCP wasn't enabled. Debug.Print ("No IP Address and DHCP is not enabled."); return false; } // Note: ListNetworkInterfaces() and ListNetworkInfo() are called but not defined in this snippet. } } ``` -------------------------------- ### Add Main Entry Point (C#) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Linux/index.md Add a static asynchronous Main method to the application's main class. This method serves as the entry point for the executable and calls MeadowOS.Start to initialize the Meadow environment. ```csharp public static async Task Main(string[] args) { await MeadowOS.Start(args); } ``` -------------------------------- ### Add Main Method to MeadowApp Class (C#) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Windows/index.md Adds the standard `Main` entry point method to the `MeadowApp` class. This method is required for a console application and initiates the MeadowOS startup process when the application is executed. ```csharp public static async Task Main(string[] args) { await MeadowOS.Start(args); } ``` -------------------------------- ### Verify Meadow Template Installation Output (Console) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/MCUs/Project_Lab_Cellular/index.md Displays the expected output after successfully installing the Meadow project templates, listing the names, short names, supported languages (including C#, F#, VB.NET), and tags for each available template. ```console The following template packages will be installed: WildernessLabs.Meadow.Template Success: WildernessLabs.Meadow.Template installed the following templates: Template Name Short Name Language Tags ----------------------- ------------------ -------------- ------------------- Meadow Core-Compute App meadow-ccm [C#],F#,VB.NET Meadow/Console Meadow Desktop App meadow-desktop [C#] Meadow/Console Meadow F7 Feather App meadow-feather [C#],F#,VB.NET Meadow/Console Meadow Jetson Nano App meadow-jetson-nano [C#] Meadow/Console Meadow Library meadow-library [C#],F#,VB.NET Meadow/Library Meadow Project Lab App meadow-project-lab [C#] Meadow/Console Meadow Raspberry Pi App meadow-rpi [C#] Meadow/Console Meadow reTerminal App meadow-reterminal [C#] Meadow/Console Meadow StartKit App meadow-startkit [C#] Meadow/App/StartKit ``` -------------------------------- ### Installing dfu-util via Meadow.CLI Console Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Deploying_Meadow.OS/index.md Executes the `meadow dfu install` command from a console with admin rights to install the necessary dfu-util tool. This tool is required for flashing the Meadow board with the OS firmware. Ensure Meadow.CLI is already installed. ```console meadow dfu install ``` -------------------------------- ### Install Meadow Project Templates (Console) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/MCUs/Project_Lab_Cellular/index.md Use this command in a console window to install the official Wilderness Labs Meadow project templates for creating new Meadow applications and libraries. ```Console dotnet new install WildernessLabs.Meadow.Template ``` -------------------------------- ### Install Meadow Project Templates (Console) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/MCUs/Project_Lab_Cellular/index.md Installs the Wilderness Labs Meadow project templates using the .NET command-line interface. This command adds the available templates to your local .NET environment. ```console dotnet new install WildernessLabs.Meadow.Template ``` -------------------------------- ### Install Meadow Project Templates (dotnet) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Getting_Started_Meadow.Desktop/Getting_Started_Linux/index.md Installs the WildernessLabs.Meadow.Template NuGet package globally using the .NET CLI, making Meadow project templates available for use with `dotnet new`. ```console dotnet new install WildernessLabs.Meadow.Template ``` -------------------------------- ### Configure Project Output Type (XML) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Linux/index.md Modify the project file (.csproj) to change the OutputType property to 'Exe', making the project an executable application. This example targets .NET 7. ```xml Exe net7.0 enable enable ... ``` -------------------------------- ### Install Meadow Templates - .NET CLI Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/SBCs/SeeedStudio_ReTerminal/index.md Installs the WildernessLabs.Meadow.Template NuGet package using the .NET command-line interface. This package provides project templates for creating Meadow applications in various IDEs. Requires the .NET runtime to be installed. ```console dotnet new install WildernessLabs.Meadow.Template ``` -------------------------------- ### Install DocFX on Windows Source: https://github.com/wildernesslabs/documentation/blob/develop/docfx/README.md Installs the DocFX documentation generator tool on Windows using the Chocolatey package manager. Requires Chocolatey to be installed. ```powershell choco install docfx -y ``` -------------------------------- ### Initializing Hardware and Onboard LED (C#) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Hello_World/index.md Details the `Initialize` method, used for setting up hardware components. This snippet shows how to instantiate and configure an `RgbPwmLed` using the device's onboard LED pins, preparing it for use in the application. ```C# RgbPwmLed onboardLed; ... public override Task Initialize() { Console.WriteLine("Initialize hardware..."); onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, CommonType.CommonAnode); return base.Initialize(); } ``` -------------------------------- ### Meadow Template Installation Output Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Getting_Started_Meadow.Desktop/Getting_Started_Linux/index.md Shows the expected output after successfully installing the Meadow project templates, listing the available templates like `meadow-desktop`, `meadow-feather`, etc. ```console The following template packages will be installed: WildernessLabs.Meadow.Template Success: WildernessLabs.Meadow.Template installed the following templates: Template Name Short Name Language Tags ----------------------- ------------------ -------------- ------------------- Meadow Core-Compute App meadow-ccm [C#],F#,VB.NET Meadow/Console Meadow Desktop App meadow-desktop [C#] Meadow/Console Meadow F7 Feather App meadow-feather [C#],F#,VB.NET Meadow/Console Meadow Jetson Nano App meadow-jetson-nano [C#] Meadow/Console Meadow Library meadow-library [C#],F#,VB.NET Meadow/Library Meadow Project Lab App meadow-project-lab [C#] Meadow/Console Meadow Raspberry Pi App meadow-rpi [C#] Meadow/Console Meadow reTerminal App meadow-reterminal [C#] Meadow/Console Meadow StartKit App meadow-startkit [C#] Meadow/App/StartKit ``` -------------------------------- ### Install DocFX on macOS Source: https://github.com/wildernesslabs/documentation/blob/develop/docfx/README.md Installs the DocFX documentation generator tool on macOS using the Homebrew package manager. Requires Homebrew to be installed. ```bash brew install docfx ``` -------------------------------- ### View Meadow Template Installation Results - Console Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/SBCs/SeeedStudio_ReTerminal/index.md Displays the output from the `dotnet new install` command, confirming the successful installation of the Meadow templates. It lists the available templates by name, short name, language support, and tags, allowing users to verify the installation and see template options. ```console The following template packages will be installed: WildernessLabs.Meadow.Template Success: WildernessLabs.Meadow.Template::1.8.0.1 installed the following templates: Template Name Short Name Language Tags ----------------------- ------------------ -------------- ------------------- Meadow Core-Compute App meadow-ccm [C#],F#,VB.NET Meadow/Console Meadow Desktop App meadow-desktop [C#] Meadow/Console Meadow F7 Feather App meadow-feather [C#],F#,VB.NET Meadow/Console Meadow Jetson Nano App meadow-jetson-nano [C#] Meadow/Console Meadow Library meadow-library [C#],F#,VB.NET Meadow/Library Meadow Project Lab App meadow-project-lab [C#] Meadow/Console Meadow Raspberry Pi App meadow-rpi [C#] Meadow/Console Meadow reTerminal App meadow-reterminal [C#] Meadow/Console Meadow StartKit App meadow-startkit [C#] Meadow/App/StartKit ``` -------------------------------- ### MeadowApp.cs Structure (C#) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Hello_World/index.md Presents the main `MeadowApp.cs` file from a "Hello, World" project, showing the basic structure of a Meadow application class that implements `IApp`. It includes the `Initialize` and `Run` methods, and helper methods for cycling onboard LED colors. ```csharp using Meadow; using Meadow.Devices; using Meadow.Foundation; using Meadow.Foundation.Leds; using Meadow.Peripherals.Leds; using System; using System.Threading; using System.Threading.Tasks; namespace HelloMeadow { // Change F7FeatherV2 to F7FeatherV1 for V1.x boards public class MeadowApp : App { RgbPwmLed onboardLed; public override Task Initialize() { Console.WriteLine("Initialize hardware..."); onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, CommonType.CommonAnode); return base.Initialize(); } public override Task Run() { CycleColors(TimeSpan.FromMilliseconds(1000)); return base.Run(); } void CycleColors(TimeSpan duration) { Console.WriteLine("Cycle colors..."); while (true) {\n ShowColorPulse(Color.Blue, duration); ShowColorPulse(Color.Cyan, duration); ShowColorPulse(Color.Green, duration); ShowColorPulse(Color.GreenYellow, duration); ShowColorPulse(Color.Yellow, duration); ShowColorPulse(Color.Orange, duration); ShowColorPulse(Color.OrangeRed, duration); ShowColorPulse(Color.Red, duration); ShowColorPulse(Color.MediumVioletRed, duration); ShowColorPulse(Color.Purple, duration); ShowColorPulse(Color.Magenta, duration); ShowColorPulse(Color.Pink, duration); } } void ShowColorPulse(Color color, TimeSpan duration) { onboardLed.StartPulse(color, (duration / 2)); Thread.Sleep(duration); onboardLed.Stop(); } } } ``` -------------------------------- ### Install Meadow Project Templates (Console) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/MCUs/Project_Lab_Cellular/index.md Installs the official Wilderness Labs Meadow project templates using the .NET command-line interface. This command adds templates for various Meadow application types. ```console dotnet new install WildernessLabs.Meadow.Template ``` -------------------------------- ### Install Meadow CLI .NET Tool (macOS) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Deploying_Meadow.OS/index.md Installs the WildernessLabs.Meadow.CLI tool globally using the .NET SDK. ```console dotnet tool install WildernessLabs.Meadow.CLI --global ``` -------------------------------- ### Install Meadow Project Templates (VS Code, Console) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Getting_Started_Meadow.Desktop/Getting_Started_Windows/index.md Installs the official Wilderness Labs Meadow project templates using the .NET command-line interface, making them available for creating new Meadow projects. ```Console dotnet new install WildernessLabs.Meadow.Template ``` -------------------------------- ### Create New Meadow.Desktop Project (dotnet) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Getting_Started_Meadow.Desktop/Getting_Started_Linux/index.md Creates a new project based on the `meadow-desktop` template using the .NET CLI, naming the project 'LinuxDemo'. This sets up the basic project structure. ```console dotnet new meadow-desktop --name LinuxDemo ``` -------------------------------- ### Build Meadow.Mac App (Command) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Mac/index.md Compiles the Meadow.Mac application project using the .NET SDK, preparing it for execution. ```Command dotnet build ``` -------------------------------- ### Build Meadow.Desktop Project (VS Code, Console) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Getting_Started_Meadow.Desktop/Getting_Started_Windows/index.md Builds the Meadow.Desktop application project in the current directory using the .NET command-line interface, compiling the code and preparing it for execution. ```Console dotnet build ``` -------------------------------- ### Installing Meadow Project Templates with dotnet CLI Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/MCUs/F7_Feather/index.md This command uses the .NET command-line interface (CLI) to install the official Wilderness Labs Meadow project templates from NuGet. These templates provide starting points for various Meadow application types. ```console dotnet new install WildernessLabs.Meadow.Template ``` -------------------------------- ### Build, Deploy, and Run Meadow App (meadow cli) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/MCUs/Project_Lab/index.md Uses the Meadow command-line tool to build the current project, trim unnecessary code, deploy it to a connected Meadow device, and start the application. The first deployment may take longer due to transferring necessary libraries. ```console meadow app run ``` -------------------------------- ### List Available Meadow Templates (VS Code, Console Output) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Getting_Started_Meadow.Desktop/Getting_Started_Windows/index.md Displays the list of Meadow project templates successfully installed by the previous command, showing their names, short names, languages, and tags. ```Console The following template packages will be installed: WildernessLabs.Meadow.Template Success: WildernessLabs.Meadow.Template installed the following templates: Template Name Short Name Language Tags ----------------------- ------------------ -------------- ------------------- Meadow Core-Compute App meadow-ccm [C#],F#,VB.NET Meadow/Console Meadow Desktop App meadow-desktop [C#] Meadow/Console Meadow F7 Feather App meadow-feather [C#],F#,VB.NET Meadow/Console Meadow Jetson Nano App meadow-jetson-nano [C#] Meadow/Console Meadow Library meadow-library [C#],F#,VB.NET Meadow/Library Meadow Project Lab App meadow-project-lab [C#] Meadow/Console Meadow Raspberry Pi App meadow-rpi [C#] Meadow/Console Meadow reTerminal App meadow-reterminal [C#] Meadow/Console Meadow StartKit App meadow-startkit [C#] Meadow/App/StartKit ``` -------------------------------- ### Build Meadow.Blazor Application (Command) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Blazor/index.md Builds the Meadow.Blazor project using the .NET CLI, compiling the code and checking for errors. ```command dotnet build ``` -------------------------------- ### Install Meadow Project Templates (Shell) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Getting_Started_Meadow.Desktop/Getting_Started_Mac/index.md Installs the official Wilderness Labs Meadow project templates using the .NET CLI, making them available for creating new Meadow projects. ```Shell dotnet new install WildernessLabs.Meadow.Template ``` -------------------------------- ### Expected App Output (Bash) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Linux/index.md Shows the expected console output when the simple Meadow.Linux application successfully initializes and runs on the target device. ```bash Initialize... Run... Hello, Meadow.Linux! ``` -------------------------------- ### Add Meadow.Linux NuGet Package (Bash) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Linux/index.md Adds the necessary Meadow.Linux NuGet package reference to the project, enabling Meadow functionality on Linux. ```bash dotnet add package Meadow.Linux ``` -------------------------------- ### Output of Meadow Template Installation Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/MCUs/Project_Lab/index.md Shows the successful installation of the Meadow templates and lists the available project templates with their short names, languages, and tags. ```console The following template packages will be installed: WildernessLabs.Meadow.Template Success: WildernessLabs.Meadow.Template installed the following templates: Template Name Short Name Language Tags ----------------------- ------------------ -------------- ------------------- Meadow Core-Compute App meadow-ccm [C#],F#,VB.NET Meadow/Console Meadow Desktop App meadow-desktop [C#] Meadow/Console Meadow F7 Feather App meadow-feather [C#],F#,VB.NET Meadow/Console Meadow Jetson Nano App meadow-jetson-nano [C#] Meadow/Console Meadow Library meadow-library [C#],F#,VB.NET Meadow/Library Meadow Project Lab App meadow-project-lab [C#] Meadow/Console Meadow Raspberry Pi App meadow-rpi [C#] Meadow/Console Meadow reTerminal App meadow-reterminal [C#] Meadow/Console Meadow StartKit App meadow-startkit [C#] Meadow/App/StartKit ``` -------------------------------- ### Change App Base Class (C#) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Mac/index.md Updates the application class definition to inherit from App, indicating that the application is designed to run on the Meadow.Mac platform. ```C# public class MeadowApp : App { ... } ``` -------------------------------- ### Build Meadow Project (dotnet) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Getting_Started_Meadow.Desktop/Getting_Started_Linux/index.md Builds the current Meadow project using the .NET CLI. This compiles the source code and prepares the application for execution on the target platform (Linux desktop). ```console dotnet build ``` -------------------------------- ### Add Meadow.Mac NuGet Package (Command) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Mac/index.md Adds the necessary Meadow.Mac NuGet package to the project, providing the core libraries for running Meadow applications on macOS. ```Command dotnet add package Meadow.Mac ``` -------------------------------- ### Install project dependencies with Bundler (Shell) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/readme.md Uses Bundler to read the project's Gemfile and install all required Ruby gems specifically for this documentation site project. ```Shell $ bundle install ``` -------------------------------- ### Run Meadow.Mac App (Command) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Mac/index.md Executes the compiled Meadow.Mac application on the macOS environment. The console output should display 'Initialize...', 'Run...', and 'Hello, Meadow.Mac!'. ```Command dotnet run ``` -------------------------------- ### Rebooting the Linux Machine (Bash) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Linux/index.md Executes the `reboot` command with superuser privileges to restart the Linux machine. This is often required for configuration changes, such as enabling interfaces, to take effect. ```bash sudo reboot ``` -------------------------------- ### Add Meadow.Blazor NuGet Package (Command) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Blazor/index.md Adds the Meadow.Blazor NuGet package to the current project using the .NET CLI, providing necessary components for Meadow integration. ```command dotnet add package Meadow.Blazor ``` -------------------------------- ### Change Application Base Type to Windows (C#) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Windows/index.md Updates the application class definition to inherit from `App`, adapting an existing Meadow application to target and run on the Windows platform. ```csharp public class MeadowApp : App { ... } ``` -------------------------------- ### Install Meadow Project Templates (Bash) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Hello_World/index.md Installs the necessary project templates for creating Meadow applications using the .NET CLI. This command is typically run once to make the templates available system-wide for use with `dotnet new`. ```Bash dotnet new install WildernessLabs.Meadow.Template ``` -------------------------------- ### Update Project File Output Type (XML) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Windows/index.md Modifies the project file (.csproj) to set the `OutputType` property to `Exe`, ensuring the project builds as a standard executable application for Windows. ```xml Exe net8.0 enable enable ... ``` -------------------------------- ### Essential Meadow Namespaces (C#) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Hello_World/index.md Lists and explains the purpose of common `using` directives found at the beginning of a Meadow application class, detailing the functionality provided by the `Meadow`, `Meadow.Devices`, `Meadow.Foundation`, `Meadow.Foundation.Leds`, and `Meadow.Peripherals.Leds` namespaces. ```csharp using Meadow; using Meadow.Devices; using Meadow.Foundation; using Meadow.Foundation.Leds; using Meadow.Peripherals.Leds; ``` -------------------------------- ### Launch local Jekyll server (Shell) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/readme.md Executes the Jekyll serve command via Bundler from the `Documentation/docs` directory to build and host the site locally, typically accessible at http://127.0.0.1:4001/. Changes to files should trigger automatic site regeneration. ```Shell bundle exec jekyll serve ``` -------------------------------- ### Add Main Entry Point (C#) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Mac/index.md Adds a standard Main method to the application class, serving as the entry point for the executable when run on macOS, which then calls into the MeadowOS startup process. ```C# public static async Task Main(string[] args) { await MeadowOS.Start(args); } ``` -------------------------------- ### Configure Project Output Type (XML) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Mac/index.md Modifies the project file (.csproj) to set the output type to 'Exe' and target .NET 8.0, which is required for running the application directly on macOS. ```XML Exe net8.0 enable enable ... ``` -------------------------------- ### Install Meadow.CLI - .NET CLI Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow.Cloud/Device_Provisioning/index.md Installs the WildernessLabs.Meadow.CLI global tool using the .NET command-line interface. This tool is required for interacting with Meadow devices and Meadow.Cloud. ```console dotnet tool install --global WildernessLabs.Meadow.CLI ``` -------------------------------- ### Create New Meadow.Mac Console App (Command) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Mac/index.md Creates a new .NET console application project named 'MeadowMacSampleApp' and navigates into its directory, setting up the basic structure for a Meadow.Mac application. ```Command dotnet new console --output MeadowMacSampleApp cd MeadowMacSampleApp ``` -------------------------------- ### Integrate Meadow into WebApplication (C#) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Blazor/index.md Demonstrates how to integrate the Meadow application lifecycle into a Blazor Server `WebApplication` by calling the `UseMeadow` extension method, specifying the main Meadow application class. ```csharp using Meadow.Blazor; using Meadow.Blazor.Services; var builder = WebApplication.CreateBuilder(args); ... var app = builder.Build(); ... app.UseMeadow(); ... app.Run(); ``` -------------------------------- ### Create New Meadow Project (Bash) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Hello_World/index.md Creates a new Meadow application project using the installed templates via the .NET CLI. The `--output` parameter allows specifying the directory where the new project files will be generated. ```Bash dotnet new Meadow ``` ```Bash dotnet new Meadow --output MeadowApp1 ``` -------------------------------- ### Install Meadow.CLI (Desktop) - .NET CLI Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow.Cloud/Device_Provisioning/index.md Installs the WildernessLabs.Meadow.CLI global tool using the .NET command-line interface, specifically for the Meadow.Desktop provisioning path. This tool is required for interacting with Meadow devices and Meadow.Cloud. ```console dotnet tool install WildernessLabs.Meadow.CLI --global ``` -------------------------------- ### Create New .NET Console Application (Command Line) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Windows/index.md Creates a new .NET console application project named 'MeadowWindowsSampleApp' and navigates into its directory. This project structure is suitable for Meadow.Windows development. ```command dotnet new console --output MeadowWindowsSampleApp cd MeadowWindowsSampleApp ``` -------------------------------- ### Build Meadow.Windows Project (VS Code) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Desktop/Hello_Simulator/index.md Builds the Meadow.Windows application project using the .NET command-line interface. This compiles the source code and prepares the application for execution on the local machine. ```console dotnet build ``` -------------------------------- ### Run Deployed App via SSH (Bash) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Linux/index.md Connects to the target Meadow.Linux device via SSH, navigates to the deployed application directory, and executes the application's DLL using the dotnet command. ```bash ssh pi@raspberry cd MeadowLinuxSampleApp dotnet MeadowLinuxSampleApp.dll ``` -------------------------------- ### Install Meadow Project Templates (Console) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/SBCs/RaspberryPi/index.md This command installs the WildernessLabs.Meadow.Template NuGet package, which provides project templates for creating various Meadow applications, including the Raspberry Pi template. ```Console dotnet new install WildernessLabs.Meadow.Template ``` -------------------------------- ### Define Basic Meadow Application Class (C#) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Blazor/index.md Defines the main application class inheriting from `App`, providing basic `Initialize` and `Run` methods for a Meadow application running on a desktop environment. ```csharp using Meadow; internal class MeadowApplication : App { public override Task Initialize() { //initialize hardware here and add to sensor service return base.Initialize(); } public override Task Run() { return base.Run(); } } ``` -------------------------------- ### List Available Meadow Templates (Console Output) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/SBCs/RaspberryPi/index.md This is the expected output after successfully installing the Meadow project templates, showing the names, short names, supported languages (like C#, F#, VB.NET), and tags for each available template. ```Console The following template packages will be installed: WildernessLabs.Meadow.Template Success: WildernessLabs.Meadow.Template::1.8.0.1 installed the following templates: Template Name Short Name Language Tags ----------------------- ------------------ -------------- ------------------- Meadow Core-Compute App meadow-ccm [C#],F#,VB.NET Meadow/Console Meadow Desktop App meadow-desktop [C#] Meadow/Console Meadow F7 Feather App meadow-feather [C#],F#,VB.NET Meadow/Console Meadow Jetson Nano App meadow-jetson-nano [C#] Meadow/Console Meadow Library meadow-library [C#],F#,VB.NET Meadow/Library Meadow Project Lab App meadow-project-lab [C#] Meadow/Console Meadow Raspberry Pi App meadow-rpi [C#] Meadow/Console Meadow reTerminal App meadow-reterminal [C#] Meadow/Console Meadow StartKit App meadow-startkit [C#] Meadow/App/StartKit ``` -------------------------------- ### Create New Meadow.Desktop Project (VS Code, Console) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Getting_Started_Meadow.Desktop/Getting_Started_Windows/index.md Creates a new Meadow.Desktop application project named 'WindowsDemo' using the installed Meadow templates via the .NET command-line interface. ```Console dotnet new meadow-desktop --name WindowsDemo ``` -------------------------------- ### Run Meadow.Desktop Project (VS Code, Console) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Getting_Started_Meadow.Desktop/Getting_Started_Windows/index.md Executes the built Meadow.Desktop application project from the current directory using the .NET command-line interface, launching the application window. ```Console dotnet run ``` -------------------------------- ### Defining Meadow Application Class (C#) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Hello_World/index.md Illustrates the definition of a Meadow application class, inheriting from `App`. This class serves as the entry point for the application, automatically discovered and launched by Meadow.OS, and provides hooks for system events. ```C# public class HelloMeadow : App ``` -------------------------------- ### Initialize Hardware in Meadow Application (C#) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Blazor/index.md Extends the `MeadowApplication` class to initialize hardware components like an FTDI expander, a digital output port, a BME680 sensor, and an LED, adding them to the `Resolver.Services` for dependency injection. ```csharp using Meadow; using Meadow.Foundation.ICs.IOExpanders; using Meadow.Foundation.Leds; using Meadow.Foundation.Sensors.Atmospheric; using Meadow.Peripherals.Leds; internal class MeadowApplication : App { public override Task Initialize() { FtdiExpanderCollection.Devices.Refresh(); var ftdi = FtdiExpanderCollection.Devices[0]; var output = ftdi.Pins.D7.CreateDigitalOutputPort(false); Resolver.Services.Add(output); var bme680 = new Bme680(ftdi.CreateSpiBus(), ftdi.Pins.C7); Resolver.Services.Add(bme680); var led = new Led(ftdi.Pins.C0); Resolver.Services.Add(led); return base.Initialize(); } public override Task Run() { return base.Run(); } } ``` -------------------------------- ### Downloading Meadow.OS Firmware via Meadow.CLI Console Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/Deploying_Meadow.OS/index.md Executes the `meadow firmware download` command to fetch the latest Meadow.OS binary files from the Wilderness Labs servers. This command requires the user to be logged into their Wilderness Labs account using the `meadow login` command. ```console meadow firmware download ``` -------------------------------- ### Implement Basic Meadow.Mac App (C#) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Mac/index.md Provides the core C# code for a simple Meadow.Mac application, including the App class definition, the Main entry point, and basic Initialize and Run methods with logging. ```C# using Meadow; using Meadow.Devices; public class MeadowApp : App { static async Task Main(string[] args) { await MeadowOS.Start(args); } public override Task Initialize() { Resolver.Log.Info("Initialize..."); return base.Initialize(); } public override Task Run() { Resolver.Log.Info("Run..."); Resolver.Log.Info("Hello, Meadow.Mac!"); return base.Run(); } } ``` -------------------------------- ### Build Meadow Project (Console) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Getting_Started/SBCs/RaspberryPi/index.md Builds the current Meadow project using the .NET CLI. This compiles the application code and prepares it for execution or deployment. ```Console dotnet build ``` -------------------------------- ### Enabling SPI and I2C on Raspberry Pi OS (Bash) Source: https://github.com/wildernesslabs/documentation/blob/develop/docs/Meadow/Meadow_Desktop/Meadow_Linux/index.md Uses the `raspi-config` utility in non-interactive mode to enable the SPI and I2C interfaces on a Raspberry Pi. Setting the value to `0` enables the feature. Requires `sudo`. ```bash sudo raspi-config nonint do_spi 0 sudo raspi-config nonint do_i2c 0 ```