Rotary-Dial/examples/dialtoserial/dialtoserial.ino

39 lines
822 B
C++

#include <Homie.h>
#include <ArduinoOTA.h>
#include "RotaryDialer.h"
#define PIN_READY D6
#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);
void setup() {
Serial.begin(115200);
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() {
Homie.loop();
ArduinoOTA.handle();
if (dialer.update()) {
int ivalue = dialer.getNextNumber();
// Serial.println(dialer.getNextNumber());
dialNode.setProperty("number").send(String(ivalue));
}
}