<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > stm32控制lcd寫字符,畫線,漢字等

          stm32控制lcd寫字符,畫線,漢字等

          作者: 時間:2016-12-03 來源:網(wǎng)絡(luò) 收藏
          1、畫直線算法

          對于畫直線,在lcd上由于顯示的粒度問題,就區(qū)別到x,y軸上的步調(diào)問題。涉及到步調(diào)問題,就牽扯到,斜率問題。因此,畫線算法就算將就完成了,還要注意相對于lcd來說,x,y軸又是什么一個方向?,F(xiàn)實(shí)現(xiàn)一個比較粗略的畫線算法。

          本文引用地址:http://www.ex-cimer.com/article/201612/325183.htm

          void lcd_line(u16 x1,u16 y1,u16 x2,u16 y2,u16 Color)

          {

          u16 temp,x,y;

          Set_direction(0);

          if((x1 == x2) && (y1 == y2))

          {

          //畫原點(diǎn)

          LCD_open_windows(x1,y1,1,1);

          }

          else if(abs(y1-y2)>abs(x1-x2))

          {

          //走y軸,同時判斷大小,進(jìn)行交換

          if(y1 > y2)

          {

          x1 ^= x2 ^= x1 ^= x2;

          y1 ^= y2 ^= y1 ^= y2;

          }

          for( y = y1 ; y <= y2; y ++)

          {

          x = x1 + (y - y1) * (x2 - x1) / (y2 - y1);

          LCD_ColorPoint(x ,y ,Color);

          }

          }

          else

          {

          if(x1 > x2)

          {

          x1 ^= x2 ^= x1 ^= x2;

          y1 ^= y2 ^= y1 ^= y2;

          }

          for( x = x1 ; x <= x2; x ++)

          {

          y = y1 + (x - x1) * (y2 - y1) / (x2 - x1);

          LCD_ColorPoint(x ,y ,Color);

          }

          }

          }

          主要是要關(guān)注,斜率問題,以及了解lcd的屬性,斜率大于1,要知道,走y軸,才能密集x軸,而不會出現(xiàn)一個明顯的斷點(diǎn)。

          2、寫ascii。

          對應(yīng)寫ascii,可以先做一個字模,取對應(yīng)的字模,如8 * 16,由于lcd寫ascii的原理,主要是打點(diǎn),因此,可以對A寫一個簡單的程序

          unsigned char code_A[]=

          {

          /*------------------------------------------------------------------------------

          ;若數(shù)據(jù)亂碼,請檢查字模格式設(shè)置,注意選擇正確的取模方向和字節(jié)位順序。

          ;源文件/文字: A

          ;寬×高(像素): 8×16

          ;字模格式/大小:單色點(diǎn)陣液晶字模,橫向取模,字節(jié)正序/16字節(jié)

          ;數(shù)據(jù)轉(zhuǎn)換日期 : 2015/2/10 15:00:31

          ------------------------------------------------------------------------------*/

          //0x08,0x10,0x01,//寬的像素?cái)?shù),高的像素?cái)?shù),寬的字節(jié)數(shù),參數(shù)設(shè)置可選

          0x00,0x00,0x00,0x08,0x08,0x0C,0x14,0x14,0x12,0x1E,0x22,0x21,0x21,0x73,0x00,0x00,

          };

          //8 * 16的ascii字符

          void lcd_ascii(u16 x,u16 y,const u8 *str,u16 Color)

          {

          u8 i , j;

          u8 temp;

          for (i = 0;i < 16 ; i ++)

          {

          temp = str[i];

          for(j = 0 ;j < 8 ; j ++)

          {

          if((temp >> (7 - j) ) & 0x01 == 0x01)

          {

          LCD_ColorPoint(x + (j) ,y + i,Color);

          }

          }

          }

          }

          主要原理是,取得要顯示的每一位值,是1寫對應(yīng)的值即可。

          unsigned char code_A_24x48[]=

          {

          /*------------------------------------------------------------------------------

          ;若數(shù)據(jù)亂碼,請檢查字模格式設(shè)置,注意選擇正確的取模方向和字節(jié)位順序。

          ;源文件/文字: A

          ;寬×高(像素): 24×48

          ;字模格式/大小:單色點(diǎn)陣液晶字模,橫向取模,字節(jié)正序/144字節(jié)

          ;數(shù)據(jù)轉(zhuǎn)換日期 : 2015/2/10 15:09:19

          ------------------------------------------------------------------------------*/

          //0x18,0x30,0x03,//寬的像素?cái)?shù),高的像素?cái)?shù),寬的字節(jié)數(shù),參數(shù)設(shè)置可選

          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

          0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x38,0x00,0x00,0x3C,0x00,0x00,0x7C,

          0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x6C,0x00,0x00,0xCE,0x00,0x00,0xCE,0x00,

          0x00,0xCE,0x00,0x00,0xC6,0x00,0x01,0x87,0x00,0x01,0x87,0x00,0x01,0x87,0x00,0x01,

          0x83,0x00,0x03,0x03,0x80,0x03,0x03,0x80,0x03,0x03,0x80,0x03,0x03,0x80,0x06,0x01,

          0xC0,0x07,0xFF,0xC0,0x06,0x01,0xC0,0x06,0x01,0xC0,0x0C,0x01,0xE0,0x0C,0x00,0xE0,

          0x0C,0x00,0xE0,0x0C,0x00,0xE0,0x18,0x00,0xF0,0x18,0x00,0x70,0x18,0x00,0x70,0x18,

          0x00,0x70,0x38,0x00,0x78,0xFE,0x01,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

          };

          void lcd_ascii_24x48(u16 x,u16 y,const u8 *str,u16 Color)

          {

          u8 i,j,k;

          u8 buffer[3];

          for (i = 0;i < 48 ; i ++)

          {

          for(j = 0; j < 3 ; j ++)

          {

          buffer[j] = str[i * 3 + j];

          }

          for( j = 0; j < 3 ; j ++)

          {

          for (k = 0 ; k < 8 ; k++)

          {

          if( ( buffer[j] >> (7 - k)) & 0x01 == 0x01)

          {

          LCD_ColorPoint(x + 8 * (j) + k,y + i,Color);

          }

          }

          }

          }

          }

          3、寫漢字

          unsigned char yuan[]=

          {

          /*------------------------------------------------------------------------------

          ;若數(shù)據(jù)亂碼,請檢查字模格式設(shè)置,注意選擇正確的取模方向和字節(jié)位順序。

          ;源文件/文字:袁

          ;寬×高(像素): 48×48

          ;字模格式/大小:單色點(diǎn)陣液晶字模,橫向取模,字節(jié)正序/288字節(jié)

          ;數(shù)據(jù)轉(zhuǎn)換日期 : 2015/2/10 13:17:47

          ------------------------------------------------------------------------------*/

          //0x30,0x30,0x06,//寬的像素?cái)?shù),高的像素?cái)?shù),寬的字節(jié)數(shù),參數(shù)設(shè)置可選

          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,

          0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,

          0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0xC0,0x0C,0x00,0x00,0x00,0x00,0xC0,0x1E,0x00,

          0x00,0x1F,0xFF,0xFF,0xFF,0x00,0x00,0x08,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0xC0,

          0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x40,0x00,0x00,

          0x00,0xC0,0x00,0xE0,0x07,0xFF,0xFF,0xFF,0xFF,0xF0,0x03,0xFF,0xFF,0xFF,0xFF,0xF8,

          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x10,0x00,0x00,0x06,0x00,0x00,

          0x3C,0x00,0x00,0x07,0xFF,0xFF,0xFC,0x00,0x00,0x07,0x00,0x00,0x38,0x00,0x00,0x07,

          0x00,0x00,0x38,0x00,0x00,0x07,0x00,0x00,0x38,0x00,0x00,0x07,0x00,0x00,0x38,0x00,

          0x00,0x07,0x00,0x00,0x38,0x00,0x00,0x07,0x00,0x00,0x38,0x00,0x00,0x07,0xFF,0xFF,

          0xF8,0x00,0x00,0x07,0xFF,0xFF,0xF8,0x00,0x00,0x07,0x0F,0x10,0x31,0x80,0x00,0x04,

          0x1E,0x18,0x03,0xC0,0x00,0x00,0x3C,0x08,0x07,0xE0,0x00,0x00,0x78,0x0C,0x0F,0x00,

          0x00,0x00,0xF8,0x06,0x1C,0x00,0x00,0x01,0xF8,0x07,0x70,0x00,0x00,0x07,0xB8,0x03,

          0xC0,0x00,0x00,0x0E,0x38,0x01,0xC0,0x00,0x00,0x1C,0x38,0x00,0xE0,0x00,0x00,0x70,

          0x38,0x00,0x70,0x00,0x01,0xC0,0x38,0x10,0x7C,0x00,0x03,0x00,0x38,0xE0,0x3F,0x00,

          0x0C,0x00,0x3B,0xC0,0x0F,0xE0,0x10,0x00,0x3F,0x00,0x07,0xFC,0x00,0x00,0x7E,0x00,

          0x03,0xF0,0x00,0x00,0x38,0x00,0x00,0xE0,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,

          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

          };

          //lcd顯示48 * 48字符

          void lcd_show_48x48(u16 x,u16 y,const u8 *str,u16 Color)

          {

          u8 i,j,k;

          u8 buffer[6];

          for (i = 0;i < 48 ; i ++)

          {

          for(j = 0; j < 6 ; j ++)

          {

          buffer[j] = str[i * 6 + j];

          }

          for( j = 0; j < 6 ; j ++)

          {

          for (k = 0 ; k < 8 ; k++)

          {

          if( ( buffer[j] >> 7 - k) & 0x01 == 0x01)

          {

          LCD_ColorPoint(x + 8 * (j) + k,y + i,Color);

          }

          }

          }

          }

          }



          關(guān)鍵詞: stm32控制lcd字符畫線漢

          評論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();