101 lines
3.2 KiB
C
101 lines
3.2 KiB
C
|
/*****************************************************************
|
|||
|
;Project: Light
|
|||
|
;MCU:
|
|||
|
;Date:
|
|||
|
;File:
|
|||
|
;Function:
|
|||
|
******************************************************************/
|
|||
|
#include "cyclingLed_task.h"
|
|||
|
#include "config.h"
|
|||
|
#include "tick.h"
|
|||
|
#include "ws2812.h"
|
|||
|
#include "detect_task.h"
|
|||
|
/*---------------------------------------------------------------*/
|
|||
|
//<2F>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
extern TaskFlagUnion_t tTaskFlag;
|
|||
|
/*---------------------------------------------------------------*/
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
unsigned short cycSpeed = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
|
|||
|
unsigned char cycReSpeedFlag = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>ˢ<EFBFBD>±<EFBFBD>־
|
|||
|
/*---------------------------------------------------------------*/
|
|||
|
//<2F><><EFBFBD><EFBFBD>LED<45><44>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>
|
|||
|
void cyclingLed_Task(void)
|
|||
|
{
|
|||
|
static unsigned char rotate_cycLed=0; //<2F><>ǰ<EFBFBD><C7B0>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>led
|
|||
|
static unsigned short cycDelay=100; //<2F><><EFBFBD>õƵ<C3B5>תȦ<D7AA>ٶ<EFBFBD>
|
|||
|
static unsigned short timer_cyc = 0; //<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ڵ㣨<DAB5>൱<EFBFBD>ڶ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ӣ<EFBFBD>
|
|||
|
static unsigned int cycColor = 0x0000;
|
|||
|
static unsigned short timer_cycIntervalMax = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>ʱ<EEB3A4><CAB1>
|
|||
|
|
|||
|
if(tTaskFlag.tFlag.cycFlag == 1)
|
|||
|
{
|
|||
|
if( Get_TaskInitFlag() == 1)
|
|||
|
{
|
|||
|
WS_CloseAll();
|
|||
|
rotate_cycLed= 0;
|
|||
|
TimerSet(timer_cycIntervalMax,TIME_CYCBREAK_MAX);
|
|||
|
TimerSet(timer_cyc,0);
|
|||
|
Set_TaskInitFlag(0);
|
|||
|
}
|
|||
|
|
|||
|
//--ÿ4<C3BF><34>ˢ<EFBFBD><CBA2>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>û<EFBFBD><C3BB>ˢ<EFBFBD>¾ͽ<C2BE><CDBD>ٶ<EFBFBD><D9B6><EFBFBD>Ϊ0
|
|||
|
if(cycReSpeedFlag == 1)
|
|||
|
TimerSet(timer_cycIntervalMax,TIME_CYCBREAK_MAX); //ˢ<>¶<EFBFBD>ʱ<EFBFBD><CAB1>ʱ<EFBFBD>䣨<EFBFBD><E4A3A8><EFBFBD>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾ͻ<CBBE>ˢ<EFBFBD>£<EFBFBD>
|
|||
|
if(TimerCheck(timer_cycIntervalMax,TIME_CYCBREAK_MAX))
|
|||
|
{
|
|||
|
cycSpeed= 0;
|
|||
|
cycReSpeedFlag = 1;
|
|||
|
TimerSet(timer_cycIntervalMax,TIME_CYCBREAK_MAX); //ˢ<>¶<EFBFBD>ʱ<EFBFBD><CAB1>ʱ<EFBFBD><CAB1>
|
|||
|
}
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ٶȸı<C8B8>
|
|||
|
if(cycReSpeedFlag == 1)
|
|||
|
{
|
|||
|
if( (cycSpeed <= 5) )
|
|||
|
{
|
|||
|
cycColor = 0xff0000; //<2F><>ɫ
|
|||
|
cycDelay = 125;
|
|||
|
}
|
|||
|
else if( (cycSpeed > 5) && (cycSpeed <= 20) )
|
|||
|
{
|
|||
|
cycColor = 0xff0000; //<2F><>ɫ
|
|||
|
cycDelay = 125;
|
|||
|
}
|
|||
|
else if( (cycSpeed > 20) && (cycSpeed <= 30) )
|
|||
|
{
|
|||
|
cycColor = 0xffff00; //<2F><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>
|
|||
|
cycDelay = 65;
|
|||
|
}
|
|||
|
else if( (cycSpeed > 30))
|
|||
|
{
|
|||
|
cycColor = 0x00ff00; //<2F><>ɫ
|
|||
|
cycDelay = 35;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
cycColor = 0x000000;
|
|||
|
cycDelay = 20;
|
|||
|
}
|
|||
|
|
|||
|
cycReSpeedFlag = 0;
|
|||
|
}
|
|||
|
|
|||
|
//--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ10<31><30><EFBFBD><EFBFBD>
|
|||
|
if (TimerCheck(timer_cyc,cycDelay)) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>Ƿ<C7B7>
|
|||
|
{
|
|||
|
LedBuff_CleanAll();//ledBuffȫд<C8AB><D0B4>
|
|||
|
//---ָ<><D6B8>ledBuffд<66><D0B4>color
|
|||
|
LedBuff_WriteOrder( rotate_cycLed ,cycColor);
|
|||
|
LedBuff_WriteOrder((rotate_cycLed+1)%10 ,cycColor);
|
|||
|
LedBuff_WriteOrder((rotate_cycLed+2)%10 ,cycColor);
|
|||
|
WS_Show();
|
|||
|
//--<2D><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
TimerSet(timer_cyc,cycDelay);
|
|||
|
//--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Ҫ<EFBFBD><D2AA>ʾ<EFBFBD>ĵ<EFBFBD>
|
|||
|
rotate_cycLed++;
|
|||
|
if(rotate_cycLed>=LED_NUM)
|
|||
|
rotate_cycLed=0;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|