[开发板] 【CW32L031CxTx StartKit评估板测评】OLED显示人体检测

[复制链接]
 楼主| yinwuqing110 发表于 2023-11-4 21:20 | 显示全部楼层 |阅读模式
#申请原创#上期咱分享了关于驱动HC-SR501红外人体检测模块的内容,上期贴子:https://bbs.21ic.com/icview-3337106-1-1.html
     今天使用OLED屏幕实时监测HC-SR501检测结果,如若红外监测模块检测到有人经过,则OLED屏展现“有人经过”,OLED模块采用IIC通讯方式。
     此次实现监测功能,用到的硬件接口有:
     HC-SR501-OUT:GPIOA_7
     OLED-SCL:       GPIOB_10
     OLED-SDA:       GPIOB_11
     硬件连接示意图如下:
示意图.png
     由于官方提供的底层库函数与标准的STM32库函数很相似,因此移植基于STM32的工程就变得非常简单啦。工程中运用到提取字模的软件,众所周知,“PCtoLCD2002”非常好用,菜单中“模式”有“字符模式”与“图形模式”,根据需求我们可以使用该取模软件对中文字符进行取模,或者对单色位图进行取模。取模软件的选项设置如下:
字模设置.png
      部分代码展示如下:
  1. /* 包含头文件 ----------------------------------------------------------------*/
  2. #include "bsp_HC-SR501.h"

  3. /**
  4.   * 函数功能: 人体红外感应模块IO引脚初始化.
  5.   * 输入参数: 无
  6.   * 返 回 值: 无
  7.   * 说    明:对人体红外感应模块接入的引脚进行初始化
  8.   *           
  9.   */
  10. void HC_SR501_GPIO_Init(void)
  11. {
  12.    /* 定义IO硬件初始化结构体变量 */
  13.   GPIO_InitTypeDef GPIO_InitStruct;
  14.        
  15.         /* 使能(开启)HC_SR501引脚对应IO端口时钟 */  
  16.         __RCC_GPIOA_CLK_ENABLE();
  17.    
  18.         //GPIO_InitStruct.IT = GPIO_IT_HIGH;
  19.         /* 设定HC_SR501对应引脚IO为浮空输入模式 */
  20.   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;  
  21.   /* 设定HC_SR501对应引脚IO编号 */
  22.   GPIO_InitStruct.Pins = HC_SR501_GPIO_PIN;  

  23.   /* 初始化HC_SR501对应引脚IO */
  24.   GPIO_Init(HC_SR501_GPIO, &GPIO_InitStruct);
  25. }

  26. /**
  27.   * 函数功能: 简单粗暴的延时函数
  28.   * 输入参数: time;延时时间设置
  29.   * 返 回 值: 无
  30.   * 说    明:软件消抖
  31.   */
  32. static void HC_SR501_ScanDelay(void)
  33. {  
  34.   uint32_t i,j;
  35.   for(i=0;i<10;++i)
  36.     for(j=0;j<100;++j){ }               
  37. }

  38. /**
  39.   * 函数功能: 读取引脚的状态
  40.   * 输入参数:无
  41.   * 返 回 值: HC_SR501_HIGH:有人;
  42.   *           HC_SR501_LOW:没人
  43.   * 说    明:无。
  44.   */
  45. HC_SR501_State_TypeDef HC_SR501_StateRead(void)
  46. {
  47.   /* 读取模块输出信号,若此时输出的是高电平 ,则进入下一步判断*/
  48.   if(GPIO_ReadPin(HC_SR501_GPIO,HC_SR501_GPIO_PIN)==HC_SR501_ACTIVE_LEVEL)
  49.   {
  50.     /* 延时一小段时间,消除抖动 */
  51.     HC_SR501_ScanDelay();
  52.     /* 延时时间后再来判断引脚状态,如果还是高电平那么确实就是高电平 */
  53.     if(GPIO_ReadPin(HC_SR501_GPIO,HC_SR501_GPIO_PIN)==HC_SR501_ACTIVE_LEVEL)
  54.     {      
  55.        /* 按键扫描完毕,确定有人,返回有人状态(高电平) */
  56.       return HC_SR501_HIGH;
  57.     }
  58.   }
  59.   /* 没人,返回没人状态 */
  60.   return HC_SR501_LOW;
  61. }
  1. #ifndef __BSP_HC_SR501_H__
  2. #define __BSP_HC_SR501_H__

  3. /* 包含头文件 ----------------------------------------------------------------*/
  4. #include "../inc/main.h"

  5. /* 类型定义 --------------------------------------------------------------*/
  6. typedef enum
  7. {
  8.   HC_SR501_LOW   = 0,
  9.   HC_SR501_HIGH = 1,
  10. }HC_SR501_State_TypeDef;

  11. /* 宏定义 --------------------------------------------------------------------*/
  12. #define HC_SR501_RCC_CLK_ENABLE()         _RCC_GPIOA_CLK_ENABLE()
  13. #define HC_SR501_GPIO_PIN                 GPIO_PIN_7
  14. #define HC_SR501_GPIO                     CW_GPIOA
  15. #define HC_SR501_ACTIVE_LEVEL             1

  16. /* 扩展变量 ------------------------------------------------------------------*/
  17. /* 函数声明 ------------------------------------------------------------------*/
  18. void HC_SR501_GPIO_Init(void);
  19. HC_SR501_State_TypeDef HC_SR501_StateRead(void);

  20. #endif  
  1. #include "stdlib.h"
  2. #include "oled.h"
  3. #include "oledfont.h"
  4. #include "../inc/main.h"

  5. void IIC_Start()
  6. {
  7.         OLED_SCLK_Set();
  8.         OLED_SDIN_Set();
  9.         OLED_SDIN_Clr();
  10.         OLED_SCLK_Clr();
  11. }

  12. //IIC Stop
  13. void IIC_Stop()
  14. {
  15.         OLED_SCLK_Set() ;
  16.         //OLED_SCLK_Clr();
  17.         OLED_SDIN_Clr();
  18.         OLED_SDIN_Set();
  19.        
  20. }

  21. void IIC_Wait_Ack()
  22. {
  23.         OLED_SCLK_Set() ;
  24.         OLED_SCLK_Clr();
  25. }

  26. // IIC Write byte

  27. void Write_IIC_Byte(unsigned char IIC_Byte)
  28. {
  29.         unsigned char i;
  30.         unsigned char m,da;
  31.         da=IIC_Byte;
  32.         OLED_SCLK_Clr();
  33.         for(i=0;i<8;i++)               
  34.         {
  35.                 m=da;
  36.                 m=m&0x80;
  37.                 if(m==0x80)
  38.                 {OLED_SDIN_Set();}
  39.                 else OLED_SDIN_Clr();
  40.                         da=da<<1;
  41.                 OLED_SCLK_Set();
  42.                 OLED_SCLK_Clr();
  43.                 }


  44. }

  45. // IIC Write Command

  46. void Write_IIC_Command(unsigned char IIC_Command)
  47. {
  48.    IIC_Start();
  49.    Write_IIC_Byte(0x78);            //Slave address,SA0=0
  50.         IIC_Wait_Ack();       
  51.    Write_IIC_Byte(0x00);                        //write command
  52.         IIC_Wait_Ack();       
  53.    Write_IIC_Byte(IIC_Command);
  54.         IIC_Wait_Ack();       
  55.    IIC_Stop();
  56. }

  57. // IIC Write Data

  58. void Write_IIC_Data(unsigned char IIC_Data)
  59. {
  60.    IIC_Start();
  61.    Write_IIC_Byte(0x78);                        //D/C#=0; R/W#=0
  62.         IIC_Wait_Ack();       
  63.    Write_IIC_Byte(0x40);                        //write data
  64.         IIC_Wait_Ack();       
  65.    Write_IIC_Byte(IIC_Data);
  66.         IIC_Wait_Ack();       
  67.    IIC_Stop();
  68. }
  69. void OLED_WR_Byte(unsigned dat,unsigned cmd)
  70. {
  71.         if(cmd)
  72.                         {

  73.    Write_IIC_Data(dat);
  74.    
  75.                 }
  76.         else {
  77.    Write_IIC_Command(dat);
  78.                
  79.         }
  80. }


  81. // fill_Picture

  82. void fill_picture(unsigned char fill_Data)
  83. {
  84.         unsigned char m,n;
  85.         for(m=0;m<8;m++)
  86.         {
  87.                 OLED_WR_Byte(0xb0+m,0);                //page0-page1
  88.                 OLED_WR_Byte(0x00,0);                //low column start address
  89.                 OLED_WR_Byte(0x10,0);                //high column start address
  90.                 for(n=0;n<128;n++)
  91.                         {
  92.                                 OLED_WR_Byte(fill_Data,1);
  93.                         }
  94.         }
  95. }


  96. /***********************Delay****************************************/
  97. void Delay_50ms(unsigned int Del_50ms)
  98. {
  99.         unsigned int m;
  100.         for(;Del_50ms>0;Del_50ms--)
  101.                 for(m=6245;m>0;m--);
  102. }

  103. //坐标设置

  104.         void OLED_Set_Pos(unsigned char x, unsigned char y)
  105. {         OLED_WR_Byte(0xb0+y,OLED_CMD);
  106.         OLED_WR_Byte(((x&0xf0)>>4)|0x10,OLED_CMD);
  107.         OLED_WR_Byte((x&0x0f),OLED_CMD);
  108. }             
  109. //开启OLED显示   
  110. void OLED_Display_On(void)
  111. {
  112.         OLED_WR_Byte(0X8D,OLED_CMD);  //SET DCDC命令
  113.         OLED_WR_Byte(0X14,OLED_CMD);  //DCDC ON
  114.         OLED_WR_Byte(0XAF,OLED_CMD);  //DISPLAY ON
  115. }
  116. //关闭OLED显示     
  117. void OLED_Display_Off(void)
  118. {
  119.         OLED_WR_Byte(0X8D,OLED_CMD);  //SET DCDC命令
  120.         OLED_WR_Byte(0X10,OLED_CMD);  //DCDC OFF
  121.         OLED_WR_Byte(0XAE,OLED_CMD);  //DISPLAY OFF
  122. }                                            
  123. //清屏函数,清完屏,整个屏幕是黑色的!和没点亮一样!!!          
  124. void OLED_Clear(void)  
  125. {  
  126.         u8 i,n;                    
  127.         for(i=0;i<8;i++)  
  128.         {  
  129.                 OLED_WR_Byte (0xb0+i,OLED_CMD);    //设置页地址(0~7)
  130.                 OLED_WR_Byte (0x00,OLED_CMD);      //设置显示位置—列低地址
  131.                 OLED_WR_Byte (0x10,OLED_CMD);      //设置显示位置—列高地址   
  132.                 for(n=0;n<128;n++)OLED_WR_Byte(0,OLED_DATA);
  133.         } //更新显示
  134. }
  135. void OLED_On(void)  
  136. {  
  137.         u8 i,n;                    
  138.         for(i=0;i<8;i++)  
  139.         {  
  140.                 OLED_WR_Byte (0xb0+i,OLED_CMD);    //设置页地址(0~7)
  141.                 OLED_WR_Byte (0x00,OLED_CMD);      //设置显示位置—列低地址
  142.                 OLED_WR_Byte (0x10,OLED_CMD);      //设置显示位置—列高地址   
  143.                 for(n=0;n<128;n++)OLED_WR_Byte(1,OLED_DATA);
  144.         } //更新显示
  145. }
  146. //在指定位置显示一个字符,包括部分字符
  147. //x:0~127
  148. //y:0~63
  149. //mode:0,反白显示;1,正常显示                                 
  150. //size:选择字体 16/12
  151. void OLED_ShowChar(u8 x,u8 y,u8 chr,u8 Char_Size)
  152. {             
  153.         unsigned char c=0,i=0;       
  154.                 c=chr-' ';//得到偏移后的值                       
  155.                 if(x>Max_Column-1){x=0;y=y+2;}
  156.                 if(Char_Size ==16)
  157.                         {
  158.                         OLED_Set_Pos(x,y);       
  159.                         for(i=0;i<8;i++)
  160.                         OLED_WR_Byte(F8X16[c*16+i],OLED_DATA);
  161.                         OLED_Set_Pos(x,y+1);
  162.                         for(i=0;i<8;i++)
  163.                         OLED_WR_Byte(F8X16[c*16+i+8],OLED_DATA);
  164.                         }
  165.                         else {       
  166.                                 OLED_Set_Pos(x,y);
  167.                                 for(i=0;i<6;i++)
  168.                                 OLED_WR_Byte(F6x8[c][i],OLED_DATA);
  169.                                
  170.                         }
  171. }
  172. //m^n函数
  173. u32 oled_pow(u8 m,u8 n)
  174. {
  175.         u32 result=1;         
  176.         while(n--)result*=m;   
  177.         return result;
  178. }                                  
  179. //显示2个数字
  180. //x,y :起点坐标         
  181. //len :数字的位数
  182. //size:字体大小
  183. //mode:模式        0,填充模式;1,叠加模式
  184. //num:数值(0~4294967295);                           
  185. void OLED_ShowNum(u8 x,u8 y,u32 num,u8 len,u8 size2)
  186. {                
  187.         u8 t,temp;
  188.         u8 enshow=0;                                                  
  189.         for(t=0;t<len;t++)
  190.         {
  191.                 temp=(num/oled_pow(10,len-t-1))%10;
  192.                 if(enshow==0&&t<(len-1))
  193.                 {
  194.                         if(temp==0)
  195.                         {
  196.                                 OLED_ShowChar(x+(size2/2)*t,y,' ',size2);
  197.                                 continue;
  198.                         }else enshow=1;
  199.                           
  200.                 }
  201.                  OLED_ShowChar(x+(size2/2)*t,y,temp+'0',size2);
  202.         }
  203. }
  204. //显示一个字符号串
  205. void OLED_ShowString(u8 x,u8 y,u8 *chr,u8 Char_Size)
  206. {
  207.         unsigned char j=0;
  208.         while (chr[j]!='\0')
  209.         {                OLED_ShowChar(x,y,chr[j],Char_Size);
  210.                         x+=8;
  211.                 if(x>120){x=0;y+=2;}
  212.                         j++;
  213.         }
  214. }
  215. //显示汉字
  216. void OLED_ShowCHinese(u8 x,u8 y,u8 no)
  217. {                                  
  218.         u8 t,adder=0;
  219.         OLED_Set_Pos(x,y);       
  220.     for(t=0;t<16;t++)
  221.                 {
  222.                                 OLED_WR_Byte(Hzk[2*no][t],OLED_DATA);
  223.                                 adder+=1;
  224.      }       
  225.                 OLED_Set_Pos(x,y+1);       
  226.     for(t=0;t<16;t++)
  227.                         {       
  228.                                 OLED_WR_Byte(Hzk[2*no+1][t],OLED_DATA);
  229.                                 adder+=1;
  230.       }                                       
  231. }
  232. /***********功能描述:显示显示BMP图片128×64起始点坐标(x,y),x的范围0~127,y为页的范围0~7*****************/
  233. void OLED_DrawBMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,unsigned char BMP[])
  234. {        
  235. unsigned int j=0;
  236. unsigned char x,y;
  237.   
  238.   if(y1%8==0) y=y1/8;      
  239.   else y=y1/8+1;
  240.         for(y=y0;y<y1;y++)
  241.         {
  242.                 OLED_Set_Pos(x0,y);
  243.     for(x=x0;x<x1;x++)
  244.             {      
  245.                     OLED_WR_Byte(BMP[j++],OLED_DATA);                   
  246.             }
  247.         }
  248. }

  249. //初始化SSD1306                                            
  250. void OLED_Init(void)
  251. {        
  252.           GPIO_InitTypeDef  configStruct;
  253.                 /* enable the OLED GPIO clock */
  254.                 __RCC_GPIOB_CLK_ENABLE();

  255.     /* configure OLED GPIO pin */
  256.                 configStruct.Pins = GPIO_PIN_10|GPIO_PIN_11;
  257.           configStruct.Mode = GPIO_MODE_OUTPUT_PP;
  258.     configStruct.IT = GPIO_IT_NONE;
  259.           GPIO_Init(CW_GPIOB, &configStruct);
  260.        
  261.           GPIO_WritePin(CW_GPIOB,GPIO_PIN_10,GPIO_Pin_SET);       
  262.                 GPIO_WritePin(CW_GPIOB,GPIO_PIN_11,GPIO_Pin_SET);       
  263.        
  264.     Delay(8000);
  265.     OLED_WR_Byte(0xAE,OLED_CMD);//--display off
  266.                 OLED_WR_Byte(0x00,OLED_CMD);//---set low column address
  267.                 OLED_WR_Byte(0x10,OLED_CMD);//---set high column address
  268.                 OLED_WR_Byte(0x40,OLED_CMD);//--set start line address  
  269.                 OLED_WR_Byte(0xB0,OLED_CMD);//--set page address
  270.                 OLED_WR_Byte(0x81,OLED_CMD); // contract control
  271.                 OLED_WR_Byte(0xFF,OLED_CMD);//--128   
  272.                 OLED_WR_Byte(0xA1,OLED_CMD);//set segment remap
  273.                 OLED_WR_Byte(0xA6,OLED_CMD);//--normal / reverse
  274.                 OLED_WR_Byte(0xA8,OLED_CMD);//--set multiplex ratio(1 to 64)
  275.                 OLED_WR_Byte(0x3F,OLED_CMD);//--1/32 duty
  276.                 OLED_WR_Byte(0xC8,OLED_CMD);//Com scan direction
  277.                 OLED_WR_Byte(0xD3,OLED_CMD);//-set display offset
  278.                 OLED_WR_Byte(0x00,OLED_CMD);//
  279.                
  280.                 OLED_WR_Byte(0xD5,OLED_CMD);//set osc division
  281.                 OLED_WR_Byte(0x80,OLED_CMD);//
  282.                
  283.                 OLED_WR_Byte(0xD8,OLED_CMD);//set area color mode off
  284.                 OLED_WR_Byte(0x05,OLED_CMD);//
  285.                
  286.                 OLED_WR_Byte(0xD9,OLED_CMD);//Set Pre-Charge Period
  287.                 OLED_WR_Byte(0xF1,OLED_CMD);//
  288.                
  289.                 OLED_WR_Byte(0xDA,OLED_CMD);//set com pin configuartion
  290.                 OLED_WR_Byte(0x12,OLED_CMD);//
  291.                
  292.                 OLED_WR_Byte(0xDB,OLED_CMD);//set Vcomh
  293.                 OLED_WR_Byte(0x30,OLED_CMD);//
  294.                
  295.                 OLED_WR_Byte(0x8D,OLED_CMD);//set charge pump enable
  296.                 OLED_WR_Byte(0x14,OLED_CMD);//
  297.                
  298.                 OLED_WR_Byte(0xAF,OLED_CMD);//--turn on oled panel
  299. }  
  1. #ifndef __OLED_H
  2. #define __OLED_H

  3. #include "cw32l031_gpio.h"
  4. #include "stdlib.h"          
  5. #include "stdint.h"


  6. #define OLED_MODE 0
  7. #define SIZE 8
  8. #define XLevelL                0x00
  9. #define XLevelH                0x10
  10. #define Max_Column        128
  11. #define Max_Row                64
  12. #define        Brightness        0xFF
  13. #define X_WIDTH         128
  14. #define Y_WIDTH         64                                                              
  15. //-----------------OLED IIC端口定义----------------                                            

  16. #define OLED_SCLK_Clr() GPIO_WritePin(CW_GPIOB,GPIO_PIN_10,GPIO_Pin_RESET)//SCL   PB10
  17. #define OLED_SCLK_Set() GPIO_WritePin(CW_GPIOB,GPIO_PIN_10,GPIO_Pin_SET)

  18. #define OLED_SDIN_Clr() GPIO_WritePin(CW_GPIOB,GPIO_PIN_11,GPIO_Pin_RESET)//SDA  PB11
  19. #define OLED_SDIN_Set() GPIO_WritePin(CW_GPIOB,GPIO_PIN_11,GPIO_Pin_SET)

  20.                      
  21. #define OLED_CMD  0        //写命令
  22. #define OLED_DATA 1        //写数据


  23. typedef uint32_t  u32;
  24. typedef uint16_t u16;
  25. typedef uint8_t  u8;

  26. //OLED控制用函数
  27. void OLED_WR_Byte(unsigned dat,unsigned cmd);  
  28. void OLED_Display_On(void);
  29. void OLED_Display_Off(void);                                                                                          
  30. void OLED_Init(void);
  31. void OLED_Clear(void);
  32. void OLED_DrawPoint(u8 x,u8 y,u8 t);
  33. void OLED_Fill(u8 x1,u8 y1,u8 x2,u8 y2,u8 dot);
  34. void OLED_ShowChar(u8 x,u8 y,u8 chr,u8 Char_Size);
  35. void OLED_ShowNum(u8 x,u8 y,u32 num,u8 len,u8 size);
  36. void OLED_ShowString(u8 x,u8 y, u8 *p,u8 Char_Size);         
  37. void OLED_Set_Pos(unsigned char x, unsigned char y);
  38. void OLED_ShowCHinese(u8 x,u8 y,u8 no);
  39. void OLED_DrawBMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,unsigned char BMP[]);
  40. void Delay_50ms(unsigned int Del_50ms);
  41. void Delay_1ms(unsigned int Del_1ms);
  42. void fill_picture(unsigned char fill_Data);
  43. void Picture(void);
  44. void IIC_Start(void);
  45. void IIC_Stop(void);
  46. void Write_IIC_Command(unsigned char IIC_Command);
  47. void Write_IIC_Data(unsigned char IIC_Data);
  48. void Write_IIC_Byte(unsigned char IIC_Byte);
  49. void IIC_Wait_Ack(void);
  50. #endif  
  1. #include "../inc/main.h"
  2. #include "oled.h"
  3. #include "bmp.h"
  4. #include "bsp_HC-SR501.h"

  5. /******************************************************************************
  6. * Local pre-processor symbols/macros ('#define')
  7. ******************************************************************************/
  8. #define LED_GPIO_PORT CW_GPIOB
  9. #define LED_GPIO_PINS GPIO_PIN_8 | GPIO_PIN_9

  10. int32_t main(void)
  11. {
  12.                 uint8_t t = 0;
  13.     GPIO_InitTypeDef GPIO_InitStruct = {0};
  14.                 HC_SR501_GPIO_Init();

  15.     RCC_HSI_Enable(RCC_HSIOSC_DIV6);
  16.     __RCC_GPIOC_CLK_ENABLE();

  17.     GPIO_InitStruct.IT = GPIO_IT_NONE;
  18.     GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  19.     GPIO_InitStruct.Pins = LED_GPIO_PINS;

  20.     GPIO_Init(LED_GPIO_PORT, &GPIO_InitStruct);

  21.                 OLED_Init();                       
  22.                 OLED_Clear();
  23.                 t=' ';
  24.                 OLED_ShowCHinese(10,0,25);//欢
  25.                 OLED_ShowCHinese(18+10,0,26);//迎
  26.                 OLED_ShowCHinese(36+10,0,27);//使
  27.                 OLED_ShowCHinese(54+10,0,28);//用
  28.                 OLED_ShowString(6,3,(uint8_t *)"CW32L031CxTx",16);
  29.                 OLED_ShowString(6,6,(uint8_t *)"2023-11-01",16);
  30.                 Delay(650000);
  31.                 OLED_Clear();
  32.                 OLED_ShowCHinese(10,0,29);//芯
  33.                 OLED_ShowCHinese(18+10,0,30);//源
  34.                 OLED_ShowCHinese(36+10,0,31);//电
  35.                 OLED_ShowCHinese(54+10,0,32);//子
  36.                 OLED_ShowString(16,3,(uint8_t *)"StartKit REV01",16);
  37.     while (1)
  38.     {
  39.                                 OLED_Clear();
  40.                                 OLED_ShowChar(48,6,t,16);//ASCII
  41.                                 t++;
  42.                                 if(t>'~')t=' ';
  43.                                 OLED_ShowNum(103,6,t,3,16);//ASCII
  44.                                 Delay(650000);
  45.                                
  46.         if (t > '~')
  47.         {
  48.             t = ' ';
  49.         }

  50.                                 if(HC_SR501_StateRead()==HC_SR501_LOW)
  51.                                 {
  52.                                         GPIO_WritePin(LED_GPIO_PORT,LED_GPIO_PINS,GPIO_Pin_RESET);
  53.                                         Delay(0xFFFF);
  54.                                 }
  55.                                 else
  56.                                 {
  57.                                         GPIO_WritePin(LED_GPIO_PORT,LED_GPIO_PINS,GPIO_Pin_SET);
  58.                                         OLED_Clear();
  59.                                         OLED_DrawBMP(0,0,128,8,BMP3);
  60.                                         Delay(250000);       
  61.                                 }
  62.     }
  63. }

  64. /**
  65. * [url=home.php?mod=space&uid=247401]@brief[/url] 循环延时
  66. *
  67. * @param nCount
  68. */
  69. void Delay(__IO uint32_t nCount)
  70. {
  71.     /* Decrement nCount value */
  72.     while (nCount != 0)
  73.     {
  74.         nCount--;
  75.     }
  76. }
      开发板上的硬件接口连接见下图:
检测有人经过.jpg
       实测的效果见下面视频,由于HC-SR501红外人体检测模块检测周边环境灵敏度比较高,拍摄时有时候会一直触发“有人经过”的情景。整体来看,监测的效果比较准确,芯源官方提供的底层库函数接口非常标准,很容易移植。最后再提供一份关于OLED屏操作的指引文档。
0.96寸OLED使用文档新手必看V2.0.pdf (1.84 MB, 下载次数: 3)


 楼主| yinwuqing110 发表于 2023-11-4 21:36 | 显示全部楼层
本帖最后由 yinwuqing110 于 2023-11-4 21:49 编辑

开机启动展示如下:
启动展示.gif

您需要登录后才可以回帖 登录 | 注册

本版积分规则

106

主题

1098

帖子

7

粉丝
快速回复 在线客服 返回列表 返回顶部

106

主题

1098

帖子

7

粉丝
快速回复 在线客服 返回列表 返回顶部