韦东山嵌入式第一期学习笔记DAY_20——17_9_LCD显示文字

作者:GWD 时间:2019.7.25

一、课程内容
概述:实现LCD显示字符
第一步、从linux内核中拷出font_8*16.c文件,并修改
在这里插入图片描述
第二步、写字符显示函数

extern const unsigned char fontdata_8x16[ ];

static unsigned int fb_base;
static int xres, yres, bpp;

void font_get_lcd_params(void)

{
	get_lcd_params(&fb_base,&xres,&yres,&bpp);
}

void fb_print_char(int x,int y,char c,unsigned int color)
{
	int i,j;
	unsigned char *dots = &fontdata_8x16[c*16];
	unsigned char dat ;
	int bit ;
	for(j=y;j<y+16;j++)
	{
		bit = 7;
		dat = *dots++;
		for(i=x;i<x+8;i++)
		{
			if(dat &(1<<bit))
			{
				fb_put_pixel(i,j,color);
			}
			bit --;
		}
	}
}

void fb_print_string(int x, int y, char* str, unsigned int color)

{
	int i = 0, j;
	
	while (str[i])
	{
		if (str[i] == '\n')
			y = y+16;
		else if (str[i] == '\r')
			x = 0;

		else
		{
			fb_print_char(x, y, str[i], color);
			x = x+8;
			if (x >= xres) /* 换行 */
			{
				x = 0;
				y = y+16;
			}
		}
		i++;
	}
}





第三步、测试函数

#include "geometry.h"
#include "font.h"
void lcd_test(void)
{
	unsigned int fb_base;
	int xres, yres, bpp;
	/* 初始化LCD */
	lcd_init();
	/* 使能LCD */
	lcd_enable();
	get_lcd_params(&fb_base, &xres, &yres, &bpp);
	fb_get_lcd_params( );
	font_get_lcd_params( );
	clear_screen( );	
	draw_line(0, 0, xres - 1, 0, 0);
	draw_line(xres - 1, 0, xres - 1, yres - 1, 0);
	draw_line(0, yres - 1, xres - 1, yres - 1, 0);
	draw_line(0, 0, 0, yres - 1, 0);
	draw_line(0, 0, xres - 1, yres - 1, 0);
	draw_line(xres - 1, 0, 0, yres - 1, 0);
	draw_circle(xres/2, yres/2, yres/4, 0);
	fb_print_string(10,10,"www.100ask.net\n\r100ask.taobao.com",0);
}

二、LCD部分的完整框架在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值