本次实验是为了了解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++;
- // if(time == 10){
- // OLED_Clear();
- // time = 0;
- // os_app_resume(APP_03); //简单定时10*500ms=5s后恢复运行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); /* 延时500个tick */
- }
- }
复制代码
线程二:红外遥控判断
线程三:计时器
- //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); /* 延时500个tick */
- }
- }
复制代码
代码下载1:01.RT红外定时器.zip-OS文档类资源-CSDN下载
代码下载2:
代码.7z
(619.56 KB, 下载次数: 16)
|