4
0
Fork 0
mirror of https://github.com/zzzzDev4/IAS-Better-Tea.git synced 2025-04-21 07:31:20 +02:00
firmware/src/SmartButton.cpp
2024-06-26 15:23:32 +02:00

32 lines
No EOL
489 B
C++

#include "SmartButton.hpp"
#include <Arduino.h>
SmartButton::SmartButton(int pin)
{
m_pin = pin;
}
void SmartButton::init()
{
pinMode(m_pin, INPUT);
}
bool SmartButton::isJustPressed()
{
if (digitalRead(m_pin) == HIGH)
{
m_isDown = false;
return false;
}
if (digitalRead(m_pin) == LOW && !m_isDown)
{
m_isDown = true;
return true;
}
return false;
}
bool SmartButton::isDown()
{
return digitalRead(m_pin) == LOW;
}