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