Controlling display brightness in the lcd_pcf8574 library

Hi all.
I have a Futaba M204SD02A VFD display. Its interface is compatible with the lcd_base library.
Its difference is that it is a vacuum fluorescent display. Accordingly, its brightness can be adjusted.
I improved this library to adjust brightness and added the set_brightness function.
lcd_display.h

  void set_brightness(uint8_t brightness);

lcd_display.cpp

void LCDDisplay::set_brightness(uint8_t brightness) {
  //BR1, BR0 =  0,0:  Sets the luminance level to 100%. 
  //     0,1:  Sets the luminance level to 75%. 
  //     1,0:  Sets the luminance level to 50%. 
  //     1,1:  Sets the luminance level to 25%.
  uint8_t display_function = LCD_DISPLAY_COMMAND_FUNCTION_SET;

  // brightness=0 Minimum brightness
  // brightness=3 Maximum brightness
  // invert 2 least significant bits
  brightness ^= 3;

  if (!this->is_four_bit_mode())
    display_function |= LCD_DISPLAY_FUNCTION_8_BIT_MODE;

  if (this->rows_ > 1)
    display_function |= LCD_DISPLAY_FUNCTION_2_LINE;

  this->command_(display_function | brightness);
}

Usage example:

display:
  - platform: lcd_pcf8574
    id: vfd
    dimensions: 20x4
    address: 0x27
    update_interval: 4s
...
sun:
  latitude: xx
  longitude: yy
  on_sunrise:
    - then:
        - logger.log: Good morning!
        - lambda: |-
            id(vfd).set_brightness(3);
  on_sunset:
    - then:
        - logger.log: Good evening!
        - lambda: |-
            id(vfd).set_brightness(0);

I would appreciate it if you could add this type of display to the library in future updates.

Who is ‘you’ in your last sentence. If you want to get your changes (and this device) added to ESPHome, you have to create a Pull Request (PR). See Contributing — ESPHome.

I’m not smart enough to write the complete library code. But I suspect that the choice of model can be made by analogy with the ssd1306_base.h library