Posts

Raspberry Pi Pico 2/CircuitPython 9 display on 1.54" 240x240 ST7789 SPI IPS

Image
CircuitPython 9.2.0 run on Raspberry Pi Pico 2 to display on 1.54" 240x240 ST7789 SPI IPS . Connection: Code: cpy_pico2_st7789.py , with color test and scrolling text. """ Raspberry Pi Pico 2/CircuitPython 9 to display on 1.54" 240x240 ST7789 SPI IPS Connection: ----------- GND GND VCC 3V3 SCL GP18 SDA GP19 RES GP20 DC GP21 CS GP17 BLK GP22 CircuitPython Libraries Bundle for Version 9.x needed: (https://circuitpython.org/libraries) - adafruit_st7789.mpy - adafruit_display_text folder """ import os, sys import microcontroller import board import busio import displayio import terminalio import adafruit_st7789 from adafruit_display_text import label import time disp_sck = board.GP18 disp_mosi = board.GP19 disp_res = board.GP20 disp_dc = board.GP21 disp_cs = board.GP17 disp_blk = board.GP22 # Release any resources currently in use for the displays displayio.release_displays() disp_spi = busio

CircuitPython 9 on Raspberry Pi Pico 2 to get info

Image
Simple CircuitPython code run on  Raspberry Pi Pico 2 /CircuitPython 9 to get info and pin alias. cpy_pico2_info.py import os, sys import microcontroller import board print("====================================") print(sys.implementation[0], os.uname()[3], "\nrun on", os.uname()[4]) print("====================================") print() # List all the Available Names # ref: https://learn.adafruit.com/circuitpython-essentials/circuitpython-pins-and-modules#what-are-all-the-available-names-3082670 board_pins = [] for pin in dir(microcontroller.pin): if isinstance(getattr(microcontroller.pin, pin), microcontroller.Pin): pins = [] for alias in dir(board): if getattr(board, alias) is getattr(microcontroller.pin, pin): pins.append("board.{}".format(alias)) if len(pins) > 0: board_pins.append(" ".join(pins)) for pins in sorted(board_pins): print(pins) o

my display module: 4.0" 480x320 TFT SPI ST7796 with FT6336U Capacitive Touch

Image
Product Page: ~ LCD wiki - SKU: SKU: MSP4031

Raspberry Pi Pico 2/MicroPython display bmp images on 240x240 ST7789 SPI Display

Image
Previous exercise " Raspberry Pi Pico 2/MicroPython read bmp images and draw on ST7789 display pixel-by-pixel " is a slow approach. Because it draw in pixel-by-pixel, each involve a write sequency. But it help me understand bmp much more. Here is another approach, form a bytearray passing to st7789pt blit_buffer() method, such that the driver write the whole buffer in one sequency to improve the speed much more. For connection and installing st7789py_mpy on Raspberry Pi Pico 2/MicroPython, read: https://coxxect.blogspot.com/2024/10/raspberry-pi-pico-2micropython-display.html To prepare 240x240 RGB565/RGB888 bmp using Python or GIMP, read: https://coxxect.blogspot.com/2024/11/resize-jpg-and-convert-to-bmp-in-rgb888.html Exercise code: mpy_pico2_bmp_buffer.py """ Raspberry Pi Pico/MicroPython exercise to display on 1.54" IPS 240x240 with SPI ST7789 driver Read, decode bmp in /images/ directory, and disply on 240x240 SPI ST77

Resize jpg and convert to bmp in RGB888 and RGB565 mode, using Python/GIMP

Image
This video show how to resize jpg and convert to bmp in RGB888 and RGB565 mode, in two approach: - Using Python code - Using GIMP Approach 1 using Python: Tested on Python 3.13.0 with cv2 4.10.0 (OpenCV) installed, run on Python virtual environment/Windows 11. To create Python virtual environment in Windows 11, and install libraries, read  https://coxxect.blogspot.com/2024/10/create-python-virtual-environment-in.html . py_cv_batch_resize_RGB888.py """ Python/cv2 to resize all jpg in 'images' folder, and save to 'resized_images_rgb888' folder in RGB888 mode. This code was generated by Copilot mainly. Run on Windows 11/Python 3.13.0 in virtualenvironment, with OpebCV/cv2 installed. To create Python virtual environment in Windows 11, and libraries include OpenCV/cv2, ref: https://coxxect.blogspot.com/2024/10/create-python-virtual-environment-in.html """ import os import cv2 TARGET_WIDTH = 240 TARGET_HEIGHT = 240 def

Raspberry Pi Pico 2/MicroPython read bmp images and draw on ST7789 display pixel-by-pixel.

Image
Follow the former exercises of  Raspberry Pi Pico 2/MicroPython display on 1.54" 240x240 ST7789 SPI IPS and  Python code to read .bmp info from header (work on Desktop Python and MicroPython) , this exercise read bmp images, and draw on ST7789 display pixel-by-pixel. Exercise code: mpy_pico2_bmp.py """ Raspberry Pi Pico/MicroPython exercise to display on 1.54" IPS 240x240 with SPI ST7789 driver Pixel-by-Pixel Read, decode bmp in /images/ directory, and disply on 240x240 SPI ST7789 display. Target: - 240x240 RGB565 .bmp - 240x240 RGB888 .bmp ref: Using library: russhughes/st7789py_mpy https://github.com/russhughes/st7789py_mpy to install st7789py_mpy on Raspberry Pi Pico 2/MicroPython, https://coxxect.blogspot.com/2024/10/raspberry-pi-pico-2micropython-display.html to know more about bmp structure: https://coxxect.blogspot.com/2024/10/python-code-to-read-bmp-info-from.html to convert jpg to RGB565/RGB888 bmp using GIMP, read the

Python code to read .bmp info from header (work on Desktop Python and MicroPython)

Image
This exercise read header of bmp file to get information about the image, such as image width and height, number of bit per pixel, specially offset, such that we can get the bitmap image later. This help me understanding more about bmp file structure. For the BMP file format, I reference  https://en.wikipedia.org/wiki/BMP_file_format . Exercise Code: The Python code work on desktop Python and MicroPython, tested on: - Python 3.13.0 on Windows 11 - MicroPython v1.24.0 on Raspberry Pi Pico2 with RP2350 py_bmp_info.py """ Python/MicroPython exercise to read bmp file and get the bmp info, to understand the structure of bmp header. Work on both: - desktop Python (tested on Windows 11) .bmp image have to be save in 'images' directory under working directory. - MicroPython (tested on Raspberry Pi Pico2 with RP2350 running MicroPython v1.24.0 on 2024-10-25 ) .bmp files have to be saved in /images/ directory. To prepare the bmp using GIMP