Align LCD backlight control to that of the LCD API 1.0

Issue #14 resolved
Francisco Malpartida
repo owner created an issue

Change setBacklight method to be aligned with the LCD 1.0 API.

LCD::setBacklight ( uint8_t value );

Comments (5)

  1. Bill Perry

    I have seen some other APIs for setting the backlight. I think one would be useful to incorporate as well. I have seen backlight() and noBackight() as well. To turn the backlight on and off (no dimming). I bring this up because in the Arduino core code if you call analogWrite() on a pin that does not support pwm, the code will set the pin to LOW for values 0-127 and HIGH for values 128-255. In my opinion this is wrong, I think any pin that does not support pwm should be LOW for 0 and HIGH for any other value. Because of this core code, it makes it very difficult to implement the setBacklight() function as it is intended to work because any value between 1-127 will turn the backlight off vs turn it on.

    I'm wrestling with this very issue in the glcd library. My thought for glcd is to add all three:

    • setBacklight()
    • backlight()
    • noBacklight()

    backlight() turns on the backlight noBacklight() turns of the backlight() setBacklight() can either call analogWrite() - which technically does not implement the lcd 1.0 api becaue of the core code. or it calls backlight()/noBacklight() depending on the value. (I'll have a "hidden" ifdef/define to control the setBacklight behavior but by default it won't support dimming)

    While backlight dimming is cool and I've played around with it for some cool blink effects, my preference is actually for backlight() noBacklight() as it ensures a consistent interface and functionality across all hardware that supports backlight control, but that is just my person opinion.

    In the mean time I'm going to try to lobby the Arduino team to change the analogWrite() behavior on non pwm pins.

  2. Log in to comment