35 lines
530 B
C++
35 lines
530 B
C++
/*
|
|
* Button.hpp
|
|
*
|
|
* Created on: Jun 8, 2024
|
|
* Author: Carst
|
|
*/
|
|
|
|
#ifndef BUTTON_HPP_
|
|
#define BUTTON_HPP_
|
|
|
|
#include "stm32g0xx_ll_gpio.h"
|
|
|
|
namespace ElektronischeLast
|
|
{
|
|
class Button
|
|
{
|
|
private:
|
|
GPIO_TypeDef* port;
|
|
uint16_t pin;
|
|
bool state;
|
|
bool stateLast;
|
|
const uint32_t debounce = 25UL;
|
|
uint32_t debounceTimer;
|
|
public:
|
|
void init(GPIO_TypeDef* port, uint16_t pin);
|
|
bool cyclic(void);
|
|
bool isPressed(void);
|
|
bool isReleased(void);
|
|
};
|
|
}
|
|
|
|
|
|
|
|
#endif /* BUTTON_HPP_ */
|