k3ng / k3ng_cw_keyer

K3NG Arduino CW Keyer
http://blog.radioartisan.com/arduino-cw-keyer/
GNU General Public License v3.0
430 stars 222 forks source link

Add FEATURE_LCD_BACKLIGHT_AUTO_DIM dims LCD and/or Power LED after x … #110

Closed FrugalGuy closed 3 years ago

FrugalGuy commented 3 years ago

…minutes

Feature simply tracks last active time. After x minutes of no activity, lcd.noBacklight() is called (assuming FEATURE_DISPLAY), which turns off the LCD's backlight. Additionally, analogWrite(keyer_power_led,keyer_power_led_asleep_duty); is called to dim the optional Power LED. If anything is written to the LCD, or button is pressed, or encoder is turned, or keyboard key is pressed, then lcd.backlight() is called to switch on the backlight, and keyer_power_led_awake_duty is used for PWM to LED.
To save cycles, check_backlight() usually returns immediately and will only dim/brighten once per second.

Defines are added to all of: keyer_debug.h, keyer_features_and_options.h, keyer_pin_settings.h, and keyer_settings*.h.

Potential Issues

  1. I only tested with FEATURE_LDC_YDv1. Specifically, I'm not certain the non-I2C boards use lcd.noBacklight() and lcd.backlight().
  2. I see the Adafruit has a colored backlight. I didn't do anything about saving / restoring that color.
  3. At first I thought about running the backlight off PWM as well (so you could control brightness when awake or asleep), but that seemed needlessly complex in circuitry (might need a transistor if board PWM pin can't supply enough current) for little value.
  4. I don't see how to update documentation, or I'd happily add a sentence to the DISPLAY doc pages to mention this possibility.
k3ng commented 3 years ago

In addition to the code contribution, thank you so much for updating all the feature and pin files!!! 73 Goody K3NG