Skip to main content

ESP32-S3-LCD-1.28 Working with MicroPython

MicroPython Getting Started​

New to ESP32 MicroPython development and looking for a quick start? We have prepared a comprehensive ESP32 MicroPython Getting Started Tutorial for you.

Note: This tutorial uses the ESP32-S3-Zero as a teaching example, and all hardware code is based on its pinout. Before proceeding, we recommend checking the pinout diagram of your specific development board to ensure the pin configuration is correct.

Setting Up the Development Environment​

1. Configure Thonny and Flash MicroPython Firmware​

2. Additional Tips​

  • The development board currently uses custom firmware for development. The firmware is available in the ESP32-S3-LCD-1.28 Example. The firmware is merged into a single file. Note that the download address is the 0x00 position.

  • Firmware path:

    ...\ESP32-S3-LCD-1.28-Demo\Firmware\MicroPython-bin
  • If flashing the MicroPython firmware using the Espressif Flash Download Tool, the flashing address is 0x0.

  • The bin file in the factory-bin folder is for testing onboard functions and does not need to be flashed here.

  • The MicroPython firmware is produced from this link. For more learning resources on MicroPython firmware compilation.

Thonny Usage Instructions​

If you are just getting started with ESP32 and Thonny and don't yet know how to use Thonny, expand this section. Hope it can help you!

Selecting the Development Board and Model​

  • After downloading and installing the latest Thonny IDE, open Thonny IDE -> Configure interpreter..., as shown below:
    ESP32-S3-Touch 1
    ESP32-S3-Touch 1
  • Select ESP32 and select the corresponding COM port.
    ESP32-S3-Touch 1
  • Click this button. If you see output statements in the shell, the development board firmware is working successfully.
    ESP32-S3-Touch 1

Uploading Examples​

The following uses the "ESP32-S3-Touch_1.28" example as an example. If you use other examples, follow the same steps.

  • How to find the example you want. If the files column is not initially visible, you can find it under View.
    ESP32-S3-Touch 1
    ESP32-S3-Touch 1
  • To upload local files to the development board, select the file, right-click, and find "upload to/" to download.
    ESP32-S3-Touch 1
  • The following is the interface after all uploads are complete. The downloaded files must match the files in the red box; otherwise, it may fail to run.
    ESP32-S3-Touch 1
  • Select the file with the .py extension and click the green button to flash and run.
    ESP32-S3-Touch 1
  • Before running another file, click the red stop button first so that the other file can run properly.
    ESP32-S3-Touch 1

Example​

Demo-flow-02

ESP32-S3-LCD-1.28 Example

ExampleBasic Description
alien.pyRandomly displays the "alien.jpg" image
bitarray.pyCreates and displays multiple "Pac-Man" sprite animations at random positions
hello.pyRandomly displays "Hello!" text in different colors and can cycle through different rotation angles
hershey.pyCycles through different greetings
jpg.pyAlternately displays two JPEG images
noto_fonts.pyDisplays the names of three different fonts
pbitmap.pyDisplays a precompiled bitmap image
rotation.pyCycles through text display effects at different rotation values
scroll.pyImplements smooth scrolling of characters on the display

Uploading Examples and Special Examples​

Uploading Examples​

  • To upload local files to the development board, select the file, right-click, and find "upload to/" to download.

    ESP32-S3-LCD-1.28

  • The following is the interface after all downloads are complete. The downloaded files must match the files in the red box; otherwise, it may fail to run.

    ESP32-S3-LCD-1.28

  • Select the file with the .py extension and click the green button to flash and run (the running image is shown later).
    ESP32-S3-LCD-1.28

  • Before running another file, click the red stop button first so that the other file can run properly.
    ESP32-S3-LCD-1.28

Special Examples​

  • Among the provided examples, boot.py is an automatically generated blank file, and bluenarble.py stores an image. Running them shows no visible effect.
    ESP32-S3-LCD-1.28

alien.py​

Example Description

  • This example randomly displays the "alien.jpg" image on a specific display.

Hardware Connection

  • Connect the development board to the computer.

ESP32-S3-LCD-1.28

Code Analysis

  • GC9A01(): The importance of the GC9A01 constructor is that it establishes the hardware connection, sets initial parameters, and creates an operable display object, laying the foundation for subsequent display operations.
    • spi_interface: Establishes SPI communication with the display.
    • width and height: Sets the display resolution.
    • reset_pin: Connects the various control pins of the display.
    • rotation: Sets the initial rotation angle.

Expected Behavior

  • LCD screen display

ESP32-S3-Touch 1

bitarray.py​

Example Description

  • This example creates and displays multiple "Pac-Man" sprite animations at random positions on a specific display.

Hardware Connection

  • Connect the development board to the computer.

Code Analysis

  • move method of the pacman class: Responsible for updating the state of the "Pac-Man" sprite, implementing its movement and animation on the screen.

    • First, it increments the sprite's current step count, then uses modulo operation to ensure the step cycles within the defined SPRITE_STEPS range, corresponding to different animation frames or states of the sprite.
    • Then it moves the sprite horizontally. When the sprite's horizontal position reaches a specific value of 302, it resets the step count to trigger a specific animation state or behavior. Finally, a modulo operation ensures the sprite's horizontal position cycles within a certain range to avoid exceeding the display area.
  • tft.map_bitarray_to_rgb565

    • The tft.map_bitarray_to_rgb565 function selects bitmap data from SPRITE_BITMAPS based on the sprite's current step count and converts it into an RGB565 format buffer sprite. It also specifies the sprite's width, foreground color, and background color
  • tft.blit_buffer

    • The tft.blit_buffer function draws the converted buffer onto a specific position on the display, determined by the sprite's current coordinates, and specifies the sprite's width and height.

Expected Behavior

  • LCD screen display

ESP32-S3-Touch 1

hello.py​

Example Description

  • This example randomly displays "Hello!" text in different colors on a specific display and can cycle through different rotation angles.

Hardware Connection

  • Connect the development board to the computer.

Code Analysis

  • tft.text: Draws the text "Hello!" on the display.

    • It uses a specified font, with the text position determined randomly within the display range, and the foreground and background colors determined by randomly generated RGB565 color values.
  • while True: Implements the dynamic effect of randomly displaying "Hello!" text at different rotation angles.

    • Through an infinite loop and iterating through four rotation angles, it sets the display rotation angle, clears the screen, calculates the text display range, and repeatedly calls the tft.text function to display the text at random positions with random colors.

Expected Behavior

  • LCD screen display

ESP32-S3-Touch 1

hershey.py​

Example Description

  • The example cycles through different greetings on a specific display.

Hardware Connection

  • Connect the development board to the computer.

Code Analysis

  • main: The loop portion of the function cycles through different fonts, colors, and greetings on the display.

    • It moves the display position line by line, gets the next color, font, and greeting, clears the previous line's content and draws new content, resets the line position when it exceeds a certain range, and adds a delay to control the display speed.
  • cycle: Creates an iterable object.

    • It accepts parameters. If the parameter is iterable, it cycles directly; if it is a single element, it converts it to an iterable list and cycles through it. This is used to conveniently cycle through lists of colors, fonts, and greetings.

Expected Behavior

  • LCD screen display

ESP32-S3-Touch 1

jpg.py​

Example Description

  • This example displays two JPEG images alternately on a specific display

Hardware Connection

  • Connect the development board to the computer.

Code Analysis

  • main:

    • It iterates through the list of image filenames, calls the tft.jpg function to display the image at a specific position in a slower manner, and then waits 5 seconds.
  • tft.jpg: Displays the specified JPEG image on the display.

    • It reads and decodes the image file and draws it to the display, determining the display position and mode based on the passed parameters.

Expected Behavior

  • LCD screen display

ESP32-S3-Touch 1ESP32-S3-Touch 1

noto_fonts.py​

Example Description

  • The example displays the names of three different fonts (NotoSans, NotoSerif, NotoSansMono) on a specific display, centering the font names on different lines.

Hardware Connection

  • Connect the development board to the computer.

Code Analysis

  • main: The program entry point, initializes the display and shows three font names.

    • It creates and initializes the display object, fills the background with black, and calls the center function to display the three font names in sequence.
  • center: Centers the given string on the display with the specified font.

    • It gets the display width, calculates the string width. If it is less than the screen width, it calculates the coordinates for horizontal centering; otherwise, it left-aligns. Finally, it displays the string at the specified position.

Expected Behavior

  • LCD screen display

ESP32-S3-Touch 1

pbitmap.py​

Example Description

  • This example displays a precompiled bitmap image on a specific display.

Hardware Connection

  • Connect the development board to the computer.

Code Analysis

  • main: The program entry point, initializes the display and shows the bitmap.

    • It creates the display object, fills the background with black after initialization, and calls tft.pbitmap to display the image from the precompiled bitmap module.
  • tft.pbitmap: Displays a precompiled bitmap on the display.

    • It reads the bitmap data and draws it to the display, determining the display position based on the passed parameters.

Expected Behavior

  • LCD screen display

ESP32-S3-Touch 1

rotation.py​

Example Description

  • This example cycles through text display effects at different rotation values on a specific display.

Hardware Connection

  • Connect the development board to the computer.

Code Analysis

  • main: The program entry point, initializes the display and cycles through text effects at different rotation values.

    • It creates and initializes the display object, sets different rotation values in sequence within a loop, clears the screen, and displays text containing rotation value information for observation.
  • tft.rotation: Sets the display rotation angle.

    • It adjusts the display orientation based on the passed parameters.

Expected Behavior

  • LCD screen display

ESP32-S3-Touch 1

scroll.py​

Example Description

  • This example implements smooth scrolling of characters on a specific display.

Hardware Connection

  • Connect the development board to the computer.

Code Analysis

  • main: The program entry point, initializes the display, sets colors, and scrolls characters.

    • It creates the display object, sets up a color generator to get foreground colors, initializes the display and sets the scroll area, clears the top row in a loop, displays characters in a new row and updates the color and character values, and implements scrolling by setting the scroll address while controlling the speed.
  • cycle: Creates an iterable object.

    • It accepts parameters. If the parameter is iterable, it cycles directly; if it is a single element, it converts it to an iterable list and cycles through it.

Expected Behavior

  • LCD screen display

ESP32-S3-Touch 1