Description

1. Environment & Components

Coding Environment Tested on: ROG Zephyrus M16 Intel Core i7-11800H 16GB RAM Windows 10 21H2 WSL2: Ubuntu 20.04.5 LTS Board: Pico4ML Sensors: build-in LCD (ST7735) build-in camera (hm01b0) LSM6DS33 Gryo IMU and Accel sensor Pico4ML Pico4ML is using RP2040 for the microprocessor, with an LCD screen drived by ST7735. Basically we are refering to the code to drive the camera and LCD display. LSM6DS33 6-DoF Accel + Gyro IMU The sensor is basically dirved by i2c.

2. Developing Overview

To start with, we are planning to implement a simple flappy bird game on the C platform, with one button to manipulate the flying of the bird. To achieve our plan, we first implemented the flappy bird game with microPython on the RP2040 chip. With the external LCD screen, we can successfully play this game with the python code. Then, the next step was to write up drives to transform the code into C and make it able to operate on the PICO4ML broad.

3. Challenge We Ran into

One major problem we met during our development was the fps frequency. In the first attempt that we launch the program, we ran the chip at its normal frequency. However, the calculation speed does not provide optimal performance for the game, it runs pretty slowly and the movement is obviously discrete. Thus, we overclocked the chip to improve its performance. Finally, the fps has been stabled to 15 frames per second, which seems much more smooth for a visual game.

4. Reflection on Our Design

The biggest mistake that we made in our project is that we didn’t realize that the PICO4ML broad has its own IMU sensor embedded on the chip; Thus, it is totally unnecessary for us to implement an external drive for an additional chip.

5. Advantage

The advantage of our project is that we have to implement a control-free strategy, that the player doesn’t need to use any button to play the game; all he or she need to do is to flip over the board, then we can start the game and play! In addition, the game has great completion, which means that the game has its way to attract people to continue playing: who does not want to control his or her cars to rush on a busy street?

6. PIO module

We are basically using pio to drive the i2c, just like what we do in Lab2b. This is a more reliable and faster way to estabilish communication between sensors and MCU. We modified the code in Lab 2b, by configuring the registers within the IMU chips, we successfully received the serial data in the test program on QT2040 broad; then we transplanted the function onto our PICO4ML broad. When we fully grasp how i2c works, we can use pio to simulate an identical i2c function.

7. Future Improvements

As a final project embryo, there is a lot we could improve to make the game more playable. For example, as we mentioned in the challenges sections, we can use external resources and pictures to replace the code-generated shape, to make the game more pretty. Also, we could implement more functions to the game. As an embedded program, we need also replace the communication protocol between LCD and the chip. Currently we are using GPIO to drive the spi protocol, which seems not fast enough and requires more operational effort; later we can also switch it to PIO ports, which could be faster and this would be beneficial for the performance of the program.

6. PIO module

We are basically using pio to drive the i2c, just like what we do in Lab2b. This is a more reliable and faster way to estabilish communication between sensors and MCU. We modified the code in Lab 2b, by configuring the registers within the IMU chips, we successfully received the serial data in the test program on QT2040 broad; then we transplanted the function onto our PICO4ML broad.

i2c

When we fully grasp how i2c works, we can use pio to simulate an identical i2c function. And also, we can find the promblems of the example of pio-i2c in pico-example.

i2cex

Initialization

pio

We are also trying to use PIO to simulate the SPI function used in driving ST7735. However, due to limited time, we did not make it.

In addition, after exploring the rp2040 for an entire semester along with numerous sensors and components, we realized that strong enough portability is an important part of embedded systems or embedded programming. And PIO module is just perfect for this possibility. For example, in the first lab, we are trying to drive the WS2812 LED. We first read the datasheet and figure out what is the working principle, and then we programmed the IO port to meet the requirements. Thus, if possible, we can drive all the devices only if we have the correct ‘rules’ by the PIO module.

Also, PIO can provide stimulation to the GPIO functions like I2C, and SPI. This is a more efficient and reliable way to establish this communication method. Also, when we are in the process of finding a simulation method, we are having a better understanding of the working principle of these communication methods.