From f7bdd404bd3f1777309a4cfb7d023cb218fa0285 Mon Sep 17 00:00:00 2001 From: Mitch Bradley Date: Mon, 28 Jun 2021 09:26:43 -1000 Subject: [PATCH] Added Macros.h --- Grbl_Esp32/src/Machine/Macros.h | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Grbl_Esp32/src/Machine/Macros.h diff --git a/Grbl_Esp32/src/Machine/Macros.h b/Grbl_Esp32/src/Machine/Macros.h new file mode 100644 index 00000000..5db60aae --- /dev/null +++ b/Grbl_Esp32/src/Machine/Macros.h @@ -0,0 +1,54 @@ +#pragma once + +/* + Part of Grbl_ESP32 + 2021 - Stefan de Bruijn, Mitch Bradley + + Grbl_ESP32 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. + + Grbl_ESP32 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. + + You should have received a copy of the GNU General Public License + along with Grbl_ESP32. If not, see . +*/ + +#include "../Configuration/Configurable.h" + +namespace Machine { + class Macros : public Configuration::Configurable { + public: + static const int n_startup_lines = 2; + static const int n_macros = 4; + + private: + String _startup_line[n_startup_lines]; + String _macro[n_macros]; + + public: + Macros() = default; + + String macro(size_t index) { return index < n_macros ? _macro[index] : ""; } + String startup_line(size_t index) { return index < n_startup_lines ? _startup_line[index] : ""; } + + // Configuration helpers: + + // TODO: We could validate the startup lines + + void group(Configuration::HandlerBase& handler) override { + handler.item("n0", _startup_line[0]); + handler.item("n1", _startup_line[1]); + handler.item("macro0", _macro[0]); + handler.item("macro1", _macro[1]); + handler.item("macro2", _macro[2]); + handler.item("macro3", _macro[3]); + } + + ~Macros() {} + }; +}