Hi,
I would like to detect some object on different levels during different elapsed times.
What's the best way to do that ?
Thank you
Hi,
I would like to detect some object on different levels during different elapsed times.
What's the best way to do that ?
Thank you
I would like to detect some object on different levels
Is there some context for this? What different levels are you talking about?
during different elapsed times.
Using millis() and a start time? Or is there some other meaning to "different elapsed times"?
levels are
0 to 20 cm : level1
20 to 40 cm : level2
40 to 60 cm : level3
60 to infinite : level4
This is my code for instant:
void FunctionalTasks::set_m_currentDist()
{
//
SRF02::update();
m_currentDist = _UltraSonicPtr->read();
String str = String(m_currentDist);
str.concat("cm");
_Tracer->LcdPrintTopLineFromRightFast(str);
// check
if ( m_currentDist < 200 )
{
startSensorChrono();
}
}
void FunctionalTasks::set_m_startTime_ultrasonic ( unsigned long pm_startTime_ultrasonic )
{
m_startTime_ultrasonic=pm_startTime_ultrasonic;
}
unsigned long FunctionalTasks::get_m_startTime_ultrasonic ()
{
return m_startTime_ultrasonic;
}
void FunctionalTasks::startSensorChrono()
{
//
if( m_startTime_ultrasonic==0)
{
_idxTab=0;
set_m_startTime_ultrasonic(millis());
}
else
{
checkSensorChrono();
feedDistanceSamples();
}
}
void FunctionalTasks::checkSensorChrono()
{
//
if( m_startTime_ultrasonic==0)
{
set_m_startTime_ultrasonic(millis());
}
}
void FunctionalTasks::feedDistanceSamples()
{
if ( _idxTab <_MAX_DIST_SAMPLES )
{
_tab[_idxTab]=get_m_currentDist();
_idxTab++;
}
else
{
_idxTab=0;
}
}