Akinori Hashimoto / myTimer

Dependents:   DetectFreqAboveTH RN41

myTimer.cpp

Committer:
AkinoriHashimoto
Date:
2016-03-29
Revision:
5:c9304777ce1a
Parent:
4:2f7a8e62597a
Child:
6:4cb4eea64805

File content as of revision 5:c9304777ce1a:

#include "myTimer.h"


myTimer::myTimer()
{
    this->stop();
    this->reset();
}

void myTimer::stop()
{
    this->timer.stop();
    return;
}

void myTimer::reset()
{
    this->timer.reset();
    return;
}

void myTimer::start(bool _RESET)
{
    if(_RESET)
        this->reset();
    this->timer.start();
    return;
}

int myTimer::read_ms(bool _START, bool _RESET, bool _STOP)
{
    int ans= 0;
    if(_STOP)
        this->stop();

    ans= this->timer.read_ms();

    if(_RESET)
        this->reset();

    if(_START)
        this->start();

    return ans;
}
int myTimer::read_us(bool _START, bool _RESET, bool _STOP)
{
    int ans= 0;
    if(_STOP)
        this->stop();

    ans= this->timer.read_us();

    if(_RESET)
        this->reset();

    if(_START)
        this->start();

    return ans;
}

void myTimer::wait_ms(int waitTime, bool _START, bool _RESET, bool _STOP)
{
    int wt= waitTime- this->read_ms(_START, _RESET, _STOP);
    if(wt <= 0)
        return;
    ::wait_ms(wt);
    if(_RESET)
        this->reset();
    return;
}