Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SlowTicker.h
00001 /* 00002 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 00003 Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 00004 Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 00005 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. 00006 */ 00007 00008 00009 00010 #ifndef SLOWTICKER_H 00011 #define SLOWTICKER_H 00012 00013 using namespace std; 00014 #include <vector> 00015 #include "libs/nuts_bolts.h" 00016 #include "libs/Module.h" 00017 #include "libs/Kernel.h" 00018 #include "libs/Hook.h" 00019 00020 class SlowTicker : public Module{ 00021 public: 00022 SlowTicker(); 00023 void set_frequency( int frequency ); 00024 void tick(); 00025 // For some reason this can't go in the .cpp, see : http://mbed.org/forum/mbed/topic/2774/?page=1#comment-14221 00026 template<typename T> void attach( double frequency, T *optr, uint32_t ( T::*fptr )( uint32_t ) ){ 00027 Hook* hook = new Hook(); 00028 hook->frequency = frequency; 00029 hook->attach(optr, fptr); 00030 hook->counter = -2; 00031 if( frequency > this->max_frequency ){ 00032 this->max_frequency = frequency; 00033 } 00034 this->set_frequency(this->max_frequency); 00035 this->hooks.push_back(hook); 00036 } 00037 00038 vector<Hook*> hooks; 00039 double max_frequency; 00040 }; 00041 00042 00043 00044 00045 00046 #endif
Generated on Tue Jul 12 2022 14:14:42 by
1.7.2