📄 lcd_driver.c
字号:
**************************************************************************************************************/ U32 LCD_GetPixel(U16 x, U16 y) { return GETPIXEL(x,y);}/**************************************************************************************************************- 函数名称 : void LCD_DrawHLine (U16 x0, U16 y, U16 x1) - 函数说明 : 画水平线函数- 输入参数 : x,y,x1- 输出参数 : 无**************************************************************************************************************/void LCD_DrawHLine (U16 x0, U16 y0, U16 x1) { while (x0 <= x1) { SETPIXEL(x0, y0, LCD_COLOR); x0++; }}/**************************************************************************************************************- 函数名称 : void LCD_DrawVLine (U16 x, U16 y0, U16 y1) - 函数说明 : 画竖直线函数- 输入参数 : x,y,x1- 输出参数 : 无**************************************************************************************************************/void LCD_DrawVLine(U16 x0, U16 y0, U16 y1) { while (y0 <= y1) { SETPIXEL(x0, y0, LCD_COLOR); y0++; }}/**************************************************************************************************************- 函数名称 : void LCD_FillRect(U16 x0, U16 y0, U16 x1, U16 y1)- 函数说明 : 填充矩形函数- 输入参数 : x0,y0,x1,y1- 输出参数 : 无**************************************************************************************************************/void LCD_FillRect(U16 x0, U16 y0, U16 x1, U16 y1) { for (; y0 <= y1; y0++) { LCD_DrawHLine(x0,y0, x1); }}/**************************************************************************************************************- 函数名称 : void LCD_Clear(U16 x0, U16 y0, U16 x1, U16 y1)- 函数说明 : 清屏函数- 输入参数 : x0,y0,x1,y1- 输出参数 : 无**************************************************************************************************************/void LCD_Clear(U16 x0, U16 y0, U16 x1, U16 y1) { LCD_COLOR = 0x00; for (; y0 <= y1; y0++) { LCD_DrawHLine(x0,y0, x1); }}/**************************************************************************************************************- 函数名称 : static void DrawPoint(U16 x0,U16 y0, U16 xoff, U16 yoff)- 函数说明 : 画辅助点函数- 输入参数 : x,y- 输出参数 : 无**************************************************************************************************************/static void _DrawPoint(U32 x0,U32 y0, U32 xoff, U32 yoff) { LCD_DrawPixel(x0+xoff,y0+yoff); LCD_DrawPixel(x0-xoff,y0+yoff); LCD_DrawPixel(x0+yoff,y0+xoff); LCD_DrawPixel(x0+yoff,y0-xoff); if (yoff) { LCD_DrawPixel(x0+xoff,y0-yoff); LCD_DrawPixel(x0-xoff,y0-yoff); LCD_DrawPixel(x0-yoff,y0+xoff); LCD_DrawPixel(x0-yoff,y0-xoff); }}/**************************************************************************************************************- 函数名称 : void LCD_DrawCircle(U16 x0, U16 y0, U16 r)- 函数说明 : 画圆函数- 输入参数 : x,y- 输出参数 : 无**************************************************************************************************************/void LCD_DrawCircle(U32 x0, U32 y0, U32 r) { U32 i; U32 imax = ((int)((int)r*707))/1000 + 1; U32 sqmax = (int)r*(int)r + (int)r/2; U16 y = r; _DrawPoint(x0,y0,r,0); for (i=1; i<= imax; i++) { if ((i*i+y*y) > sqmax) { _DrawPoint(x0,y0,i,y); y--; } _DrawPoint(x0,y0,i,y); }}/**************************************************************************************************************- 函数名称 : void LCD_FillCircle(U16 x0, U16 y0, U16 r)- 函数说明 : 填充圆函数- 输入参数 : x,y- 输出参数 : 无**************************************************************************************************************/void LCD_FillCircle (U16 x0, U16 y0, U16 r) { U32 i; U32 imax = ((int)((int)r*707))/1000+1; U32 sqmax = (int)r*(int)r+(int)r/2; U16 x = r; LCD_DrawHLine(x0-r,y0,x0+r); for (i=1; i<= imax; i++) { if ((i*i+x*x) >sqmax) { if (x>imax) { LCD_DrawHLine (x0-i+1,y0+x, x0+i-1); LCD_DrawHLine (x0-i+1,y0-x, x0+i-1); } x--; } LCD_DrawHLine(x0-x,y0+i, x0+x); LCD_DrawHLine(x0-x,y0-i, x0+x); }}/**************************************************************************************************************- 函数名称 : Log2Phy(int Color)- 函数说明 : 逻辑颜色转实际颜色函数- 输入参数 : color- 输出参数 : 无**************************************************************************************************************/U16 Log2Phy(U32 Color) { U32 r,g,b; b = Color & 255; g = (Color >> 8 ) & 255; r = Color >> 16; b = (b + 42) / 85; g = (g * 7 + 127) / 255; r = (r * 7 + 127) / 255; return b + (g << 2) + (r << 5);}/**************************************************************************************************************- 函数名称 : LCD_Log2Phy(int Color)- 函数说明 : 逻辑颜色转实际颜色上层函数- 输入参数 : color- 输出参数 : 无**************************************************************************************************************/U16 LCD_Log2Phy(U32 Color) { U16 PhyColor; PhyColor = Log2Phy(Color); return PhyColor;}/**************************************************************************************************************- 函数名称 : void Set_Color(int color)- 函数说明 : 设定颜色的上层函数- 输入参数 : color- 输出参数 : 无**************************************************************************************************************/void Set_Color(U32 color) { LCD_SetColor(LCD_Log2Phy(color));}/**************************************************************************************************************- 函数名称 : void Set_Color(int color)- 函数说明 : 设定颜色函数- 输入参数 : color- 输出参数 : 无**************************************************************************************************************/void LCD_SetColor(U16 PhyColor) { LCD_COLOR = PhyColor; }/**************************************************************************************************************- 函数名称 : void Set_Color(int color)- 函数说明 : 设定颜色的上层函数- 输入参数 : color- 输出参数 : 无**************************************************************************************************************/void Set_BkColor(U32 color) { LCD_SetBkColor(LCD_Log2Phy(color));}/**************************************************************************************************************- 函数名称 : void Set_Color(int color)- 函数说明 : 设定颜色函数- 输入参数 : color- 输出参数 : 无**************************************************************************************************************/void LCD_SetBkColor(U16 PhyColor) { LCD_BKCOLOR = PhyColor; }/**************************************************************************************************************- 函数名称 : int LCDInit(void)- 函数说明 : 注册LCD设备- 输入参数 : 无- 输出参数 : 0,或-EBUSY**************************************************************************************************************/int __init LCD_Init(void){ int result; Setup_LCDInit(); printk("Registering S3C2410LCD Device\t--- >\t"); result = register_chrdev(LCD_MAJOR, "S3C2410LCD", &LCD_fops);//注册设备 if (result<0) { printk(KERN_INFO"[FALLED: Cannot register S3C2410LCD_driver!]\n"); return -EBUSY; } else printk("[OK]\n"); printk("Initializing S3C2410LCD Device\t--- >\t"); printk("[OK]\n"); printk("S3C2410LCD Driver Installed.\n"); return 0;}/**************************************************************************************************************- 函数名称 : LCD_CstnOnOff- 函数说明 : 打开和关闭lcd设备- 输入参数 : 无- 输出参数 : 无**************************************************************************************************************/void Lcd_CstnOnOff(int onoff){ // 1:CSTN Panel on 0:CSTN Panel off // if(onoff==1) { LCDCON1 |= 1; // ENVID=ON printk("\nLCDCON1 is already enable.\n"); } else LCDCON1 = LCDCON1 & 0x3fffe; // ENVID Off GPBUP = GPBUP|(1<<5); // Pull-up disable GPBDAT =( GPBDAT & (~(1<<5))) |(onoff<<5); // GPB5=On or Off GPBCON =( GPBCON & (~(3<<10)))|(1<<10); //GPD9=output}/**************************************************************************************************************- 函数名称 : LCD_Exit- 函数说明 : 卸载lcd设备- 输入参数 : 无- 输出参数 : 无**************************************************************************************************************/void __exit LCDdriver_Exit(void){ Lcd_CstnOnOff(0); unregister_chrdev(LCD_MAJOR, "S3C2410LCD"); printk("You have uninstall The LCD Driver succesfully,\n if you want to install again,please use the insmod command \n");}module_init(LCD_Init);module_exit(LCDdriver_Exit);/******************************************************************************************************************** 结束文件 ********************************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -