#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/input.h> //输入子系统头文件
#define LCD_SIZE 800*480 //LCD分辨率800px*480x, aRGB像素,4字节,32位
#define IMG_COUNTS 10 //图片数量
/* ***************全局变量**************** */
int lcd_fd; //LCD设备文件描述符
int ts_fd; //触摸屏设备文件描述符
unsigned int* lcd_mmp; //LCD设备文件映射的显存首地址
/* *******************函数声明********************* */
//打开LCD设备文件并映射显存,成功返回0
int open_lcd(void);
//关闭LCD设备文件、撤销显存映射,成功返回0
int close_lcd();
//打开触摸屏设备文件,成功返回0
int open_ts(void);
//关闭触摸屏设备文件,成功返回0
int close_ts(void);
//获取点击触摸屏的坐标(x,y),参数是存储坐标值的数组名,返回存储坐标值的数组首地址
unsigned int* get_position(unsigned int *pos);
//LCD显示某个颜色块,参数是起点的宽度、高度值,色块的宽度、高度,颜色数据
void show_color(int x_start, int y_start, int width, int height, unsigned int color);
//LCD显示图片
int show_pic_full(const char *img_path);
/* ******************主函数******************** */
int main(int argc, const char *argv[])
{
//1、打开LCD、触摸屏文件
open_lcd();
open_ts();
//2、获取点击触摸屏的坐标pos_x, pos_y
unsigned int abs[2]={0}; //保存点击坐标位置,abs[0]是X轴的值,abs[0]是Y轴的值
printf("abs=%p\n",abs);
//3、判断坐标的pos_x,在LCD上刷图显示
//点击左边,x值小于400,图片路径数组往前一个,点击右边,x值大于400,图片路径数组往后一个
//图片路径数组
const char *imgs_path[IMG_COUNTS]={"/zyb/1014/1.ebm",
"/zyb/1014/2.ebm",