u8g2支持UC1705x液晶驱动到PY32

最近在代码开发的时想使用u8g2支持手里的一块UC1705x驱动显示屏,在移植过程中,发现没有uc1705x的驱动C文件,于是秉着代码的一致性,写了这篇文章,并记录移植和驱动文件的设计过程。

开发环境

主控:PY32F4系列
液晶型号:XJCG12864-12P3431插接(TB上有)
u8g2库

u8g2介绍

U8G2图形库介绍
U8g2:用于单色显示的库,版本 2
U8g2 是一个用于嵌入式设备的单色图形库。U8g2支持单色OLED和LCD,包括以下控制器:SSD1305, SSD1306, SSD1309, SSD1316, SSD1320, SSD1322, SSD1325, SSD1327, SSD1329, SSD1606, SSD1607,895,SH11607,84D1607,SH11607,84D1607,94D1607,94D1607,84D1607,4D1607,4D1607,4D1607,84D1807 ,PCF8812,HX1230,UC1601,UC1604,UC1608,UC1610,UC1611,UC1617,UC1638,UC1701,ST7511,ST7528,ST7565,ST7567,ST7571,ST7586,ST7588,ST75256,ST75320,NT7534,ST7920,IST3020,IST7920,LD7032,KS0108 、KS0713、HD44102、T7932、SED1520、SBN1661、IL3820、MAX7219(完整列表见此处)。
从上面型号支持中很直观就能看到没有UC1705的驱动支持,不过有UC1701的代码,这很好,我们可以参照这块代码编写UC1705的驱动代码;

u8g2的移植与UC1705驱动编写过程

  1. 下载u8g2的代码文件
    u8g2下载链接:https://github.com/olikraus/u8g2;
    在这里插入图片描述

  2. 复制C文件到当前工程
    在当前工程中新建u8g2文件夹(用于存放u8g2C文件),解压压缩文件,将文件夹中的csrc文件夹中的全部文件复制到当前工程u8g2文件夹中,其中u8x8_d_xxxxx.c文件全部删除(只保留u8g2_d_memory.c、u8g2_d_setup.c、u8x8_d_uc1701_mini12864.c)三个文件;以mui为前缀的文件也需要删除(四个文件mui.c、mui.h、mui_u8g2.c、mui_u8g2.h);

  3. 编写硬件驱动接口
    在工程中新建一个u8g2_port.c、u8g2_port.h、u8g2_app.c、u8g2_app.h四个文件;
    编写接口适配stm32:

//	u8g2_port.c文件
#include "main.h"

//	定义当前屏结构
u8g2_t u8g2;
/**
  * @brief 				配置u8g2硬件接口,4线屏
  */
uint8_t u8g2_gpio_and_delay_stm32(U8X8_UNUSED u8x8_t *u8x8, U8X8_UNUSED uint8_t msg, U8X8_UNUSED uint8_t arg_int, U8X8_UNUSED void *arg_ptr)
{
  switch(msg)
  {
    //Initialize SPI peripheral
	case U8X8_MSG_GPIO_AND_DELAY_INIT://40
      u8g2_lcd_gpio_init();
      break;
	//Function which implements a delay, arg_int contains the amount of ms
	case U8X8_MSG_DELAY_MILLI://41
      delay_ms(arg_int);
      break;
	//Function which delays 10us
    case U8X8_MSG_DELAY_10MICRO://42
			delay_us(arg_int);
	  break;
	//Function which delays 100ns
    case U8X8_MSG_DELAY_100NANO://43
      __NOP();
      break;
    //Function to define the logic level of the clockline
	case U8X8_MSG_GPIO_SPI_CLOCK://64
      if(arg_int) HAL_GPIO_WritePin(SCK_GPIO,SCK_GPIO_PIN,GPIO_PIN_SET);
	  else HAL_GPIO_WritePin(SCK_GPIO,SCK_GPIO_PIN,GPIO_PIN_RESET);
      break;
    //Function to define the logic level of the data line to the display
	case U8X8_MSG_GPIO_SPI_DATA://65
  	  if(arg_int) HAL_GPIO_WritePin(SDA_GPIO,SDA_GPIO_PIN,GPIO_PIN_SET);
      else HAL_GPIO_WritePin(SDA_GPIO,SDA_GPIO_PIN,GPIO_PIN_RESET);
	  break;
    // Function to define the logic level of the CS line
	case U8X8_MSG_GPIO_CS://73
	  if(arg_int) HAL_GPIO_WritePin(CS_GPIO,CS_GPIO_PIN,GPIO_PIN_SET);
	  else HAL_GPIO_WritePin(CS_GPIO,CS_GPIO_PIN,GPIO_PIN_RESET);
	  break;
	//Function to define the logic level of the Data/ Command line
	case U8X8_MSG_GPIO_DC://74
	  if(arg_int) HAL_GPIO_WritePin(A0_GPIO,A0_GPIO_PIN,GPIO_PIN_SET);
	  else HAL_GPIO_WritePin(A0_GPIO,A0_GPIO_PIN,GPIO_PIN_RESET);
	  break;
	//Function to define the logic level of the RESET line
	case U8X8_MSG_GPIO_RESET://75
	  if(arg_int) HAL_GPIO_WritePin(RES_GPIO,RES_GPIO_PIN,GPIO_PIN_SET);
	  else HAL_GPIO_WritePin(RES_GPIO,RES_GPIO_PIN,GPIO_PIN_RESET);
	  break;
	default:
	  return 0; //A message was received which is not implemented, return 0 to indicate an error
	}
	return 1; // command processed successfully.
}

/**
  * @brief 				初始化u8g2硬件接口
  */
void u8g2_port_init(void)
{
	u8g2_Setup_uc1705x_f(&u8g2, U8G2_R2, u8x8_byte_4wire_sw_spi, u8g2_gpio_and_delay_stm32); // 初始化 u8g2 结构体
	
	u8g2_InitDisplay(&u8g2);		// 根据所选的芯片进行初始化工作,初始化完成后,显示器处于关闭状态
	u8g2_SetPowerSave(&u8g2, 0); 	// 唤醒显示器
	//u8g2_SetContrast(&u8g2, 50);	//设置对比度
	u8g2_ClearBuffer(&u8g2);		//清除显示缓存,先清屏
	u8g2_SendBuffer(&u8g2);
}

  1. 编写UC1705驱动文件
    首先新建u8x8_d_uc1705x.c的文件,将之前保留的u8x8_d_uc1701_mini12864.c文件打开并全部复制到u8x8_d_uc1705x.c中,然后按照一下文件修改;
/*

  u8x8_d_uc1705x.c (dealextreme, displays from ebay MP3 players)
  
  Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)

  Copyright (c) 2016, olikraus@gmail.com
  All rights reserved.

  Redistribution and use in source and binary forms, with or without modification, 
  are permitted provided that the following conditions are met:

  * Redistributions of source code must retain the above copyright notice, this list 
    of conditions and the following disclaimer.
    
  * Redistributions in binary form must reproduce the above copyright notice, this 
    list of conditions and the following disclaimer in the documentation and/or other 
    materials provided with the distribution.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  

  
*/
#include "u8x8.h"


static const uint8_t u8x8_d_uc1705x_init_seq[] = {
    
  U8X8_START_TRANSFER(),             	/* enable chip, delay is part of the transfer start */
  
	U8X8_C(0x0e2),            				/* soft reset */
  U8X8_C(0x0ae),		                /* display off */
  U8X8_C(0x040),		                /* set display start line to 0 */
  
  U8X8_C(0x0a0),		                /* ADC set to reverse */	// 从左往后,还是从右往左扫描(0xa1)
  U8X8_C(0x0c8),		                /* common output mode */	// 从上往下,还是从下往上扫描(0xc0)
  
  U8X8_C(0x0a6),		                /* display normal, bit val 0: LCD pixel off. */
  U8X8_C(0x0a2),		                /* LCD bias 1/9 */
  U8X8_C(0x02f),		                /* all power  control circuits on */
  U8X8_C(0x0f8),										/* set booster ratio to */
  U8X8_C(0x000),										/* 4x */
  U8X8_C(0x023),										/* set V0 voltage resistor ratio to large */
  U8X8_C(0x081),										/* set contrast */
  U8X8_C(0x027),										/* contrast value */
  U8X8_C(0x0ac),										/* indicator */
  
  U8X8_C(0x0ae),		                /* display off */
  U8X8_C(0x0a5),		                /* enter powersafe: all pixel on, issue 142 */

//	U8X8_C(0x0e2),	//command reset
//	U8X8_C(0x0af),	
//	U8X8_C(0x0a0),	// 从左往后,还是从右往左扫描(0xa1)
//	U8X8_C(0x0c8),	// 从上往下,还是从下往上扫描(0xc0)
//	U8X8_C(0x040),	// start line
//	U8X8_C(0x025),	//V0 voltage regulator internal resistor ratio set   //对比度调节 V0的电阻率调节 范围:0x21-0x27 ,值越大,显示效果越浓(底影越浓)
//	U8X8_C(0x081),	// electronic volume mode set
//	U8X8_C(0x013),	// V0电压调节(可微调对比度)	//电压调整寄存器低位 范围:0x1e-0x32    值越大,显示效果越浓(底影越浓)//0x13 kehu
//	U8X8_C(0x02f),	//power controller set
//	U8X8_C(0x0ee),	
//	U8X8_C(0x0af),	//display on
//	U8X8_C(0x0b0),	//display on

  U8X8_END_TRANSFER(),             	/* disable chip */
  U8X8_END()             						/* end of sequence */
};

static const uint8_t u8x8_d_uc1705x_powersave0_seq[] = {
  U8X8_START_TRANSFER(),             	/* enable chip, delay is part of the transfer start */
  U8X8_C(0x0a4),		                	/* all pixel off, issue 142 */
  U8X8_C(0x0af),		                	/* display on */
  U8X8_END_TRANSFER(),             		/* disable chip */
  U8X8_END()             							/* end of sequence */
};

static const uint8_t u8x8_d_uc1705x_powersave1_seq[] = {
  U8X8_START_TRANSFER(),             	/* enable chip, delay is part of the transfer start */
  U8X8_C(0x0ae),		                	/* display off */
  U8X8_C(0x0a5),		                	/* enter powersafe: all pixel on, issue 142 */
  U8X8_END_TRANSFER(),             		/* disable chip */
  U8X8_END()             							/* end of sequence */
};

static const uint8_t u8x8_d_uc1705x_flip0_seq[] = {
  U8X8_START_TRANSFER(),             	/* enable chip, delay is part of the transfer start */
  U8X8_C(0x0a0),											/* segment remap a0/a1*/
  U8X8_C(0x0c8),											/* c0: scan dir normal, c8: reverse */
  U8X8_END_TRANSFER(),             		/* disable chip */
  U8X8_END()             							/* end of sequence */
};

static const uint8_t u8x8_d_uc1705x_flip1_seq[] = {
  U8X8_START_TRANSFER(),             	/* enable chip, delay is part of the transfer start */
  U8X8_C(0x0a1),											/* segment remap a0/a1*/
  U8X8_C(0x0c0),											/* c0: scan dir normal, c8: reverse */
  U8X8_END_TRANSFER(),             		/* disable chip */
  U8X8_END()             							/* end of sequence */
};


static const u8x8_display_info_t u8x8_uc1705x_display_info =
{
  /* chip_enable_level = */ 0,
  /* chip_disable_level = */ 1,
  
  /* post_chip_enable_wait_ns = */ 5,
  /* pre_chip_disable_wait_ns = */ 5,
  /* reset_pulse_width_ms = */ 1, 
  /* post_reset_wait_ms = */ 50, 
  /* sda_setup_time_ns = */ 1,		
  /* sck_pulse_width_ns = */ 75,	/* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
  /* sck_clock_hz = */ 4000000UL,	/* since Arduino 1.6.0, the SPI bus speed in Hz. Should be  1000000000/sck_pulse_width_ns */
  /* spi_mode = */ 0,		/* active high, rising edge */
  /* i2c_bus_clock_100kHz = */ 4,
  /* data_setup_time_ns = */ 30,
  /* write_pulse_width_ns = */ 40,
  /* tile_width = */ 16,		/* width of 16*8=128 pixel */
  /* tile_height = */ 8,
  /* default_x_offset = */ 0,
  /* flipmode_x_offset = */ 4,
  /* pixel_width = */ 128,
  /* pixel_height = */ 64
};

uint8_t u8x8_d_uc1705x(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
{
  uint8_t x, c;
  uint8_t *ptr;
  switch(msg)
  {
    case U8X8_MSG_DISPLAY_SETUP_MEMORY://9
      u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1705x_display_info);
      break;
    case U8X8_MSG_DISPLAY_INIT://10
      u8x8_d_helper_display_init(u8x8);
      u8x8_cad_SendSequence(u8x8, u8x8_d_uc1705x_init_seq);
      break;
    case U8X8_MSG_DISPLAY_SET_POWER_SAVE://11
      if ( arg_int == 0 )
				u8x8_cad_SendSequence(u8x8, u8x8_d_uc1705x_powersave0_seq);
      else
				u8x8_cad_SendSequence(u8x8, u8x8_d_uc1705x_powersave1_seq);
      break;
    case U8X8_MSG_DISPLAY_SET_FLIP_MODE://13
      if ( arg_int == 0 )
      {
				u8x8_cad_SendSequence(u8x8, u8x8_d_uc1705x_flip0_seq);
				u8x8->x_offset = u8x8->display_info->default_x_offset;
      }
      else
      {
				u8x8_cad_SendSequence(u8x8, u8x8_d_uc1705x_flip1_seq);
				u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
      }	
      break;
#ifdef U8X8_WITH_SET_CONTRAST
    case U8X8_MSG_DISPLAY_SET_CONTRAST://14
      u8x8_cad_StartTransfer(u8x8);
      u8x8_cad_SendCmd(u8x8, 0x081 );
      u8x8_cad_SendArg(u8x8, arg_int >> 2 );	/* uc1701 has range from 0 to 63 */
      u8x8_cad_EndTransfer(u8x8);
      break;
#endif

    case U8X8_MSG_DISPLAY_DRAW_TILE://15
      u8x8_cad_StartTransfer(u8x8);
    
      x = ((u8x8_tile_t *)arg_ptr)->x_pos;
      x *= 8;
      x += u8x8->x_offset;
		
      u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
      u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
      u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
    
      c = ((u8x8_tile_t *)arg_ptr)->cnt;
      c *= 8;
      ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
		
			//LOG_MSG("c %d,ptr %d,x %d,arg_int %d",c,*ptr,x,arg_int);
      /* 
			The following if condition checks the hardware limits of the uc1701 
			controller: It is not allowed to write beyond the display limits.
			This is in fact an issue within flip mode.
				
			bug: this check should be inside the while loop, see u8x8_d_pcd8544_84x48.c 
      */
      if ( c + x > 132u )
      {
				c = 132u;
				c -= x;
      }
      do
      {
				u8x8_cad_SendData(u8x8, c, ptr);	/* note: SendData can not handle more than 255 bytes */
				arg_int--;
      } while( arg_int > 0 );
      
      u8x8_cad_EndTransfer(u8x8);
      break;
    default:
      return 0;
  }
  return 1;
}

打开u8g2_d_setup.c文件,注释掉里面的全部代码(只保留头文件引用),添加如下setup代码:

#include "malloc.h"

/* uc1701 */
/* uc1701 1 */
void u8g2_Setup_uc1705x_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
{
  uint8_t tile_buf_height;
  uint8_t *buf;
  u8g2_SetupDisplay(u8g2, u8x8_d_uc1705x, u8x8_cad_001, byte_cb, gpio_and_delay_cb);
  buf = u8g2_m_16_8_1(&tile_buf_height);
  u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);
}

/* uc1701 2 */
void u8g2_Setup_uc1705x_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
{
  uint8_t tile_buf_height;
  uint8_t *buf;
  u8g2_SetupDisplay(u8g2, u8x8_d_uc1705x, u8x8_cad_001, byte_cb, gpio_and_delay_cb);
  buf = u8g2_m_16_8_2(&tile_buf_height);
  u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);
}

/* uc1701 f */
void u8g2_Setup_uc1705x_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
{
  uint8_t tile_buf_height;
  uint8_t *buf;
  u8g2_SetupDisplay(u8g2, u8x8_d_uc1705x, u8x8_cad_001, byte_cb, gpio_and_delay_cb);
  	//buf = u8g2_m_16_8_f(&tile_buf_height);		//	非malloc模式
	//	使用malloc 管控内存
	buf = (u8*)mymalloc(SRAMIN, 2048);				//	malloc模式(正点原子)
	tile_buf_height = 8;
  u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);
}

打开u8g2_d_memory.c文件,除了引用头文件和u8g2_m_16_8_1、u8g2_m_16_8_2、u8g2_m_16_8_f函数,其他全部注释掉;
对了千万别忘记将新增加的函数添加至对应的头文件;
好了,至此,驱动部分编写完成。
6. 编写测试app
接下来让我们写一段代码测试一下,打开u8g2_app.c文件,新建一个测试demo:



const unsigned char bmp38[] = {
	0xFF,0x57,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x57,0x75,0x55,0xD5,0x7F,0x0F,0x2A,0x2A,0x2A,0x22,0x2A,0x2A,
0x2A,0x2A,0x2A,0x2A,0x2E,0x3B,0x2A,0xEA,0xBF,0x1F,0x15,0x15,0x15,0x9D,0x04,0x15,0x15,0x15,0x15,0x15,0x85,0x97,0x95,0xD5,
0x5F,0x5F,0x0A,0x0A,0x0A,0x5C,0x0E,0x0A,0x0A,0x0A,0x0A,0x0A,0x46,0x02,0x4A,0xCA,0xAF,0xAF,0x05,0x05,0x05,0x8E,0x3F,0x05,
0x05,0x05,0x05,0x05,0xA7,0x27,0x25,0xE5,0x53,0x57,0x03,0x02,0x02,0x8E,0x7F,0x02,0x02,0x02,0x02,0x02,0x52,0x13,0x12,0xD2,
0xAB,0xAB,0x01,0x01,0x81,0x8F,0xFF,0x00,0x01,0x01,0x01,0x01,0xA8,0x0B,0x09,0xC9,0x53,0x55,0x04,0x00,0x00,0x47,0x7F,0x04,
0x00,0x00,0x00,0x00,0x54,0x15,0x44,0xC4,0xF7,0x7F,0x1F,0x55,0xD5,0x47,0xFF,0x57,0x55,0x55,0x55,0x55,0xF7,0x5F,0x55,0xD5,
0x2B,0x7F,0x3F,0x2A,0x8A,0x6F,0x7B,0x2F,0x2A,0x2A,0x2A,0x2A,0x2E,0x3B,0x2A,0xEA,0x9F,0xBF,0x3F,0x15,0x95,0xFF,0x1F,0x0F,
0x15,0x15,0x15,0x15,0x95,0x95,0x95,0xD5,0x4B,0x5E,0x4F,0x0A,0xCA,0xFF,0x0E,0x0E,0x0A,0x0A,0x0A,0x0A,0x4E,0x02,0x4A,0xCA,
0xA7,0xAD,0x27,0x05,0x85,0xFF,0x37,0x0E,0x05,0x05,0x05,0x05,0xA7,0x27,0x25,0xE5,0x53,0x52,0x53,0x02,0x82,0xFF,0x7F,0x1E,
0x02,0x02,0x02,0x02,0x52,0x12,0x12,0xD2,0xAB,0xA9,0x29,0x01,0x81,0xFF,0xEF,0x3F,0x01,0x01,0x01,0x01,0x08,0x21,0x89,0xC9,
0x53,0x44,0x54,0x00,0x00,0xFF,0xFF,0x1F,0x00,0x00,0x00,0x00,0x54,0x14,0x44,0xC4,0x57,0xD5,0x7F,0x55,0x15,0xFF,0xFF,0x3F,
0x55,0x55,0x55,0x55,0x51,0x57,0x55,0xD5,0x2B,0x2A,0x3F,0x2A,0x2A,0xFE,0xFF,0x3F,0x2A,0x2A,0x2A,0x2A,0x0A,0x28,0x2A,0xEA,
0x97,0x95,0x3D,0x15,0x15,0xFE,0xFF,0x3F,0x15,0x15,0x15,0x15,0x15,0x95,0x95,0xD5,0x4B,0x4A,0x5A,0x0A,0x0A,0x7E,0x7F,0x0E,
0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x4A,0xCA,0xA3,0xA5,0x25,0x05,0x05,0xFC,0xFF,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x25,0xE5,
0x53,0x52,0x52,0x02,0x02,0x7E,0x7F,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0xC2,0x83,0xA9,0x29,0x00,0x01,0xFC,0xFF,0x00,
0x01,0x01,0x01,0x01,0x01,0x01,0x89,0xC9,0x03,0x54,0x54,0x00,0x00,0x7C,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0xC4,
0x53,0x55,0x55,0x55,0x55,0xFE,0x7F,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0xD5,0x2B,0x2A,0x2A,0x2A,0x2A,0xFE,0x3F,0x2A,
0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0xEA,0x13,0x95,0x95,0x05,0x15,0xFD,0x3D,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x95,0xD5,
0x0B,0x4A,0x4A,0x0A,0x0A,0xFA,0x7F,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x4A,0xCA,0x03,0x85,0xA5,0x25,0x05,0xF1,0x3F,0x05,
0x05,0x05,0x05,0x05,0x05,0x05,0x25,0xE5,0x03,0x02,0x52,0x12,0x02,0xD2,0x1F,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x12,0xC2,
0x03,0x01,0xA9,0xA9,0x01,0xA9,0x2F,0x01,0x01,0x01,0x01,0x01,0x01,0x09,0x89,0xC9,0x03,0x00,0x54,0x54,0x00,0x50,0x77,0x00,
0x00,0x00,0x00,0x00,0x00,0x04,0x44,0xC4,0x53,0x55,0x55,0x55,0x55,0xF1,0x7F,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0xD5,
0x2B,0x2A,0x2A,0x2A,0x2A,0x7A,0x3F,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0xEA,0x13,0x15,0x95,0x95,0x15,0xF5,0x3F,0x15,
0x15,0x15,0x15,0x15,0x95,0x95,0x95,0xD5,0x0B,0x0A,0x4A,0x4A,0x4A,0x7A,0x7F,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x4A,0xCA,
0x03,0x05,0x05,0xA5,0x25,0xA1,0x3F,0x05,0x05,0x05,0x05,0x05,0x25,0x05,0x25,0xC5,0x13,0x02,0x02,0x52,0x52,0x52,0x5F,0x02,
0x02,0x02,0x02,0x02,0x02,0x02,0x12,0xC2,0x03,0x01,0x01,0xA9,0xA9,0xA1,0xBB,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x89,0xC9,
0x03,0x00,0x00,0x50,0x54,0x44,0x7D,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0xC4,0x53,0x55,0x55,0x55,0x55,0xF5,0x7F,0x55,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0xD5,0x2B,0x2A,0x2A,0x2A,0x2A,0xEA,0x7F,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0xEA,
0x17,0x15,0x15,0x95,0x95,0xF5,0xFF,0x14,0x15,0x15,0x15,0x15,0x95,0x95,0x95,0xD5,0x0B,0x0A,0x0A,0x0A,0x4A,0x4A,0x7F,0x0A,
0x0A,0x0A,0x0A,0x0A,0x4A,0x4A,0x4A,0xCA,0x23,0x05,0x05,0x05,0xA5,0xA5,0x3F,0x05,0x05,0x05,0x05,0x05,0x25,0x25,0x25,0xE5,
0x13,0x02,0x02,0x02,0x52,0x52,0x7F,0x02,0x02,0x02,0x02,0x02,0x12,0x12,0x12,0xD2,0x0B,0x01,0x01,0x01,0xA9,0xA9,0x3F,0x01,
0x01,0x01,0x01,0x01,0x09,0x09,0x89,0xC9,0x03,0x00,0x00,0x00,0x40,0x54,0x3F,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x44,0xC4,
0x53,0x55,0x55,0x55,0x55,0xF5,0x3F,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0xD5,0x2B,0x2A,0x2A,0x0A,0x2A,0xFA,0x3F,0x2A,
0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0xEA,0x97,0x95,0x95,0x95,0x95,0xF5,0x9F,0x95,0x95,0x95,0x95,0x15,0x15,0x95,0x95,0xD5,
0x4B,0x4A,0x4A,0x4A,0x4A,0x5A,0x4F,0x4A,0x4A,0x4A,0x4A,0x4A,0x4A,0x4A,0x4A,0xCA,0xA7,0xA5,0xA5,0xA5,0xA5,0xA7,0xA7,0xA5,
0xA5,0xA5,0xA5,0xA5,0xA5,0xA5,0xA5,0xE7,0x53,0x52,0x52,0x52,0x52,0x52,0x53,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0xD3,
0xAB,0xA9,0xA9,0xA9,0xA9,0xE9,0xA9,0xA9,0xA9,0xA9,0xA9,0xA9,0xA9,0xA9,0xA9,0xE9,0x57,0x54,0x54,0x54,0x54,0x54,0x55,0x54,
0x44,0x54,0x54,0x54,0x54,0x54,0x54,0xD4,0x57,0x55,0x55,0x55,0x55,0xF5,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0xD5,
0x2B,0x2A,0x2A,0x2A,0x2A,0xFA,0x2B,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0xEA,0x97,0x95,0x95,0x95,0x95,0xFD,0x95,0x95,
0x95,0x95,0x95,0x95,0x95,0x95,0x95,0xD5,0x4B,0x4A,0x4A,0x4A,0x4A,0x5E,0x4B,0x4A,0x4A,0x4A,0x4A,0x4A,0x4A,0x4A,0x4A,0xCA,
0xA7,0xA5,0xA5,0xA5,0x25,0xBF,0xA5,0xA5,0xA5,0x25,0xA5,0xA5,0xA5,0xA5,0xA5,0xE5,0x53,0x52,0x52,0x52,0x12,0x5F,0x12,0x12,
0x12,0x52,0x52,0x52,0x52,0x52,0x52,0xD2,0xAB,0xA9,0xA9,0x89,0xA9,0xFD,0x89,0x89,0x89,0xA9,0xA9,0xA9,0xA9,0xA9,0xA9,0xE9,
0x53,0x44,0x44,0x44,0x44,0x70,0x47,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x54,0xD4,//C:\Users\19005\Desktop\R-C\R-C_0037_图层 1.bmp0
};

const u8 *bmp_arry[38] = {bmp1,bmp2,bmp3,bmp4,bmp5,bmp6,bmp7,bmp8,bmp9,bmp10, \
													bmp11,bmp12,bmp13,bmp14,bmp15,bmp16,bmp17,bmp18,bmp19,bmp20, \
													bmp21,bmp22,bmp23,bmp24,bmp25,bmp26,bmp27,bmp28,bmp29,bmp30,bmp31,bmp32,bmp33,bmp34,bmp35,bmp36,bmp37,bmp38};
void u8g2_test(void)
{
	while(1)
		{
			for(int i = 0;i < 38;i ++)
			{
				u8g2_ClearBuffer(u8g2);
				//	刷新坤坤,其他的图片自己取模,因为取模代码量较大,只贴部分
				u8g2_DrawXBM(u8g2,0,0,127,63,bmp_arry[i]);
				u8g2_SendBuffer(u8g2);
				delay_ms(100);
			}
		}
}

看成品

在这里插入图片描述

  • 12
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

哈希Yin先森

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值