This commit is contained in:
starcalc 2018-04-26 23:45:30 +02:00
parent 796d3db498
commit 71dfc33a9c
1 changed files with 21 additions and 5 deletions

View File

@ -1,22 +1,38 @@
/** #include <Homie.h>
* Print each digit over Serial as it is dialed. #include <ArduinoOTA.h>
* See the README for detailed documentation.
*/
#include "RotaryDialer.h" #include "RotaryDialer.h"
#define PIN_READY D6 #define PIN_READY D6
#define PIN_PULSE D5 #define PIN_PULSE D5
#define FW_NAME "esp-waehlscheibe"
#define FW_VERSION "1.0.0"
HomieNode dialNode("dial", "number");
RotaryDialer dialer = RotaryDialer(PIN_READY, PIN_PULSE); RotaryDialer dialer = RotaryDialer(PIN_READY, PIN_PULSE);
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
dialer.setup(); dialer.setup();
Homie_setFirmware(FW_NAME, FW_VERSION);
Homie_setBrand(FW_NAME);
dialNode.advertise("number");
Homie.setLoopFunction(loopHandler);
Homie.setup();
ArduinoOTA.setHostname(Homie.getConfiguration().deviceId);
ArduinoOTA.begin();
}
void loopHandler()
{
} }
void loop() { void loop() {
Homie.loop();
ArduinoOTA.handle();
if (dialer.update()) { if (dialer.update()) {
Serial.println(dialer.getNextNumber()); int ivalue = dialer.getNextNumber();
// Serial.println(dialer.getNextNumber());
dialNode.setProperty("number").send(String(ivalue));
} }
} }