基于ILI9341液晶屏+STM32U5单片的显示试验

news2025/1/13 17:27:43

试验要求:

1、通过串口,下发两个命令 STR和PIC;

2、STR模式:

        (1)串口输入什么,屏幕上显示什么

        (2)如果屏幕满,自动下滚

        (3)输入回车,进行换行

        (4)输入PIC切换到PIC模式

3、PIC模式:

        (1)快速连续播放内置的单片机图片(以达到动图效果)

        (2)串口输入STR切换至STR模式 

1、运行效果展示

1.1 STR模式(最终运行效果)

串口输入

LCD液晶屏显示

2.1 PIC模式(GIF图片效果,并非最终运行效果)

1、配置工程

1.1、通过原理图找对应的功能引脚(SPI+UART)

spi

uart

1.2、配置spi和uart

略。

1.3、找ILI9341驱动库并修改

主要是注意修改对应的管脚功能,例如下图,需要改成实际使用的管脚。

2、STR模式的准备工作

2.1、字模原理及验证

原理:通过以下网址学习

26. LCD—液晶显示中英文 — [野火]STM32 HAL库开发实战指南——基于F103系列开发板 文档

通过工具生成的字符A和B的字模

/* 16X32的字模: 大写 */
unsigned char capLetterSet[2][64]={
    {// A 0x41  //
        0x00,0x00,0x00,0x00,0x01,0x80,0x03,0x80,0x02,0xC0,0x02,0xC0,0x06,0xC0,0x04,0xE0,
        0x04,0x60,0x04,0x60,0x04,0x60,0x0C,0x70,0x08,0x30,0x08,0x30,0x08,0x30,0x1F,0xF8,
        0x10,0x18,0x10,0x18,0x10,0x18,0x10,0x18,0x10,0x1C,0x30,0x0C,0x20,0x0C,0x20,0x0C,
        0x60,0x0E,0xF8,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
    },
    {// B 0x42 //
        0x00,0x00,0x00,0x00,0x3F,0xE0,0x18,0x38,0x18,0x18,0x18,0x0C,0x18,0x0C,0x18,0x0C,
        0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x18,0x18,0x30,0x1F,0xE0,0x18,0x30,0x18,0x18,
        0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x1C,
        0x18,0x38,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
    }
};

普通的C工程验证:

 

void Printf_Charater(unsigned char* matrix, int matrixLen)
{
   int i,j;
   unsigned char kk;

   /*i用作行计数*/
   for ( i=0; i<32; i++) {
      /*j用作一字节内数据的移位计数*/
      /*一行像素的第一个字节*/
      for (j=0; j<8; j++) {
            /*一个数据位一个数据位地处理*/
            kk = matrix[2*i] << j ;  //左移J位
            if ( kk & 0x80) {
               printf("*"); //如果最高位为1,输出*号,表示笔迹
            } else {
               printf(" "); //如果最高位为0,输出空格,表示空白
            }
      }
      /*一行像素的第二个字节*/
      for (j=0; j<8; j++) {
            kk = matrix[2*i+1] << j ;  //左移J位
            if ( kk & 0x80) {
               printf("*"); //如果最高位为1,输出*号,表示笔迹
            } else {
               printf(" "); //如果最高位为0,输出空格,表示空白
            }
      }
      printf("\n");    //输出完一行像素,换行
   }
   printf("\n\n");     //一个字输出完毕
}

void screen_print(char* str){
    for(int i=0;str[i]!=0;i++){
        char ch=str[i];
        unsigned char *charater_matrix=capLetterSet[ch-'A'];
        Printf_Charater(charater_matrix, 64);
    }
}

结论:本试验中采用16x32的字模。按照我的理解,就是把对应的字符转换成字模,液晶屏显示是,以16位为1行,每位代表这个像素点显示还是不显示(1-显示,0-不显示),共32行。本案例中,每个字节的高位代表较小的列号(MSP)

3、源码

3.1、main.c


int fputc(int ch, FILE * fp){
	HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 10);
	return ch;
}

char uart_buff[128]={0};
int uart_buff_index=0;
char uart_ch;
typedef enum{
	MODE_STR,
	MODE_PIC
}mode_t;
mode_t mode;

extern unsigned char gImages[5][153600];

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart){
	//只处理串叿 1 的数据中斿
	if(huart != &huart1){
		HAL_UART_Receive_IT(&huart1, (uint8_t*)&uart_ch, 1);
		return;
	}
	uart_buff[uart_buff_index++]=uart_ch;
	printf("%c",uart_ch);
	if(uart_ch != '\r'){
		HAL_UART_Receive_IT(&huart1, (uint8_t*)&uart_ch, 1);
		return;
	}
	uart_buff[uart_buff_index-1]=0;//将\r替换成\0
	printf("串口收到数据:[%s],uart_buff_index=[%d]!!!\n\r", uart_buff, uart_buff_index);
	uart_buff_index=0;//重新计数
	
	if(strcmp("STR", uart_buff)==0){//字符串模式 STR
		printf("当前模式:STR(字符串显示模式(STR)\n\r");
		HAL_UART_Receive_IT(&huart1, (uint8_t*)&uart_ch, 1);
		mode = MODE_STR;
		//清屏
		return;
	}
	if(strcmp("PIC", uart_buff)==0){//图片模式
		printf("当前模式:PIC(图片显示模式)\n\r");
		HAL_UART_Receive_IT(&huart1, (uint8_t*)&uart_ch, 1);
		//
		mode = MODE_PIC;
		//清屏
		return;
	}
	if(mode == MODE_STR){
		//显示uart_buff的内容,并且换行
		printf("STR模式调用, uart_buff=[%s]\n\r", uart_buff);
		LCD_str_print(uart_buff);
		LCD_str_print("\n");
	}
	//
	HAL_UART_Receive_IT(&huart1, (uint8_t*)&uart_ch, 1);
}


int main(void)
{
  HAL_Init();
  SystemClock_Config();
  SystemPower_Config();
  MX_GPIO_Init();
  MX_ICACHE_Init();
  MX_USART1_UART_Init();
  MX_SPI1_Init();

  /* USER CODE BEGIN 2 */
  ILI9341_Init();	
  HAL_UART_Receive_IT(&huart1, (uint8_t*)&uart_ch, 1);
  int i=0;
  while (1)
  {
	if(mode == MODE_PIC){//图片显示模式
		LCD_picture(gImages[i%5]);
		i++;
		HAL_Delay(25);
	}else{
		HAL_Delay(1000);
	}
  }
}

/* 其他代码是cube自动生成的,略... */

3.2、LCD_font.c 字模集合(26个大写英文字母、*和空格)

#include "LCD_str.h"

unsigned char starMatrix[64]={//*
			0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x80,0x00,0x80,// * //
      0x00,0x80,0x00,0x80,0x00,0x80,0x40,0x81,0x20,0x82,0x10,0x84,0x08,0x88,0x04,0x90,
      0x02,0xA0,0x01,0xC0,0x02,0x20,0x04,0x10,0x08,0x08,0x10,0x04,0x20,0x02,0x40,0x01,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

unsigned char spaceMatrix[64]={//空格
			0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

unsigned char font_lowChSet[26][64]={//A-0x41
    {
      0x00,0x00,0x00,0x00,0x01,0x80,0x03,0x80,0x02,0xC0,0x02,0xC0,0x06,0xC0,0x04,0xE0,// A //
      0x04,0x60,0x04,0x60,0x04,0x60,0x0C,0x70,0x08,0x30,0x08,0x30,0x08,0x30,0x1F,0xF8,
      0x10,0x18,0x10,0x18,0x10,0x18,0x10,0x18,0x10,0x1C,0x30,0x0C,0x20,0x0C,0x20,0x0C,
      0x60,0x0E,0xF8,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x3F,0xE0,0x18,0x38,0x18,0x18,0x18,0x0C,0x18,0x0C,0x18,0x0C,// B //
      0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x18,0x18,0x30,0x1F,0xE0,0x18,0x30,0x18,0x18,
      0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x1C,
      0x18,0x38,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x03,0xE4,0x07,0x34,0x0E,0x1C,0x1C,0x0C,0x18,0x06,0x38,0x06,// C //
      0x38,0x02,0x30,0x02,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,
      0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x02,0x38,0x02,0x18,0x06,0x18,0x04,0x0E,0x0C,
      0x07,0x38,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x3F,0xE0,0x18,0x30,0x18,0x18,0x18,0x1C,0x18,0x0C,0x18,0x0C,// D //
      0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,
      0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x1C,0x18,0x18,
      0x18,0x30,0x3F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x3F,0xFC,0x18,0x0C,0x18,0x04,0x18,0x04,0x18,0x00,0x18,0x00,// E //
      0x18,0x00,0x18,0x00,0x18,0x08,0x18,0x08,0x18,0x18,0x1F,0xF8,0x18,0x18,0x18,0x08,
      0x18,0x08,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x04,0x18,0x04,
      0x18,0x0C,0x3F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x3F,0xFC,0x18,0x0C,0x18,0x06,0x18,0x06,0x18,0x02,0x18,0x00,// F //
      0x18,0x00,0x18,0x00,0x18,0x08,0x18,0x08,0x18,0x18,0x1F,0xF8,0x18,0x18,0x18,0x08,
      0x18,0x08,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,
      0x3C,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x03,0xE4,0x07,0x34,0x0E,0x1C,0x1C,0x0C,0x18,0x06,0x38,0x06,// G //
      0x30,0x02,0x30,0x02,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,
      0x30,0x3F,0x30,0x0E,0x30,0x0E,0x30,0x0E,0x38,0x0E,0x18,0x0E,0x1C,0x0E,0x0E,0x1E,
      0x07,0x30,0x03,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x3E,0x3E,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,// H //
      0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x1F,0xFC,0x18,0x0C,0x18,0x0C,
      0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,
      0x3C,0x1E,0x7E,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x0F,0xF0,0x03,0xC0,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,// I //
      0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,
      0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,
      0x03,0xC0,0x0F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x0F,0xFC,0x01,0xE0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,// J //
      0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,
      0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x60,0xC0,0x70,0xC0,0x70,0xC0,
      0x39,0x80,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x3E,0x3E,0x18,0x18,0x18,0x10,0x18,0x20,0x18,0x20,0x18,0x40,// K //
      0x18,0x40,0x18,0x80,0x18,0x80,0x19,0x00,0x1E,0x00,0x1F,0x00,0x1B,0x80,0x19,0x80,
      0x18,0xC0,0x18,0xC0,0x18,0x60,0x18,0x70,0x18,0x30,0x18,0x18,0x18,0x1C,0x18,0x0C,
      0x18,0x0E,0x3E,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x7F,0x00,0x3C,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,// L //
      0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,
      0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x04,0x18,0x04,0x18,0x0C,
      0x18,0x1C,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x78,0x07,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x34,0x16,0x34,0x16,// M //
      0x34,0x16,0x36,0x36,0x32,0x26,0x32,0x26,0x32,0x26,0x33,0x66,0x31,0x46,0x31,0x46,
      0x31,0x46,0x31,0xC6,0x30,0x86,0x30,0x86,0x30,0x06,0x30,0x06,0x30,0x06,0x30,0x06,
      0x30,0x06,0x78,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x3C,0x1E,0x1C,0x0C,0x1C,0x0C,0x1C,0x0C,0x1E,0x0C,0x1A,0x0C,// N //
      0x1A,0x0C,0x1B,0x0C,0x19,0x0C,0x19,0x0C,0x19,0x8C,0x18,0x8C,0x18,0x8C,0x18,0xCC,
      0x18,0x4C,0x18,0x4C,0x18,0x6C,0x18,0x2C,0x18,0x2C,0x18,0x3C,0x18,0x1C,0x18,0x1C,
      0x18,0x1C,0x3C,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x07,0xE0,0x18,0x18,0x30,0x0C,0x60,0x06,0x60,0x06,0x60,0x06,// O //
      0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,
      0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x30,0x0C,
      0x18,0x18,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x3F,0xF0,0x18,0x38,0x18,0x1C,0x18,0x0C,0x18,0x0C,0x18,0x0C,// P //
      0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x1C,0x18,0x38,0x1F,0xF0,0x18,0x00,0x18,0x00,
      0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,
      0x3C,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x03,0xC0,0x0E,0x70,0x1C,0x38,0x18,0x18,0x30,0x0C,0x30,0x0C,// Q //
      0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,
      0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x33,0xCC,0x36,0x6C,0x1C,0x38,0x1C,0x39,
      0x0E,0x79,0x03,0xCF,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x3F,0xF0,0x18,0x38,0x18,0x1C,0x18,0x0C,0x18,0x0C,0x18,0x0C,// R //
      0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x1C,0x18,0x38,0x1F,0xE0,0x19,0xC0,0x18,0xE0,
      0x18,0xE0,0x18,0x70,0x18,0x70,0x18,0x38,0x18,0x38,0x18,0x1C,0x18,0x1C,0x18,0x0E,
      0x3C,0x0E,0x7E,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x03,0xE4,0x0E,0x74,0x1C,0x1C,0x18,0x0C,0x30,0x06,0x30,0x02,// S //
      0x30,0x02,0x38,0x00,0x18,0x00,0x1E,0x00,0x0F,0x00,0x03,0xC0,0x01,0xE0,0x00,0x70,
      0x00,0x38,0x00,0x1C,0x00,0x0C,0x40,0x0C,0x40,0x0C,0x60,0x0C,0x30,0x1C,0x38,0x38,
      0x2E,0x70,0x27,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x3F,0xFC,0x31,0x8C,0x21,0x84,0x61,0x86,0x41,0x82,0x01,0x80,// T //
      0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,
      0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,
      0x03,0xC0,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x7E,0x1F,0x3C,0x0E,0x18,0x04,0x18,0x04,0x18,0x04,0x18,0x04,// U //
      0x18,0x04,0x18,0x04,0x18,0x04,0x18,0x04,0x18,0x04,0x18,0x04,0x18,0x04,0x18,0x04,
      0x18,0x04,0x18,0x04,0x18,0x04,0x18,0x04,0x18,0x04,0x18,0x04,0x18,0x04,0x0C,0x0C,
      0x06,0x18,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x7E,0x3F,0x38,0x0E,0x18,0x0C,0x18,0x0C,0x18,0x0C,0x18,0x0C,// V //
      0x0C,0x08,0x0C,0x08,0x0C,0x18,0x0C,0x10,0x0C,0x10,0x06,0x10,0x06,0x30,0x06,0x20,
      0x06,0x20,0x06,0x20,0x03,0x60,0x03,0x40,0x03,0x40,0x03,0x40,0x03,0xC0,0x01,0x80,
      0x01,0x80,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0xFB,0xEF,0x61,0x82,0x61,0x82,0x61,0x82,0x61,0x82,0x31,0x86,// W //
      0x31,0x84,0x31,0x84,0x31,0x84,0x31,0xC4,0x31,0xC4,0x31,0xC4,0x31,0x44,0x12,0x48,
      0x1A,0x48,0x1A,0x48,0x1A,0x48,0x1A,0x68,0x1A,0x68,0x0C,0x30,0x0C,0x30,0x0C,0x30,
      0x0C,0x30,0x0C,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0xFC,0x3F,0x70,0x0C,0x30,0x0C,0x38,0x08,0x18,0x10,0x1C,0x10,// X //
      0x0C,0x10,0x0E,0x20,0x06,0x20,0x07,0x40,0x03,0x40,0x03,0x80,0x01,0x80,0x01,0xC0,
      0x02,0xC0,0x02,0xC0,0x04,0x60,0x04,0x70,0x08,0x30,0x08,0x38,0x10,0x18,0x30,0x1C,
      0x30,0x0E,0xFE,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x78,0x1F,0x30,0x06,0x18,0x04,0x18,0x04,0x18,0x04,0x0C,0x08,// Y //
      0x0C,0x08,0x0C,0x08,0x06,0x10,0x06,0x10,0x03,0x20,0x03,0xE0,0x01,0xC0,0x01,0xC0,
      0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,
      0x03,0xE0,0x0F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    },
    {
      0x00,0x00,0x00,0x00,0x1F,0xFE,0x18,0x0C,0x10,0x0C,0x30,0x1C,0x20,0x18,0x20,0x18,// Z //
      0x00,0x38,0x00,0x30,0x00,0x70,0x00,0x60,0x00,0xE0,0x00,0xC0,0x00,0xC0,0x01,0xC0,
      0x01,0x80,0x03,0x80,0x03,0x00,0x07,0x00,0x06,0x02,0x0E,0x02,0x0C,0x06,0x1C,0x04,
      0x1C,0x0C,0x3F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    }
    };



3.3、LCD_str.c 字符和字符串的LCD打印

#include "LCD_str.h"
#include "bsp_ili9341_4line.h"
#include <stdio.h>

void LCD_str_print(char* str){
	static int global_x=0;
	static int global_y=0;
	//
	for(int i=0;str[i]!=0;i++){
		if(str[i]=='\n'){
			global_x=0;
			global_y+=32;
			continue;
		}
		if(global_x+16 > 240){
			global_x=0;
			global_y+=32;
		}
		LCD_ch_show(global_x, global_y, str[i]);
		global_x+=16;
	}
}

void LCD_ch_show(int start_x, int start_y, char ch){
	//获取对应字符的字模
	unsigned char* matrix;
	if(ch == ' '){//空格
		matrix = spaceMatrix;
	}else if(ch < 'A' || ch > 'Z'){
		matrix = starMatrix;
	}else{//A-Z之间
		matrix = font_lowChSet[ch-'A'];
	}
	//显示
	for(int row=0;row<32;row++){//16x32 每行2字节	从高位开始计数
		//第一个字符
		unsigned char mm=matrix[row*2];
		int col=0;
		for(col=0; col<8;col++){
			if(mm & 0x80){
				//显示 x在变, y没变,y代表row
				_HW_DrawPoint(col+start_x,row+start_y, GREEN);
			}
			mm <<= 1;
		}
		//第二个字符
		mm=matrix[row*2+1];
		for(col=8; col<16;col++){
			if(mm & 0x80){
				//显示 x在变, y没变,y代表row
				_HW_DrawPoint(col+start_x,row+start_y, GREEN);
			}
			mm <<= 1;
		}
	}
		
}

3.4、LCD图片打印相关函数代码

void LCD_picture(unsigned char* pic)
{
       uint8_t temp[2] = {};
      //1. 给 ILI9341寄存器 写入 写数据命令
      ILI9341_WR_REG(0x2C);
    
      //屏幕中, 一个像素点占用两个字节
      uint32_t len = 2*240*320;
      uint32_t i = 0;
      while(i < len)
      {
          temp[0] = pic[i];
          temp[1] = pic[i+1];
          HAL_SPI_Transmit(&hspi1,temp,2,0);
          i = i+2;
      }
}

void LCD_pictures(unsigned char (*pics)[153600], int picPages)
{
			unsigned int i=0;
			while(1){
				LCD_picture(pics[i%picPages]);
				i++;
			}
}

4、小结

关于原理图:SPI的转接板的序号并没有对上,不知道是原理图有错还是我的查找方法不正确。

关于字模

        (1)本试验采用的16x32的字模,若是需要更小或更大的字体,需要重新生成字模或者通过某种算法扩展;

        (2)本试验仅支持A-Z的大写字母,如果需要更多的字符需要重新生成字模;

        (3)多字节的字符,例如中文,应该需要某种算法来找到对应的字模矩阵,没研究。

关于cube:关于cubeMax,重新生成导入到keil中,可能会有中文的乱码。还不知道怎么解决

关于烧录程序:本次的试验,用到的图片和字模都比较占用空间,目前是直接写到.c文件中,这样的话会占用较多的栈空间。按我的理解,应该放到硬盘中(例如flash),需要的时候再加载进来,单目前还不知道怎么使用flash。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2276069.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Elasticsearch:向量数据库基础设施类别的兴衰

过去几年&#xff0c;我一直在观察嵌入技术如何从大型科技公司的 “秘密武器” 转变为日常开发人员工具。接下来发生的事情 —— 向量数据库淘金热、RAG 炒作周期以及最终的修正 —— 教会了我们关于新技术如何在更广泛的生态系统中找到一席之地的宝贵经验。 更多有关向量搜索…

《系统爆破:MD5易破,后台登录可爆破?》

声明&#xff1a;笔记的只是方便各位师傅学习知识&#xff0c;以下代码、网站只涉及学习内容&#xff0c;其他的都与本人无关&#xff0c;切莫逾越法律红线&#xff0c;否则后果自负。 爆破Sales系统 一、爆破MD5 场景&#xff1a;已知MD5的加密字符串&#xff0c;如何得知明…

《Spring Framework实战》14:4.1.4.5.自动装配合作者

欢迎观看《Spring Framework实战》视频教程 自动装配合作者 Spring容器可以自动连接协作bean之间的关系。您可以通过检查ApplicationContext的内容&#xff0c;让Spring自动为您的bean解析协作者&#xff08;其他bean&#xff09;。自动装配具有以下优点&#xff1a; 自动装配…

GitLab CI/CD使用runner实现自动化部署前端Vue2 后端.Net 7 Zr.Admin项目

1、查看gitlab版本 建议安装的runner版本和gitlab保持一致 2、查找runner 执行 yum list gitlab-runner --showduplicates | sort -r 找到符合gitlab版本的runner&#xff0c;我这里选择 14.9.1版本 如果执行出现找不到下载源&#xff0c;添加官方仓库 执行 curl -L &quo…

冒泡排序基础与实现

目录 1. 原理图 ​编辑 2. 什么是冒泡排序 3. 工作原理 3.1 具体步骤 3.2 时间复杂度 3.3 空间复杂度 4. 代码实现 5. 总结 1. 原理图 2. 什么是冒泡排序 冒泡排序&#xff08;Bubble Sort&#xff09;是一种简单的排序算法&#xff0c;它通过重复地遍历要排序的列表&am…

acwing_5722_十滴水

acwing_5722_十滴水 下面这篇大佬的题解属实是把指针用明白了&#xff0c;可以好好理解一下&#xff1a; 原题解连接&#xff1a;AcWing 5722. 一个简单模拟实现 - AcWing map/unordered_map的用法:见收藏夹 #include<iostream> #include<unordered_map> #incl…

【AI进化论】 AI微信机器人 | sealos + 智能微秘书 打造AI机器人 | 智能微秘书配置教程

一、sealos 什么是sealos &#xff1f; One cloud OS for all applications 1、创建sealos账号密码 根据链接&#xff08;帮我凑点sealos使用额度感谢&#xff09;&#xff1a;https://cloud.sealos.run/?uidXfUpoQk92c 登录后如下页面&#xff1a; 2、创建应用 点击【应…

Agentless:OpenAI 采用的非代理框架

不需要代理库来解决复杂的业务问题。Agentless 是OpenAI采用的非代理框架&#xff0c;用于在 o3 的 SWE Bench 上实现最高精度。SWE-bench 是 github的真实软件工程问题基准。Agentless 遵循简单的三阶段流程&#xff1a;本地化、修复和补丁验证&#xff1a; 1 ⃣生成存储库的…

Model-based RL自动出价算法的演进之路

▐ 导读 近年来&#xff0c;强化学习自动出价算法已成为智能投放领域的标志性技术&#xff0c;然而其所存在的在离线不一致、线上数据覆盖空间受限等关键问题尚未被完全解决。在本文中&#xff0c;我们提出一种Model-based RL&#xff08;MBRL&#xff09;自动出价算法训练新范…

【Cocos TypeScript 零基础 7.1】

目录 重写 小结一下心得页面跳转背景移动精简 player敌机精灵 重写 小结一下心得 本人重写了整个项目 有了点小心得 页面跳转 director.loadScene(s2)背景移动 canvas 是画布 为什么要向上图布局? 方便计算相对坐标,脚本还是只写一个 绑定上 BG 一样跑,不影响 export cl…

鸿蒙UI(ArkUI-方舟UI框架)

参考&#xff1a;https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V13/arkts-layout-development-overview-V13 ArkUI简介 ArkUI&#xff08;方舟UI框架&#xff09;为应用的UI开发提供了完整的基础设施&#xff0c;包括简洁的UI语法、丰富的UI功能&#xff…

禅道使用实践(2)-产品篇

前言 本文目的皆在指导产品团队使用禅道基于实操完成产品&#xff0c;项目的创建&#xff0c;需求汇总&#xff0c;版本规划&#xff0c;以及验收发布的基本流程。希望能帮助到首次使用禅道而不知道从何下手的团队。 基本概念 此章节内容与我上一篇的开发篇相同&#xff0c;从…

js逆向说明

一 负载的内容传输用这个格式 Content-Type: multipart/form-data Content-Type 是 HTTP 请求头中的一个字段&#xff0c;它告诉服务器请求体的类型。在这个例子中&#xff0c;Content-Type 的值为 multipart/form-data&#xff0c;这表示请求体采用了 multipart/form-data 格…

django基于Python的汽车销售管理系统的设计与实现

Django 基于 Python 的汽车销售管理系统的设计与实现 一、系统概述 Django 基于 Python 的汽车销售管理系统是一款专为汽车销售企业打造的综合性信息化管理平台。该系统借助 Django 框架的高效性、安全性以及 Python 语言丰富的库和工具&#xff0c;全面覆盖汽车销售业务的各…

计算机网络相关习题整理

第一讲 传输媒介 【知识点回顾】 两种导线可以减小电磁干扰&#xff1a; 双绞线&#xff08;分为非屏蔽双绞线、屏蔽双绞线&#xff09;&#xff08;RJ-45用&#xff09;同轴电缆&#xff08;短距离使用&#xff09;网络通信的基本单位&#xff1a;位&#xff08;bit&#xff…

HTTPS SSL/TLS 工作流程

目录 一、HTTP/HTTPS 简介1、HTTP协议相关内容2、HTTPS协议3、HTTP版本差异&#xff1a; 二、HTTPS 协议工作流程解析1. 客户端请求 SSL 握手2. 服务端接收 SSL 握手连接3. TLS 握手中的密钥协商4. HTTP 数据的加密与解密5. 安全性保障 三、HTTPS 协议的相关知识拓展1. TLS 与 …

SpringBoot项目实战(39)--Beetl网页HTML文件中静态图片及CSS、JS文件的引用和展示

使用Beetl开发网页时&#xff0c;在网页中使用的CSS、JS、图片等静态资源需要进行适当的配置才可以展示。大致的过程如下&#xff1a; &#xff08;1&#xff09;首先Spring Security框架需要允许js、css、图片资源免授权访问。 &#xff08;2&#xff09;网站开发时&#xff0…

node_exporter 安装

cd /root/node_exporter wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz tar xvfz node_exporter-1.7.0.linux-amd64.tar.gz #运行 cd /root/node_exporter/node_exporter-1.7.0.linux-amd64 ./node_exp…

【STM32-学习笔记-4-】PWM、输入捕获(PWMI)

文章目录 1、PWMPWM配置 2、输入捕获配置3、编码器 1、PWM PWM配置 配置时基单元配置输出比较单元配置输出PWM波的端口 #include "stm32f10x.h" // Device headervoid PWM_Init(void) { //**配置输出PWM波的端口**********************************…

【复习小结】1-13

数学追求更简洁的表达&#xff0c;计算机追求更简单的表达。数据结构把数学的逻辑结构放进计算器的存储器。 DAY4 闰年的计算 布尔类型是一种数据类型&#xff0c;用于表示逻辑值的简单类型&#xff0c;它的值只能是真&#xff08;true&#xff09;或假&#xff08;false&…