当前位置:网站首页>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;
}
边栏推荐
- Pat class a 1030 travel plan
- Ventuz Foundation Series "one step at the door"
- [cocos creator] get the resource UUID
- The general trend of data news releases the power of visual reporting ----- essays after reading
- Mutual call between Lua and C #
- [step on the pit series] MySQL failed to modify the root password
- Worldview satellite remote sensing image data / meter resolution remote sensing image
- 微软安全响应中心
- Redis profile
- 优质博客——
猜你喜欢
[untitled]
多旅行商问题——公式和求解过程概述
My touch screen production "brief history" 2
An article for you to understand - Manchester code
VMware virtual machine configuration static IP
【踩坑系列】mysql 修改root密码失败
Redis批量启停脚本
IP production stream is so close to me
unity2019_ Input management
the installer has encountered an unexpected error installing this package
随机推荐
Generate video using clipout in viz engine
[MySQL 12] MySQL 8.0.18 reinitialization
[MySQL 14] use dbeaver tool to remotely backup and restore MySQL database (Linux Environment)
freetype库的移植
I want to do large screen data visualization application feature analysis
What is a data type? What is the use of data types?
[MySQL 13] if you change your password for the first time after installing mysql, you can skip MySQL password verification to log in
[untitled]
regular expression
Mutual call between Lua and C #
Free use until 2015 -- viz artist multi touch plug-in package
Redis batch startup and shutdown script
What does (+) in Oracle mean
MaxCompute字符串分割函数-SPLIT_PART
Technical dry goods | Bert model for the migration of mindspore NLP model - text matching task (2): training and evaluation
static关键字
Pycharm remote ssh pyenv error: pydev debugger: warning: trying to add breakpoint to file that does
Differences between tp3.2 and tp5.0
Project experience sharing: handwritten Chinese character recognition based on Shengsi mindspire
JS common basic case sorting (continuous update)