我是靠谱客的博主 隐形水蜜桃,最近开发中收集的这篇文章主要介绍OLED12864模块全屏缓冲刷新,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述


[本文发布地址https://blog.csdn.net/Stack_/article/details/124088511,未经许可不得转载,转载须注明出处]


一、全屏缓冲需要了解其驱动芯片SSD1306的RAM数据区和屏幕点阵的关系

在这里插入图片描述



由数据手册得知SSD1306有8页,将屏幕纵向分成64 / 8 = 8个块
每页有128个字节竖向排列代表128列

以上图页2为例,要点亮第2页第0行第0列(屏幕16行0列)交叉的像素时,向第2页第0列写入0x01;
要点亮第2页第5行第4列(屏幕21行4列)交叉的像素时,向第2页第4列写入0x20;



@ CSDN Tyrion.Mon
/* SSD1306 */
/*          COL0 COL1 COL2 COL3........COL127
 * PAGE0
 * PAGE1
 * PAGE2
 * PAGE3
 * PAGE4
 * PAGE5
 * PAGE6
 * PAGE7
 * (page0-page7地址:B0h~B7h) 
 * (col地址:8位地址-x,但需要拆分为H高4位和L低4位
 *  H(10h~1Fh), L(00h~0Fh), H = (x >> 4) | 0x10, L = (x & 0x0f)
 *          SEG0 SEG1 SEG2 ...... SEG127  (byte0-byte127:SEG0-SEG127)
 * pagex:   bit0  --  line0
 *          bit1  --  line1
 *          ...
 *          bit7  --  line7
*/
/*
*  单片机缓冲区, 将要显示的图形字符写入此缓冲区
* @ CSDN Tyrion.Mon
*/
unsigned char OLED12864_FullScreenBuffer[8][128];
/*
*  将坐标(x, y)的像素点熄灭(0)或点亮(1)
*  暂存至单片机缓冲区
* @ CSDN Tyrion.Mon
*/
void OLED_WriteBufferPoint(uint8_t pointX, uint8_t pointY, uint8_t pointVal)
{
  if (pointX < 128 && pointY < 64)
  {
    if (!pointVal)
      OLED12864_FullScreenBuffer[pointY / 8][pointX] &= ~(0x01 << (pointY % 8));
    else
      OLED12864_FullScreenBuffer[pointY / 8][pointX] |= 0x01 << (pointY % 8);
  }
}
/*
*  清除屏幕显示(全屏清除)
*  暂存至单片机缓冲区
* @ CSDN Tyrion.Mon
*/
void OLED_Clear(void)  
{  
  memset(OLED12864_FullScreenBuffer, 0, sizeof(OLED12864_FullScreenBuffer)); 
}



二、自动地址模式



在这里插入图片描述
在这里插入图片描述



商家提供的驱动初始化默认选择了页地址模式,需要将其修改为水平地址模式 Horizontal addressing mode,并在初始化中将地址定位到0行0列。这样后面刷新显示时只需顺序写入8x128个字节数据而无需指定地址


@ CSDN Tyrion.Mon

OLED_WR_Byte(0x20,OLED_CMD);// -Set Page Addressing Mode (0x00/0x01/0x02)
OLED_WR_Byte(0x02,OLED_CMD);//[1:0],00水平地址模式;01垂直地址模式模式;10,页地址模式;默认10;
初始化修改为
OLED_WR_Byte(0x20,OLED_CMD);// -Set Page Addressing Mode (0x00/0x01/0x02)
OLED_WR_Byte(0x00,OLED_CMD);//[1:0],00水平地址模式;01垂直地址模式模式;10,页地址模式;默认10;

初始化添加以下指令定位到00列
start_row = 0;
strat_col = 0;
OLED_WR_Byte (0xb0 + start_row ,OLED_CMD);       //页起始地址
OLED_WR_Byte (0x10 | (strat_col >> 4),OLED_CMD);       //列起始地址高4位
OLED_WR_Byte (strat_col & 0x0f,OLED_CMD);       //列起始地址低4位



三、送显



在主循环的中调用清缓冲区 void OLED_Clear(void)

再调用void OLED_WriteBufferPoint(uint8_t pointX, uint8_t pointY, uint8_t pointVal)将显示数据写入缓冲区

最后调用void OLED12864_FlushFullScreen(void)刷新显示即可。或者用SPI DMA自动发送此缓冲数组以获得高帧率



/*
*  将单片机缓冲区的数据刷新至SSD1306的显示RAM中
*  初始化中设置了自动地址模式,不需要再指定地址
* @ CSDN Tyrion.Mon
*/
void OLED12864_FlushFullScreen(void)
{
  uint8_t page = 0;
  uint8_t col = 0;
  uint8_t data = 0;
  uint8_t i = 0;

  DC_FOR_DATA();
  CS_SELECT();
  for(page = 0; page < 8; page++)  // page0 - page7  (行0 - 行63)
  {  
    for(col = 0; col < 128; col++)
    {  
      data = OLED12864_FullScreenBuffer[page][col];
      Spi1_SendByte(data);
    }
  }
  CS_NOT_SELECT();
}



四、补充:字符写入缓冲区



1、写入取模的字符

@ CSDN Tyrion.Mon
void OLED_ShowChar(u8 x,u8 y,u8 chr)
{       
  unsigned char c=0,i=0;  
  uint8_t px_y = y;
  uint8_t px_x = x;
  if((x>127) || (y>63)) return;    
  c=chr-' ';  //
  
  for (px_x = x; px_x < (x + 8); px_x++)  
  {
    for (i = 0; i < 8; i++)
    {
      if (F8X16[c][px_x - x] & (0x01 << i))
        OLED12864_FullScreenBuffer[(px_y+i)/8][px_x] |= (0x01 << (px_y+i) % 8);
      else
        OLED12864_FullScreenBuffer[(px_y+i)/8][px_x] &= ~(0x01 << (px_y+i) % 8);
    }
  }
  for (px_x = x; px_x < (x + 8); px_x++)  
  {
    for (i = 0; i < 8; i++)
    {
      if (F8X16[c][px_x - x + 8] & (0x01 << i))
        OLED12864_FullScreenBuffer[(px_y+i)/8 + 1][px_x] |= (0x01 << (px_y+i) % 8);
      else
        OLED12864_FullScreenBuffer[(px_y+i)/8 + 1][px_x] &= ~(0x01 << (px_y+i) % 8);
    }
  }
}
@ CSDN Tyrion.Mon
/****************************************8*16的点阵************************************/
const unsigned char F8X16[][16]=	  
{
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0
  0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//! 1
  0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" 2
  0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//# 3
  0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$ 4
  0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//% 5
  0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//& 6
  0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//' 7
  0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//( 8
  0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//) 9
  0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//* 10
  0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+ 11
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//, 12
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//- 13
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//. 14
  0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,/// 15
  0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//0 16
  0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1 17
  0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2 18
  0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3 19
  0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4 20
  0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5 21
  0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6 22
  0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7 23
  0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8 24
  0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9 25
  0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//: 26
  0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//; 27
  0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//< 28
  0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//= 29
  0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//> 30
  0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//? 31
  0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@ 32
  0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A 33
  0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B 34
  0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C 35
  0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D 36
  0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E 37
  0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F 38
  0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G 39
  0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H 40
  0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I 41
  0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J 42
  0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K 43
  0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L 44
  0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M 45
  0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N 46
  0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O 47
  0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P 48
  0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q 49
  0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R 50
  0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S 51
  0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T 52
  0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U 53
  0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V 54
  0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W 55
  0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X 56
  0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y 57
  0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z 58
  0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[ 59
  0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,// 60
  0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//] 61
  0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^ 62
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_ 63
  0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//` 64
  0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a 65
  0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b 66
  0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c 67
  0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d 68
  0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e 69
  0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f 70
  0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g 71
  0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h 72
  0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i 73
  0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j 74
  0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k 75
  0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l 76
  0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m 77
  0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n 78
  0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o 79
  0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p 80
  0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q 81
  0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r 82
  0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s 83
  0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t 84
  0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u 85
  0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v 86
  0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w 87
  0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x 88
  0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y 89
  0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z 90
  0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{ 91
  0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//| 92
  0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//} 93
  0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 94
};



2、写入字库的字符。关于字库的内容请查看另一篇文章

@ CSDN Tyrion.Mon
void OLED_Show_One_Ascii_FromFontIC(u8 x,u8 y,u8 *ascii)
{       
	unsigned char i=0;  
	uint8_t px_y = y;
	uint8_t px_x = x;

	uint8_t szhpArray[16];

	if((x>127) || (y>63)) return;   

	GT20L16S1Y_Get_Bytes_ASCII_Bold_8x16(ascii, szhpArray);

	for (px_x = x; px_x < (x + 8); px_x++) 
	{
		for (i = 0; i < 8; i++)
		{
			if (szhpArray[px_x - x] & (0x01 << i))
				OLED12864_FullScreenBuffer[(px_y+i)/8][px_x] |= (0x01 << (px_y+i) % 8);
			else
				OLED12864_FullScreenBuffer[(px_y+i)/8][px_x] &= ~(0x01 << (px_y+i) % 8);
		}
	}
	for (px_x = x; px_x < (x + 8); px_x++)  
	{
		for (i = 0; i < 8; i++)
		{
			if (szhpArray[px_x - x + 8] & (0x01 << i))
				OLED12864_FullScreenBuffer[(px_y+i)/8 + 1][px_x] |= (0x01 << (px_y+i) % 8);
			else
				OLED12864_FullScreenBuffer[(px_y+i)/8 + 1][px_x] &= ~(0x01 << (px_y+i) % 8);
		}
	}
}
void OLED_Show_One_GB2312_FromFontIC(u8 x,u8 y,u8 *GB2312)
{       
	unsigned char i=0;  
	uint8_t px_y = y;
	uint8_t px_x = x;

	uint8_t szhpArray[32];

	if((x>127) || (y>63)) return;   

	GT20L16S1Y_Get_Bytes_GB2312_15x16(GB2312, szhpArray);

	for (px_x = x; px_x < (x + 16); px_x++)  
	{
		for (i = 0; i < 16; i++)
		{
			if (szhpArray[px_x - x] & (0x01 << i))
				OLED12864_FullScreenBuffer[(px_y+i)/8][px_x] |= (0x01 << (px_y+i) % 16);
			else
				OLED12864_FullScreenBuffer[(px_y+i)/8][px_x] &= ~(0x01 << (px_y+i) % 16);
		}
	}
	for (px_x = x; px_x < (x + 16); px_x++)  
	{
		for (i = 0; i < 16; i++)
		{
			if (szhpArray[px_x - x + 16] & (0x01 << i))
				OLED12864_FullScreenBuffer[(px_y+i)/8 + 1][px_x] |= (0x01 << (px_y+i) % 16);
			else
				OLED12864_FullScreenBuffer[(px_y+i)/8 + 1][px_x] &= ~(0x01 << (px_y+i) % 16);
		}
	}
}

/**
* @brief  
* @note   LCD汉字和英文混合输出
* @param  x:显示起始X坐标
y:显示起始Y坐标
*text:要显示的字符串
* @retval None
* @author PWH
* @date   2021/4
*/
void OLED_Display_AutoSelect_GB2312_ASCII(uint16_t x, uint16_t y, uint8_t *text)
{
	while (*text != '')
	{
		if (*text & 0x80)
		{
			OLED_Show_One_GB2312_FromFontIC(x, y, text);
			text += 2;
			x += 16;
		}
		else
		{
			OLED_Show_One_Ascii_FromFontIC(x, y, text);
			text += 1;
			x += 8;
		}
	}
}	

最后

以上就是隐形水蜜桃为你收集整理的OLED12864模块全屏缓冲刷新的全部内容,希望文章能够帮你解决OLED12864模块全屏缓冲刷新所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部