Use much smaller simpler button debounce.
This commit is contained in:
parent
e6e133cff2
commit
5af0919960
@ -8,11 +8,11 @@
|
|||||||
#include <MQTT.h>
|
#include <MQTT.h>
|
||||||
#include <LiquidCrystal_I2C.h>
|
#include <LiquidCrystal_I2C.h>
|
||||||
#include <LiquidMenu.h> // LiquidMenu_config.h needs to be modified to use I2C.
|
#include <LiquidMenu.h> // LiquidMenu_config.h needs to be modified to use I2C.
|
||||||
#include <Button.h>
|
|
||||||
#include <MD_REncoder.h>
|
#include <MD_REncoder.h>
|
||||||
#include <Adafruit_MAX31865.h>
|
#include <Adafruit_MAX31865.h>
|
||||||
|
|
||||||
// My Includes
|
// My Includes
|
||||||
|
#include "button.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ kettle_mode KettleMode = OFF;
|
|||||||
encoder_state EncoderState = ENC_ST_LINE;
|
encoder_state EncoderState = ENC_ST_LINE;
|
||||||
|
|
||||||
/* ---------- User I/O objects ---------- */
|
/* ---------- User I/O objects ---------- */
|
||||||
Button EncoderButton(encoderBTN);
|
Button EncoderButton;
|
||||||
MD_REncoder RotaryEncoder(encoderDT, encoderCLK);
|
MD_REncoder RotaryEncoder(encoderDT, encoderCLK);
|
||||||
LiquidCrystal_I2C lcd(0x27,20,4);
|
LiquidCrystal_I2C lcd(0x27,20,4);
|
||||||
Adafruit_MAX31865 kettleRTD(kettleRTDCS);
|
Adafruit_MAX31865 kettleRTD(kettleRTDCS);
|
||||||
@ -53,8 +53,8 @@ void setup() {
|
|||||||
|
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
RotaryEncoder.begin();
|
RotaryEncoder.begin();
|
||||||
EncoderButton.begin();
|
|
||||||
Ethernet.begin(mac, ip);
|
Ethernet.begin(mac, ip);
|
||||||
|
EncoderButton.begin(encoderBTN);
|
||||||
kettleRTD.begin(MAX31865_3WIRE);
|
kettleRTD.begin(MAX31865_3WIRE);
|
||||||
mashRTD.begin(MAX31865_3WIRE);
|
mashRTD.begin(MAX31865_3WIRE);
|
||||||
Serial.println("Setting up...");
|
Serial.println("Setting up...");
|
||||||
|
22
boil_kettle/button.h
Normal file
22
boil_kettle/button.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#ifndef button_h
|
||||||
|
#define button_h
|
||||||
|
|
||||||
|
#include "Arduino.h"
|
||||||
|
|
||||||
|
class Button
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
uint8_t btn;
|
||||||
|
uint16_t state;
|
||||||
|
public:
|
||||||
|
void begin(uint8_t button) {
|
||||||
|
btn = button;
|
||||||
|
state = 0;
|
||||||
|
pinMode(btn, INPUT_PULLUP);
|
||||||
|
}
|
||||||
|
bool pressed() {
|
||||||
|
state = (state<<1) | digitalRead(btn) | 0xfe00;
|
||||||
|
return (state == 0xff00);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user