当前位置:网站首页>Transplantation of tslib Library
Transplantation of tslib Library
2022-07-03 07:59:00 【A chicken without learning】
Catalog
- tslib The migration of Libraries
- 1. download
- 2. Move the downloaded compressed package to linux Virtual machine , And extract the , Enter this directory
- 3. perform configure To configure the Makefile file
- 4. perform make Compile Library
- 5. Configure the compiled file to the compilation tool chain
- 6. Configure the compiled library on the development board
- 7. example
tslib The migration of Libraries
1. download
Download address :github Warehouse
2. Move the downloaded compressed package to linux Virtual machine , And extract the , Enter this directory
tar -xJf tslib-1.21.tar.xz
cd tslib-1.21
3. perform configure To configure the Makefile file
Be careful : prefix You cannot indicate the path casually , Because when you run the program later , The program will find the library file according to this path . If you plan to compile lib Put all the library files on the development board /lib Next , Then you should prefix Set to /; If you plan to compile lib All library files under are placed on the development board /usr/lib Next , Then you should prefix Set to /usr
./configure --host=arm-linux-gnueabihf prefix=/
4. perform make Compile Library
make DESTDIR=/home/hxd/tools/tslib # DESTDIR Used to specify your installation location
make install
5. Configure the compiled file to the compilation tool chain
This step is optional , When compiling the program in the future, you don't need to manually specify the path of the library file and the path of the header file that need the Library
About putting the compiled Library in that location , You can check the 1.5 Section : https://blog.csdn.net/weixin_47024013/article/details/125527484
cp /home/hxd/tools/tslib/include/* -rfd /usr/lib/gcc-cross/arm-linux-gnueabihf/9/include/ # The first path is related to the installation path of the library you specified
cp /home/hxd/tools/tslib/lib/* -rfd /usr/lib/gcc-cross/arm-linux/gnueabihf/9/
cp /home/hxd/tools/tslib/etc/* -rfd /etc/
6. Configure the compiled library on the development board
We just need to put lib All files in the folder are placed on the development board /lib Under the folder (/lib still /usr/lib It depends on your third step )
First the tslib Folder copy nfs Under the directory of , Then the development board mounts the nfs, You can also copy files to the server in other ways
cp -rfd /mnt/tslib/lib/* /lib
7. example
7.1 Single touch
#include<stdio.h>
#include<stdlib.h>
#include<tslib.h>
int main()
{
struct tsdev *ts = NULL; // device handle
struct ts_sample samp;
int pressure = 0;
ts = ts_setup(NULL, 0);
if (ts == NULL) {
fprintf(stderr, "ts_setup error\n");
exit(-1);
}
for(;;) {
if (0 > ts_read(ts, &samp, 1)) {
fprintf(stderr, "ts_read error\n");
exit(-1);
}
if (samp.pressure > 0) {
if (pressure > 0) {
printf(" Move (%d, %d)\n", samp.x, samp.y);
} else {
printf(" Press down (%d, %d)\n", samp.x, samp.y);
}
pressure = samp.pressure;
} else if (samp.pressure == 0 && pressure > 0) {
printf(" Release (%d, %d)\n", samp.x, samp.y);
pressure = samp.pressure;
}
}
}
7.2 Multi touch
#include<stdio.h>
#include<stdlib.h>
#include<sys/ioctl.h>
#include<linux/input.h>
#include<tslib.h>
#include<string.h>
int main()
{
struct tsdev *ts = NULL;
struct ts_sample_mt *mt_ptr = NULL;
struct ts_sample_mt *mt_old = NULL;
struct input_absinfo slot;
int max_slots;
int i = 0;
// initialization
ts = ts_setup(NULL, 0);
if (ts < 0) {
printf("setup error\n");
return -1;
}
// Get the number of touch points supported by the touch screen
if (0 > ioctl(ts_fd(ts), EVIOCGABS(ABS_MT_SLOT), &slot)) {
printf("ioctl error\n");
return -1;
}
max_slots = slot.maximum - slot.minimum + 1;
printf("max_slots: %d\n", max_slots);
// Open up space
mt_ptr = (struct ts_sample_mt *)malloc(sizeof(struct ts_sample_mt)*max_slots);
mt_old = (struct ts_sample_mt *)malloc(sizeof(struct ts_sample_mt)*max_slots);
if (mt_ptr == NULL || mt_old == NULL) {
printf("malloc error\n");
return -1;
}
memset(mt_ptr, 0, sizeof(struct ts_sample_mt)*max_slots);
memset(mt_old, 0, sizeof(struct ts_sample_mt)*max_slots);
for(;;) {
if (ts_read_mt(ts, &mt_ptr, max_slots, 1) < 0) {
printf("ts_read_mt error\n");
exit(-1);
}
//printf("-------debug---------\n");
for (i=0;i<max_slots;i++) {
if (mt_ptr[i].valid) {
printf("i: %d\n", i);
if (mt_ptr[i].pressure > 0) {
if (mt_old[i].pressure > 0) {
printf("slot<%d>, Move (%d, %d)\n", mt_ptr[i].slot, mt_ptr[i].x, mt_ptr[i].y);
} else {
printf("slot<%d>, Press down (%d, %d)\n", mt_ptr[i].slot, mt_ptr[i].x, mt_ptr[i].y);
}
memcpy(&mt_old[i], &mt_ptr[i], sizeof(struct ts_sample_mt));
} else {
printf("slot<%d>, Release (%d, %d)\n", mt_ptr[i].slot, mt_ptr[i].x, mt_ptr[i].y);
memcpy(&mt_old[i], &mt_ptr[i], sizeof(struct ts_sample_mt));
}
}
}
}
free(mt_ptr);
free(mt_old);
return 0;
}
边栏推荐
- [cocos creator] get the resource UUID
- 什麼是定義?什麼是聲明?它們有何區別?
- VMware virtual machine configuration static IP
- Enter three times and guess a number
- PHP微信抢红包的算法
- Huawei switches are configured with SSH login remote management switches
- P2704 [NOI2001] 炮兵阵地(状压dp)
- PostGIS space function
- Zohocrm deluge function application time verification
- register关键字
猜你喜欢

一条通往服务器所有端口的隧道
![[global product discovery 2] the first pure cloud augmented reality (AR) platform - Israel](/img/51/04f5a9dbd03438fbdf25545a81b7ba.jpg)
[global product discovery 2] the first pure cloud augmented reality (AR) platform - Israel

Docker installs MySQL and successfully uses Navicat connection

在浏览器输入url后执行什么

Unity performance optimization

the installer has encountered an unexpected error installing this package

MAE

Pat class a 1031 Hello world for u

Install cross compiler arm none liunx gnueabihf

【LeetCode】3. Merge two sorted lists · merge two ordered linked lists
随机推荐
I want to do large screen data visualization application feature analysis
oracle中的 (+)是什么意思
Unity dotween sequence animation replay problem.
YOLO系列 --- xml2txt脚本
the installer has encountered an unexpected error installing this package
Pat class a 1032 sharing
Screenshot tool snipaste
华为交换机配置ssh登录远程管理交换机
*p++、*++p、++*p、(*p)++
register关键字
一个实习生的CnosDB之旅
Redis profile
创业团队如何落地敏捷测试,提升质量效能?丨声网开发者创业讲堂 Vol.03
The difference between hdmi2.1 and hdmi2.0 and the conversion of PD signals.
HDMI2.1与HDMI2.0的区别以及转换PD信号。
Idea dereference display effect
Research shows that breast cancer cells are more likely to enter the blood when patients sleep
How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03
An intern's journey to cnosdb
Client server model