【Reference】Wei Dongshan's teaching notes
1. Program framework
1.1 Touch screen:
main press thread, sent to display process through socket
---------------------------
Package event: ts thread key thread
---------------------------
Operating system
The encapsulated data includes:
time,
type (click, up, down, left, right)
, position
, speed
, amplitude
1.2 Display
Zoom in (up) Zoom out (down) Left Right Current display control receiving sochket
libjpeg
mmap
----------------------------------------
memory memory memory memory
framebuffer
-----------
LCD
2. Display text
2.1 Text encoding method
If the source file is written in different encoding methods, the execution results will be different.
How to solve it? When compiling a program, you need to specify the character set
man gcc, /charset
-finput-charset=charset indicates the encoding method of the source file, and UTF-8 is used for parsing by default
-fexec-charset=charset indicates the encoding method used to represent the characters in the executable program, and UTF-8 is used by default
gcc -oa ac //
gcc -finput-charset=GBK -fexec-charset=UTF-8 -o utf-8_2 ansi.c
2.2 Dot matrix display of English letters and Chinese characters
Test:
A. Configure and modify kernel support to compile lcd.c into it
cp /work/drivers_and_test_new/10th_lcd/lcd.c drivers/video/
modify drivers/video/Makefile
#obj-$(CONFIG_FB_S3C2410) += s3c2410fb.o
obj-$(CONFIG_FB_S3C2410) += lcd.o
nfs 32000000 192.168.1.123:/work/nfs_root/uImage; bootm 32000000
set bootargs console=ttySAC0,115200 root=/dev/nfs nfsroot=192.168.1.123:/work/nfs_root/fs_mini_mdev_new ip=192.168.1.17
nfs 32000000 192.168.1.123:/work/nfs_root/uImage_jz244 0; bootm 32000000
nfs 32000000 192.168.1.123 :/work/nfs_root/uImage_tq2440; bootm 32000000
nfs 32000000 192.168.1.123:/work/nfs_root/uImage_mini2440; bootm 32000000
B. Boot with a new kernel
2.3 Using FreeType to display text of any size
Section 2.3.1_Digital Photo Frame_Introduction to FreeType theory
Section 2.3.2_Digital Photo Frame_Testing FreeType on a PC
On PC:
tar xjf freetype-2.4.10.tar.bz2
./configure
make
sudo make install
gcc -o example1 example1.c -I /usr/local/include/freetype2 -lfreetype -lm
gcc -finput-charset=GBK -fexec-charset=UTF-8 -o example1 example1.c -I /usr/local/include /freetype2 -lfreetype -lm
./example1 ./simsun.ttc abc
Section 2.3.3_Digital Photo Frame_Displaying a vector font on the LCD
Cross-compile:
tar xjf freetype-2.4.10.tar.bz2
./configure --host=arm-linux
make
make DESTDIR=$PWD/tmp install
The compiled header files should be placed in:
/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/include
The compiled library files should be placed in:
/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib
Copy tmp/usr/local/lib/* to /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib
sudo cp * /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib -d -rf
cp *so* /work/nfs_root/fs_mini_mdev_new/lib -d
Copy tmp/usr/local/include/* to /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/include
cp * /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/include -rf
cd /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/include
mv freetype2/freetype .
arm-linux-gcc -finput-charset=GBK -o example1 example1.c -lfreetype -lm
arm-linux-gcc -finput-charset=GBK -o show_font show_font.c -lfreetype -lm
freetype/config/ftheader.h
freetype2/freetype/config/ftheader.h
arm-linux-gcc -finput-charset=GBK -fexec-charset=GBK -o show_font show_font.c -lfreetype -lm
Section 2.3.4_Digital Photo Frame_Display several lines of text on the LCD
a. Display several lines of text starting from the left
arm-linux-gcc -finput-charset=GBK -o show_lines show_lines.c -lfreetype -lm
b. Display several lines of text in the center
100ask gif
www.100ask.net
3. Display any coded text file on LCD to make an e-book
Lesson 1 Section 3.1_Digital Photo Frame_Extra Project_Electronic Book Effects and Frames
Lesson 1 Section 3.2_Digital Photo Frame_Extra Project_E-book Code Reading and Writing
Lesson 1 Section 3.3_Digital Photo Frame_Extra Project_E-book Pointer Operation
Lesson 1 Section 3.4_Digital Photo Frame_Extra Project_Link List Operation of E-book
Lesson 1 Section 3.5_Digital Photo Frame_Extra Project_Displaying eBooks on PC
ctrl+alt+shift+f1
Download address:
https://launchpad.net/ubuntu/+source/svgalib/1:1.4.3-30
svgalib_1.4.3.orig.tar.gz
svgalib_1.4.3-30.debian.tar.gz
svgalib_1.4.3-30.dsc
patch
tar xzf svgalib_1.4.3.orig.tar.gz
tar xzf svgalib_1.4.3-30.debian.tar.gz
cd svgalib-1.4.3.orig/
for file in ../debian/patches/*.patch; do patch -p1 < $file; done
Compile and install:
sudo make install // Compilation error, you need to install libx86
and then sudo make install
Download address
: http://packages.ubuntu.com/lucid/libx86-1
tar xzf libx86_1.1+ds1.orig.tar.gz
gunzip libx86_1.1+ds1-6.diff.gz
cd libx86-1.1/
patch -p1 < ../libx86_1.1+ds1-6.diff
make // Error, modify lrmi.c, add macros, refer to 561491.patch
make
sudo make install
When I run the PC program, I get an error: error while loading shared libraries: libvga.so.1: cannot open shared object file: No such file or directory. This is a very common error. The shared library cannot be found. However, I found that the library has been installed and exists in the /usr/local/lib directory, but the program just can't find it.
That means the system does not know which directory xxx.so is in.
At this time, you need to add the directory where xxx.so is located in /etc/ld.so.conf.
Generally speaking, there are many so files in the directory /usr/local/lib, so adding the line /usr/local/lib in /etc/ld.so.conf can solve this problem. When adding, just add: /usr/local/lib at the end. After saving and exiting, use the ldconfig command to update. Also note that if these commands are due to permissions, you can add sudo
sudo vim /etc/ld.so.conf
/usr/local/lib
sudo ldconfig
After doing this, there will be no errors when running again.
sudo ./show_file -s 16 -d crt -f ./FZYTK.ttf ./utf8.txt
http://security.ubuntu.com/ubuntu/pool/main//libx/libx86/
libx86_1.1+ds1.orig.tar.bz2 // Modify
sudo apt-get source libx86
4. Write a generic Makefile
Method to compile test_Makefile:
a. gcc -o test ac bc
For ac: preprocessing, compiling, assembling
For bc: preprocessing, compiling, assembling
Finally linking
Advantages: simple command
Disadvantages: if there are many files, even if you only modify one file, all files need to be "preprocessed, compiled, assembled" again, which is
inefficient
b. Write the Makefile
core: rules
Target: Dependency 1 Dependency 2
Command
Conditions for command execution:
i. The "dependency" file is newer than the "target" file
ii. There is no "target" file
5. Use multiple methods to support multiple inputs
http://cc.byexamples.com/2007/04/08/non-blocking-user-input-in-loop-without-ncurses/
http://www.groad.net/bbs/simple/?t3959.html
5.1 Use polling method // High CPU usage
Experimental method:
a. insmod s3c_ts.ko
to determine which device node corresponds to the touch screen
b.
export TSLIB_TSDEVICE=/dev/event0
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/lib/ts
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
c. Calibration
ts_calibrate
d. telnetd -l /bin/sh //Start the telnet service to log in and observe the CPU usage
e. ./show_file -s 24 -d fb -f ./MSYH.TTF ./utf8_novel.txt
(If it fails, kill the conflicting process first)
f. Execute the top command on the development board to observe
5.2 Use select, poll // Low CPU usage, suitable for many simple occasions
Reference: Advanced Programming I/O Multiplexing in UNIX Environment
Monitor multiple files. As long as one file is readable/writable/abnormal or timed out, it returns
int select(int nfds, fd_set *readfds, fd_set *writefds,fd_set *exceptfds, struct timeval *timeout);
maximum file handle + 1. Timeout
of
the file being monitored for readability.
...
5.3 Use multithreading // Low CPU usage, very flexible
Refer to Unix_Linux_Windows_OpenMP multithreaded programming.pdf P18 3.3.2 Conditional variables
To achieve sliding page turning:
1. If the displacement difference of the touch point in the X direction exceeds 1/5 of the x resolution, the page will be turned.
gcc -o example1 example1.c -L/usr/local/lib/ -lfreetype -lm -I /usr/local/include/freetype2
gcc -finput-charset=GBK -fexec-charset=UTF-8 -o example1 example1. c -L/usr/local/lib/ -lfreetype -lm -I /usr/local/include/freetype2
gcc -finput-charset=UTF-8 -fexec-charset=UTF-8 -o example1 example1.c -L/ usr/local/lib/ -lfreetype -lm -I /usr/local/include/freetype2
6.1 Simple example of network programming6.2
Modify the e-book source code to support remote printing6.3
Improve remote printing
7. Use of libjpeg
1. Cross-compile libjpeg
tar xzf libjpeg-turbo-1.2.1.tar.gz
cd libjpeg-turbo-1.2.1
./configure --prefix=/work/projects/13.libjpeg/libjpeg-turbo-1.2.1/tmp/ --host=arm-linux
make
make install
2. Cross-compile jpg2rgb.c
2.1
arm-linux-gcc -o jpg2rgb jpg2rgb.c -I /work/projects/13.libjpeg/libjpeg-turbo-1.2.1/tmp/include -L /work/projects/13. libjpeg/libjpeg-turbo-1.2.1/tmp/lib -ljpeg
cp jpg2rgb /work/nfs_root/fs_mini_mdev_new
cp libjpeg-turbo-1.2.1/tmp/lib/*so* /work/nfs_root/fs_mini_mdev_new/lib/ -d
2.2
The compiled header files should be put into:
/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/include
:
cd /work/projects/13.libjpeg/libjpeg-turbo-1.2.1/tmp/include
cp * /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/include
Previous article:ubuntu18: Create a new S3C2440 emulator in QEMU
Next article:ARM Linux bootloader notes
Recommended ReadingLatest update time:2024-11-16 09:31
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Does anyone know how to connect this refrigerator starter?
- IAR msp430 memory allocation keywords
- Where are my favorite articles? Where are the collectors?
- In addition to round and square, are there other shapes of NFC tags?
- About Bandgap Reference and Zener Reference
- What will 5G do for rural areas?
- 【GD32L233C-START Review】+Unboxing【1】
- Starting this year, does that mean April 1st is no longer a festival?
- STC8A8K64 MCU ADC input is disturbed
- Four memory protection issues of TI C66x DSP