@@ -34,11 +34,12 @@ public static partial class Tough
3434 private static Pcf8563 _rtc ;
3535 private static Axp192 _power ;
3636 private static bool _powerLed ;
37- private static bool _vibrate ;
3837#if M5CORE2
3938 private static Ft6xx6x _touchController ;
39+ private static bool _vibrate ;
4040#elif TOUGH
4141 private static Chs6540 _touchController ;
42+ private static bool _backLight ;
4243#endif
4344 private static Thread _callbackThread ;
4445 private static CancellationTokenSource _cancelThread ;
@@ -134,6 +135,21 @@ public static Chs6540 TouchController
134135 return _touchController ;
135136 }
136137 }
138+
139+ /// <summary>
140+ /// Gets or sets the state of the display backlight.
141+ /// Set to <see langword="true"/> to turn on and <see langword="false"/> to turn off.
142+ /// </summary>
143+ public static bool Backlight
144+ {
145+ get => _backLight ;
146+ set
147+ {
148+ _backLight = value ;
149+ _power . EnableLDO3 ( _backLight ) ;
150+ }
151+ }
152+
137153#endif
138154
139155 /// <summary>
@@ -153,7 +169,7 @@ public static void InitializeScreen(int memoryBitMapAllocation = Screen.DefaultM
153169 _touchController = new ( I2cDevice . Create ( new I2cConnectionSettings ( 1 , Ft6xx6x . DefaultI2cAddress ) ) ) ;
154170#elif TOUGH
155171 _touchController = new ( I2cDevice . Create ( new I2cConnectionSettings ( 1 , Chs6540 . DefaultI2cAddress ) ) ) ;
156- #endif
172+ #endif
157173 _touchController . SetInterruptMode ( false ) ;
158174 _lastPoint = new ( ) ;
159175 _cancelThread = new ( ) ;
@@ -285,13 +301,20 @@ static Tough()
285301 _power . SetBackupBatteryChargingControl ( true , BackupBatteryCharingVoltage . V3_0 , BackupBatteryChargingCurrent . MicroAmperes200 ) ;
286302 // Sets the ESP voltage
287303 _power . DcDc1Volvate = ElectricPotential . FromVolts ( 3.35 ) ;
288- // Sets the LCD Voltage to 2.8V
289- _power . DcDc3Volvate = ElectricPotential . FromVolts ( 2.8 ) ;
290304 // Sets the SD Card voltage
291305 _power . LDO2OutputVoltage = ElectricPotential . FromVolts ( 3.3 ) ;
292306 _power . EnableLDO2 ( true ) ;
307+ // Sets the LCD backlight voltage to 2.8V
308+ _power . DcDc3Volvate = ElectricPotential . FromVolts ( 2.8 ) ;
309+
310+ #if M5CORE2
293311 // Sets the Vibrator voltage
294312 _power . LDO3OutputVoltage = ElectricPotential . FromVolts ( 2.0 ) ;
313+ #elif TOUGH
314+ // Sets backlight voltage to 3.0
315+ _power . LDO3OutputVoltage = ElectricPotential . FromVolts ( 3.0 ) ;
316+ #endif
317+
295318 // Bat charge voltage to 4.2, Current 100MA
296319 _power . SetChargingFunctions ( true , ChargingVoltage . V4_2 , ChargingCurrent . Current100mA , ChargingStopThreshold . Percent10 ) ;
297320 // Set ADC sample rate to 200hz
@@ -301,10 +324,15 @@ static Tough()
301324 _power . AdcPinCurrentSetting = AdcPinCurrentSetting . AlwaysOn ;
302325 // Set ADC1 Enable
303326 _power . AdcPinEnabled = AdcPinEnabled . All ;
304- #if M5CORE2
305- // Switch on the power led
327+
328+ // Switch on the power
306329 PowerLed = true ;
330+
331+ #if TOUGH
332+ // turn on backlight
333+ Backlight = true ;
307334#endif
335+
308336 // Set GPIO4 as output (rest LCD)
309337 _power . Gpio4Behavior = Gpio4Behavior . MnosLeakOpenOutput ;
310338 // 128ms power on, 4s power off
0 commit comments