標(biāo)題:
RT系統(tǒng)+STM32+紅外控制+1.44寸顯示屏 源程序
[打印本頁]
作者:
herui123456
時(shí)間:
2021-11-28 15:44
標(biāo)題:
RT系統(tǒng)+STM32+紅外控制+1.44寸顯示屏 源程序
本次實(shí)驗(yàn)是為了了解
RT-thread
的工作流程以及簡(jiǎn)單的實(shí)驗(yàn)RT來進(jìn)行一個(gè)學(xué)習(xí)
實(shí)驗(yàn)材料:STM32c8t6+1.44寸TFT顯示屏+紅外傳感器+分光棱鏡
實(shí)驗(yàn)結(jié)果:可以進(jìn)行紅外定時(shí)選擇,實(shí)驗(yàn)成功分為
三個(gè)線程
做任務(wù)
1.jpg
(344.07 KB, 下載次數(shù): 68)
下載附件
2021-11-28 20:56 上傳
線程一:開機(jī)時(shí)間顯示
//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++;
// if(time == 10){
// OLED_Clear();
// time = 0;
// os_app_resume(APP_03); //簡(jiǎn)單定時(shí)10*500ms=5s后恢復(fù)運(yùn)行APP_02 ,掛起自己。
// os_app_pend(APP_01);
// }
}
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); /* 延時(shí)500個(gè)tick */
}
}
復(fù)制代碼
線程二:紅外遙控判斷
//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= "*計(jì)時(shí)器 10 min*";
munite = 10;
hour=0;
second=0;
break;
case 98:
//2
str= "*計(jì)時(shí)器 20 min*";
munite = 20;
hour=0;
second=0;
break;
case 226://3
str= "*計(jì)時(shí)器 30 min*";
munite = 30;
hour=0;
second=0;
break;
case 34://4
str= "*計(jì)時(shí)器 40 min*";
munite = 40;
hour=0;
second=0;
break;
case 2://5
str= "*計(jì)時(shí)器 50 min*";
munite = 50;
hour=0;
second=0;
break;
case 194://6
str= "*計(jì)時(shí)器 60 min*";
munite = 60;
hour=0;
second=0;
break;
case 224://7
str= "*計(jì)時(shí)器 90 min*";
hour = 1;
munite = 30;
second=0;
break;
case 168://8
str= "* 計(jì)時(shí)器 2 h *";
hour = 1;
munite = 60;
second=0;
break;
case 144://9
str= "* 計(jì)時(shí)器 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);/* 恢復(fù)APP3線程! */
// if(RT_EOK == uwRet)
// {
// rt_kprintf("恢復(fù)APP3線程成功!\n");
// }
// else
// {
// rt_kprintf("恢復(fù)APP3線程失!失敗代碼:0x%lx\n",uwRet);
// }
Draw_Font16B(4,100,BRRED,str); //顯示SYMBOL
}
}
}
復(fù)制代碼
線程三:計(jì)時(shí)器
//APP3
static void APP3_thread_entry(void* parameter)
{
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=0;
second=0;
// 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); /* 延時(shí)500個(gè)tick */
}
}
復(fù)制代碼
代碼下載1:
01.RT紅外定時(shí)器.zip-OS文檔類資源-CSDN下載
代碼下載2:
代碼.7z
(619.56 KB, 下載次數(shù): 16)
2021-11-29 18:07 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1