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

Issue #370 fix #418

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open

Issue #370 fix #418

wants to merge 7 commits into from

Conversation

mkerna
Copy link

@mkerna mkerna commented Aug 31, 2023

This fixes issue #370. Some displays will require changing #define SPI_POLARITY to 1.

Fixes issue 370.  Change #define SPI_POLARITY to 1 for displays that need it.
Fixes issue 370.  Allows change to polarity.
@@ -90,7 +92,7 @@ int main() {
PIO pio = pio0;
uint sm = 0;
uint offset = pio_add_program(pio, &st7789_lcd_program);
st7789_lcd_program_init(pio, sm, offset, PIN_DIN, PIN_CLK, SERIAL_CLK_DIV);
st7789_lcd_program_init(pio, sm, offset, SPI_POLARITY, PIN_DIN, PIN_CLK, SERIAL_CLK_DIV);
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be tabs vs 4 spaces?

@@ -33,6 +33,11 @@ static inline void st7789_lcd_program_init(PIO pio, uint sm, uint offset, uint d
sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX);
sm_config_set_clkdiv(&c, clk_div);
sm_config_set_out_shift(&c, false, true, 8);

// The pin muxes can be configured to invert the output (among other things
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be tabs vs 4 spaces?

@@ -33,6 +33,11 @@ static inline void st7789_lcd_program_init(PIO pio, uint sm, uint offset, uint d
sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX);
sm_config_set_clkdiv(&c, clk_div);
sm_config_set_out_shift(&c, false, true, 8);

// The pin muxes can be configured to invert the output (among other things
// and this is a cheesy way to get CPOL=1
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment states CPOL=1 whereas that is actually CPOL=cpol. Perhaps could change to

-and this is a cheesy way to get CPOL=1
+and this is a cheesy way to set CPOL

Copy link
Author

Choose a reason for hiding this comment

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

True. But I took that comment directly from code already in the repo. I think it means that it's a cheesy way to get inverted polarity (i.e. CPOL=1, vs. CPOL=0).

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair

@mkerna
Copy link
Author

mkerna commented Sep 1, 2023

I made the changes.

pio/st7789_lcd/st7789_lcd.c Outdated Show resolved Hide resolved
@@ -33,6 +33,11 @@ static inline void st7789_lcd_program_init(PIO pio, uint sm, uint offset, uint d
sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX);
sm_config_set_clkdiv(&c, clk_div);
sm_config_set_out_shift(&c, false, true, 8);

// The pin muxes can be configured to invert the output (among other things
Copy link
Contributor

Choose a reason for hiding this comment

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

It appears to me that the closing paren must've been omitted:

-// The pin muxes can be configured to invert the output (among other things
+// The pin muxes can be configured to invert the output (among other things),

Copy link
Author

Choose a reason for hiding this comment

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

This was changed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for your help! I have no merging powers vested in me :) From my experience, the repo maintainers approved and merged after quite some time, before releasing the new SDK version.

@techrah
Copy link

techrah commented Feb 19, 2024

Thanks for this fix. Wiring up the CS pin did not work for me but this did.

@marcoswada
Copy link

Thanks for the fix. This worked for me as well.

Copy link

@marcoswada marcoswada left a comment

Choose a reason for hiding this comment

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

Tested on my hardware and the fix solved the polarity problem.

@m93a
Copy link

m93a commented May 22, 2024

I have a 240x240 display with a ST7789 driver with no CS pin, for which the current PIO example doesn't work. This PR with SPI_POLARITY set to 1 works flawlessly.

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.

None yet

6 participants