From 3d5e1f2b0ca4de32665f8ecc137e975326bb0b38 Mon Sep 17 00:00:00 2001 From: Michiel Ryvers Date: Tue, 9 Nov 2021 14:51:40 +0100 Subject: [PATCH] Change type of LuminosityPercentage to int from byte The LuminosityPercentage stayed at 0 when initializing the screen. --- nanoFramework.M5StickCommon/Screen.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nanoFramework.M5StickCommon/Screen.cs b/nanoFramework.M5StickCommon/Screen.cs index c08f48ec..1ba22a2e 100644 --- a/nanoFramework.M5StickCommon/Screen.cs +++ b/nanoFramework.M5StickCommon/Screen.cs @@ -19,7 +19,7 @@ public class Screen : ScreenBase private const int DataCommand = 23; private const int Reset = 18; private static Axp192 _power; - private static byte _lumi; + private static int _lumi; private static bool _isInitialized = false; /// @@ -53,7 +53,7 @@ public Screen() /// /// Enables or disables the screen. /// - public static new bool Enabled + public new static bool Enabled { get => IsEnabled; @@ -68,7 +68,7 @@ public Screen() /// Sets or gets the screen luminosity. /// /// On M5Stick, anything less than 20% will be fully black - public static new byte LuminosityPercentage + public new static int LuminosityPercentage { get => _lumi; @@ -76,8 +76,8 @@ public Screen() { // For M5Stick, values from 8 to 12 are working fine // 2.5 V = dark, 3.0 V full luminosity - _lumi = (byte)(value > 100 ? 100 : _lumi); - _power.LDO3OutputVoltage = ElectricPotential.FromVolts((byte)(_lumi * 0.5 / 100.0 + 2.5)); + _lumi = value > 100 ? 100 : value; + _power.LDO3OutputVoltage = ElectricPotential.FromVolts(_lumi * 0.5 / 100.0 + 2.5); } } }