character.c
来自「2440 ADS项目」· C语言 代码 · 共 89 行
C
89 行
#include "color.h"
#include "graphic.h"
#include "character.h"
#include "ascii.h"
#include "hzk16x16.h"
/*
* display an ascii character
* x,y : coordinate of the start pixel
* ascii_codes : the pointer of the character in the font lib
* the size of the ascii characters is 8*16
* color : the color of the character
*/
void display_ascii(unsigned int x, unsigned int y, unsigned char* ascii_codes, int color)
{
unsigned char* data;
unsigned char* p = ascii_codes;
int i, j, xpos = x, ypos = y;
unsigned char c;
while(*p != '\0') {
data = ASCII_FONT_BITMAP + (unsigned int)*p * 16;
for(i=0; i<16; i++) {
c = *data++;
for(j=0; j<8; j++) {
if(c & (128 >> j))
draw_dot(xpos+j, ypos+i, color);
}
}
xpos += 8;
++p;
}
}
void draw_dot2(int x, int y, int color)
{
int x0 = x * 3;
int y0 = y * 3;
int i, j;
for(i=x0-1; i<x0+2; i++)
for(j=y0-1; j<y0+2; j++)
draw_dot(i, j, color);
}
/*
* display a string,the string can contain
* only ascii characters
*
* x,y : the beginning coordinate of the string to be displayed
* 0<=x<=39 : each line holds 80 bytes (each byte contain 8 pixels) horizontally
* 0<=y<=14 : each line holds 32 pixels vertically
*
* so the whole LCD can display 80*30 ascii characters,
*
*
* color : the color of the string
*/
void display_chinese(unsigned int x, unsigned int y, unsigned char* str, int color)
{
unsigned char* data;
unsigned char* p = str;
int i, j, xpos = x, ypos = y, offset;
unsigned char ch, cl;
while(*p != '\0') {
ch = *p++;
cl = *p++;
offset = ( (ch-0xa1)*94 + (cl-0xa1) )*32;
data = GB2312_16X16_FONT_BITMAP + offset;
for(i=0; i<16; i++) {
ch = *data++;
cl = *data++;
for(j=0; j<16; j++) {
if(ch & (0x80 >> j))
draw_dot(xpos+j, ypos+i, color);
if(cl & (0x80 >> j))
draw_dot(xpos+j+8, ypos+i, color);
}
}
xpos += 16;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?