[Resurrection of the dusty development board] DIY Allwinner V3s portable terminal screen adaptation, LVGL and various peripheral driver transplantation tutorials
[Copy link]
Last week’s article introduced a terminal device called V3S-PI that I DIY because I wanted to learn Linux.
《Back to 2004! I used Allwinner V3s to make a portable terminal with a cost of 100 yuan and functions comparable to MP4》
The hardware design part of the project is analyzed in detail. This article will focus on the software adaptation part of the project and select several peripheral functions with strong universality for introduction.
V3S-PI is a development board based on Allwinner V3s. The V3s chip contains a dedicated video engine to provide advanced multimedia applications and services. Screen, audio and other interfaces were reserved at the beginning of the development board design. The author added nearly 10 peripherals and functions to this development board: get weather, play music with headphones, 10M/100M Ethernet interface, connect to wifi, access SD card, adjust screen brightness, key control, external other devices, 1 to 4 USB HUB...
After adapting the screen and porting LVGL and various peripheral drivers , the development board has been transformed into a portable terminal with functions comparable to MP4.
2.4-inch LCD color screen adaptation
The LCD color screen uses the SPI interface to connect to the main control. Since the initialization codes of each screen are different, we only need to modify the code in the st7735r_pipe_enable function based on the original st7735r.c file.
- The software part uses TinyDRM, which is no longer a fixed frame rate refresh compared to traditional fbtft.
- The DRM architecture enables faster integration with new architecture programs.
The modified code refers to the following file, and the device tree configuration reference:
In addition to spi, you need to add a backlight node so that you can operate the backlight at the user level:
After successfully adapting to the screen, LVGL is ported, and a high refresh rate of 700 frames can be achieved when refreshing the FB layer.
How to get weather information using libcurl
In order to enrich the functionality, the author also implemented the function of obtaining weather information through the libcurl library, processed the obtained JSON data through the callback function, and used the lvgl library to display the weather information.
A callback function is needed here to parse the obtained weather information in JSON format. It first uses the cJSON library to parse the obtained data and find the corresponding weather information field.
Then use other functions to lock the thread to prevent multi-thread conflicts, and then use the relevant functions of the LVGL library to set the weather information to the corresponding label.
The get_now_weather function first defines a URL string that contains the address and parameters required to obtain weather information. Then, a CURL object is created through curl_easy_init, and the corresponding options are configured, such as setting the URL, disabling progress information, ignoring SSL certificate verification, setting callback functions, etc. Then, curl_easy_perform is used to execute the request and check the returned result. Finally, curl_easy_cleanup is used to clean up the CURL object.
char * url =
"https://devapi.qweather.com/v7/weather/now?location=" LOCATION "&key=xxx";
CURL * curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
// curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, now_weather_cb);
curl_easy_setopt(curl, CURLOPT_ENCODING, "gzip");
LOCATION You need to modify the and in the URL string according to the actual situation xxx , and perform necessary parameter configuration and authorization operations according to the requirements of the weather API.
Audio Player
Buildroot integrates alsa. By default, the sound card will be muted. Open the terminal and enter alsamixer to unmute it first.
In the current interface, select Headphone, then press the M key to unmute, and then use the keyboard ↑ to adjust the volume to a suitable level. The interface can be referred to:
After the adjustment is completed, enter the mpv file name --no-video, insert headphones, and music playback can be realized:
The command prompt displays the current directory, edit the /etc/profile file, add a line, and then export /etc/profile to reload the configuration:
|