1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-09-02 19:02:35 +02:00

Added Macros.h

This commit is contained in:
Mitch Bradley
2021-06-28 09:26:43 -10:00
parent 32c879264a
commit f7bdd404bd

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#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() {}
};
}