Turn off power LED when LCD brighness is set to 0

Started by HeneryH, December 14, 2018, 09:54:03 AM

HeneryH

FYI - I often have some Pi/MightHats at a desktop in my bedroom and the power led can get bright.  I added the following code to turn off the power LED when the LCD brightness is selected to 0.

The code is in the handle2Buttons() function

    if (backlightLevel==BACKLIGHTLEVELS) 
    {
      backlightLevel=0;
      POWER_LED_OFF();           <------  Added this within the new braces
    }
    else 
    {
      if (PowerState == ON) POWER_LED_GRN() else POWER_LED_OFF();            <------  Added this within the new braces
      backlightLevel++;
    }
    LCD_BACKLIGHT(backlightLevel);
    sprintf(lcdbuff, "LCDlight:%d/100", 100*backlightLevel/BACKLIGHTLEVELS);
    refreshLCD();

Felix

Or you could use a simple photoresistor/LDR to read ambient light and dim both screen and power LED accordingly.