3 #include "libs/Kernel.h"
5 #include "libs/nuts_bolts.h"
6 #include "libs/utils.h"
11 // The Pauser module is the core of the pausing subsystem in smoothie.
12 // Basically we want several modules to be able to pause smoothie at the same
13 // time ( think both the user with a button, and the temperature control
14 // because a temperature is not reached ). To do that, modules call the take()
15 // methode, a pause event is called, and the pause does not end before all
16 // modules have called the release() method.
17 // Please note : Modules should keep track of their pause status themselves...
18 // or Not for instance it may be better for the play/pause button to be able
19 // to unpause when something else causes a pause
24 void Pauser::on_module_loaded(){
26 register_for_event(ON_BLOCK_BEGIN
);
29 void Pauser::on_block_begin(void* argument
)
31 Block
* block
= static_cast<Block
*>(argument
);
40 // Pause smoothie if nobody else is currently doing so
43 //THEKERNEL->streams->printf("take: %u \r\n", this->counter );
44 if( this->counter
== 1 ){
45 THEKERNEL
->call_event(ON_PAUSE
, &this->counter
);
49 // Unpause smoothie unless something else is pausing it too
50 void Pauser::release(){
51 if( --this->counter
<= 0 ){
53 THEKERNEL
->call_event(ON_PLAY
, &this->counter
);
56 Block
* tmp
= paused_block
;
63 // Return wether smoothie is paused
64 bool Pauser::paused(){
65 return (counter
!= 0);