lcdgfx
lcdgfx copied to clipboard
Adding brightness support to SSDXXXX
I'm using a SSD1531 display and the LCDGFX with a ESP32 and the linux simulator, with a lot of fun... Your lib is really good. :)
I can't see support to set the brightness of the display.... I would like to get it.
I'm glad to offer my support to add it but I would like you to show me where to start, It will be easier and I will be sure that I put the function in the good Class.
thank you.
Greetings.
Unlike C-style ssd1306 library, the code for the lcdgfx displays is generated automatically. So to do that, you need to have Python installed. I made support for 2.7.X and 3.X Python, but if you have issues with any of them, let me know. Next
- Go to lcdgfx/tools/templates/lcd/ssd1351/functions/ and add new folder setBrightness (this will be your function)
- Inside created folder, please create 3 files: code, doc, decl:
decl - this is declaration or function type and arguments
void
uint8_t brightness
doc file should contain description
/**
* @brief Sets screen brightness
*
* Sets screen brightness
* @param brightness new brightness for the display
*/
code file should contain code for new display function
// To start communication with display in command mode
this->start();
setDataMode(0);
// To send special command
this->send( ??? ); // This is special command according to ssd1351 datasheet
// To send command arguments
setDataMode(1); // Switch to data mode to send arguments
this->send( brightness );
// to stop communication with display and go back to data mode
this->stop();
-
Edit lcdgfx/tools/templates/lcd/ssd1351/ssd1351.json file and add
setBrightness
to"interface_list"
, add newsetBrightness
empty section to"functions"
. -
Run Python script from lcdgfx/tools folder:
./lcd_code_generator.py -c all
That's it. Now you can call from your code
display.getInterface().setBrightness(100);
Best regards.
Oh seems easy... very good integration, I will be happy to get a try.
General idea, functions accessible via display.
(display.drawRect
) are common for all displays.
And function accessible via display.getInterface()
are display specific.
@prelard812 How are your results? Have you succeeded in brightness control?
Hi, unfortunately I change the used screen and the LIB used… SO it will not be done. Sorry ☹
Thank you. I will leave this issue open. Maybe someday, I will implement brightness control.