1849 views|1 replies

155

Posts

1

Resources
The OP
 

[Luckfox RV1106 Linux Development Board Review] 10. C Program Control I2C Drive OLED [Copy link]

 

My post [Luckfox RV1106 Linux Development Board Review] link:

1. Unboxing and testing

2. SDK acquisition and image compilation

3. GPIO Lighting

4. Access the Internet through PC shared network and light up Python in Ubuntu

5. Compile the Buildroot system and test the camera

6. PWM control - command and C mode

7. PWM Control - Python and Device Tree Method

8. ADC and UART test

9. Python controls I2C to drive OLED

This article continues to use the Luckfox Pro Max board I2C interface to drive the 0.96-inch OLED (control chip SSD1306) and control it with C code. I tested four projects in total, two were successful (only a small amount of Makefile modification was required), and two failed (the reason for the failure is unknown).

1. Successful Case——ssd1306_for_linux

This is a case found on Gitee ( https://gitee.com/xianleewu/ssd1306_for_linux ). The author verified it on Orange Pi. From its README, it was analyzed that it was based on the Armbian system. I didn’t have high hopes, but I didn’t expect it to pass the verification in one try.

The case usage process is also relatively simple. First, clone the project on the Ubuntu virtual machine:

git clone https://gitee.com/xianleewu/ssd1306_for_linux.git

Then, enter the cloned project directory and modify Makefile and "src/example.c":

Figure 10-1 Modification of Makefile and example.c of ssd306_for_linux project

The above two modifications to Makefile specify the use of the compilation tool provided by Luckfox SDK, and then the modification of the source program specifies the use of the I2C3 interface. Next, use make to build, and get the executable program "OrangePI_ssd1306" in the build directory.

Figure 10-2 Build results of ssd306_for_linux

Finally, copy "OrangePI_ssd1306" to the local Win10, push it to the development board using adb, modify the execution permission using chmod, and then run the verification.

Figure 10-3 ssd306_for_linux running results

The test case of the ssd1306_for_linux project is to display the system's memory, CPU usage, CPU temperature and calendar - the Luckfox board is not connected to the Internet for time synchronization, so the local time is not accurate.

2. Successful Case——u8g2-arm-linux

Figure 10-4 Functions of the ssd306_for_linux project

From the above picture, we can see that the ssd1306_for_linux project provides relatively few functions, such as "drawing dots, drawing lines, drawing squares, writing words", etc. So I thought of using the classic u8g2 library.

I searched on Gitee and found a repository where u8g2 under Linux was compiled into lib, but there was no experimental result (one of the failed cases). However, according to the README of the repository, I found the project source code repository on Github ( https://github.com/wuhanstudio/u8g2-arm-linux ).

However, my experience of visiting Github has always been not very pleasant, and the network speed is touching. Fortunately, I have found a way to fork the project through Gitee. Friends in need can also visit my forked version: https://gitee.com/sonicfirr/u8g2-arm-linux .

The project is still cloned to the virtual machine, modify the Makefile and source code, and then download the local machine and push it to the development board for execution. I tested the C example that comes with the project, the hard I2C version (path /u8g2-arm-linux/examples/c-examples/u8g2_hw_i2c).

Figure 10-5 Modification of the u8g2-arm-linux project

Figure 10-6 The u8g2-arm-linux project build program is located in the "bin" directory

Figure 10-7 u8g2-arm-linux project test case effect

3. Failure case - u8g2-arm-linux-lib and Weixue RPI project transplantation

One of the failure cases is that I first found the u8g2 Lib ( https://gitee.com/haywire/u8g2-arm-linux-lib ) library on Gitee. I didn’t spend too much time debugging it, but when compiling, I got an error about the IO control function not being defined. I guess it might be that the original u8g2-arm-linux project used the "c-periphery" library as the underlying interface driver, and this Lib library did not package c-periphery well. Of course, it is more likely that the method of use is improper - here I roughly copied the code of u8g2_hw_i2c.c directly and tried to connect this Lib for compilation.

The second failed case took me two days and ultimately failed. Here is a brief description of the process of the attempt.

Because the OLED case officially provided by Luckfox is based on the 1.3-inch OLED of Waveshare Electronics, the driver chip is SH1107, and the project structure is as follows. After personal analysis, I created a 0.96-inch OLED driver source file in the c/lib/OLED directory, and the code in it tried to port the 0.96-inch OLED case provided by Waveshare ( https://www.waveshare.net/wiki/0.96inch_OLED_(A) ).

The first attempt was unsuccessful, so I turned to Weixue's 0.96-inch case and directly transplanted and modified it, but it still failed - the screen showed snowflakes. Weixue's case is based on the Raspberry Pi, so I finally took out the Raspberry Pi for testing, and the result was that only the first screen "clock" was displayed, and the subsequent screens were not displayed - according to the analysis of the case, there should be four more screens. So here it is judged that there is a certain problem with the case itself, or it may be that the part of the function in the case that needs to obtain screen data is invalid on Luckfox.

The underlying driver of Weixue's Raspberry Pi version can be implemented based on the three libraries of BCM2835, wiringPi or lgpio. When ported to Luckfox, it can only access the device file instead. At present, I think the I2C3 interface access is successful and the OLED can also light up. It should be the incompatibility of the GUI function. Considering that it takes a long time, I gave up debugging and prepared to turn to the direction of SPI driving LCD.

Figure 10-8 Luckfox official OLED case project

This post is from Domestic Chip Exchange

Latest reply

It is indeed difficult to port u8g2-arm-linux-lib and Weixue RPI projects.   Details Published on 2024-2-16 22:26
 
 

6570

Posts

0

Resources
2
 

It is indeed difficult to port u8g2-arm-linux-lib and Weixue RPI projects.

This post is from Domestic Chip Exchange
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list