久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 4260|回復: 0
打印 上一主題 下一主題
收起左側

102x64LCD的SPI通信程序源代碼

[復制鏈接]
跳轉到指定樓層
樓主
ID:89763 發表于 2015-9-12 20:12 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
  1. /***********************************************************
  2. 函數名稱:LCD_write_byte
  3. 函數功能:模擬SPI接口時序寫數據/命令LCD
  4. 入口參數:data    :寫入的數據;
  5.           command :寫數據/命令選擇;
  6. 出口參數:無
  7. 備 注:
  8. ***********************************************************/
  9. void LCD_write_byte(unsigned char dat, unsigned char command)
  10.   {
  11.     unsigned char i;
  12.     LCD_CE = 0; //5110片選有效,允許輸入數據
  13.     if (command == 0) //寫命令
  14.          LCD_DC = 0;  
  15.     else  
  16.         LCD_DC = 1; //寫數據
  17. for(i=0;i<8;i++) //傳送8bit數據
  18. {
  19.             if(dat&0x80)
  20.      SDIN = 1;
  21.    else
  22.      SDIN = 0;
  23.    SCLK = 0;
  24.    dat = dat << 1;
  25.    SCLK = 1;
  26.           }
  27.      LCD_CE = 1; //禁止5110
  28.   }



  29. /***********************************************************
  30. 函數名稱:LCD_init
  31. 函數功能:5110初始化
  32. 入口參數:無
  33. 出口參數:無
  34. 備 注:
  35. ***********************************************************/
  36. void LCD_init(void)
  37.   {
  38.    LCD_RST = 0;     // 產生一個讓LCD復位的低電平脈沖
  39.     delay_1us();
  40.    LCD_RST = 1;

  41.    LCD_CE = 0;     // 關閉LCD
  42.     delay_1us();
  43.    LCD_CE = 1;     // 使能LCD
  44.     delay_1us();

  45.     LCD_write_byte(0x21, 0);// 使用擴展命令設置LCD模式
  46.     LCD_write_byte(0xc8, 0);// 設置液晶偏置電壓
  47.     LCD_write_byte(0x06, 0);// 溫度校正
  48.     LCD_write_byte(0x13, 0);// 1:48
  49.     LCD_write_byte(0x20, 0);// 使用基本命令,V=0,水平尋址
  50.     LCD_clear();           // 清屏
  51.     LCD_write_byte(0x0c, 0);// 設定顯示模式,正常顯示
  52.    
  53.     LCD_CE = 0;      // 關閉LCD
  54.   }

  55. /***********************************************************
  56. 函數名稱:LCD_set_XY
  57. 函數功能:設置LCD坐標函數
  58. 入口參數:X       :0-83
  59.           Y       :0-5
  60. 出口參數:無
  61. 備 注:
  62. ***********************************************************/
  63. void LCD_set_XY(unsigned char X, unsigned char Y)
  64.   {
  65.     LCD_write_byte(0x40 | Y, 0);  // column
  66.     LCD_write_byte(0x80 | X, 0); // row
  67.   }

  68. /***********************************************************
  69. 函數名稱:LCD_write_char
  70. 函數功能:顯示英文字符
  71. 入口參數:c:  顯示的字符
  72. 出口參數:無
  73. 備 注:
  74. ***********************************************************/
  75. void LCD_write_char(unsigned char c)
  76. {
  77.     unsigned char line;
  78.     c -= 32; //數組的行號
  79.     for (line=0; line<6; line++)
  80.       LCD_write_byte(font6x8[c][line], 1);
  81. }

  82. /***********************************************************
  83. 函數名稱:LCD_draw_bmp_pixel
  84. 函數功能:位圖繪制函數
  85. 入口參數:X、Y    :位圖繪制的起始X、Y坐標;
  86.           *map    :位圖點陣數據;
  87.           Pix_x   :位圖像素(長)
  88.           Pix_y   :位圖像素(寬)
  89. 出口參數:無
  90. 備 注:
  91. ***********************************************************/
  92. void LCD_draw_bmp_pixel(unsigned char X,unsigned char Y,unsigned char *map, unsigned char Pix_x,unsigned char Pix_y)
  93. {
  94.     unsigned int i,n;
  95.     unsigned char row;         //計算位圖所占行數
  96.       if (Pix_y%8==0) //如果為位圖所占行數為整數
  97.          row=Pix_y/8;      
  98.       else
  99.          row=Pix_y/8+1;//如果為位圖所占行數不是整數
  100.       LCD_set_XY(X,Y);
  101.       for (n=0;n<row;n++)     //換行
  102.        {
  103.          for(i=0;i<Pix_x;i++)
  104.            {
  105.     LCD_set_XY(X+i,Y+n);
  106.              LCD_write_byte(map[i+n*Pix_x], 1);
  107.            }                        
  108.        }      
  109. }
復制代碼






  1. #include <stdint.h>
  2. #include "msp430F5529.h"

  3. #define DOGS102x6_DRAW_NORMAL         0x00
  4. #define DOGS102x6_DRAW_INVERT         0x01
  5. // For all commands, CD signal must = 0
  6. #define SET_COLUMN_ADDRESS_MSB        0x10  //Set SRAM col. addr. before write, last 4 bits =
  7.                                             // ca4-ca7
  8. #define SET_COLUMN_ADDRESS_LSB        0x00  //Set SRAM col. addr. before write, last 4 bits =
  9.                                             // ca0-ca3
  10. #define SET_POWER_CONTROL             0x2F  //Set Power control - booster, regulator, and follower
  11.                                             // on
  12. #define SET_SCROLL_LINE               0x40  //Scroll image up by SL rows (SL = last 5 bits),
  13.                                             // range:0-63
  14. #define SET_PAGE_ADDRESS              0xB0  //Set SRAM page addr (pa = last 4 bits), range:0-8
  15. #define SET_VLCD_RESISTOR_RATIO       0x27  //Set internal resistor ratio Rb/Ra to adjust contrast
  16. #define SET_ELECTRONIC_VOLUME_MSB     0x81  //Set Electronic Volume "PM" to adjust contrast
  17. #define SET_ELECTRONIC_VOLUME_LSB     0x0F  //Set Electronic Volume "PM" to adjust contrast (PM =
  18.                                             // last 5 bits)
  19. #define SET_ALL_PIXEL_ON              0xA4  //Disable all pixel on (last bit 1 to turn on all pixels
  20.                                             // - does not affect memory)
  21. #define SET_INVERSE_DISPLAY           0xA6  //Inverse display off (last bit 1 to invert display -
  22.                                             // does not affect memory)
  23. #define SET_DISPLAY_ENABLE            0xAF  //Enable display (exit sleep mode & restore power)
  24. #define SET_SEG_DIRECTION             0xA1  //Mirror SEG (column) mapping (set bit0 to mirror
  25.                                             // display)
  26. #define SET_COM_DIRECTION             0xC8  //Mirror COM (row) mapping (set bit3 to mirror display)
  27. #define SYSTEM_RESET                  0xE2  //Reset the system. Control regs reset, memory not
  28.                                             // affected
  29. #define NOP                           0xE3  //No operation
  30. #define SET_LCD_BIAS_RATIO            0xA2  //Set voltage bias ratio (BR = bit0)
  31. #define SET_CURSOR_UPDATE_MODE        0xE0  //Column address will increment with write operation
  32.                                             // (but no wrap around)
  33. #define RESET_CURSOR_UPDATE_MODE      0xEE  //Return cursor to column address from before cursor
  34.                                             // update mode was set
  35. #define SET_ADV_PROGRAM_CONTROL0_MSB  0xFA  //Set temp. compensation curve to -0.11%/C
  36. #define SET_ADV_PROGRAM_CONTROL0_LSB  0x90

  37. int k;
  38. static const uint8_t FONT6x8[] = {
  39.     /* 6x8 font, each line is a character each byte is a one pixel wide column
  40.      * of that character. MSB is the top pixel of the column, LSB is the bottom
  41.      * pixel of the column. 0 = pixel off. 1 = pixel on. */

  42.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // space
  43.     0x00, 0x00, 0xFA, 0x00, 0x00, 0x00, // !
  44.     0x00, 0xE0, 0x00, 0xE0, 0x00, 0x00, // "
  45.     0x28, 0xFE, 0x28, 0xFE, 0x28, 0x00, // #
  46.     0x24, 0x54, 0xFE, 0x54, 0x48, 0x00, // $
  47.     0xC4, 0xC8, 0x10, 0x26, 0x46, 0x00, // %
  48.     0x6C, 0x92, 0x6A, 0x04, 0x0A, 0x00, // &
  49.     0x00, 0x10, 0xE0, 0xC0, 0x00, 0x00, // '
  50.     0x00, 0x38, 0x44, 0x82, 0x00, 0x00, // (
  51.     0x00, 0x82, 0x44, 0x38, 0x00, 0x00, // )
  52.     0x54, 0x38, 0xFE, 0x38, 0x54, 0x00, // *
  53.     0x10, 0x10, 0x7C, 0x10, 0x10, 0x00, // +
  54.     0x00, 0x02, 0x1C, 0x18, 0x00, 0x00, // ,
  55.     0x10, 0x10, 0x10, 0x10, 0x10, 0x00, // -
  56.     0x00, 0x00, 0x06, 0x06, 0x00, 0x00, // .
  57.     0x04, 0x08, 0x10, 0x20, 0x40, 0x00, // /
  58.     //96 Bytes
  59.     0x7C, 0x8A, 0x92, 0xA2, 0x7C, 0x00, // 0
  60.     0x00, 0x42, 0xFE, 0x02, 0x00, 0x00, // 1
  61.     0x42, 0x86, 0x8A, 0x92, 0x62, 0x00, // 2
  62.     0x84, 0x82, 0x92, 0xB2, 0xCC, 0x00, // 3
  63.     0x18, 0x28, 0x48, 0xFE, 0x08, 0x00, // 4
  64.     0xE4, 0xA2, 0xA2, 0xA2, 0x9C, 0x00, // 5
  65.     0x3C, 0x52, 0x92, 0x92, 0x0C, 0x00, // 6
  66.     0x82, 0x84, 0x88, 0x90, 0xE0, 0x00, // 7
  67.     0x6C, 0x92, 0x92, 0x92, 0x6C, 0x00, // 8
  68.     0x60, 0x92, 0x92, 0x94, 0x78, 0x00, // 9
  69.     0x00, 0x00, 0x28, 0x00, 0x00, 0x00, // :
  70.     0x00, 0x00, 0x02, 0x2C, 0x00, 0x00, // ;
  71.     0x00, 0x10, 0x28, 0x44, 0x82, 0x00, // <
  72.     0x28, 0x28, 0x28, 0x28, 0x28, 0x00, // =
  73.     0x00, 0x82, 0x44, 0x28, 0x10, 0x00, // >
  74.     0x40, 0x80, 0x8A, 0x90, 0x60, 0x00, // ?
  75.     //96*2 = 192 Bytes
  76.     0x7C, 0x82, 0xBA, 0x9A, 0x72, 0x00, // @
  77.     0x3E, 0x48, 0x88, 0x48, 0x3E, 0x00, // A
  78.     0xFE, 0x92, 0x92, 0x92, 0x6C, 0x00, // B
  79.     0x7C, 0x82, 0x82, 0x82, 0x44, 0x00, // C
  80.     0xFE, 0x82, 0x82, 0x82, 0x7C, 0x00, // D
  81.     0xFE, 0x92, 0x92, 0x92, 0x82, 0x00, // E
  82.     0xFE, 0x90, 0x90, 0x90, 0x80, 0x00, // F
  83.     0x7C, 0x82, 0x92, 0x92, 0x5E, 0x00, // G
  84.     0xFE, 0x10, 0x10, 0x10, 0xFE, 0x00, // H
  85.     0x00, 0x82, 0xFE, 0x82, 0x00, 0x00, // I
  86.     0x04, 0x02, 0x82, 0xFC, 0x80, 0x00, // J
  87.     0xFE, 0x10, 0x28, 0x44, 0x82, 0x00, // K
  88.     0xFE, 0x02, 0x02, 0x02, 0x02, 0x00, // L
  89.     0xFE, 0x40, 0x38, 0x40, 0xFE, 0x00, // M
  90.     0xFE, 0x20, 0x10, 0x08, 0xFE, 0x00, // N
  91.     0x7C, 0x82, 0x82, 0x82, 0x7C, 0x00, // O
  92.     //96*3 = 288 Bytes
  93.     0xFE, 0x90, 0x90, 0x90, 0x60, 0x00, // P
  94.     0x7C, 0x82, 0x8A, 0x84, 0x7A, 0x00, // Q
  95.     0xFE, 0x90, 0x98, 0x94, 0x62, 0x00, // R
  96.     0x64, 0x92, 0x92, 0x92, 0x4C, 0x00, // S
  97.     0x80, 0x80, 0xFE, 0x80, 0x80, 0x00, // T
  98.     0xFC, 0x02, 0x02, 0x02, 0xFC, 0x00, // U
  99.     0xF8, 0x04, 0x02, 0x04, 0xF8, 0x00, // V
  100.     0xFC, 0x02, 0x1C, 0x02, 0xFC, 0x00, // W
  101.     0xC6, 0x28, 0x10, 0x28, 0xC6, 0x00, // X
  102.     0xC0, 0x20, 0x1E, 0x20, 0xC0, 0x00, // Y
  103.     0x86, 0x8A, 0x92, 0xA2, 0xC2, 0x00, // Z
  104.     0x00, 0xFE, 0x82, 0x82, 0x82, 0x00, // [
  105.     0x40, 0x20, 0x10, 0x08, 0x04, 0x00, // '\'
  106.     0x00, 0x82, 0x82, 0x82, 0xFE, 0x00, // ]
  107.     0x20, 0x40, 0x80, 0x40, 0x20, 0x00, // ^
  108.     0x01, 0x01, 0x01, 0x01, 0x01, 0x00, // _
  109.     //96*4 = 384 Bytes
  110.     0x00, 0xC0, 0xE0, 0x10, 0x00, 0x00, // `
  111.     0x04, 0x2A, 0x2A, 0x2A, 0x1E, 0x00, // a
  112.     0xFE, 0x14, 0x22, 0x22, 0x1C, 0x00, // b
  113.     0x1C, 0x22, 0x22, 0x22, 0x14, 0x00, // c
  114.     0x1C, 0x22, 0x22, 0x14, 0xFE, 0x00, // d
  115.     0x1C, 0x2A, 0x2A, 0x2A, 0x18, 0x00, // e
  116.     0x00, 0x10, 0x7E, 0x90, 0x40, 0x00, // f
  117.     0x18, 0x25, 0x25, 0x25, 0x3E, 0x00, // g
  118.     0xFE, 0x10, 0x20, 0x20, 0x1E, 0x00, // h
  119.     0x00, 0x22, 0xBE, 0x02, 0x00, 0x00, // i
  120.     0x00, 0x04, 0x02, 0x02, 0xBC, 0x00, // j
  121.     0x00, 0xFE, 0x08, 0x14, 0x22, 0x00, // k
  122.     0x00, 0x82, 0xFE, 0x02, 0x00, 0x00, // l
  123.     0x3E, 0x20, 0x1E, 0x20, 0x1E, 0x00, // m
  124.     0x3E, 0x10, 0x20, 0x20, 0x1E, 0x00, // n
  125.     0x1C, 0x22, 0x22, 0x22, 0x1C, 0x00, // o
  126.     //96*5 = 480 Bytes
  127.     0x3F, 0x18, 0x24, 0x24, 0x18, 0x00, // p
  128.     0x18, 0x24, 0x24, 0x18, 0x3F, 0x00, // q
  129.     0x3E, 0x10, 0x20, 0x20, 0x10, 0x00, // r
  130.     0x12, 0x2A, 0x2A, 0x2A, 0x24, 0x00, // s
  131.     0x20, 0x20, 0xFC, 0x22, 0x24, 0x00, // t
  132.     0x3C, 0x02, 0x02, 0x04, 0x3E, 0x00, // u
  133.     0x38, 0x04, 0x02, 0x04, 0x38, 0x00, // v
  134.     0x3C, 0x02, 0x0C, 0x02, 0x3C, 0x00, // w
  135.     0x22, 0x14, 0x08, 0x14, 0x22, 0x00, // x
  136.     0x32, 0x09, 0x09, 0x09, 0x3E, 0x00, // y
  137.     0x22, 0x26, 0x2A, 0x32, 0x22, 0x00, // z
  138.     0x00, 0x10, 0x6C, 0x82, 0x00, 0x00, // {
  139.     0x00, 0x00, 0xEE, 0x00, 0x00, 0x00, // |
  140.     0x00, 0x82, 0x6C, 0x10, 0x00, 0x00, // }
  141.     0x40, 0x80, 0x40, 0x20, 0x40, 0x00, // ~
  142.     0x00, 0x60, 0x90, 0x90, 0x60, 0x00, // degrees symbol
  143.     //96*6 = 576 Bytes
  144.     //Special Characters ** NON-ASCII **
  145.     0x00, 0x00, 0xFE, 0x82, 0x82, 0x82, // [
  146.     0x82, 0x82, 0x82, 0xFE, 0x00, 0x00  //  ]
  147. };
  148. uint8_t dogs102x6Memory[816 + 2];
  149. uint8_t currentPage = 0, currentColumn = 0;
  150. uint8_t backlight  = 8;
  151. uint8_t contrast = 0x0F;
  152. uint8_t Dogs102x6_initMacro[] = {
  153.     SET_SCROLL_LINE,
  154.     SET_SEG_DIRECTION,
  155.     SET_COM_DIRECTION,
  156.     SET_ALL_PIXEL_ON,
  157.     SET_INVERSE_DISPLAY,
  158.     SET_LCD_BIAS_RATIO,
  159.     SET_POWER_CONTROL,
  160.     SET_VLCD_RESISTOR_RATIO,
  161.     SET_ELECTRONIC_VOLUME_MSB,
  162.     SET_ELECTRONIC_VOLUME_LSB,
  163.     SET_ADV_PROGRAM_CONTROL0_MSB,
  164.     SET_ADV_PROGRAM_CONTROL0_LSB,
  165.     SET_DISPLAY_ENABLE,
  166.     SET_PAGE_ADDRESS,
  167.     SET_COLUMN_ADDRESS_MSB,
  168.     SET_COLUMN_ADDRESS_LSB
  169. };
  170. /***********************************************************
  171. 函數名稱:delay xus
  172. 函數功能:模擬SPI接口時序寫數據/命令LCD
  173. 入口參數:us   :寫入的數據;
  174. 出口參數:無
  175. 備 注:
  176. ***********************************************************/
  177. void delay_xus(unsigned xus)
  178. {
  179.   while(xus--);
  180. }

  181. /***************************************************************************//**
  182. * @brief   Sends commands to LCD via 3 wire SPI
  183. * @param   sCmd Pointer to the commands to be written to the LCD
  184. * @param   i Number of commands to be written to the LCD
  185. * @return  None
  186. ******************************************************************************/

  187. void LCD_write_comd(uint8_t *scmd, uint8_t i)
  188.   {
  189.     uint16_t gie=__get_SR_register() & GIE;
  190.     __disable_interrupt();
  191.     P7OUT &=~BIT4;   //CS=0,選中液晶
  192.     P5OUT &=~BIT6;   //輸入指令
  193.     while(i)
  194.       {
  195.         while (!(UCB1IFG & UCTXIFG)) ;//等待發送
  196.         UCB1TXBUF = *scmd;          //send
  197.         scmd++;
  198.         i--;
  199.       }
  200.     while (UCB1STAT & UCBUSY) ;
  201.     UCB1RXBUF;
  202.     P7OUT |=BIT4;
  203.     __bis_SR_register(gie);
  204.   }
  205. /***************************************************************************//**
  206. * @brief   Sends Data to LCD via 3 wire SPI
  207. * @param   sData Pointer to the Data to be written to the LCD
  208. * @param   i Number of data bytes to be written to the LCD
  209. * @return  None
  210. ******************************************************************************/
  211. void LCD_write_data(uint8_t *sData, uint8_t i)
  212.   {
  213.         uint16_t gie=__get_SR_register() & GIE;
  214.     __disable_interrupt();
  215.     P7OUT &=~BIT4;
  216.     P5OUT |=BIT6;     //select input data
  217.     while(i)
  218.       {
  219.             dogs102x6Memory[2 + (currentPage * 102) + currentColumn] = (uint8_t)*sData;
  220.             currentColumn++;
  221.             if (currentColumn > 101)
  222.                    {
  223.                        currentColumn = 101;
  224.                    }
  225.              while (!(UCB1IFG & UCTXIFG)) ;
  226.              UCB1TXBUF = *sData++;
  227.           i--;
  228.        }
  229.      while (UCB1STAT & UCBUSY) ;
  230.      UCB1RXBUF;
  231.      P7OUT |= BIT4;
  232.      __bis_SR_register(gie);


  233.   }

  234. /***************************************************************************//**
  235. * @brief   Sets Address of the LCD RAM memory
  236. *
  237. *          (0,0) is the upper left corner of screen.
  238. * @param   pa Page Address of the LCD RAM memory to be written (0 - 7)
  239. * @param   ca Column Address of the LCD RAM memory to be written (0 - 101)
  240. * @return  None
  241. ******************************************************************************/

  242. void Dogs102x6_setAddress(uint8_t pa, uint8_t ca)
  243. {
  244.     uint8_t cmd[1];

  245.     // Page boundary check
  246.     if (pa > 7)
  247.     {
  248.         pa = 7;
  249.     }

  250.     // Column boundary check
  251.     if (ca > 101)
  252.     {
  253.         ca = 101;
  254.     }

  255.     // Page Address Command = Page Address Initial Command + Page Address
  256.     cmd[0] = SET_PAGE_ADDRESS + (7 - pa);
  257.     uint8_t H = 0x00;
  258.     uint8_t L = 0x00;
  259.     uint8_t ColumnAddress[] = { SET_COLUMN_ADDRESS_MSB, SET_COLUMN_ADDRESS_LSB };

  260.     currentPage = pa;
  261.     currentColumn = ca;

  262.     // Separate Command Address to low and high
  263.     L = (ca & 0x0F);
  264.     H = (ca & 0xF0);
  265.     H = (H >> 4);
  266.     // Column Address CommandLSB = Column Address Initial Command
  267.     //                             + Column Address bits 0..3
  268.     ColumnAddress[0] = SET_COLUMN_ADDRESS_LSB + L;
  269.     // Column Address CommandMSB = Column Address Initial Command
  270.     //                             + Column Address bits 4..7
  271.     ColumnAddress[1] = SET_COLUMN_ADDRESS_MSB + H;

  272.     // Set page address
  273.     LCD_write_comd(cmd, 1);
  274.     // Set column address
  275.     LCD_write_comd(ColumnAddress, 2);
  276. }

  277. /***********************************************************
  278. 函數名稱:LCD_init
  279. 函數功能:5110初始化
  280. 入口參數:無
  281. 出口參數:無
  282. 備 注:
  283. ***********************************************************/

  284. void LCD_init(void)
  285.   {
  286.         P5DIR |=BIT7;        //P57 out
  287.     P5OUT &= ~BIT7;     // P57=0
  288.     P5OUT |= BIT7;       //P57=1

  289.     P7DIR |=BIT4;       //P74 out
  290.     P7OUT &=~BIT4;      //P4=0

  291.     P5DIR |=BIT6;       //P56 out
  292.     P5OUT &=BIT6;       //P56=0

  293.     P4SEL |=BIT1;       //P41選擇 SIMO
  294.     P4DIR |=BIT1;       //P41 OUT

  295.     P4SEL |=BIT3;        //P43 select SCLK
  296.     P4DIR |=BIT3;        //SCLK  out


  297.        UCB1CTL1 |= UCSWRST;

  298.        UCB1CTL0 = UCCKPH + UCMSB + UCMST + UCMODE_0 + UCSYNC;

  299.        UCB1CTL1 = UCSSEL_2 + UCSWRST;
  300.        UCB1BR0 = 0x02;
  301.        UCB1BR1 = 0;

  302.        UCB1CTL1 &= ~UCSWRST;
  303.        UCB1IFG &= ~UCRXIFG;


  304.        LCD_write_comd(Dogs102x6_initMacro, 13);


  305.        P7OUT |=BIT4;     //P74=1

  306.        dogs102x6Memory[0] = 102;
  307.        dogs102x6Memory[1] = 8;


  308.   }




  309. /***************************************************************************//**
  310. * @brief   Writes a character from FONT6x8[] array to the LCD at (row,col).
  311. *
  312. *          (0,0) is the upper left corner of screen.
  313. * @param   row Page Address (0 - 7) (there are 8 pages on the screen, each is 8 pixels tall)
  314. * @param   col Column Address (there are 102 columns on the screen)
  315. * @param   f Pointer to the character to be written to the LCD
  316. * @param   style The style of the text
  317. *                - NORMAL = 0 = dark letters with light background
  318. *                - INVERT = 1 = light letters with dark background
  319. * @return  None
  320. ******************************************************************************/

  321. void Dogs102x6_charDraw(uint8_t row, uint8_t col, uint16_t f, uint8_t style)
  322. {
  323.     // Each Character consists of 6 Columns on 1 Page
  324.     // Each Page presents 8 pixels vertically (top = MSB)
  325.     uint8_t b;
  326.     uint16_t h;
  327.     uint8_t inverted_char[6];

  328.     // Row boundary check
  329.     if (row > 7)
  330.     {
  331.         row = 7;
  332.     }

  333.     // Column boundary check
  334.     if (col > 101)
  335.     {
  336.         col = 101;
  337.     }

  338.     // handle characters not in our table
  339.     if (f < 32 || f > 129)
  340.     {
  341.         // replace the invalid character with a '.'
  342.         f = '.';
  343.     }

  344.     // subtract 32 because FONT6x8[0] is "space" which is ascii 32,
  345.     // multiply by 6 because each character is columns wide
  346.     h = (f - 32) * 6;

  347.     Dogs102x6_setAddress(row, col);
  348.     if (style == DOGS102x6_DRAW_NORMAL)
  349.     {
  350.         // write character
  351.             LCD_write_data((uint8_t *)FONT6x8 + h, 6);
  352.     }
  353.     else
  354.     {
  355.         for (b = 0; b < 6; b++)
  356.         {
  357.             // invert the character
  358.             inverted_char[b] = FONT6x8[h + b] ^ 0xFF;
  359.         }
  360.         // write inverted character
  361.         LCD_write_data(inverted_char, 6);
  362.     }
  363. }

  364. ////////////////////////////////////////////
  365. //CS--P7.4;DC--P5.6;SIMO--P4.1            //
  366. //EN--P7.6;RST--P5.7;SCLK--P4.3           //
  367. ////////////////////////////////////////////
  368. int main( void )
  369. {  // Stop watchdog timer to prevent time out reset
  370.   WDTCTL = WDTPW + WDTHOLD;
  371.   P7DIR |=BIT4+BIT6;
  372.   P5DIR |=BIT6+BIT7;
  373.   P4DIR |=BIT1+BIT3;
  374.   LCD_init();
  375.   Dogs102x6_setAddress(25,4);
  376.   Dogs102x6_stringDraw(0,0," AAAA ",DOGS102x6_DRAW_NORMAL);




  377. }
復制代碼




分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 欧美一级片在线观看 | 日韩久久在线 | 亚洲一区二区三区久久 | 久久精品网 | 精品久久久久久久久久久下田 | 在线中文字幕视频 | 国产精品99999999| 欧洲精品视频一区 | 91污在线 | 中国免费黄色片 | 色婷婷综合久久久中字幕精品久久 | 欧美日韩视频在线第一区 | 国产一区不卡在线观看 | 欧美日韩国产精品 | 精品亚洲永久免费精品 | 91免费视频 | 先锋影音资源网站 | 成人综合在线视频 | 国产精品视频网 | 中文字幕啪啪 | 国产极品车模吞精高潮呻吟 | 精品久| 国产一级淫片a直接免费看 免费a网站 | 日韩国产在线观看 | 国产午夜精品一区二区三区四区 | 羞羞视频在线观看 | 亚洲成人三级 | 一区欧美 | 国产一区久久 | 成人国产精品免费观看视频 | 台湾av在线| 亚洲精品一 | 天天干天天草 | 95国产精品 | 台湾佬久久 | 噜噜噜噜狠狠狠7777视频 | 日本不卡一区二区三区 | 欧美日韩国产一区二区三区 | 色综久久| 欧美性网 | h片在线免费看 |