Skip to content

Instantly share code, notes, and snippets.

@hatsunea
Last active August 12, 2022 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hatsunea/64d3f8d28ba82043ce42568278b307df to your computer and use it in GitHub Desktop.
Save hatsunea/64d3f8d28ba82043ce42568278b307df to your computer and use it in GitHub Desktop.
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