RT系统+STM32+红外控制(HX1813)+1.44寸显示屏

Posted HR_CMD

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RT系统+STM32+红外控制(HX1813)+1.44寸显示屏相关的知识,希望对你有一定的参考价值。

本次实验是为了了解RT-thread的工作流程以及简单的实验RT来进行一个学习

实验材料:STM32c8t6+1.44寸TFT显示屏+红外传感器+分光棱镜

实验结果:可以进行红外定时选择,实验成功分为三个线程做任务

线程一:开机时间显示

//APP1
static void led1_thread_entry(void* parameter)

  rt_uint8_t hour=0,munite=0,second=0;
	rt_uint8_t dispBuff[100];
	 //Show_Picture(); 
	Demo_Menu();
	while (1)
	
	 if(second<59) 
		 second++; 
	 
	 else 
	 
		 second=0;
		 munite++;
		 if(munite==60) 
		 
			 second=0;
			 munite=0;
			 hour++;
			 if(hour==24)
			 
				 second=0;
				 munite=0;
				 hour=0;
			 
		 
	 

	sprintf(dispBuff,"-%02d:%02d:%02d-",hour,munite,second);	
  Draw_Font24B(4,30,RED,dispBuff);	
//	Draw_Font16B(4,40,YELLOW,dispBuff);//8*16 “ABC”
	rt_thread_delay(1000);   /* 延时500个tick */	

	

 线程二:红外遥控判断

//APP2
static void APP2_thread_entry(void* parameter)
	
  rt_err_t uwRet = RT_EOK;	
	rt_uint8_t key=0;
	rt_uint8_t dispBuff[100];
	rt_uint8_t t=0;	
	rt_uint8_t *str=0;
	while(1)
	

	  key=Remote_Scan();
			
		if(key)
			
		switch(key)
			
				case 162:
						//1
						str= "*计时器 10 min*";
						munite = 10;
						hour=0;		
						second=0;
            break;
        
        case 98:
						//2					
					  str= "*计时器 20 min*";
            munite = 20;
						hour=0;	
						second=0;
            break;
        
        case 226://3
					 str= "*计时器 30 min*";
					 munite = 30;
					hour=0;	
						second=0;
            break;
        
        case 34://4
					 str= "*计时器 40 min*";
						munite = 40;
					  hour=0;	
				    second=0;
            break;
        
        case 2://5
					 str= "*计时器 50 min*";
           munite = 50;
					 hour=0;
					 second=0;			
            break;
        
        case 194://6
					 str= "*计时器 60 min*";
           munite = 60;
					hour=0;
					second=0;
            break;
        
        case 224://7
					 str= "*计时器 90 min*";
					 hour = 1;
           munite = 30;
					 second=0;
            break;
        
        case 168://8
					 str= "*  计时器 2 h *";
           hour = 1;
					munite = 60;
					second=0;
            break;
        
        case 144://9
					 str= "*  计时器 3 h *";
           hour = 2;
						munite = 60;
						second=0;
            break;
        
        case 152:
					 str= "detected code 0";
            
            break;
        
        case 104:
					 str= "detected code *";
          
            break;
        
        case 176:
					 str= "detected code #";
           
            break;
                
        case 24:
					 str= "detected code ↑";
          
            break;
                
        case 16:
					 str= "detected code ←";
            
            break;
        
        case 74:
					  str= "detected code ↓";
         
            break;
        
        case 90:
					  str= "detected code →";
            break;
        
        case 56:
            str= "detected code OK ";
            break;
        
        default:
					  str= "EMOURE";
         
            break;

			

//			uwRet = rt_thread_resume(APP3_thread);/* 恢复APP3线程! */
//			if(RT_EOK == uwRet)
//			
//				rt_kprintf("恢复APP3线程成功!\\n");
//			
//			else
//			
//				rt_kprintf("恢复APP3线程失败!失败代码:0x%lx\\n",uwRet);
//			
			Draw_Font16B(4,100,BRRED,str);	//显示SYMBOL
		

	

 线程三:计时器

//APP3
static void APP3_thread_entry(void* parameter)

	rt_err_t uwRet = RT_EOK;	
	rt_uint8_t dispBuff[100];
  while (1)
    
  	 if(second>0) 
			 second--; 
		 
		 else 
		 
			 second=59;
			 munite--;
			 //time++;
			 if(munite==0) 
			 
				 munite=60;
			   second=59;
				 
				 hour--;
				 if(hour==0)
				 
					 munite=60;
			     second=59;
//					uwRet = rt_thread_suspend(APP3_thread);/* 挂起APP3线程 */
//					if(RT_EOK == uwRet)
//					
//						rt_kprintf("挂起APP3线程成功!\\n");
//					
//					else
//					
//						rt_kprintf("挂起APP3线程失败!失败代码:0x%lx\\n",uwRet);
//					
				 
				
			 
			 
     
	
		sprintf(dispBuff," time:%02d:%02d:%02d",hour,munite,second);		
		Draw_Font16B(4,80,YELLOW,dispBuff);//8*16 “ABC”
	  rt_thread_delay(980);   /* 延时500个tick */	

    

程序代码:01.RT红外定时器.zip-OS文档类资源-CSDN下载

以上是关于RT系统+STM32+红外控制(HX1813)+1.44寸显示屏的主要内容,如果未能解决你的问题,请参考以下文章

基于STM32的智能家居控制系统设计与实现(带红外遥控控制空调)

资料分享基于STM32无线蓝牙大棚温湿度监测控制系统设计基于STM32无线远距离红外通信系统设计

STM32单片机WIFI-APP智能温控空调冷热可调红外遥控

17 基于STM32的非接触红外测温器

17 基于STM32的非接触红外测温器

STM32标准库与HAL库对照学习教程外设篇--红外避障传感器