Skip to content

drivers: display: Introduce ST7565R #91320

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

giyorah
Copy link

@giyorah giyorah commented Jun 9, 2025

Introduce support for Sitronix's ST7565R display controller.
Tested on JHD12864 LCD display.

Copy link
Contributor

@JarmouniA JarmouniA left a comment

Choose a reason for hiding this comment

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

A node is needed in tests/drivers/build_all/display/app.overlay to build controller code in CI.

* Copyright (c) 2025 Giyora Haroon
*
* This controller supports 8-bit parallel and 4-line SPI interfaces.
* This implementation covers the SPI interface.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed in the comment


/* Configure data_cmd pin if specified */
if (config->data_cmd.port &&
gpio_pin_configure_dt(&config->data_cmd, GPIO_OUTPUT_INACTIVE) < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Combine those statement with the previous one

{
const struct st7565r_config *config = dev->config;
uint8_t zero_buf[config->width];
memset(zero_buf, 0, sizeof(zero_buf));
Copy link
Contributor

Choose a reason for hiding this comment

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

can be combined with previous statement = {0}

Copy link
Author

Choose a reason for hiding this comment

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

Width does come from a static value in the devicetree. However, since config->width is a runtime value, zero_buf is considered a variable length array, which can't be initialized with = {0}. I'll have to stick with the memset call here.

Copy link
Member

@henrikbrixandersen henrikbrixandersen left a comment

Choose a reason for hiding this comment

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

Review comments needs to be resolved, not just marked as resolved.

Copy link

@JarmouniA JarmouniA dismissed their stale review June 13, 2025 08:58

addressed

*/

#ifndef ST7565R_H
#define ST7565R_H
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs full path for uniqueness reasons -- check other headers for the convention to follow

Copy link
Author

Choose a reason for hiding this comment

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

I see two different conventions (1 from ssd1306_regs, 2 from display_st7735r):

  1. DISPLAY_ST7565R_H
  2. ST7565R_DISPLAY_DRIVER_H__

Which one should it be?

Copy link
Contributor

@JarmouniA JarmouniA Jun 16, 2025

Choose a reason for hiding this comment

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

_ZEPHYR_DRIVERS_DISPLAY_ST565R_H_

uint8_t zero_buf[ST7565R_MAX_WIDTH] = {0};
uint8_t col_cmds[2] = {ST7565R_SET_HIGHER_COL_ADDRESS_CMD,
ST7565R_SET_LOWER_COL_ADDRESS_CMD};
const uint8_t num_pages = (config->height + 7) / 8;
Copy link
Contributor

@kartben kartben Jun 13, 2025

Choose a reason for hiding this comment

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

You might want to set ST7565R_MAX_HEIGHT to 64 or carefully review how you're handling the special "COMS" case.
I don't think the 65th line is meant to be used for displayable pixels anyway. This comment applies to multiple other places in the driver where you're treating page 8 improperly.

Datasheet says:

Page address 8 (D3, D2, D1, D0 = 1, 0, 0, 0) is a special RAM for icons, and only display data D0 is used.

Copy link
Author

Choose a reason for hiding this comment

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

You are correct. Is setting ST7565R_MAX_HEIGHT to 64 acceptable? Maybe someone can add support for "COMS" in the future (my display doesn't support it).

Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines 351 to 357
if (pf == PIXEL_FORMAT_MONO10) { /* 1=black, 0=white */
cmd = ST7565R_SET_REVERSE_DISPLAY;
} else if (pf == PIXEL_FORMAT_MONO01) { /* 0=black, 1=white */
cmd = ST7565R_SET_NORMAL_DISPLAY;
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

you have this backwards AFAICT (fix everywhere)

image

Copy link
Author

@giyorah giyorah Jul 12, 2025

Choose a reason for hiding this comment

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

Tested this again. My code correctly reflects the following "RAM -> LCD" mode:

image

Edit: I'm not sure what's going on, will debug more when I get a chance.

Edit 2: there was a bug in cfb, addressed lately in Cfb fixes #85893. My ncs workspace did not include this fix, and that was the issue. Working as expected now

@henrikbrixandersen henrikbrixandersen dismissed their stale review June 18, 2025 09:59

GENMASK() review comment addressed.

Introduce support for Sitronix's ST7565R display controller.
Tested on JHD12864 LCD display.

Signed-off-by: Giyora Haroon <dev@giyorah.com>
Copy link

@giyorah giyorah requested a review from kartben July 17, 2025 20:44
@kartben kartben dismissed their stale review July 22, 2025 12:06

i believe my comments to date have been addressed - thanks!

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

Successfully merging this pull request may close these issues.

5 participants