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
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pio/st7789_lcd/st7789_lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#define PIN_RESET 4
#define PIN_BL 5

#define SPI_POLARITY 0 // default to 0, some displays require polarity 1
lurch marked this conversation as resolved.
Show resolved Hide resolved

#define SERIAL_CLK_DIV 1.f

#ifndef M_PI
Expand Down Expand Up @@ -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);

gpio_init(PIN_CS);
gpio_init(PIN_DC);
Expand Down
7 changes: 6 additions & 1 deletion pio/st7789_lcd/st7789_lcd.pio
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// but we are using a threshold of 8 here (consume 1 byte from each FIFO entry
// and discard the remainder) to make things easier for software on the other side

static inline void st7789_lcd_program_init(PIO pio, uint sm, uint offset, uint data_pin, uint clk_pin, float clk_div) {
static inline void st7789_lcd_program_init(PIO pio, uint sm, uint offset, bool cpol, uint data_pin, uint clk_pin, float clk_div) {
pio_gpio_init(pio, data_pin);
pio_gpio_init(pio, clk_pin);
pio_sm_set_consecutive_pindirs(pio, sm, data_pin, 1, true);
Expand All @@ -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.

// and this is a cheesy way to allow changing polarity
gpio_set_outover(clk_pin, cpol ? GPIO_OVERRIDE_INVERT : GPIO_OVERRIDE_NORMAL);

pio_sm_init(pio, sm, offset, &c);
pio_sm_set_enabled(pio, sm, true);
}
Expand Down