Posts

Showing posts with the label code.CircuitPython

CircuitPython BLU UART on Seeed Studio XIAO nRF52840/ESP32S3 Sense, connect to Raspberry Pi as Serial Console.

Image
Implement CircuitPython BLU UART on Seeed Studio XIAO nRF52840 Sense / XIAO ESP32S3 Sense running CircuitPython 9.2.7. Library needed: ~ adafruit_ble To install adafruit_ble on CircuitPython device using circup: circup install adafruit_ble Read " Install and using CircUp (CircuitPython library updater) to install CircuitPython libraries " for more about CircUp. Code: cpy_ble_uart.py """ Circuitpython 9.2.7 BLE exercise Run on XIAO nRF52840 Sense/ESP32S3 Sense Act as bridge between BLE UART and UART To make it run as standalone (without REPL connection), copy to CircuitPython device, name "code.py". """ import os, sys import time import board, busio import digitalio from adafruit_ble import BLERadio from adafruit_ble.advertising.standard import ProvideServicesAdvertisement from adafruit_ble.services.nordic import UARTService #------------------------ print("========================================...

CircuitPython on Pico 2 + Touch LCD, act as a HID mouse.

Image
Refer to the cpy_pico2_st7796_BusDisplay_FT6336.py exercise in last post " Use ST7796 SPI LCD on CircuitPython/Raspberry Pi Pico 2, by instancing BusDisplay object using custom init_sequence ", It simple read touch reported by adafruit_focaltouch and display a cursor on screen, no any actual function. In this exercise I will add a simple handler to detect touch action such as touch-down, touch-up, and touch-move, and finally report to PC as HID mouse function. Connection, refer to last post " Use ST7796 SPI LCD on CircuitPython/Raspberry Pi Pico 2, by instancing BusDisplay object using custom init_sequence ". To install libraries for following exercise using circup: circup install adafruit_display_text adafruit_focaltouch adafruit_hid adafruit_button Exercise Code: cpy_pico2_st7796_BusDisplay_FT6336_handler.py Before we report HID mouse function, we have to detect touch action touch-down, touch-up, and touch-move. In this code, a ...

Control onboard LED of Raspberry Pi Pico 2/2W using MicroPython/CircuitPython

Image
The onboard LED on Raspberry Pi Pico and Pico 2 is connected to GPIO25. On Pico W and Pico 2 W, it's connected to the wireless chip. Following are exercise to control the onboard LED using MicroPython/CircuitPython, tested on Pico 2 and Pico 2 W. mpy_rp2_led.py """ MicroPython on Raspberry Pi Pico 2/2W to control onboard LED """ import os, sys import time #import board #from digitalio import DigitalInOut, Direction sys_info_text = sys.implementation[0] + " " + os.uname()[3] +\ "\nrun on " + os.uname()[4] print("=======================================") print(sys_info_text) print("=======================================") led = machine.Pin("LED", machine.Pin.OUT) print("led:", led) # Control onboard led using led.on() and led.off() while True: led.on() time.sleep(0.5) led.off() time.sleep(0.5) """ # Toggle onboard led using led.togg...

Use ST7796 SPI LCD on CircuitPython/Raspberry Pi Pico 2, by instancing BusDisplay object using custom init_sequence.

Image
Currently, it's no ST7796 driver for CircuitPython. So I create ST7796 display by instancing object of busdisplay.BusDisplay with custom init_sequence(ST7796_INIT_SEQUENCE). Tested on WaveShare "3.5 inch 320×480 Capacitive Touch LCD", embedded with ST7796S driver chip and FT6336U capacitive touch control chip , with Raspberry Pi Pico 2 running CircuitPython 9.2.4. For the init_sequence, I reference the MicroPython demo of Working with Raspberry Pi Pico in WaveShare wiki , with a little bit modification. Exactly  ONE bit: (D6 MX/Column Address Order) on MADCTL (36h), to flip left/right. (refer ST7796S Datasheet ) In following exercises, various various function of the ST7796 display module was tested, include: - Display area, color test. (cpy_pico2_st7796_BusDisplay.py) - Touch function of FT6336U capacitive touch drive.(cpy_pico2_st7796_BusDisplay_FT6336.py). - display bmp image (from CIRCUITPY device/SD) using adafruit_imageload. (cpy_pi...

CircuitPython on my DIY Pico Cam: Raspberry Pi Pico 2 + OV5640 camera sensor

Image
CircuitPython 9.2.4 exercise run on  my DIY Pico Cam: Raspberry Pi Pico 2 + Waveshare OV5640 Camera Board, display on 240x240 ST7789 display/240x240 GC9A01 round display . cpy_pico2_cam.py """ Raspberry Pi Pico 2/CircuitPython 9.2.4 + Waveshare OV5640 Camera Board (adafruit_ov5640) + 1.54" 240x240 ST7789 SPI IPS (adafruit_st7789) or 1.28" 240x240 Round GC9A01 SPI IPS (gc9a01) CircuitPython Libraries Bundle for Version 9.x needed: (https://circuitpython.org/libraries) - adafruit_ov5640 folder - adafruit_st7789.mpy (optional for st7789 display) - gc9a01.mpy (optional for gc9a01 display) or install using circup: circup install adafruit_ov5640, adafruit_st7789, gc9a01 For Installing and using CircUp, read: https://coxxect.blogspot.com/2024/12/install-and-using-circup-circuitpython.html ref of adafruit_ov5640: https://docs.circuitpython.org/projects/ov5640/en/latest/ """ import sys, os import board import busio from displayio import ( ...

espcamera exercise on ESP32S3/CircuitPython 9 + ov5640 camera

Image
espcamera exercise on Seeed Studio XIAO ESP32S3 Sense /CircuitPython 9.2.3 + Third party ov5640 (5 megapixel) camera module (MF/Manual Focusing) , display on 1.28" 240x240 GC9A01 Round IPS LCD . Connection and library setup, refer to the post " Seeed Studio XIAO ESP32S3 Sense/CircuitPython display on 1.28" 240x240 GC9A01 Round IPS LCD ". cpy_XS3_espcamera.py """ Seeed Studio XIAO ESP32S3 Sense/CircuitPython 9.2.3 with 1.28" 240x240 Round GC9A01 SPI IPS LCD espcamera exercise to access camera Tested with: - default ov2640 in Seeed Studio XIAO ESP32S3 Sense - XIAO ov5640 Camera (Auto-Focusing) - Third party ov5640 camera sensor (MF/Manual Focusing) camera sensor (sensor_name) is auto-detected. Library needed: - gc9a01.mpy ref: https://docs.circuitpython.org/en/stable/shared-bindings/espcamera/ """ import os, sys import board import busio import gc9a01 import espcamera import displayio disp_res = board.D0 di...

download bmp via WiFi and display using OnDiskBitmap, running on ESP32S3/CircuitPython 9.

Image
Previous exercises post " Seeed Studio XIAO ESP32S3 Sense/CircuitPython display on 1.28" 240x240 GC9A01 Round IPS LCD " and " Display bmp with XIAO ESP32S3 Sense/CircuitPython on GC9A01 Round LCD using OnDiskBitmap, adafruit_imageload and adafruit_slideshow ". It's another exercise running on Seeed Studio XIAO ESP32S3 Sense/CircuitPython 9.2.1, to download bmp from Python http server via WiFi, save to local filesystem, and display on 1.28" 240x240 GC9A01 Round IPS LCD using OnDiskBitmap. Actually, it's ESP32S3 version of another previous exercise " Pico 2 W/CircuitPython download bmp via WiFi, and display using OnDiskBitmap ". Connection between XIAO ESP32S3 Sense and GC9A01 Round IPS LCD, refer to previous exercise " Seeed Studio XIAO ESP32S3 Sense/CircuitPython display on 1.28" 240x240 GC9A01 Round IPS LCD ". To run http server on using Python (tested in Windows 11/Python 3): > python -m ...

Display bmp with XIAO ESP32S3 Sense/CircuitPython on GC9A01 Round LCD using OnDiskBitmap, adafruit_imageload and adafruit_slideshow

Image
Previous exercise on " Seeed Studio XIAO ESP32S3 Sense/CircuitPython display on 1.28" 240x240 GC9A01 Round IPS LCD ", it's another exercise to display bmp using OnDiskBitmap, adafruit_imageload and adafruit_slideshow. Actually, it's ported from my previous exercises on Raspberry Pi Pico with 1.54" 240x240 ST7789 SPI IPS: ~  Raspberry Pi Pico 2/CircuitPython 9 display bmp on ST7789 LCD using adafruit_imageload/adafruit_slideshow ~  displayio.OnDiskBitmap on Pico 2 W/CircuitPython 9 Connection, same as in previous exercise . All testing images were generated using "Image Creator in Bing", not real. Converted to 240x240 RGB888/RGB565 using Python . The exercises need libraries gc9a01, adafruit_imageload and adafruit_slideshow. To install the libraries using circup: circup install gc9a01, adafruit_imageload, adafruit_slideshow To know how to install and use circup, read:  https://coxxect.blogspot.com/2024/12/inst...

Seeed Studio XIAO ESP32S3 Sense/CircuitPython display on 1.28" 240x240 GC9A01 Round IPS LCD

Image
This exercise run on  Seeed Studio XIAO ESP32S3 Sense running CircuitPython 9.2.1, to display on  1.28" 240x240 GC9A01 Round IPS LCD . Also exercises to run Turtle graphics on CircuitPython. Libraries (or modules) gc9a01, adafruit_display_text and adafruit_turtle are needed. In old approach, you can download them from  CircuitPython Libraries and copy to CircuitPython device manually. In this video, the libraries were installed using another approach CircUp. To install CircUp, read my previous post " Install and using CircUp (CircuitPython library updater) to install CircuitPython libraries ". If you use old approach to download manually, notice that gc9a01.mpy is in Community Bundle (circuitpython-community-bundle-...), not Adafruit Circuit Bundle (adafruit-circuitpython-bundle-...). Connection: Exercise Code: cpy_XS3_gc9a01_color.py , simple demo exercise with color test. """ Color test on Seeed Studio XIAO...