Thursday, December 23, 2010

Re: Copy folded text title without content


What is your eventual goal? 

My goal is that one.

In state of copying the whole text like that :

#include <UltrasonCmd.h>
#include <Wire.h>
#include <Utils.h>

//=============================================================================
/* {{{1 ULTRASONIC CONSTRUCTOR */
UltrasonCmd::UltrasonCmd()
{
//sensor
_b_startSampling=false;
reinitSamplingParam();
m_lastAverageTime=millis();
// level
_nbSameDetectedLevel=0;
_levelDetected=0;
_lastlevelDetected=0;

// level kept
_savedLevel=0;
_savedLevelMemo=0;
//
_firstLevelDetection=true;
b_currentlyProcessingDetection=false;

// exiting menu
_startTimeExitMenu=0;

// Menu entering/leaving detection parameters are :
initEnterLeaveMenuDetection();

// set current detection to do
// currentDetection=NULL;
currentDetection=&enterLeaveMenuDetection;
_crMenu=false;

// RELAYS
_crOnAllRelays=false;
_b_OnAllRelays=false; 
_distToOnAll=50;
m_currentDistMemo=999;
b_saveCurrentDistMemo=false;


/* ULTRASONIC MENU MEMBERS {{{2 */
// menu geo localization
_b_InMenu=false;
/* }}}2 */

}
UltrasonCmd::~UltrasonCmd()
{
}
/* }}}1 */
//=============================================================================
/* {{{1 ULTRASONIC SETTER */
void UltrasonCmd::setSonicSensor(SRF02 *sonicsensorPtr)
{
_sonicSensor = sonicsensorPtr;
}
void UltrasonCmd::setTracer(Traces *TracerPtr) {

if (  TracerPtr != NULL )
{
_Tracer = TracerPtr;
_Tracer->Print("Tracer is available on UltraCmd instance");
}
}
/* }}}1 */
//=============================================================================
/* {{{1 ULTRASONIC GETTER */
int UltrasonCmd::getSavedLevel()
{
return _savedLevel;
}
/* }}}1 */
//=============================================================================
/* {{{1 ULTRASONIC SENSOR CHECK */
void UltrasonCmd::sensorCheck()
{
// ultrasonic sensor check
SRF02::update();

// sampling only if thing is under 100cm
if ( checkToStartSampling() )
{
// startSampling();
sampling();
}

// check if has to leave/exiting menu
// checkToLeaveMenu();


}
bool UltrasonCmd::checkToStartSampling()
{
if ( (_sonicSensor->read()<300)                   // distance is lesser than 300cm
&& (millis() > 10000))                       // it is 10 seconds that programm has started
//&& ((millis() - m_lastAverageTime)> 250)  // 250 msecond elapsed since last average
  // )
{
return true;
}
return false;
}
// void UltrasonCmd::startSampling()
// {
// if(!_b_startSampling)
// {
// _b_startSampling=true;
// _delayBeforeSampling=millis();
// }
// }
void UltrasonCmd::reinitSamplingParam()
{
_b_startSampling=false;
_averageDist=0;
_idxDistSamples=0;
}
void UltrasonCmd::sampling()
{
// if ( ( _b_startSampling==true ) && ((millis()-_delayBeforeSampling)>500) )
// if ( (millis()-_delayBeforeSampling)>500) 
{
if ( _idxDistSamples<currentDetection->nbSamplesToCheck )
{
_averageDist=_averageDist+_sonicSensor->read();
_idxDistSamples++;
}
else
{
_averageDist=_averageDist/currentDetection->nbSamplesToCheck;
if ( _averageDist > 0 )
{
// memorize current Distance 
if ( b_saveCurrentDistMemo )
{
set_m_currentDistMemo(_averageDist);
}
// set current Distance
set_m_currentDist(_averageDist);
b_saveCurrentDistMemo=!b_saveCurrentDistMemo;
}
m_lastAverageTime=millis();
}
}
}
int UltrasonCmd::get_m_currentDist()
{
return m_currentDist;
}
void UltrasonCmd::set_m_currentDist(int pm_value)
{
m_currentDist=pm_value;

reinitSamplingParam();

// checkToOnOffRelays();

}
int UltrasonCmd::get_m_currentDistMemo()
{
return m_currentDistMemo;
}
void UltrasonCmd::set_m_currentDistMemo(int pm_value)
{
m_currentDistMemo=pm_value;
}
/* }}}1 */
//=============================================================================
/* {{{1 ULTRASONIC SENSOR LEVEL ANALYSIS*/
void UltrasonCmd::levelDetection()
{
if(b_currentlyProcessingDetection==false)
{
b_currentlyProcessingDetection=true;

if ( (0<m_currentDist) && (m_currentDist<20) )
{
_levelDetected=1;
}
else if ( (20<=m_currentDist) && (m_currentDist<40) )
{
_levelDetected=2;
}
else if ( (40<=m_currentDist) && (m_currentDist<60) )
{
_levelDetected=3;
}
else if ( (60<=m_currentDist) && (m_currentDist<80) )
{
_levelDetected=4;
}
else if ( (80<=m_currentDist) && (m_currentDist<120) )
{
_levelDetected=5;
}
else
{
_levelDetected=0;
}

if ( _levelDetected > 0 )
{
if ( _firstLevelDetection )
{
_firstLevelDetection=false;
_savedLevelMemo=_levelDetected;
}
else
{
// check tree times same level to set remembered level
if ( _levelDetected == _savedLevelMemo  )
{
if ( _nbSameDetectedLevel < currentDetection->nbSameDetections )
{
_nbSameDetectedLevel++;
}
else if ( _nbSameDetectedLevel == currentDetection->nbSameDetections )
{
setDetectedLevel();
}
}
else
{
_nbSameDetectedLevel=0;
_savedLevelMemo=_levelDetected;
}
// set remembered level
if( _nbSameDetectedLevel == currentDetection->nbSameDetections )
{
setDetectedLevel();
}
}
}
b_currentlyProcessingDetection=false;
}
}
void UltrasonCmd::setDetectedLevel()
{
_savedLevel=_levelDetected;
_savedLevelMemo=_levelDetected;
_nbSameDetectedLevel=0;
_startTimeExitMenu=millis();
}
/* }}}1 */
//=============================================================================
/* ULTRASONIC ENTERING/LEAVING MENU METHODS MEMBERS {{{1 */
void UltrasonCmd::checkToEnterMenu()
{
// check level
if ( _savedLevel==currentDetection->levelNumber )
{
_b_InMenu=true; 
}
else
{
_b_InMenu=false; 
}
}
void UltrasonCmd::checkToLeaveMenu()
{
if ( _b_InMenu )
{
if ((millis()-_startTimeExitMenu)>20000)
{
_b_InMenu=false;

_nbSameDetectedLevel=0;
_savedLevel=0;
_savedLevelMemo=0;
_levelDetected=0;

_startTimeExitMenu=0;

setCrEnteringMenu(false);
}
}
}
void UltrasonCmd::initEnterLeaveMenuDetection()
{
enterLeaveMenuDetection.nbSamplesToCheck=100;
enterLeaveMenuDetection.nbSameDetections=4;
enterLeaveMenuDetection.levelNumber=1;
}
void UltrasonCmd::setCrEnteringMenu(bool param)
{
_crMenu=param;
}
bool UltrasonCmd::getCrEnteringMenu()
{
return _crMenu;
}
bool UltrasonCmd::isInMenu()
{
return _b_InMenu;
}
/* }}}1 */
//=============================================================================
/* ULTRASONIC ON ALL RELAYS/OFF MENU METHODS MEMBERS {{{1 */
void UltrasonCmd::setDistToOnRelays(int param)
{
_distToOnAll=param;
}
int UltrasonCmd::getDistToOnRelays()
{
return _distToOnAll;
}
bool UltrasonCmd::checkToOnOffRelays()
{
if (_crOnAllRelays==false)
{
if (m_currentDist<_distToOnAll)
{
return true; 
}
else
{
return false; 
}
}
}
void UltrasonCmd::initOnAllRelaysDetection()
{
onAllRelaysDetection.nbSamplesToCheck=100;
onAllRelaysDetection.nbSameDetections=2;
onAllRelaysDetection.levelNumber=5;
}
void UltrasonCmd::setCrOnRelays(bool param)
{
_crOnAllRelays=param;
_b_OnAllRelays=false; 
}
bool UltrasonCmd::getCrOnRelays()
{
return _crOnAllRelays;
}
/* }}}1 */
UltrasonCmd UltraCmd = UltrasonCmd();



I would like to copy and paste only that :
#include <UltrasonCmd.h>
#include <Wire.h>
#include <Utils.h>

//=============================================================================
/* {{{1 ULTRASONIC CONSTRUCTOR */ /* }}}1 */
//=============================================================================
/* {{{1 ULTRASONIC SETTER */ /* }}}1 */
//=============================================================================
/* {{{1 ULTRASONIC GETTER */ /* }}}1 */
//=============================================================================
/* {{{1 ULTRASONIC SENSOR CHECK */ /* }}}1 */
//=============================================================================
/* {{{1 ULTRASONIC SENSOR LEVEL ANALYSIS*/ /* }}}1 */
//=============================================================================
/* ULTRASONIC ENTERING/LEAVING MENU METHODS MEMBERS {{{1 */ /* }}}1 */
//=============================================================================
/* ULTRASONIC ON ALL RELAYS/OFF MENU METHODS MEMBERS {{{1 */ /* }}}1 */
UltrasonCmd UltraCmd = UltrasonCmd();



In order to sum up my code you see ? 

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: