Last active
August 12, 2022 21:19
-
-
Save hatsunea/64d3f8d28ba82043ce42568278b307df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using System.Threading; | |
using nanoFramework.M5Stack; | |
using Console = nanoFramework.M5Stack.Console; | |
namespace M5StickCPowerSample | |
{ | |
public class Program | |
{ | |
public static void Main() | |
{ | |
Setup(); | |
Loop(); | |
} | |
private static void Setup() | |
{ | |
M5StickCPlus.InitializeScreen(); | |
Console.ForegroundColor = nanoFramework.Presentation.Media.Color.White; | |
} | |
private static void Loop() | |
{ | |
while (true) | |
{ | |
Console.CursorTop = 0; | |
Console.WriteLine($"DateTime:{DateTime.UtcNow.AddHours(9):yyyyMMdd HHmmss}"); | |
Console.WriteLine($"Aps:{M5StickCPlus.Power.GetApsVoltage().Volts:F} V"); | |
Console.WriteLine($"Battery:"); | |
Console.WriteLine($" Charge:{M5StickCPlus.Power.GetBatteryChargeCurrent().Milliamperes:F} mA"); | |
Console.WriteLine($" Discharge:{M5StickCPlus.Power.GetBatteryDischargeCurrent().Milliamperes:F} mA"); | |
Console.WriteLine($" {M5StickCPlus.Power.GetBatteryVoltage().Volts:F} V"); | |
Console.WriteLine($"ExternalPower:"); | |
Console.WriteLine($" {M5StickCPlus.Power.GetUsbCurrentInput().Milliamperes:F} mA"); | |
Console.WriteLine($" {M5StickCPlus.Power.GetUsbVoltageInput().Volts:F} V"); | |
Console.WriteLine($"Temperature:{M5StickCPlus.Power.GetInternalTemperature().DegreesCelsius:F} C"); | |
Console.WriteLine($"Input:"); | |
Console.WriteLine($" {M5StickCPlus.Power.GetInputCurrent().Milliamperes:F} mA"); | |
Console.WriteLine($" {M5StickCPlus.Power.GetInputVoltage().Volts:F} V"); | |
Thread.Sleep(1000); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment