lcdgfx icon indicating copy to clipboard operation
lcdgfx copied to clipboard

Adding brightness support to SSDXXXX

Open prelard812 opened this issue 4 years ago • 8 comments

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.

prelard812 avatar Sep 10 '20 20:09 prelard812

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

  1. Go to lcdgfx/tools/templates/lcd/ssd1351/functions/ and add new folder setBrightness (this will be your function)
  2. 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();
  1. Edit lcdgfx/tools/templates/lcd/ssd1351/ssd1351.json file and add setBrightness to "interface_list", add new setBrightness empty section to "functions".

  2. 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.

lexus2k avatar Sep 10 '20 22:09 lexus2k

Oh seems easy... very good integration, I will be happy to get a try.

prelard812 avatar Sep 11 '20 00:09 prelard812

General idea, functions accessible via display. (display.drawRect) are common for all displays. And function accessible via display.getInterface() are display specific.

lexus2k avatar Sep 11 '20 02:09 lexus2k

@prelard812 How are your results? Have you succeeded in brightness control?

lexus2k avatar Nov 08 '20 00:11 lexus2k

Hi, unfortunately I change the used screen and the LIB used… SO it will not be done. Sorry ☹

prelard812 avatar Nov 09 '20 17:11 prelard812

Thank you. I will leave this issue open. Maybe someday, I will implement brightness control.

lexus2k avatar Nov 09 '20 21:11 lexus2k