feat:encoder with existing lib #2
@ -5,7 +5,7 @@
|
||||
#include <ESP8266WiFi.h>
|
||||
|
||||
#include "DiscordAPI.h"
|
||||
#include "Encoder.h"
|
||||
#include "SwitchableEncodeur.h"
|
||||
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ private:
|
||||
/**
|
||||
* Encoder object
|
||||
*/
|
||||
Encoder* encoder;
|
||||
SwitchableEncodeur* encoder;
|
||||
|
||||
/**
|
||||
* Old encoder position
|
||||
|
@ -1,9 +1,12 @@
|
||||
#include "Program.h"
|
||||
|
||||
|
||||
Program::Program() {
|
||||
// Startup
|
||||
|
||||
// Startup Serial
|
||||
Serial.begin(MONITOR_SPEED);
|
||||
|
||||
// Startup WiFi
|
||||
WiFi.begin(WSSID, PASS);
|
||||
|
||||
Serial.print("Connecting to ");
|
||||
@ -12,7 +15,8 @@ Program::Program() {
|
||||
int i = 0;
|
||||
while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
|
||||
delay(1000);
|
||||
Serial.print(++i); Serial.print(' ');
|
||||
Serial.print(++i);
|
||||
Serial.print(' ');
|
||||
}
|
||||
|
||||
Serial.println('\n');
|
||||
@ -20,21 +24,19 @@ Program::Program() {
|
||||
Serial.print("IP address:\t");
|
||||
Serial.println(WiFi.localIP()); // Send the IP address of the ESP8266 to the computer
|
||||
|
||||
|
||||
|
||||
// Startup Discord API
|
||||
this->discord = new DiscordAPI(DISCORD_HOOK);
|
||||
delay(1000);
|
||||
Serial.println(this->discord->sendHeure("10h", "18h"));
|
||||
|
||||
this->encoder = new Encoder(ENCODER_DT, ENCODER_CLK);
|
||||
|
||||
this->oldPosition = -999;
|
||||
// Startup Encoder
|
||||
this->encoder = new SwitchableEncodeur(ENCODER_DT, ENCODER_CLK, ENCODER_SWITCH, 3);
|
||||
}
|
||||
|
||||
void Program::loop() {
|
||||
long newPosition = this->encoder->read()/4;
|
||||
if (newPosition != this->oldPosition) {
|
||||
this->oldPosition = newPosition;
|
||||
Serial.println(newPosition);
|
||||
if(this->encoder->update()){
|
||||
Serial.print(this->encoder->getValue());
|
||||
Serial.print(" ");
|
||||
Serial.println(this->encoder->getMenu());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user