diff --git a/README.md b/README.md index f6d80b7..a2880a6 100644 --- a/README.md +++ b/README.md @@ -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: +

+ adafruit 1.3 inch display +

+(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 --------------------- @@ -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 @@ -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 ------------- diff --git a/adafruit-1.3-display.fzz b/adafruit-1.3-display.fzz new file mode 100644 index 0000000..6f127b1 Binary files /dev/null and b/adafruit-1.3-display.fzz differ diff --git a/adafruit-1.3-display_bb.png b/adafruit-1.3-display_bb.png new file mode 100644 index 0000000..ff9992b Binary files /dev/null and b/adafruit-1.3-display_bb.png differ diff --git a/st7789/micropython.cmake b/st7789/micropython.cmake new file mode 100644 index 0000000..3074c69 --- /dev/null +++ b/st7789/micropython.cmake @@ -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) diff --git a/st7789/micropython.mk b/st7789/micropython.mk index 79dda11..7f1a9ec 100644 --- a/st7789/micropython.mk +++ b/st7789/micropython.mk @@ -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 diff --git a/st7789/st7789.c b/st7789/st7789.c index 10e451c..1eb78a9 100644 --- a/st7789/st7789.c +++ b/st7789/st7789.c @@ -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);