-
-
Notifications
You must be signed in to change notification settings - Fork 146
/
Program.cs
50 lines (39 loc) · 1.42 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// Copyright (c) 2018 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//
using System;
using System.Diagnostics;
using System.Threading;
using System.Device.Adc;
namespace TestAdc
{
public class Program
{
public static void Main()
{
AdcController adc1 = new AdcController();
int max1 = adc1.MaxValue;
int min1 = adc1.MinValue;
Debug.WriteLine("min1=" + min1.ToString() + " max1=" + max1.ToString());
AdcChannel ac0 = adc1.OpenChannel(0);
// the following indexes are valid for STM32F769I-DISCO board
AdcChannel vref = adc1.OpenChannel(0);
AdcChannel vbat = adc1.OpenChannel(8);
// VP
//AdcChannel ac3 = adc1.OpenChannel(3);
// VN
while (true)
{
int value = ac0.ReadValue();
int valueVref = vref.ReadValue();
int valueVbat = vbat.ReadValue();
double percent = ac0.ReadRatio();
Debug.WriteLine("value0=" + value.ToString() + " ratio=" + percent.ToString());
Debug.WriteLine("verf" + valueVref.ToString() + " ratio=" + percent.ToString());
Debug.WriteLine("vbat" + valueVbat.ToString() + " ratio=" + percent.ToString());
Thread.Sleep(1000);
}
}
}
}