App-lvgl-touchPad/main_app/main.c

126 lines
2.5 KiB
C
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "stdio.h"
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include "Printer_sys.h"
#include "cJSON.h"
#define DRM_FOURCC "/dev/dri/card0"
#define LCD_FB "/dev/fb0"
#define MYFIFO "/myfifo" /* 命名管道文件名*/
#define BUFFER_SIZE 512
#define MAX_BUFFER_SIZE 4096 /* 4096 定义在于 limits.h 中*/
#define QID 0x4321
static pthread_t Thread_Lv_Main;
typedef struct
{
int page_type;//来自哪个页面
char control_name[26];//控件名称
char data[128];
}http_data_t;
struct message
{
long msg_type;
http_data_t http_page;
};
int fifo_write(http_data_t* data)
{
int fd;
int nwrite;
/* 以只写阻塞方式打开 FIFO 管道 */
fd = open(MYFIFO, O_WRONLY | O_CREAT, 0644); //(10)
if (fd == -1)
{
printf("Open fifo file error\n");
exit(1);
}
/*向管道中写入字符串*/
nwrite = write(fd, *(&data), sizeof(http_data_t)); //(11)
close(fd);
}
void Get_FB_Info(void)
{
struct fb_fix_screeninfo fb_fix;
struct fb_var_screeninfo fb_var;
int fd;
/* 打开 framebuffer 设备 */
if (0 > (fd = open(LCD_FB, O_WRONLY))) {
perror("open error");
exit(-1);
}
/* 获取参数信息 */
ioctl(fd, FBIOGET_VSCREENINFO, &fb_var);
ioctl(fd, FBIOGET_FSCREENINFO, &fb_fix);
printf("分辨率: %d*%d\n"
"像素深度 bpp: %d\n"
"一行的字节数: %d\n"
"像素格式: R<%d %d> G<%d %d> B<%d %d>\n",
fb_var.xres, fb_var.yres, fb_var.bits_per_pixel,
fb_fix.line_length,
fb_var.red.offset, fb_var.red.length,
fb_var.green.offset, fb_var.green.length,
fb_var.blue.offset, fb_var.blue.length);
/* 关闭设备文件退出程序 */
close(fd);
}
extern int mouse_test();
extern int Bluetooth_Printer(const char* com);
int main(int argc, char *argv[])
{
int res;
printf("------- main app -------\n");
// drm_test();
// Get_FB_Info();
// /*创建线程,线程为test_thread函数*/
// //LCD_FB_Test(argc,argv);
res = pthread_create(&Thread_Lv_Main, NULL, Lv_main_task, (void*)(unsigned long long)(520));
if(res != 0)
{
printf("create thread fail\n");
exit(res);
}
while (1)
{
sleep(1);
}
// return 0;
}