Commit | Line | Data |
---|---|---|
df27a6a3 | 1 | /* |
4cff3ded AW |
2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). |
3 | 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. | |
4 | 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. | |
df27a6a3 | 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. |
4cff3ded AW |
6 | */ |
7 | ||
8 | #ifndef KERNEL_H | |
9 | #define KERNEL_H | |
4cff3ded | 10 | |
879341be JM |
11 | #define THEKERNEL Kernel::instance |
12 | ||
61134a65 JM |
13 | #include "Module.h" |
14 | #include <array> | |
15 | #include <vector> | |
e0d0ea84 | 16 | #include <string> |
61134a65 | 17 | |
4cff3ded | 18 | //Module manager |
a0e79e9b | 19 | class Config; |
4cff3ded | 20 | class Module; |
3fceb8eb | 21 | class Conveyor; |
d9ebc974 | 22 | class SlowTicker; |
61134a65 JM |
23 | class SerialConsole; |
24 | class StreamOutputPool; | |
25 | class GcodeDispatch; | |
26 | class Robot; | |
27 | class Stepper; | |
28 | class Planner; | |
61134a65 JM |
29 | class StepTicker; |
30 | class Adc; | |
31 | class PublicData; | |
43b1a6e8 | 32 | |
4cff3ded AW |
33 | class Kernel { |
34 | public: | |
35 | Kernel(); | |
879341be | 36 | static Kernel* instance; // the Singleton instance of Kernel usable anywhere |
33e4cc02 | 37 | const char* config_override_filename(){ return "/sd/config-override"; } |
35089dc7 | 38 | |
4cff3ded | 39 | void add_module(Module* module); |
96f67b65 | 40 | void register_for_event(_EVENT_ENUM id_event, Module *module); |
93ea6adb JM |
41 | void call_event(_EVENT_ENUM id_event, void * argument= nullptr); |
42 | ||
43 | bool kernel_has_event(_EVENT_ENUM id_event, Module *mod); | |
44 | void unregister_for_event(_EVENT_ENUM id_event, Module *module); | |
4cff3ded | 45 | |
73706276 JM |
46 | bool is_using_leds() const { return use_leds; } |
47 | bool is_halted() const { return halted; } | |
48 | ||
76217df5 | 49 | // These modules are available to all other modules |
4cff3ded | 50 | SerialConsole* serial; |
df27a6a3 | 51 | StreamOutputPool* streams; |
38d375e7 | 52 | |
4cff3ded AW |
53 | Robot* robot; |
54 | Stepper* stepper; | |
55 | Planner* planner; | |
56 | Config* config; | |
663d7943 | 57 | Conveyor* conveyor; |
4cff3ded | 58 | |
13e4a3f9 | 59 | int debug; |
3c132bd0 AW |
60 | SlowTicker* slow_ticker; |
61 | StepTicker* step_ticker; | |
62 | Adc* adc; | |
e0d0ea84 | 63 | std::string current_path; |
a157d099 JM |
64 | uint32_t base_stepping_frequency; |
65 | uint32_t acceleration_ticks_per_second; | |
f29b0272 | 66 | |
4cff3ded | 67 | private: |
e0d0ea84 | 68 | // When a module asks to be called for a specific event ( a hook ), this is where that request is remembered |
96f67b65 | 69 | std::array<std::vector<Module*>, NUMBER_OF_DEFINED_EVENTS> hooks; |
73706276 JM |
70 | struct { |
71 | bool use_leds:1; | |
72 | bool halted:1; | |
73 | }; | |
4cff3ded AW |
74 | |
75 | }; | |
76 | ||
77 | #endif |