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