-
Notifications
You must be signed in to change notification settings - Fork 944
Issue #370 fix #418
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
base: develop
Are you sure you want to change the base?
Issue #370 fix #418
Changes from 3 commits
de4ef55
0fbb30e
e6daba9
ddb810e
8e17b7b
5a72b25
2f08893
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,8 @@ | |
#define PIN_RESET 4 | ||
#define PIN_BL 5 | ||
|
||
#define SPI_POLARITY 0 // default to 0, some displays require polarity 1 | ||
|
||
#define SERIAL_CLK_DIV 1.f | ||
|
||
#ifndef M_PI | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be tabs vs 4 spaces? |
||
|
||
gpio_init(PIN_CS); | ||
gpio_init(PIN_DC); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be tabs vs 4 spaces? |
||
// and this is a cheesy way to get CPOL=1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment states -and this is a cheesy way to get CPOL=1
+and this is a cheesy way to set CPOL There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair |
||
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); | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.