Posts

Showing posts from November, 2024

my dev. board: Raspberry Pi Pico 2 W

Image
my dev. board: Raspberry Pi Pico 2 W Currently (24-11-30), there are no official firmware in micropython.org . You can download the preview version here . scroll down to download MicroPython UF2 for Pico 2 W (mp_firmware_unofficial_latest.uf2). As first test, I try to blink the onboard LED by following https://projects.raspberrypi.org/en/projects/getting-started-with-the-pico , but failed. Later, I found the reason: Refer to Raspberry Pi Pico 2 W Datasheet   and schematic , Pico 2 W (should be same as in Pico W) onboard LED is connected to CYW43439KUBG chip, not RP2350, so have to specially handled like this: led = machine.Pin("LED", machine.Pin.OUT) blink.py , MicroPython code to blink the onboard LED from machine import Pin, Timer led = machine.Pin("LED", machine.Pin.OUT) print("led:", led) timer = Timer() def blink(timer): led.toggle() timer.init(freq=2.5, mode=Timer.PERIODIC, callback=blink) while True: ...

Raspberry Pi Pico 2/CircuitPython 9 display bmp on ST7789 LCD using adafruit_imageload/adafruit_slideshow

Image
Previous post show how  Raspberry Pi Pico 2/CircuitPython 9 display on 1.54" 240x240 ST7789 SPI IPS . This post show two exercises to display bmp using adafruit_imageload/adafruit_slideshow. adafruit_imageload  decodes an image file into new bitmap and palette objects of the provided type. It’s designed to load code needed during decoding as needed. This is meant to minimize the memory overhead of the decoding code. adafruit_slideshow  CircuitPython helper library for displaying a slideshow of images on a display. Connection: Keep using the same connection in previous exercise . Test images: All the test images shown in the above video were AI generated using "Image Creator in Bing", and resize and convert to 240x240 RGBB888/RGB565 bmp using Python/GIMP . Exercise Code: cpy_pico2_st7789_imageload.py, display bmp using adafruit_imageload """ Raspberry Pi Pico 2/CircuitPython 9 to display on 1.54" 240x240 ST7789 SPI...

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  (tested work on Pico 2 W also) 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.releas...

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...