Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for panel-controlled backlights #586

Open
tylercamp opened this issue Jul 4, 2024 · 0 comments
Open

Support for panel-controlled backlights #586

tylercamp opened this issue Jul 4, 2024 · 0 comments
Labels
enhancement New feature or request pinned exempt from stale bot

Comments

@tylercamp
Copy link
Sponsor

(Moved from #583 )

Some panels, i.e. SSD1963, come with built-in backlight control which require device-specific commands to manage.

Currently there isn't any ILight implementation which supports this.


For SSD1963 specifically, these commands are needed for backlight control:

  void Set_1963_PWM(uint8_t value)
  {
    startWrite();
    writeCommand16(0xBE);
    _bus_instance.flush();

    writeData( 0x05 );
    writeData( value );
    writeData( 0x01 );
    writeData( 0xFF );
    writeData( 0x00 );
    writeData( 0x00 );

    endWrite();
  }

Since this type of backlight control is specific to the particular Panel_LCD, I wonder if any of these minor refactors would be appropriate:

// additional class to be mixed in when appropriate and manually called by the user if needed
class IPanel_LCD_InteractiveBacklight {
   // (1) panel is capable of creating an ILight instance which references this panel for commands
   virtual ILight* createLight() = 0;
   
   // ... or ...
   
   // (2) panel directly exposes a `setBrightness`, and a new `Light_InteractivePanel` class
   //       would simply defer to this
   virtual void setBrightness(...) = 0;
};

// ... or ...

class Panel_SSD1963 {
public:
   // (3) panel defines its own `ILight` impl to be explicitly created by the user and assigned to `LGFX_Device`
   class Light : ILight { ... };
};

// ... or ...
class Panel_Device {

   // ...
   
   // (4) all panels may directly offer a `ILight`; panels like SSD1963 will always have backlight control
   //
   // if no `ILight` was specifically assigned to `LGFX_Device`, then it would defer to 
   // the panel
   virtual ILight* getLight() { return nullptr; };
   
   // ...
};

(2) seems most in line with current LGFX patterns

@tylercamp tylercamp added the enhancement New feature or request label Jul 4, 2024
@tobozo tobozo added the pinned exempt from stale bot label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pinned exempt from stale bot
Projects
None yet
Development

No branches or pull requests

2 participants