Skip to content

Commit

Permalink
TFT display pins updated:
Browse files Browse the repository at this point in the history
  TFT_CS_PIN (6)
  TFT_RST_PIN (8)
  TFT_DC_PIN (10)
  TFT_DATA_PIN (12)
  TFT_CLK_PIN (13)
  TFT_LED_PIN (9)
  • Loading branch information
xrip committed Jan 11, 2024
1 parent d2149bf commit 9e47cee
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 27 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE
#BUILD_IN_GAMES

#TFT
TFT_CS_PIN=6
TFT_RST_PIN=8
TFT_DC_PIN=10
TFT_DATA_PIN=12
TFT_CLK_PIN=13
TFT_LED_PIN=9
)

pico_add_extra_outputs(${PROJECT_NAME})
30 changes: 15 additions & 15 deletions drivers/st7789/st7789.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static const uint8_t init_seq[] = {

static inline void lcd_set_dc_cs(const bool dc, const bool cs) {
sleep_us(5);
gpio_put_masked((1u << PIN_DC) | (1u << PIN_CS), !!dc << PIN_DC | !!cs << PIN_CS);
gpio_put_masked((1u << TFT_DC_PIN) | (1u << TFT_CS_PIN), !!dc << TFT_DC_PIN | !!cs << TFT_CS_PIN);
sleep_us(5);
}

Expand Down Expand Up @@ -117,21 +117,21 @@ static inline void start_pixels() {
void graphics_init() {
const uint offset = pio_add_program(pio, &st7789_lcd_program);
sm = pio_claim_unused_sm(pio, true);
st7789_lcd_program_init(pio, sm, offset, PIN_DIN, PIN_CLK, SERIAL_CLK_DIV);

gpio_init(PIN_CS);
gpio_init(PIN_DC);
gpio_init(PIN_RESET);
gpio_init(PIN_BL);
gpio_set_dir(PIN_CS, GPIO_OUT);
gpio_set_dir(PIN_DC, GPIO_OUT);
gpio_set_dir(PIN_RESET, GPIO_OUT);
gpio_set_dir(PIN_BL, GPIO_OUT);

gpio_put(PIN_CS, 1);
gpio_put(PIN_RESET, 1);
st7789_lcd_program_init(pio, sm, offset, TFT_DATA_PIN, TFT_CLK_PIN, SERIAL_CLK_DIV);

gpio_init(TFT_CS_PIN);
gpio_init(TFT_DC_PIN);
gpio_init(TFT_RST_PIN);
gpio_init(TFT_LED_PIN);
gpio_set_dir(TFT_CS_PIN, GPIO_OUT);
gpio_set_dir(TFT_DC_PIN, GPIO_OUT);
gpio_set_dir(TFT_RST_PIN, GPIO_OUT);
gpio_set_dir(TFT_LED_PIN, GPIO_OUT);

gpio_put(TFT_CS_PIN, 1);
gpio_put(TFT_RST_PIN, 1);
lcd_init(init_seq);
gpio_put(PIN_BL, 1);
gpio_put(TFT_LED_PIN, 1);
for (int i = 0; i < sizeof palette; i++ ) {
graphics_set_palette(i, 0x0000);
}
Expand Down
24 changes: 12 additions & 12 deletions drivers/st7789/st7789.h
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
#ifndef _ST7789_LCD_H_
#define _ST7789_LCD_H_

#ifndef PIN_RESET
#define PIN_RESET 6
#ifndef TFT_RST_PIN
#define TFT_RST_PIN 8
#endif


#ifndef PIN_CS
#define PIN_CS 7
#ifndef TFT_CS_PIN
#define TFT_CS_PIN 6
#endif


#ifndef PIN_BL
#define PIN_BL 8
#ifndef TFT_LED_PIN
#define TFT_LED_PIN 9
#endif


#ifndef PIN_CLK
#define PIN_CLK 10
#ifndef TFT_CLK_PIN
#define TFT_CLK_PIN 13
#endif

#ifndef PIN_DIN
#define PIN_DIN 11
#ifndef TFT_DATA_PIN
#define TFT_DATA_PIN 12
#endif

#ifndef PIN_DC
#define PIN_DC 13
#ifndef TFT_DC_PIN
#define TFT_DC_PIN 10
#endif

#define TEXTMODE_COLS 53
Expand Down

0 comments on commit 9e47cee

Please sign in to comment.