Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ firmware by yourself.
ESP8266, ESP32, and STM32 ports are supported for now.


Connecting to the Raspberry Pi Pico
----------------------------------
This repository is a fork of
[https://github.com/devbis/st7789_mpy/](https://github.com/devbis/st7789_mpy/)
focused on the [Raspberry Pi Pico](https://www.raspberrypi.org/products/raspberry-pi-pico/).

Here is a firmware for the rp2040 with the st7789 module:
[rp2-st7789-20210412.uf2](https://github.com/udifuchs/st7789_mpy/releases/download/rp2-20210412/rp2-st7789-20210412.uf2). It is based on the github version of MicroPython from 2021-04-12.

Here is a sample wiring for connecting the [Adafruit 1.3 LCD display](https://learn.adafruit.com/adafruit-1-3-and-1-54-240-x-240-wide-angle-tft-lcd-displays) to the Raspberry PI Pico:
<p align="center">
<img src="adafruit-1.3-display_bb.png" alt="adafruit 1.3 inch display"/>
</p>
(the source [fritzing]() file is [here](adafruit-1.3-display.fzz).)
The "Lite" pin is not connected to make it fit on a mini breadboard.

Building instruction
---------------------

Expand All @@ -42,6 +58,15 @@ And then compile the module with specified USER_C_MODULES dir
$ make USER_C_MODULES=../../../st7789_mpy/ all


For rp2040 (requires micropython 1.15):

$ cd micropython/ports/rp2

And then compile the module with specified USER_C_MODULES dir

$ make USER_C_MODULES=../../../st7789_mpy/st7789/micropython.cmake all


If you have other user modules, copy the st7789_driver/st7789 to
the user modules directory

Expand Down Expand Up @@ -102,6 +127,19 @@ Also, the driver was tested on STM32 board:
display = st7789.ST7789(spi, 135, 240, reset=machine.Pin('B3', machine.Pin.OUT), dc=machine.Pin('B6', machine.Pin.OUT))
display.init()

For the rp2040 with the wiring shown above use:

import machine
import st7789

spi = machine.SPI(1, baudrate=500_000_000, polarity=1)
display = st7789.ST7789(
spi, 240, 240,
reset=machine.Pin(15, machine.Pin.OUT),
dc=machine.Pin(14, machine.Pin.OUT),
cs=machine.Pin(13, machine.Pin.OUT),
)
display.init()

Methods
-------------
Expand Down
Binary file added adafruit-1.3-display.fzz
Binary file not shown.
Binary file added adafruit-1.3-display_bb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions st7789/micropython.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
add_library(usermod_st7789 INTERFACE)

target_sources(usermod_st7789 INTERFACE
${CMAKE_CURRENT_LIST_DIR}/st7789.c
)

target_include_directories(usermod_st7789 INTERFACE
${CMAKE_CURRENT_LIST_DIR}
)

target_link_libraries(usermod INTERFACE usermod_st7789)
2 changes: 1 addition & 1 deletion st7789/micropython.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ ST7789_MOD_DIR := $(USERMOD_DIR)
SRC_USERMOD += $(addprefix $(ST7789_MOD_DIR)/, \
st7789.c \
)
CFLAGS_USERMOD += -I$(ST7789_MOD_DIR) -DMODULE_ST7789_ENABLED=1
CFLAGS_USERMOD += -I$(ST7789_MOD_DIR)
# CFLAGS_USERMOD += -DEXPOSE_EXTRA_METHODS=1
2 changes: 1 addition & 1 deletion st7789/st7789.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,4 +663,4 @@ const mp_obj_module_t mp_module_st7789 = {
.globals = (mp_obj_dict_t*)&mp_module_st7789_globals,
};

MP_REGISTER_MODULE(MP_QSTR_st7789, mp_module_st7789, MODULE_ST7789_ENABLED);
MP_REGISTER_MODULE(MP_QSTR_st7789, mp_module_st7789, 1);