/*----------------------------------------
汉字与32位字体组合,以汉字(2节节)做索引 取模方式:字节倒序,纵向取模 ------------------------------------------*/ typedef struct{ uchar chineselib[2]; uchar zimolib [32]; }testlib; code testlib comlib[]={ "〇", 0x00,0x00,0x00,0x00,0xE0,0xF0,0x18,0x08,0x08,0x18,0xF0,0xE0,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x0F,0x1F,0x30,0x20,0x20,0x30,0x1F,0x0F,0x00,0x00,0x00,0x00, "一", 0x00,0x00,0x00,0x00,0x00,0x10,0x10,0xF8,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x3F,0x20,0x20,0x00,0x00,0x00,0x00,0x00, "二", 0x00,0x00,0x00,0x00,0x70,0x78,0x08,0x08,0x88,0xF8,0x70,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x30,0x38,0x2C,0x26,0x23,0x31,0x30,0x00,0x00,0x00,0x00,0x00, "三", 0x00,0x00,0x00,0x00,0x30,0x38,0x88,0x88,0xC8,0x78,0x30,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x18,0x38,0x20,0x20,0x21,0x3F,0x1E,0x00,0x00,0x00,0x00,0x00, "四", 0x00,0x00,0x00,0x00,0x00,0xC0,0xE0,0x30,0xFC,0xFC,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x03,0x07,0x24,0x24,0x3F,0x3F,0x24,0x20,0x00,0x00,0x00,0x00, "五", 0x00,0x00,0x00,0x00,0xF8,0xF8,0x88,0x88,0x88,0x88,0x08,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x19,0x39,0x21,0x20,0x20,0x3F,0x1F,0x00,0x00,0x00,0x00,0x00,}
uint index_chinese(uchar chinese_get_low, uchar chinese_get_high) { testlib *findcount; uint position = 0; //位置
for(findcount=comlib;(findcount->chineselib[0] != chinese_get_low) || (findcount->chineselib[1] != chinese_get_high);findcount++) { if( (findcount->chineselib[0] == 0) && (findcount->chineselib[1] == 0) ) return 0x00;//找不到就退出 position++; } return position; }
void chinese_string_process(uchar xaddress,uchar Lcdlayer, uchar* chinese_string) { testlib *findpost; //最终定位坐标 uchar *outdata; bit L_R_display = 0; //0=左窗口 uchar chinese_get_low,chinese_get_high; //汉字内码 uchar scan_16cow_count; //16行扫描计数 uchar address; //显示屏的物理地址设置ADC(A0)=0xa0是0~61,ADC(A0)=0xa1是19~80 while(*chinese_string) { chinese_get_low = *chinese_string; //取内码 chinese_string++; chinese_get_high = *chinese_string; chinese_string++; findpost = comlib + index_chinese(chinese_get_low,chinese_get_high); //坐标已经算出来了 outdata = findpost->zimolib; //输出数据的起始位置 //-------下面为显示部分,不同硬件不同驱动,我这字模16*16显示--------- for (scan_16cow_count = 16; scan_16cow_count > 1; scan_16cow_count--) { if (xaddress > 79) { L_R_display = 1; address = xaddress % 80+19; } else address = xaddress;
if( Lcdlayer == 0 ) //显示第一层 { lcd_set_page(0,0); lcd_set_address(address,address); if ( L_R_display ) lcd_send_data_to_E1 ( *outdata ); else lcd_send_data_to_E2 ( *outdata ); lcd_set_page(1,1); lcd_set_address(address,address); if ( L_R_display ) lcd_send_data_to_E1( *(outdata+16) ); else lcd_send_data_to_E2( *(outdata+16) ); } else //否则,显示第二层 { lcd_set_page(2,2); lcd_set_address(address,address); if ( L_R_display ) lcd_send_data_to_E1 ( *outdata ); else lcd_send_data_to_E2 ( *outdata ); lcd_set_page(3,3); lcd_set_address(address,address); if ( L_R_display ) lcd_send_data_to_E1( *(outdata+16) ); else lcd_send_data_to_E2( *(outdata+16) ); }
xaddress++; outdata++;
} }
}
使用范例 chinese_string_process(16*3+19,layer,"〇一二五三四");
|