📄 lcm.c
字号:
uint8 temp;
int z;
if(offs==0){//when first line is times of 8
MemCopy(pp,pm,wide,(ctrl&0x01));//get the data with ctrl mode
if(high>=8){//still have a full row line data to write
//MemCopy(pp,pm,ctrl,wide);
high=high-8;
}else {//have a last line need part of the pp data
SetPosition(row, scol);
rdat();//Dummy Read
for( z=0;z<wide;z++){
temp=rdat();
//temp=LcmRDat(row,scol+z);
*(pm+z)=(*(pm+z)&ByteMask[high])|(temp&(~ByteMask[high]));
}
high-=high;
}
pp+=wide;//pp move
}else{//first line is not times of 8
uint8 Mask;
if(sxrow%8!=0){//always this is the first line
MemCopy(pp,pm,wide,(ctrl&0x01)|(1<<MCLSEN)|(offs<<MCSHIFTBITS));//get the data and left shift offs bits
if(high<8-offs){//this case always when then end
Mask=ByteMask[offs]|(~ByteMask[offs+high]);
sxrow+=high;
high-=high;
}else {
Mask=ByteMask[offs];
sxrow+=(8-offs);
high-=(8-offs);
}
SetPosition(row, scol);
rdat();//Dummy Read
for( z=0;z<wide;z++){
temp=rdat();
//temp=LcmRDat(row,scol+z);
*(pm+z)=*(pm+z)|(temp&Mask);
}
//pp still in the first line;
}else{//case that first bit is in times of 8
MemCopy(pp,pm,wide,(ctrl&0x01)|(1<<MCRSEN)|((8-offs)<<MCSHIFTBITS));//get the data and left shift offs bits
pp+=wide;//pp move
for( z=0;z<wide;z++){
if(ctrl&0x01){
#ifdef AVRBITMAPPGM
temp=~(pgm_read_byte(pp+z));
#else
temp=~(*(pp+z));
#endif
}else{
#ifdef AVRBITMAPPGM
temp=pgm_read_byte(pp+z);
#else
temp=*(pp+z);
#endif
}
*(pm+z)=*(pm+z)|(temp<<offs);
}
if(high<8){//this case always when the end
SetPosition(row, scol);
rdat();//Dummy Read
for( z=0;z<wide;z++){
temp=rdat();
*(pm+z)=(*(pm+z)&ByteMask[high])|(temp&(~ByteMask[high]));
}
sxrow+=high;
high-=high;
}else{
sxrow+=8;
high-=8;
}
}
}
}//end Get a row line data
LcmPutRowData(row, scol, pm,wide);
}
free(pm);
return 0;
}
/*
name:LcmDBmp()
function:draw the rect
author:einsn
date :2006-11-27
*/
#ifdef AVRBITMAPPGM
void LcmDBmp(uint8 xrow,uint8 col,BITMAP* pp)
{
uint8 high,wide;
high=pgm_read_byte(pp++);
wide=pgm_read_byte(pp++);
LcmDPic(xrow&0x7f,col,high,wide,(xrow>>7),pp);
}
#endif
/*
name:LcmFill()
function:
author:einsn
date :2006-12-24
*/
void LcmFill(uint8 full){
uint8 ii,jj;
for(ii=0;ii<ROWSIZE;ii++){
SetPosition(ii,0);
for(jj=0;jj<COLSIZE;jj++)
wdat(full);
}
}
#if 0
int8 LcmWStr8(uint8 xrow,uint8 col,char *str){
return 0;
}
volatile CURSOR Cursor;
/*
name:CursorAction()
function:
author:einsn
date :2006-12-25
*/
void CursorAction(PCURSOR pCursor){
uint8 offs=pCursor->Row%8;
uint8 r;
uint8 high=pCursor->Rlen;
uint8 *pm=(uint8*)malloc(pCursor->Clen);
uint8 ByteMask[8]={0,0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f};
if(pm==NULL)return ;
pCursor->Reverse^=0x01;//reverse
for(r=pCursor->Row/8;r<(pCursor->Row+pCursor->Rlen)/8+1;r++){
if(offs==0){
if(high>=8){
LcmGetRowData(r,pCursor->Col,pm,pCursor->Clen);
for(uint8 z=0;z<pCursor->Clen;z++){
*(pm+z)=~(*(pm+z));
}
LcmPutRowData(r,pCursor->Col,pm,pCursor->Clen);
high-=8;
}else {
LcmGetRowData(r,pCursor->Col,pm,pCursor->Clen);
for(uint8 z=0;z<pCursor->Clen;z++){
*(pm+z)=(~(*(pm+z))&ByteMask[high])|(*(pm+z)&(~ByteMask[high]));
}
LcmPutRowData(r,pCursor->Col,pm,pCursor->Clen);
high-=high;
}
}else{
uint8 mask;
if(high<(8-offs)){
mask=ByteMask[offs]|(~ByteMask[offs+high]);
high-=high;
}else {
mask=ByteMask[offs];
high-=(8-offs);
}
LcmGetRowData(r,pCursor->Col,pm,pCursor->Clen);
for(uint8 z=0;z<pCursor->Clen;z++){
*(pm+z)=((~(*(pm+z)))&(~mask))|(*(pm+z)&mask);
}
LcmPutRowData(r,pCursor->Col,pm,pCursor->Clen);
offs=0;
}
}
free(pm);
}
/*
name:CursorAction()
function:
author:einsn
date :2006-12-25
REVERTIMES: the times of the signal const
*/
#define CURREVERTIMES 40
void CursorTimerHook(void *p)
{
if(Cursor.Active==1){
if(Cursor.Cnt>CURREVERTIMES){
Cursor.Cnt=0;
CursorAction((PCURSOR)&Cursor);
}else {
Cursor.Cnt++;
}
}
}
int8 LcmCursor(uint8 row,uint8 col,uint8 rlen,uint8 clen,uint8 ctrl){
if(ctrl==CURSOR_OPEN){
if(Cursor.Active==1){
if(Cursor.Reverse==1){
CursorAction((PCURSOR)&Cursor);
}
Cursor.Active=0;
Cursor.Reverse=0;
SIGTimerRemove((SIGNALHOOK)CursorTimerHook,(void*)NULL);
}
{
Cursor.Row=row;
Cursor.Col=col;
Cursor.Rlen=rlen;
Cursor.Clen=clen;
if(rlen==0||clen==0)return -1;
Cursor.Active=1;
Cursor.Reverse=0;
Cursor.Cnt=0;
if(SIGTimerLoad((SIGNALHOOK)CursorTimerHook,(void*)NULL)==-1){
Cursor.Active=0;
return -1;
}
Cursor.Active=1;
CursorAction((PCURSOR)&Cursor);//reverse first;
}
}else {
if(Cursor.Active==1){
if(Cursor.Reverse==1){
CursorAction((PCURSOR)&Cursor);
}
Cursor.Active=0;
Cursor.Reverse=0;
SIGTimerRemove((SIGNALHOOK)CursorTimerHook,(void*)NULL);
}
}
return 0;
}
/*
*
* Function below is to support HZ12 & ASC 12
*
* 2007-02-09
*
* Einsn Liu
*
*/
/*
*
* Name:LcmGetHZ12LibData
* Function:display the char data
* Author:Einsn Liu
* Date:2007-02-09
*
*/
static void LcmGetHZ12LibData(char *chn,uint8* pbyte){
PGB12 pGb12=(PGB12)&CLIBHZ12[0];
prog_char *pgm=&pGb12->Index[0];
do{
if(*chn==pgm_read_byte(pgm)&&*(chn+1)==pgm_read_byte(pgm+1)){
//find the lib byte;
pgm=&pGb12->Msk[0];
for(uint8 i=0;i<26;i++){
*pbyte++=pgm_read_byte(pgm++);
}
return;
}
pGb12++;
pgm=&pGb12->Index[0];
}while(pgm_read_byte(pgm)!=0);
//not find
memset(pbyte,0xe7,26);
}
/*
*
* Name:LcmGetASC12LibData
* Function:display the char data
* Author:Einsn Liu
* Date:2007-02-09
*
*/
static void LcmGetASC12LibData(char ch,uint8 *pbyte){
prog_char *pgm=(prog_char*)&CLIBAsc12[0];
uint16 offset;
if(ch<0x20||ch>0x80)return;
offset=(ch-0x20)*14;
pgm+=offset;
for(uint8 i=0;i<14;i++){
*pbyte++=pgm_read_byte(pgm++);
}
}
/*
*
* Name:DispChnAsc12
* Function:display the char data
* Author:Einsn Liu
* Date:2007-02-09
*
*/
static void DispChnAsc12(uint8 xrow,uint8 col, uint8 *ph,uint8 colwide)
{
uint8 i;
uint8 *pm=(uint8 *)malloc(colwide);
if(pm==NULL)return;
if(xrow%8==0)
{
xrow/=8;
LcmPutRowData(xrow,col,ph,colwide);
ph+=colwide;
LcmGetRowData(xrow+1,col, pm, colwide);
for( i=0;i<colwide;i++)
{
*(pm+i)=(*(pm+i)&0xf0)|(*(ph+i)&0x0f);
}
LcmPutRowData(xrow+1,col,pm,colwide);
}else{
uint8 rest=12;
uint8 xl=xrow%8;
uint8 ByteMask[8]={0,0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f};
xrow/=8;
LcmGetRowData(xrow,col, pm, colwide);
for( i=0;i<colwide;i++)
{
*(pm+i)=(*(ph+i)<<xl)|(*(pm+i)&ByteMask[xl]);
}
LcmPutRowData(xrow++,col,pm,colwide);
rest-=(8-xl);
if(rest>7){
for( i=0;i<colwide;i++)
{
*(pm+i)=(*(ph+i)>>(8-xl))|(*(ph+colwide+i)<<xl);
}
LcmPutRowData(xrow++,col,pm,colwide);
rest-=8;
ph+=colwide;
if(rest>0){
LcmGetRowData(xrow,col, pm, colwide);
for( i=0;i<colwide;i++)
{
*(pm+i)=(*(ph+i)>>(4-rest))|(*(pm+i)&~ByteMask[rest]);
}
LcmPutRowData(xrow,col,pm,colwide);
}
}else{
for( i=0;i<colwide;i++)
{
*(ph+i)=(*(ph+i)>>(8-xl))|(*(ph+colwide+i)<<xl);
}
//ph+=colwide;
LcmGetRowData(xrow,col, pm, colwide);
for( i=0;i<colwide;i++)
{
*(pm+i)=(*(ph+i)&ByteMask[rest])|(*(pm+i)&~ByteMask[rest]);
}
LcmPutRowData(xrow,col,pm,colwide);
}
}
free(pm);
}
/*
*
* Name:LcmPAsc12
* Function:
* Author:Einsn Liu
* Date:2007-02-09
*
*/
static int8 LcmPAsc12(uint8 xrow,uint8 col,char asc)
{
uint8 rev=xrow>>7;
uint8 *pch;
xrow&=0x7f;
pch=(uint8 *)malloc(14);
if(pch==NULL)return -1;
//memset(phz,0,16);
LcmGetASC12LibData(asc,pch);
if(rev){
for(uint8 i=0;i<14;i++){
*(pch+i)=~(*(pch+i));
}
}
DispChnAsc12(xrow,col,pch,7);
free(pch);
return 0;
}
/*
*
* Name:LcmPChn12
* Function:
* Author:Einsn Liu
* Date:2007-02-09
*
*/
static int8 LcmPChn12(uint8 xrow,uint8 col,char *str)
{
uint8 rev=xrow>>7;
//uint32 ChnCode=*str;
uint8 *phz;
xrow&=0x7f;
phz=(uint8 *)malloc(26);
if(phz==NULL)return -1;
LcmGetHZ12LibData(str,phz);
if(rev){
for(uint8 i=0;i<26;i++){
*(phz+i)=~(*(phz+i));
}
}
DispChnAsc12(xrow,col,phz,13);
free(phz);
return 0;
}
/*
*
* Name:LcmWStr12
* Function:
* Author:Einsn Liu
* Date:2007-02-09
*
*/
int8 LcmWStr12(uint8 xrow,uint8 col,char *str)
{
while(*str!='\0'){
if(*(uint8 *)str<=128){
LcmPAsc12(xrow,col,*str++);
col+=7;
}else {
if(LcmPChn12(xrow,col,str++)==0){
str++;
col+=13;
}
}
}
return 0;
}
/*
* Name:LcmWCStr( )
* Function:
*
* In:the lstr struct handle
* Out:true
*
* Author:Einsn Liu
* Date:2007-02-09
*
*/
int8 LcmWCStr12(uint8 xrow,uint8 col,char *str,uint8 cnt)
{
while(*str!='\0'&&cnt-->0){
if(*(uint8 *)str<=128){
LcmPAsc12(xrow,col,*str++);
col+=7;
}else if(cnt!=0){
if(LcmPChn12(xrow,col,str++)==0){
str++;
col+=13;
cnt--;
}
}
}
return 0;
}
/*
*
* Name:LcmWFStr12
* Function:
* Author:Einsn Liu
* Date:2007-02-09
*
*/
void LcmWFStr12(uint8 xrow,uint8 col,prog_char *fstr)
{
char *p;
p=malloc(strlen_P(fstr)+1);
if(p==NULL)return;
strcpy_P(p,fstr);
LcmWStr12(xrow,col,p);
free(p);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -