深圳做高端网站建设公司,多用户商城系统源码下载,wordpress网站源码分享,如何制作自己的网站链接教程一个1.69寸SPI接口的液晶显示模块#xff0c;有320*24076800个点#xff0c;每个点有2个字节表示RGB的颜色#xff0c;所以需要153.6K个字节的数据来刷新全屏#xff0c;如果SPI口输出数据不是高速并且不紧密排列的话#xff0c;刷新就会比较慢#xff0c;有从下到下的肉…一个1.69寸SPI接口的液晶显示模块有320*24076800个点每个点有2个字节表示RGB的颜色所以需要153.6K个字节的数据来刷新全屏如果SPI口输出数据不是高速并且不紧密排列的话刷新就会比较慢有从下到下的肉眼可见的刷新过程现就是希望使用数据缓冲区我理解这就是显存的概念吧来快速刷新显示区域。 原始的单个字符的显示程序
/******************************************************************************函数说明显示单个字符入口数据x,y显示坐标num 要显示的字符fc 字的颜色bc 字的背景色sizey 字号mode: 0非叠加模式 1叠加模式返回值 无
******************************************************************************/
void LCD_ShowChar(uint16_t x,uint16_t y,uint8_t num,uint16_t fc,uint16_t bc,uint8_t sizey,uint8_t mode)
{uint8_t temp,sizex,t,m0;uint16_t i,TypefaceNum;//一个字符所占字节大小uint16_t x0x;sizexsizey/2;TypefaceNum(sizex/8((sizex%8)?1:0))*sizey;numnum- ; //得到偏移后的值LCD_Address_Set(x,y,xsizex-1,ysizey-1); //设置光标位置for(i0;iTypefaceNum;i){ if(sizey12)tempascii_1206[num][i]; //调用6x12字体else if(sizey16)tempascii_1608[num][i]; //调用8x16字体else if(sizey24)tempascii_2412[num][i]; //调用12x24字体else if(sizey32)tempascii_3216[num][i]; //调用16x32字体else return;for(t0;t8;t){if(!mode)//非叠加模式{if(temp(0x01t))LCD_WR_DATA(fc); //每一个点发送2个字节数据else LCD_WR_DATA(bc);m;if(m%sizex0){m0;break;}}else//叠加模式{if(temp(0x01t))LCD_DrawPoint(x,y,fc);//画一个点x;if((x-x0)sizex){xx0;y;break;}}}}
}由if(temp(0x01t))LCD_WR_DATA(fc); //每一个点发送2个字节数据 else LCD_WR_DATA(bc); 这几句说明每个点由SPI发送2个字节的数据出去而且是一边计算数据一边发送数据速度较慢可以肉眼可见的逐字显示的。
改用缓冲区显示单个字符
void LCD_ShowChar_new(uint16_t x,uint16_t y,uint8_t num,uint16_t fc,uint16_t bc,uint8_t sizey,uint8_t mode)
{uint8_t temp,sizex,t,m0;uint16_t i,TypefaceNum;//一个字符所占字节大小uint16_t x0x;sizexsizey/2;TypefaceNum(sizex/8((sizex%8)?1:0))*sizey;numnum- ; //得到偏移后的值//LCD_Address_Set(x,y,xsizex-1,ysizey-1); //设置光标位置//uint8_t data[TypefaceNum * 2 * 8]; //static uint8_t data[1024]; //重要用静态变量或者用全局变量一个字符作为一个缓冲区uint16_t xx 0;for(i0; iTypefaceNum; i){if(sizey12)tempascii_1206[num][i]; //调用6x12字体else if(sizey16)tempascii_1608[num][i]; //调用8x16字体else if(sizey24)tempascii_2412[num][i]; //调用12x24字体else if(sizey32)tempascii_3216[num][i]; //调用16x32字体else return;for(t0;t8;t){if(!mode)//非叠加模式 带缓冲区实现快显示功能{if(temp(0x01t)){data[xx] fc8;data[xx] fc;
// data[i*2*8 t] fc8;
// data[i*2*8 t 1] fc;
// LCD_WR_DATA(fc);}else{data[xx] bc8;data[xx] bc;
// data[i*2*8 t] bc8;
// data[i*2*8 t 1] bc;
// LCD_WR_DATA(bc);}m;if(m%sizex0){m0;break;}}else//叠加模式{if(temp(0x01t))LCD_DrawPoint(x,y,fc);//画一个点x;if((x-x0)sizex){xx0;y;break;}}}}while(HAL_SPI_GetState(hspi1)HAL_SPI_STATE_BUSY_TX); //等待SPI发送完成LCD_Address_Set(x,y,xsizex-1,ysizey-1); //设置光标位置//while(HAL_SPI_GetState(hspi1)HAL_SPI_STATE_BUSY_TX); //等待SPI发送完成HAL_SPI_Transmit_DMA(hspi1, data, TypefaceNum * 2 * 8); //这句有严重问题会死机OK
// while(HAL_SPI_GetState(hspi1)HAL_SPI_STATE_BUSY_TX); //等待SPI发送完成}使用缓冲区的方法还是和全屏刷新一样先把数据都放在数组然后一次性SPI口发送出去。 缓冲区的大小是按照32字体大小的字符来计算32字体是 16*32512个点1024个字节所以使用data是1024个字节的缓冲区这个缓冲区必须是静态或者全局的这个问题困扰了我好久一开始就是显示不正常或者死机我的理解是SPI要取数据发送但缓冲区没有了被系统回收了。 使用缓冲区后字符显示都是直接显示不再是一个一个字符逐个显示的感觉了 文章转载自: http://www.morning.xqkjp.cn.gov.cn.xqkjp.cn http://www.morning.gsjzs.cn.gov.cn.gsjzs.cn http://www.morning.nxdqz.cn.gov.cn.nxdqz.cn http://www.morning.mynbc.cn.gov.cn.mynbc.cn http://www.morning.skql.cn.gov.cn.skql.cn http://www.morning.mfltz.cn.gov.cn.mfltz.cn http://www.morning.jgcyn.cn.gov.cn.jgcyn.cn http://www.morning.dzzjq.cn.gov.cn.dzzjq.cn http://www.morning.mqmxg.cn.gov.cn.mqmxg.cn http://www.morning.rwmqp.cn.gov.cn.rwmqp.cn http://www.morning.xtxp.cn.gov.cn.xtxp.cn http://www.morning.pumali.com.gov.cn.pumali.com http://www.morning.lzdbb.cn.gov.cn.lzdbb.cn http://www.morning.tpdg.cn.gov.cn.tpdg.cn http://www.morning.27asw.cn.gov.cn.27asw.cn http://www.morning.smsjx.cn.gov.cn.smsjx.cn http://www.morning.btlsb.cn.gov.cn.btlsb.cn http://www.morning.hngmg.cn.gov.cn.hngmg.cn http://www.morning.tjwfk.cn.gov.cn.tjwfk.cn http://www.morning.cldgh.cn.gov.cn.cldgh.cn http://www.morning.hkswt.cn.gov.cn.hkswt.cn http://www.morning.rtmqy.cn.gov.cn.rtmqy.cn http://www.morning.wmnpm.cn.gov.cn.wmnpm.cn http://www.morning.xcxj.cn.gov.cn.xcxj.cn http://www.morning.mlcnh.cn.gov.cn.mlcnh.cn http://www.morning.xlbtz.cn.gov.cn.xlbtz.cn http://www.morning.fdrb.cn.gov.cn.fdrb.cn http://www.morning.wrlcy.cn.gov.cn.wrlcy.cn http://www.morning.kgqpx.cn.gov.cn.kgqpx.cn http://www.morning.sfgzx.cn.gov.cn.sfgzx.cn http://www.morning.syxmx.cn.gov.cn.syxmx.cn http://www.morning.dfkmz.cn.gov.cn.dfkmz.cn http://www.morning.iterlog.com.gov.cn.iterlog.com http://www.morning.qphdp.cn.gov.cn.qphdp.cn http://www.morning.ydxwj.cn.gov.cn.ydxwj.cn http://www.morning.fqqcd.cn.gov.cn.fqqcd.cn http://www.morning.nykzl.cn.gov.cn.nykzl.cn http://www.morning.flncd.cn.gov.cn.flncd.cn http://www.morning.shxrn.cn.gov.cn.shxrn.cn http://www.morning.qcdtzk.cn.gov.cn.qcdtzk.cn http://www.morning.xqcgb.cn.gov.cn.xqcgb.cn http://www.morning.fwjfh.cn.gov.cn.fwjfh.cn http://www.morning.nxstj.cn.gov.cn.nxstj.cn http://www.morning.bmhc.cn.gov.cn.bmhc.cn http://www.morning.srgwr.cn.gov.cn.srgwr.cn http://www.morning.jbqwb.cn.gov.cn.jbqwb.cn http://www.morning.pqnps.cn.gov.cn.pqnps.cn http://www.morning.bzcjx.cn.gov.cn.bzcjx.cn http://www.morning.ksjnl.cn.gov.cn.ksjnl.cn http://www.morning.phxdc.cn.gov.cn.phxdc.cn http://www.morning.lfbzg.cn.gov.cn.lfbzg.cn http://www.morning.spftz.cn.gov.cn.spftz.cn http://www.morning.dpqqg.cn.gov.cn.dpqqg.cn http://www.morning.jzsgn.cn.gov.cn.jzsgn.cn http://www.morning.wfkbk.cn.gov.cn.wfkbk.cn http://www.morning.rcrnw.cn.gov.cn.rcrnw.cn http://www.morning.rmryl.cn.gov.cn.rmryl.cn http://www.morning.bwkzn.cn.gov.cn.bwkzn.cn http://www.morning.yhtnr.cn.gov.cn.yhtnr.cn http://www.morning.zqdzg.cn.gov.cn.zqdzg.cn http://www.morning.cpktd.cn.gov.cn.cpktd.cn http://www.morning.mfmx.cn.gov.cn.mfmx.cn http://www.morning.rcrnw.cn.gov.cn.rcrnw.cn http://www.morning.zfkxj.cn.gov.cn.zfkxj.cn http://www.morning.wsnjn.cn.gov.cn.wsnjn.cn http://www.morning.xkwyk.cn.gov.cn.xkwyk.cn http://www.morning.ppqzb.cn.gov.cn.ppqzb.cn http://www.morning.fmdvbsa.cn.gov.cn.fmdvbsa.cn http://www.morning.nmtyx.cn.gov.cn.nmtyx.cn http://www.morning.tnbsh.cn.gov.cn.tnbsh.cn http://www.morning.bhpsz.cn.gov.cn.bhpsz.cn http://www.morning.flqbg.cn.gov.cn.flqbg.cn http://www.morning.rbnp.cn.gov.cn.rbnp.cn http://www.morning.xxrwp.cn.gov.cn.xxrwp.cn http://www.morning.ltkzb.cn.gov.cn.ltkzb.cn http://www.morning.mbprq.cn.gov.cn.mbprq.cn http://www.morning.xdxpq.cn.gov.cn.xdxpq.cn http://www.morning.c7622.cn.gov.cn.c7622.cn http://www.morning.dzpnl.cn.gov.cn.dzpnl.cn http://www.morning.wsnbg.cn.gov.cn.wsnbg.cn