📄 io.c
字号:
/*-------------------------------------------------------------------
FILE NAME:
io.c
DESCRIPTION:
this file includes input and output functions.
AUTHOR:
WYF
VERSION:
2005.1122.00
COMPANY:
DATANG MICROELECTRONICS TECHNOLOGY CO,.LTD
HISTORY:
2005.1122 Creat this file
...
--------------------------------------------------------------------*/
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include "nucleus.h"
#include "ADSmx21_defs.h"
#include "drv_defs.h"
#include "drv_extr.h"
#include "io.h"
extern unsigned short display_buf[DISPLAY_LINE_HEIGHT*DISPLAY_LINE_MAX][320];
extern int line, totalline;
extern int row;
/*-----------------------------------------------------
ASCII code map to char table position for 16*8
48~57====0~9
58 ==== :
59 ==== ;
65~90===='A'~'Z'
-----------------------------------------------------*/
const unsigned char ascii_load_table[]=
{ 00,00,00,00,00,00,00,00,00,00,97,00,00,00,00,00,//0~15
00,00,00,00,00,00,00,00,00,00,00,00,00,00,98,96,//16~31
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,//32~47
16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,//48~63
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,//64~79
48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,//80~95
64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,//96~111
80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95 //112~
};
/* ASCCII characters dot-matrix 12*6 */
const unsigned char ascii_table_12[][LCD_CHAR_HEIGTH_12]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //" "
{0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00,0x00,0x00}, //!
{0x28,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //"
{0x00,0x28,0x28,0xFC,0x28,0x50,0xFC,0x50,0x50,0x00,0x00,0x00}, //#
{0x20,0x78,0xA8,0xA0,0x60,0x30,0x28,0xA8,0xF0,0x20,0x00,0x00}, //$
{0x00,0x48,0xA8,0xB0,0x50,0x28,0x34,0x54,0x48,0x00,0x00,0x00}, //%
{0x00,0x20,0x50,0x50,0x78,0xA8,0xA8,0x90,0x6C,0x00,0x00,0x00}, //&
{0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //`
{0x04,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x04,0x00,0x00}, //(
{0x40,0x20,0x10,0x10,0x10,0x10,0x10,0x10,0x20,0x40,0x00,0x00}, //)
{0x00,0x00,0x20,0xA8,0x70,0x70,0xA8,0x20,0x00,0x00,0x00,0x00}, //*
{0x00,0x20,0x20,0x20,0xF8,0x20,0x20,0x20,0x00,0x00,0x00,0x00}, //+
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x80,0x00}, //,
{0x00,0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //-
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00}, //.
{0x08,0x10,0x10,0x10,0x20,0x20,0x40,0x40,0x40,0x80,0x00,0x00}, ///
{0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x00,0x00}, //0
{0x00,0x20,0x60,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00,0x00}, //1
{0x00,0x70,0x88,0x88,0x10,0x20,0x40,0x80,0xF8,0x00,0x00,0x00}, //2
{0x00,0x70,0x88,0x08,0x30,0x08,0x08,0x88,0x70,0x00,0x00,0x00}, //3
{0x00,0x10,0x30,0x50,0x50,0x90,0x78,0x10,0x18,0x00,0x00,0x00}, //4
{0x00,0xF8,0x80,0x80,0xF0,0x08,0x08,0x88,0x70,0x00,0x00,0x00}, //5
{0x00,0x70,0x90,0x80,0xF0,0x88,0x88,0x88,0x70,0x00,0x00,0x00}, //6
{0x00,0xF8,0x90,0x10,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00}, //7
{0x00,0x70,0x88,0x88,0x70,0x88,0x88,0x88,0x70,0x00,0x00,0x00}, //8
{0x00,0x70,0x88,0x88,0x88,0x78,0x08,0x48,0x70,0x00,0x00,0x00}, //9
{0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00}, //:
{0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x20,0x20,0x00,0x00}, //;
{0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x00,0x00,0x00}, //<
{0x00,0x00,0x00,0xF8,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00}, //=
{0x40,0x20,0x10,0x08,0x04,0x08,0x10,0x20,0x40,0x00,0x00,0x00}, //>
{0x00,0x70,0x88,0x88,0x10,0x20,0x20,0x00,0x20,0x00,0x00,0x00}, //?
{0x00,0x70,0x88,0x98,0xA8,0xA8,0xB8,0x80,0x78,0x00,0x00,0x00}, //@
{0x00,0x20,0x20,0x30,0x50,0x50,0x78,0x48,0xCC,0x00,0x00,0x00}, //A
{0x00,0xF0,0x48,0x48,0x70,0x48,0x48,0x48,0xF0,0x00,0x00,0x00}, //B
{0x00,0x78,0x88,0x80,0x80,0x80,0x80,0x88,0x70,0x00,0x00,0x00}, //C
{0x00,0xF0,0x48,0x48,0x48,0x48,0x48,0x48,0xF0,0x00,0x00,0x00}, //D
{0x00,0xF8,0x48,0x50,0x70,0x50,0x40,0x48,0xF8,0x00,0x00,0x00}, //E
{0x00,0xF8,0x48,0x50,0x70,0x50,0x40,0x40,0xE0,0x00,0x00,0x00}, //F
{0x00,0x38,0x48,0x80,0x80,0x9C,0x88,0x48,0x30,0x00,0x00,0x00}, //G
{0x00,0xCC,0x48,0x48,0x78,0x48,0x48,0x48,0xCC,0x00,0x00,0x00}, //H
{0x00,0xF8,0x20,0x20,0x20,0x20,0x20,0x20,0xF8,0x00,0x00,0x00}, //I
{0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x90,0xE0,0x00,0x00}, //J
{0x00,0xEC,0x48,0x50,0x60,0x50,0x50,0x48,0xEC,0x00,0x00,0x00}, //K
{0x00,0xE0,0x40,0x40,0x40,0x40,0x40,0x44,0xFC,0x00,0x00,0x00}, //L
{0x00,0xD8,0xD8,0xD8,0xD8,0xA8,0xA8,0xA8,0xA8,0x00,0x00,0x00}, //M
{0x00,0xDC,0x48,0x68,0x68,0x58,0x58,0x48,0xE8,0x00,0x00,0x00}, //N
{0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x00,0x00}, //O
{0x00,0xF0,0x48,0x48,0x70,0x40,0x40,0x40,0xE0,0x00,0x00,0x00}, //P
{0x00,0x70,0x88,0x88,0x88,0x88,0xE8,0x98,0x70,0x18,0x00,0x00}, //Q
{0x00,0xF0,0x48,0x48,0x70,0x50,0x48,0x48,0xEC,0x00,0x00,0x00}, //R
{0x00,0x78,0x88,0x80,0x60,0x10,0x08,0x88,0xF0,0x00,0x00,0x00}, //S
{0x00,0xF8,0xA8,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00,0x00}, //T
{0x00,0xCC,0x48,0x48,0x48,0x48,0x48,0x48,0x30,0x00,0x00,0x00}, //U
{0x00,0xCC,0x48,0x48,0x50,0x50,0x30,0x20,0x20,0x00,0x00,0x00}, //V
{0x00,0xA8,0xA8,0xA8,0x70,0x50,0x50,0x50,0x50,0x00,0x00,0x00}, //W
{0x00,0xD8,0x50,0x50,0x20,0x20,0x50,0x50,0xD8,0x00,0x00,0x00}, //X
{0x00,0xD8,0x50,0x50,0x20,0x20,0x20,0x20,0x70,0x00,0x00,0x00}, //Y
{0x00,0xF8,0x90,0x10,0x20,0x20,0x40,0x48,0xF8,0x00,0x00,0x00}, //Z
{0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x00,0x00}, //[
{0x80,0x40,0x40,0x40,0x20,0x20,0x10,0x10,0x10,0x08,0x00,0x00}, /*\*/
{0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x70,0x00,0x00}, //]
{0x20,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //^
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x00}, //_
{0x40,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //'
{0x00,0x00,0x00,0x00,0x30,0x48,0x38,0x48,0x3C,0x00,0x00,0x00}, //a
{0x00,0xC0,0x40,0x40,0x70,0x48,0x48,0x48,0x70,0x00,0x00,0x00}, //b
{0x00,0x00,0x00,0x00,0x38,0x48,0x40,0x40,0x38,0x00,0x00,0x00}, //c
{0x00,0x18,0x08,0x08,0x38,0x48,0x48,0x48,0x3C,0x00,0x00,0x00}, //d
{0x00,0x00,0x00,0x00,0x30,0x48,0x78,0x40,0x38,0x00,0x00,0x00}, //e
{0x00,0x1C,0x20,0x20,0x78,0x20,0x20,0x20,0x78,0x00,0x00,0x00}, //f
{0x00,0x00,0x00,0x00,0x3C,0x48,0x30,0x40,0x78,0x44,0x38,0x00}, //g
{0x00,0xC0,0x40,0x40,0x70,0x48,0x48,0x48,0xEC,0x00,0x00,0x00}, //h
{0x00,0x20,0x00,0x00,0x60,0x20,0x20,0x20,0x70,0x00,0x00,0x00}, //i
{0x00,0x10,0x00,0x00,0x30,0x10,0x10,0x10,0x10,0x10,0xE0,0x00}, //j
{0x00,0xC0,0x40,0x40,0x5C,0x50,0x70,0x48,0xEC,0x00,0x00,0x00}, //k
{0x00,0xE0,0x20,0x20,0x20,0x20,0x20,0x20,0xF8,0x00,0x00,0x00}, //l
{0x00,0x00,0x00,0x00,0xF0,0xA8,0xA8,0xA8,0xA8,0x00,0x00,0x00}, //m
{0x00,0x00,0x00,0x00,0xF0,0x48,0x48,0x48,0xEC,0x00,0x00,0x00}, //n
{0x00,0x00,0x00,0x00,0x30,0x48,0x48,0x48,0x30,0x00,0x00,0x00}, //o
{0x00,0x00,0x00,0x00,0xF0,0x48,0x48,0x48,0x70,0x40,0xE0,0x00}, //p
{0x00,0x00,0x00,0x00,0x38,0x48,0x48,0x48,0x38,0x08,0x1C,0x00}, //q
{0x00,0x00,0x00,0x00,0xD8,0x60,0x40,0x40,0xE0,0x00,0x00,0x00}, //r
{0x00,0x00,0x00,0x00,0x78,0x40,0x30,0x08,0x78,0x00,0x00,0x00}, //s
{0x00,0x00,0x20,0x20,0x70,0x20,0x20,0x20,0x18,0x00,0x00,0x00}, //t
{0x00,0x00,0x00,0x00,0xD8,0x48,0x48,0x48,0x3C,0x00,0x00,0x00}, //u
{0x00,0x00,0x00,0x00,0xEC,0x48,0x50,0x30,0x20,0x00,0x00,0x00}, //v
{0x00,0x00,0x00,0x00,0xA8,0xA8,0x70,0x50,0x50,0x00,0x00,0x00}, //w
{0x00,0x00,0x00,0x00,0xD8,0x50,0x20,0x50,0xD8,0x00,0x00,0x00}, //x
{0x00,0x00,0x00,0x00,0xEC,0x48,0x50,0x30,0x20,0x20,0xC0,0x00}, //y
{0x00,0x00,0x00,0x00,0x78,0x10,0x20,0x20,0x78,0x00,0x00,0x00}, //z
{0x18,0x10,0x10,0x10,0x20,0x10,0x10,0x10,0x10,0x18,0x00,0x00}, //{
{0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10}, //|
{0x60,0x20,0x20,0x20,0x10,0x20,0x20,0x20,0x20,0x60,0x00,0x00}, //}
{0x40,0xA4,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //~
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00}, //.
{0x00,0x00,0x30,0x30,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00} //CHAR_RTC_DOT
};
void display_char_12(unsigned short *p_mem, int PosX, int PosY, char ch, unsigned short cl)
{
int i = 0,j = 0,px = 0,py = 0;
unsigned char ch_index = 0; /* ascii index */
unsigned char ch_mask = 0; /* ascii characters mask */
unsigned short *pixel = NULL; /* pixel pointer */
// unsigned short *p_mem;
// p_mem = (unsigned short *)display_buf;
/* get start point position */
px = PosX;
py = PosY;
/* get the ascii characters mask index */
ch_index = ascii_load_table[ch];
for (i=0;i<LCD_CHAR_HEIGTH_12;i++)
{
/* get the mask bits */
ch_mask = ascii_table_12[ch_index][i];
/* get canvas display memory pointer */
pixel = p_mem + (py+i)*320 + px + LCD_CHAR_WIDTH_12;
/* adjust the bit mask for 2 blank bit */
ch_mask = ch_mask>>2;
/* write a line of a characters */
for (j=0;j<LCD_CHAR_WIDTH_12;j++)
{
if ((ch_mask % 2) != 0)
{
*pixel = cl;
}
else{*pixel = 0;} /* added by wyf */
ch_mask = ch_mask>>1;
pixel--;
}
}
}
void sendchar( char *ch )
{
char c;
c = *ch;
if (c == 0x08) {/* backspace */
if (row>3){
display_char_12((unsigned short *)display_buf,row*6,line*DISPLAY_LINE_HEIGHT,0x20,0xffff);
row--;
}
}
else if ((c == 0x0d)||(c == 0x0a)){
display_char_12((unsigned short *)display_buf,row*6,line*DISPLAY_LINE_HEIGHT,0,0xffff);
row=0;
totalline++;
line++;
if (line >= DISPLAY_LINE_MAX) line = 0;
memset(display_buf[line*DISPLAY_LINE_HEIGHT], 0, 320*DISPLAY_LINE_HEIGHT*2);
}
else{
display_char_12((unsigned short *)display_buf,row*6,line*DISPLAY_LINE_HEIGHT,c,0xffff);
row++;
if (row >= 53){
row = 0;
totalline++;
line++;
if (line >= DISPLAY_LINE_MAX) line = 0;
memset(display_buf[line*DISPLAY_LINE_HEIGHT], 0, 320*DISPLAY_LINE_HEIGHT*2);
}
}
}
void mputs(char *s)
{
while(*s){
sendchar(s++);
}
}
void mputc(char c)
{
sendchar(&c);
}
void clear_line(void)
{
display_char_12((unsigned short *)display_buf,row*6,line*DISPLAY_LINE_HEIGHT,0,0xffff);
memset(display_buf[line*DISPLAY_LINE_HEIGHT], 0, 320*DISPLAY_LINE_HEIGHT*2);
row=0;
}
void cursor_shink(void)
{
static char c;
if (c == '_') c = 0x20;
else c = '_';
display_char_12((unsigned short *)display_buf,row*6,line*DISPLAY_LINE_HEIGHT,c,0xffff);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -