您现在的位置是:主页 > news > 珠海学网站开发/百度seo关键词排名技术
珠海学网站开发/百度seo关键词排名技术
admin2025/4/30 0:21:55【news】
简介珠海学网站开发,百度seo关键词排名技术,python网站开发pdf,成都建站开发电子量产工具——2-3显示系统_显示管理 文章目录电子量产工具——2-3显示系统_显示管理软件总框架一、显示管理二、1.framebuffer.c2.disp_manager.h3.disp_manager.c总结软件总框架 一、显示管理 disp_manager.c的作用 1.承上启下 2.下面各个模块把DispOpr注册进来 3.上面选择…
珠海学网站开发,百度seo关键词排名技术,python网站开发pdf,成都建站开发电子量产工具——2-3显示系统_显示管理 文章目录电子量产工具——2-3显示系统_显示管理软件总框架一、显示管理二、1.framebuffer.c2.disp_manager.h3.disp_manager.c总结软件总框架 一、显示管理 disp_manager.c的作用 1.承上启下 2.下面各个模块把DispOpr注册进来 3.上面选择…
电子量产工具——2-3显示系统_显示管理
文章目录
- 电子量产工具——2-3显示系统_显示管理
- 软件总框架
- 一、显示管理
- 二、
- 1.framebuffer.c
- 2.disp_manager.h
- 3.disp_manager.c
- 总结
软件总框架
一、显示管理
disp_manager.c的作用
1.承上启下
2.下面各个模块把DispOpr注册进来
3.上面选择某个模块
4.还提供一些函数,比如PutPixel
二、
1.framebuffer.c
framebuffer.c
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <linux/fb.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>#include "disp_manager.h"static int fd_fb;
static struct fb_var_screeninfo var; /* Current var */
static int screen_size;
static unsigned char *fb_base;
static unsigned int line_width;
static unsigned int pixel_width;static int FbDeviceInit(void)
{fd_fb = open("/dev/fb0", O_RDWR);if (fd_fb < 0){printf("can't open /dev/fb0\n");return -1;}if (ioctl(fd_fb, FBIOGET_VSCREENINFO, &var)){printf("can't get var\n");return -1;}line_width = var.xres * var.bits_per_pixel / 8;pixel_width = var.bits_per_pixel / 8;screen_size = var.xres * var.yres * var.bits_per_pixel / 8;fb_base = (unsigned char *)mmap(NULL , screen_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd_fb, 0);if (fb_base == (unsigned char *)-1){printf("can't mmap\n");return -1;}return 0;
}static int FbDeviceExit(void)
{munmap(fb_base, screen_size);close(fb_base);return 0;
}/* 可以返回LCD的framebuffer, 以后上层APP可以直接操作LCD, 可以不用 FbFlushRegion* 也可以malloc返回一块无关的buffer, 要使用 FbFlushRegion**/
static int FbGetBuffer(PDispBuff ptDispBuff)
{ptDispBuff->iXres = var.xres;ptDispBuff->iYres = var.yres;ptDispBuff->iBpp = var.bits_per_pixel;ptDispBuff->buff = fb_base;return 0;
}
static int FbFlushRegion(PRegion ptRegion, PDispBuff ptDispBuff)
{return 0;
}static DispOpr g_tFramebufferOpr = {.name = "fb",.DeviceInit = FbDeviceInit,.DeviceExit = FbDeviceExit,.GetBuffer = FbGetBuffer,.FlushRegion = FbFlushRegion,
};//3.注册LCD硬件相关的结构体
void FramebufferInit(void)
{RegisterDisplay(&g_tFramebufferOpr);
}
2.disp_manager.h
disp_manager.h
#ifndef _DISP_MANAGER_H
#define _DISP_MANAGER_Htypedef struct DispBuff {int iXres;int iYres;int iBpp;char *buff;
}DispBuff, *PDispBuff;typedef struct Region {int iLeftUpX;int iLeftUpY;int iWidth;int iHeigh;
}Region, *PRegion;typedef struct DispOpr {char *name;int DeviceInit(void);int DeviceExit(void);int GetBuffer(PDispBuff ptDispBuff);int FlushRegion(PRegion ptRegion, char *buffer);struct DispOpr *ptNext;
}DispOpr, *PDispOpr;void RegisterDisplay(PDispOpr ptDispOpr);
void SelectDefaultDisplay(char *name);
int InitDefaultDisplay(void);
void DisplayInit(PDispOpr ptDispOpr);
int PutPixel(int x, int y, unsigned int dwColor);
static int FlushDisplayRegion(PRegion ptRegion, PDispBuff ptDispBuff);#endif
3.disp_manager.c
disp_manager.c
#include "disp_manager.h"/* 管理底层的LCD、WEB */
static PDispOpr g_DispDevs = NULL; //5.对应不同的显示方式 ——》SelectDefaultDisplay
static PDispOpr g_DispDefault = NULL;
static DispBuff g_tDispBuff;
static int line_width;
static int pixel_width;//dwColor double word
//8.绘制想要的图片 ————》》 更新到硬件上去FlushDisplayRegion
int PutPixel(int x, int y, unsigned int dwColor)
{unsigned char *pen_8 = g_tDispBuff->buff+y*line_width+x*pixel_width;unsigned short *pen_16; unsigned int *pen_32; unsigned int red, green, blue; pen_16 = (unsigned short *)pen_8;pen_32 = (unsigned int *)pen_8;switch (g_tDispBuff.iBpp){case 8:{*pen_8 = dwColor;break;}case 16:{/* 565 */red = (dwColor >> 16) & 0xff;green = (dwColor >> 8) & 0xff;blue = (dwColor >> 0) & 0xff;dwColor = ((red >> 3) << 11) | ((green >> 2) << 5) | (blue >> 3);*pen_16 = dwColor;break;}case 32:{*pen_32 = dwColor;break;}default:{printf("can't surport %dbpp\n", g_tDispBuff.iBpp);break;}}
}//4.注册LCD硬件相关函数 放入 g_DispDevs 链表
void RegisterDisplay(PDispOpr ptDispOpr)
{ptDispOpr->ptNext = g_DispDevs;g_DispDevs = ptDispOpr;}//6.来选择默认的输出设备
void SelectDefaultDisplay(char *name)
{PDispOpr pTmp = g_DispDevs;while (pTmp){if(strcmp(name, pTmp->name) == 0){g_DispDefault = pTmp;return 0;}pTmp = pTmp->ptNext;}return -1;
}//7.来初始化默认的设备 ————》》然后去调用/// PutPixel
int InitDefaultDisplay(void)
{int ret;ret = g_DispDefault->DeviceInit(); //先初始化硬件if(ret){printf("DeviceInit err\n");return -1;}ret = g_DispDefault->GetBuffer(g_tDispBuff); //获得一个bufferif(ret){printf("GetBuffer err\n");return -1;}line_width = g_tDispBuff.iXres * g_tDispBuff.iBpp/8;pixel_width = g_tDispBuff.iBpp/8return 0;
}//9.绘制好的区域 更新(刷)到硬件上去
static int FlushDisplayRegion(PRegion ptRegion, PDispBuff ptDispBuff)
{int ret;ret = g_DispDefault->FlushRegion(ptRegion, ptDispBuff);return 0;
}//1.display 初始化
void DisplayInit(PDispOpr ptDispOpr)
{FramebufferInit(); //2.调用framebuffer初始化
}
总结
1.display 初始化
{//2.调用framebuffer初始化}
3.注册LCD硬件相关的结构体
4.注册LCD硬件相关函数 放入 g_DispDevs 链表
5.对应不同的显示方式 ——》SelectDefaultDisplay
6.来选择默认的输出设备
7.来初始化默认的设备 ————》》然后去调用 PutPixel
8.绘制想要的图片 ————》》 更新到硬件上去 FlushDisplayRegion
9.绘制好的区域 更新(刷)到硬件上去