Skip to content

Instantly share code, notes, and snippets.

@hatsunea
Last active June 27, 2022 13:48
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/503cb91294251385ec4a1b7d85b7945c to your computer and use it in GitHub Desktop.
Save hatsunea/503cb91294251385ec4a1b7d85b7945c to your computer and use it in GitHub Desktop.
private static void Setup()
{
M5Core2.InitializeScreen();
Console.Clear();
Console.ForegroundColor = Color.White;
Console.WriteLine("ENV.III Unit test...");
// PORT A (i2C)
Qmp = new(M5Core2.GetI2cDevice(0x70))
{
PressureResolution = PressureResolution.High,
};
Qmp.SetPowerMode(PowerMode.Force);
Sht = new(M5Core2.GetI2cDevice(0x44))
{
Resolution = Resolution.High,
};
}
private static void Loop()
{
Console.ForegroundColor = Color.White;
Console.BackgroundColor = Color.Black;
while (true)
{
try
{
Console.CursorTop = 0;
Console.CursorLeft = 0;
Console.WriteLine($"DateTime:{DateTime.UtcNow:yyyyMMdd HHmmss}");
Console.WriteLine($"Pressure:{Qmp.CalcPressureHectopascals():F} hPa");
Console.WriteLine($"Temperature:{Sht.Temperature.DegreesCelsius:F} C");
Console.WriteLine($"Humidity:{Sht.Humidity.Percent:F} %");
Thread.Sleep(1000);
}
catch
{ }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment