accessing hardware in the. Net Micro Framework

Source: Internet
Author: User
Tags static class

Summary: This article describes the simple and unique way of accessing hardware in the. Net Micro Framework. Based on the simulator and Embeddedfusion Tahoe Development Board, this paper introduces how to obtain the power supply and charging status of MF equipment, how to obtain the characteristics of the processor (such as speed, etc.) and the hardware platform ID number and other basic hardware information.

I. Power supply and power supply

A MCU or a piece of development board work is started from the electricity, power state changes in the embedded device we often have to deal with the problem.

The. Net MICRO Framework provides a battery class (under the Microsoft.SPOT.Hardware namespace) that provides a set of static methods to help us easily get the power charging status of the device. Interestingly, this class containing only static methods can be instantiated in. NET MF 2.5, but it has been changed to static in the most recently released. NET Micro Framework3.0 Beta:

Battery class in. NET MF 2.5 public
sealed class Battery
//battery class in. NET MF 3.0 public
Static class Battery

Here's a simple procedure to take a look at how to use this battery class to get battery information:

public static void Main ()
{
Debug.Print ("* * Battery Info * * *");
Battery or cellular battery charging status
Debug.Print ("State of Charge:" + battery.stateofcharge () + "%");
Whether full (not necessarily to the battery must be 100% to think is full)
//Here the Isfullycharged method is only used to check whether the battery can assume the normal load
Debug.Print ("is fully charged: "+ (battery.isfullycharged ()?"      Yes ":" No "));
Readvoltage method to return the power supply voltage unit for MV so to divide by 1000 conversion to volts
float Voltagevolt = battery.readvoltage ()/1000.0f;
Debug.Print ("Voltage:" + voltagevolt.tostring ("F3") + "Volt");
Readtemperature method returns the current battery temperature of 10 times times Celsius temperature
float Degreescelsius = battery.readtemperature ()/10.0f;
Debug.Print ("Temperature:" + degreescelsius.tostring ("F1") +
"°celsius");
The Oncharger method is used to return access to an external charging power supply
Debug.Print ("on charger:" + (Battery.oncharger ()?).    Yes ":" No "));
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.