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. Basically we want several modules to be able to pause smoothie at the same time
12 // ( think both the user with a button, and the temperature control because a temperature is not reached ). To do that, modules call the take() methode,
13 // a pause event is called, and the pause does not end before all modules have called the release() method.
14 // Please note : Modules should keep track of their pause status themselves
19 void Pauser::on_module_loaded(){
21 register_for_event(ON_BLOCK_BEGIN
);
24 void Pauser::on_block_begin(void* argument
)
26 Block
* block
= static_cast<Block
*>(argument
);
35 // Pause smoothie if nobody else is currently doing so
38 //THEKERNEL->streams->printf("take: %u \r\n", this->counter );
39 if( this->counter
== 1 ){
40 THEKERNEL
->call_event(ON_PAUSE
, &this->counter
);
44 // Unpause smoothie unless something else is pausing it too
45 void Pauser::release(){
47 //THEKERNEL->streams->printf("release: %u \r\n", this->counter );
48 if( this->counter
== 0 ){
49 THEKERNEL
->call_event(ON_PLAY
, &this->counter
);
52 Block
* tmp
= paused_block
;
59 // Return wether smoothie is paused
60 bool Pauser::paused(){
61 return (counter
!= 0);