Michael Spencer / Smoothie

Dependencies:   mbed

Fork of Smoothie by Stéphane Cachat

libs/Pauser.cpp

Committer:
scachat
Date:
2012-07-31
Revision:
0:31e91bb0ef3c
Child:
2:1df0b61d3b5a

File content as of revision 0:31e91bb0ef3c:

#include "libs/Kernel.h"
#include "Pauser.h"
#include "libs/nuts_bolts.h"
#include "libs/utils.h"
#include <string>
using namespace std;

Pauser::Pauser(){}

void Pauser::on_module_loaded(){
    this->counter = 0;
}

void Pauser::take(){
    this->counter++;
    if( this->counter == 1 ){
        this->kernel->call_event(ON_PAUSE, &this->counter);
    }
}

void Pauser::release(){
    this->counter--;
    if( this->counter == 0 ){
        this->kernel->call_event(ON_PLAY, &this->counter);
    }
}