当前位置:网站首页>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;
}
边栏推荐
- vcs import src < ros2. Repos failed
- What is a data type? What is the use of data types?
- Redis批量启停脚本
- 华为交换机:配置telnet和ssh、web访问
- An article for you to understand - Manchester code
- Docker installs MySQL and successfully uses Navicat connection
- yarn link 是如何帮助开发者对 NPM 包进行 debug 的?
- 华为交换机Console密码重置、设备初始化、默认密码
- static关键字
- Unity dotween sequence animation replay problem.
猜你喜欢

Wechat applet taro learning record
![[MySQL 12] MySQL 8.0.18 reinitialization](/img/e1/9874df18bbc8d80c3c5c5fe39aefc9.png)
[MySQL 12] MySQL 8.0.18 reinitialization

WorldView卫星遥感影像数据/米级分辨率遥感影像

Install cross compiler arm none liunx gnueabihf

My touch screen production "brief history" 1

Lua framwrok framework starts

The difference between hdmi2.1 and hdmi2.0 and the conversion of PD signals.

什么是数据类型?数据类型有什么用?

JS common basic case sorting (continuous update)

Technical dry goods Shengsi mindspire dynamic transformer with variable sequence length has been released!
随机推荐
Free use until 2015 -- viz artist multi touch plug-in package
Technical dry goods | Bert model for the migration of mindspore NLP model - text matching task (2): training and evaluation
haproxy+keepalived集群搭建02
[MySQL 14] use dbeaver tool to remotely backup and restore MySQL database (Linux Environment)
HDMI2.1与HDMI2.0的区别以及转换PD信号。
[end of 2021] National Meteorological Short Video (Kwai, Tiktok) influence list in December
[at] ABC 258g - Triangle triples reachable - violence
Uniapp learning records
JSON与Object之间转换
PHP wechat red packet grabbing algorithm
static关键字
PHP common sorting algorithm
Huawei switches are configured with SSH login remote management switches
Register keyword
什麼是定義?什麼是聲明?它們有何區別?
使用 FileChannel 进行文件的复制拷贝
Idea dereference display effect
Wechat applet taro learning record
Usage of (case, when) in PostgreSQL
Pycharm remote ssh pyenv error: pydev debugger: warning: trying to add breakpoint to file that does