Has anyone figured out how to control the brightness of the backlight on the new GIGI Display Shield?
The backlight in my display is far too bright and there is no example code to explain how to control it. I have looked for backlight control in the supplied libraries to no avail, although there is a reference in edid.c noting it is on a todo list. Thinking I might be able to do my own port manipulation I traced BACKLIGHT_SWIRE on the schematic which points to PWM8 on the J2 connector, but that is a dead end -- the schematic for the GIGA R1 board does not show the J1 and J2 connectors or any of their connections.
On the datasheet, check the resistor values against your hardware (from datasheet: "backlight intensity is controlled by the LED driver (U3)." and maybe some SMD resistors)
Have you been able to find anything about how to control the Giga Display backlight level yet? If not, there is a sample sketch included in the Arduino_GigaDisplay library folder called SimpleBacklight.ino. Below is the code. I have tested it and it does work on my device.
/*
Changes the display backlight from very dim to 100%
This example code is in the public domain.
*/
#include <Arduino_GigaDisplay.h>
//Create backlight object
GigaDisplayBacklight backlight;
void setup() {
//init library
backlight.begin();
}
int i = 0;
void loop() {
backlight.set(i++ % 100);
delay(100);
}
Thank's for the heads up. I was using the 1.0.0 library which didn't include the backlight driver now included in 1.0.1.
I was surprised that the PWM was set to 50Hz as that limits the number of discrete step in brightness to 9 (the LV52204 supports 32 levels and PWM up to 100kHz). And what can I say about doing PWM in software! Too bad the processor doesn't support PWM on PB12/D74.
I have been working on my own driver in my spare time and it appears to be working so I have included the code below. It implements the digital protocol of the LV52204. There is no CPU overhead except when changing the brightness value, which can be set between 0 and 31. The driver also allows for shutting down (and restarting) the LV52204.
I began writing this using only Direct Port Access but I could not get it to work -- there was no activity on PB12 at all -- until I first initialized any B port pin with pinMode(..). I still can't figure that one out. I did some timing tests to compare Direct Port Access to pinMode and digitalWrite and found that there is almost no difference in timing. The result is the final code is written with the standard Arduino Digital I/O functions.
Regarding Direct Port Access I have read elsewhere that it is dangerous to do on the Arm processors. In hindsight is seems unnecessary given the speed of the standard I/O functions and that almost none of the port register assignments are sequential like on the original Arduinos.
Hope you find the driver useful. Please let me know if you encounter any problems.
@Irishson thank you for your library. I was about to try to programm my own snippet to turn the display on and off and you saved me from that
Did you put this library on github and maybe the arduino library or are you planing to do so?
I just thought it was peculiar to do PWM in software when the LV52204 handled PWM on its own without any cpu overhead once the device was programmed (it didn't require a huge amount of effort to write the driver). Alternatively, if the issue been coordinated properly with the GIGA team they could have picked one of the 12 PWM capable IO pins to drive the enable pin on the LV52204 and just used analogWrite() to control the backlight. Again with no cpu overhead, although it would have tied up one of the counter/timers.
Hi Don
Thanks for the info.
I have some time critical loops and the last thing I want is software PWM messing up the timing. Possibly you can clarify a few things for me...
Is software PWM used for the Giga Display backlight by default?
Is there a way to turn off PWM and just have full brightness without any inconsistencies from interrupts?
Is the software PWM disabled when running your library, which works very well BTW.
Thanks,
Joe
The Arduino_GigaDisplay driver includes the class GigaDisplayBacklight which performs the software PWM I referred to. It's use is shown in SimpleBacklight.ino in the Arduino_GigaDisplay\examples directory.
You do not need any driver if you only want to turn the backlight ON (at full brightness) or OFF. Just set D74 HIGH or LOW respectively using digitalWrite().
The LV52204 backlight driver will accept either a PMW input signal or register programming, whichever occurs first following a reset. I included a shutdown() method in my driver to allow the mode to be changed without resetting the board.