# CircuitPython with Pico 2 W

**URL:** <https://forum.clockworkpi.com/t/circuitpython-with-pico-2-w/16394>\
**Category:** PicoCalc\
**Tags:** firmware\
**Created:** [March 30, 2025, 10:10am UTC](https://forum.clockworkpi.com/t/circuitpython-with-pico-2-w/16394 "2025-03-30T10:10:09Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![lou\_filerman](https://avatars.discourse-cdn.com/v4/letter/l/c5a1d2/32.png) [@lou\_filerman](https://forum.clockworkpi.com/u/lou_filerman)\
**Post date:** [April 4, 2025, 5:22pm UTC](https://forum.clockworkpi.com/t/circuitpython-with-pico-2-w/16394/17 "2025-04-04T17:22:26Z")

</div>

I keep coming back to circuitpython thinking some feature or convenience will be an improvement over micropython, and finding while some particular thing is easier something else gets harder or I hit a wall doing something I can already do in micropython. The web workflow tools in circuitpython are functional, but the serial console (the local version, not their hosted web tools) sucks. Its a text box and a printout from the console, so you can issue a command but it gets janky fast. Whereas in the micropython webrepl, you are provided with a functional console.

My read on circuitpython so far is that a lot of the benefit is around helper functions for Adafruit hardware and integration with GUI tools, neither of which are generally helpful to me. That said, Adafruit probably has a board that’s pin-compatible with the pi pico, and that might be a better experience for working with circuitpython.

```auto
# SPDX-FileCopyrightText: 2019 Scott Shawcroft for Adafruit Industries
#
# SPDX-License-Identifier: MIT

"""
`bagaloozy_ili9488`
====================================================

Display driver for ILI9488

* Author(s): Mark Winney

Implementation Notes
--------------------

**Hardware:**

* Buy Display LCD 3.5" 320x480 TFT Display Module,OPTL Touch Screen w/Breakout Board
  <https://www.buydisplay.com/lcd-3-5-inch-320x480-tft-display-module-optl-touch-screen-w-breakout-board>

**Software and Dependencies:**

* Adafruit CircuitPython firmware for the supported boards:
  https://github.com/adafruit/circuitpython/releases

"""
try:
    # used for typing only
    from typing import Any
except ImportError:
    pass

#import displayio
import busdisplay

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ILI9488.git"

_INIT_SEQUENCE = (
    b"\xE0\x0F\x00\x03\x09\x08\x16\x0A\x3F\x78\x4C\x09\x0A\x08\x16\x1A\x0F"
    b"\xE1\x0F\x00\x16\x19\x03\x0F\x05\x32\x45\x46\x04\x0E\x0D\x35\x37\x0F"
    b"\xC0\x02\x17\x15" # Power Control 1 Vreg1out Verg2out 
    b"\xC1\x01\x41" # Power Control 2 VGH,VGL
    b"\xC5\x03\x00\x12\x80" # Power Control 3 Vcom 
    b"\x36\x01\x48" # Memory Access 
    b"\x3A\x01\x55" # Interface Pixel Format 16 bit    
    b"\xB0\x01\x00" # Interface Mode Control
    b"\xB1\x01\xA0" # Frame rate 60Hz 
    b"\xB4\x01\x02" # Display Inversion Control 2-dot 
    b"\xB6\x00" # Display Function Control RGB/MCU Interface Control 
    b"\x02\x01\x02" # MCU Source,Gate scan direction 
    b"\xE9\x01\x00" # Set Image Function Disable 24 bit data
    b"\xF7\x04\xA9\x51\x2C\x82" # Adjust Control D7 stream, loose 
    b"\x11\x80\x78" # Sleep out delay 120ms
    b"\x29\x00" # Power on display
    b"\x21" # Set display colour to inverted
)

# pylint: disable=too-few-public-methods
class ILI9488(busdisplay.BusDisplay):
    """
    ILI9488 display driver

    :param fourwire.FourWire bus: bus that the display is connected to
    """

    def __init__ (self, bus: fourwire.FourWire, **kwargs: Any):
        super(). __init__ (bus, _INIT_SEQUENCE, **kwargs)

```

That is the modified ILI9488 driver. This is my code.py:

```auto
import board
import busio
import displayio
import terminalio
from fourwire import FourWire

from bagaloozy_ili9488 import ILI9488

# Release any resources currently in use for the displays
displayio.release_displays()

WIDTH = 320
HEIGHT = 320

tft_cs = board.GP13
tft_dc = board.GP14
tft_reset = board.GP15
spi_mosi = board.GP11
spi_clk = board.GP10
spi = busio.SPI(spi_clk, spi_mosi)

display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=tft_reset, baudrate=25000000)

display = ILI9488(
    display_bus,
    rotation=720,
    width=WIDTH,
    height=HEIGHT,
)

repl = displayio.CIRCUITPYTHON_TERMINAL
display.root_group = repl
palette = displayio.Palette(2)
palette[0] = 0x000000 # black background
palette[1] = 0x00ff00 # green text

repl[0].pixel_shader = palette
repl[2].pixel_shader = palette

```

The `repl` object here has 3 indices, I forget now but I think 0 was the TileGrid containing the repl and 2 was the top bar (ip, version, etc.). Might have those switched, but index 1 is a circuitpython logo sprite in the top left corner.

---

_[View the full topic](https://forum.clockworkpi.com/t/circuitpython-with-pico-2-w/16394)._
