diff --git a/include/items/vButtonOut.h b/include/items/vButtonOut.h index 3568b516..1f6f2614 100644 --- a/include/items/vButtonOut.h +++ b/include/items/vButtonOut.h @@ -10,7 +10,7 @@ typedef std::vector MyButtonOutVector; class ButtonOut { public: - ButtonOut(unsigned int pin, boolean inv, String key); + ButtonOut(String pin, boolean inv, String key); ~ButtonOut(); @@ -18,7 +18,7 @@ class ButtonOut { private: - unsigned int _pin; + String _pin; boolean _inv; String _key; diff --git a/src/items/vButtonOut.cpp b/src/items/vButtonOut.cpp index 15790687..40263eba 100644 --- a/src/items/vButtonOut.cpp +++ b/src/items/vButtonOut.cpp @@ -5,27 +5,31 @@ #include //this class save data to flash -ButtonOut::ButtonOut(unsigned int pin, boolean inv, String key) { +ButtonOut::ButtonOut(String pin, boolean inv, String key) { _pin = pin; _inv = inv; _key = key; - pinMode(_pin, OUTPUT); + if (_pin != "") { + pinMode(_pin.toInt(), OUTPUT); + } int state = jsonReadInt(configStoreJson, key); this->execute(String(state)); } ButtonOut::~ButtonOut() {} void ButtonOut::execute(String state) { - if (state == "change") { - state = String(!digitalRead(_pin)); - digitalWrite(_pin, state.toInt()); - } - else { - if (_inv) { - digitalWrite(_pin, !state.toInt()); + if (state != "" && _pin != "") { + if (state == "change") { + state = String(!digitalRead(_pin.toInt())); + digitalWrite(_pin.toInt(), state.toInt()); } else { - digitalWrite(_pin, state.toInt()); + if (_inv) { + digitalWrite(_pin.toInt(), !state.toInt()); + } + else { + digitalWrite(_pin.toInt(), state.toInt()); + } } } eventGen2(_key, state); @@ -53,7 +57,7 @@ void buttonOut() { static bool firstTime = true; if (firstTime) myButtonOut = new MyButtonOutVector(); firstTime = false; - myButtonOut->push_back(ButtonOut(pin.toInt(), invb, key)); + myButtonOut->push_back(ButtonOut(pin, invb, key)); sCmd.addCommand(key.c_str(), buttonOutExecute); } diff --git a/src/items/vInOutput.cpp b/src/items/vInOutput.cpp index d15c0b23..d5966731 100644 --- a/src/items/vInOutput.cpp +++ b/src/items/vInOutput.cpp @@ -53,10 +53,13 @@ void inOutputExecute() { String key = sCmd.order(); String value = sCmd.next(); - if (!isDigitStr(value)) { //если значение - текст if (value.indexOf(":") == -1) { //если этот текст не время - value = getValue(value); + String tmp = getValue(value); + if(tmp != "no value") { + value = tmp; + value.replace("#"," "); + } } }