Skip to content

feat(lcd): ST7796 Add Sleep command support (BSP-780)#719

Open
AndreaGreco wants to merge 1 commit intoespressif:masterfrom
AndreaGreco:master
Open

feat(lcd): ST7796 Add Sleep command support (BSP-780)#719
AndreaGreco wants to merge 1 commit intoespressif:masterfrom
AndreaGreco:master

Conversation

@AndreaGreco
Copy link
Copy Markdown

@AndreaGreco AndreaGreco commented Jan 30, 2026

ST7796 Add Sleep command support

Add Sleep command support to ST7796


Note

Low Risk
Low risk: adds a new disp_sleep panel op that sends standard ST7796 sleep in/out commands with a datasheet-required delay; existing init/draw logic is unchanged.

Overview
Adds ST7796 sleep mode support by wiring up the disp_sleep panel operation for both the general and MIPI variants.

Implements panel_st7796_disp_sleep() to send LCD_CMD_SLPIN/LCD_CMD_SLPOUT and enforce a 120ms post-command delay per the datasheet.

Written by Cursor Bugbot for commit 34fc586. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings January 30, 2026 18:57
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jan 30, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds sleep command support (SLPIN/SLPOUT) to the ST7796 LCD driver's general (non-MIPI) variant. The feature allows entering and exiting sleep mode, which is useful for power management in LCD applications.

Changes:

  • Added panel_st7796_disp_sleep() function declaration and implementation
  • Assigned the sleep function pointer in the panel initialization code

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions bot changed the title feat(lcd): ST7796 Add Sleep command support feat(lcd): ST7796 Add Sleep command support (BSP-780) Jan 30, 2026
@AndreaGreco AndreaGreco force-pushed the master branch 2 times, most recently from 46d045b to ccf24d4 Compare February 2, 2026 22:46
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.


static esp_err_t panel_st7796_disp_sleep(esp_lcd_panel_t *panel, bool sleep)
{
st7796_panel_t *st7796 = __containerof(panel, st7796_panel_t, base);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong struct access pattern causes undefined behavior

High Severity

The panel_st7796_disp_sleep function in the MIPI file uses __containerof(panel, st7796_panel_t, base) to access the panel structure, but the MIPI version's st7796_panel_t struct doesn't have a base member. All other functions in this file correctly use (st7796_panel_t *)panel->user_data instead. Using __containerof with a non-existent member will result in undefined behavior and likely memory corruption or crash when the function is called.

Fix in Cursor Fix in Web

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


static esp_err_t panel_st7796_disp_sleep(esp_lcd_panel_t *panel, bool sleep)
{
st7796_panel_t *st7796 = __containerof(panel, st7796_panel_t, base);
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect use of __containerof. The st7796_panel_t struct in this file does not have a 'base' member. The correct way to retrieve the st7796 pointer is: (st7796_panel_t *)panel->user_data, as used in all other functions in this file (see lines 315, 270, 287, 250). The __containerof pattern is only correct in the general variant where st7796_panel_t has 'esp_lcd_panel_t base' as its first member.

Suggested change
st7796_panel_t *st7796 = __containerof(panel, st7796_panel_t, base);
st7796_panel_t *st7796 = (st7796_panel_t *)panel->user_data;

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndreaGreco Please, could you apply this suggestion?

Copy link
Copy Markdown
Collaborator

@espzav espzav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndreaGreco Thank you for this PR. LGTM - I left one comment


static esp_err_t panel_st7796_disp_sleep(esp_lcd_panel_t *panel, bool sleep)
{
st7796_panel_t *st7796 = __containerof(panel, st7796_panel_t, base);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndreaGreco Please, could you apply this suggestion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants