Progress
This commit is contained in:
parent
ebef6ce886
commit
6f7ccc267d
@ -26,7 +26,7 @@ DEPENDENCIES = ['uart']
|
||||
CONF_MARLIN2_ID = "marlin2_id"
|
||||
|
||||
Marlin2 = cg.esphome_ns.class_('Marlin2', cg.Component)
|
||||
Marlin2WriteAction = Marlin2.class_("Marlin2WriteAction", automation.Action)
|
||||
WriteAction = cg.esphome_ns.class_("WriteAction", automation.Action)
|
||||
|
||||
CONFIG_SCHEMA = cv.All(
|
||||
cv.Schema({
|
||||
@ -58,7 +58,7 @@ OPERATION_BASE_SCHEMA = cv.Schema({
|
||||
|
||||
@automation.register_action(
|
||||
"marlin2.write",
|
||||
Marlin2WriteAction,
|
||||
WriteAction,
|
||||
OPERATION_BASE_SCHEMA,
|
||||
)
|
||||
|
||||
|
@ -6,13 +6,13 @@
|
||||
|
||||
namespace esphome {
|
||||
|
||||
template<typename... Ts> class Marlin2WriteAction : public Action<Ts...> {
|
||||
template<typename... Ts> class WriteAction : public Action<Ts...> {
|
||||
public:
|
||||
explicit Marlin2WriteAction(Marlin2 *marlin2) : marlin2_(marlin2) {}
|
||||
explicit WriteAction(Marlin2 *marlin2) : marlin2_(marlin2) {}
|
||||
TEMPLATABLE_VALUE(std::string, value)
|
||||
|
||||
void play(Ts... x) override {
|
||||
this->marlin2_->write("M117 Action Called!");
|
||||
this->marlin2_->write(this->value_.value(x...));
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -52,7 +52,8 @@ namespace esphome {
|
||||
|
||||
void Marlin2::write(std::string gcode) {
|
||||
ESP_LOGD(TAG, "->GCODE: %s", gcode.c_str());
|
||||
write_str(gcode.c_str());
|
||||
|
||||
write_str((std::string("\r\n\r\n") + gcode + std::string("\r\n")).c_str());
|
||||
flush();
|
||||
}
|
||||
|
||||
@ -77,6 +78,8 @@ namespace esphome {
|
||||
}
|
||||
|
||||
void Marlin2::process_line() {
|
||||
ESP_LOGD(TAG, "#%s#",MarlinOutput.c_str());
|
||||
|
||||
if(MarlinOutput.size() < 3) {
|
||||
MarlinOutput="";
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user