/* Reflow Oven Controller * * Copyright (C) 2020 Mario Hüttel * * This file is part of the Reflow Oven Controller Project. * * The reflow oven controller is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * The Reflow Oven Control Firmware is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with the reflow oven controller project. * If not, see . */ #ifndef __BUTTON_H__ #define __BUTTON_H__ /** * @brief GPIO Port the button is connected to */ #define BUTTON_PORT GPIOD /** * @brief The RCC clock mask for @ref BUTTON_PORT */ #define BUTTON_RCC_MASK RCC_AHB1ENR_GPIODEN /** * @brief The GPIO pin number the button is connected to */ #define BUTTON_PIN 4 /** * @brief The time in ms the button has to stay pressed to be detected as a short press */ #define BUTTON_SHORT_ON_TIME_MS 50UL /** * @brief Time in ms the button has to be pressed to be counted as a long press */ #define BUTTON_LONG_ON_TIME_MS 400UL #if BUTTON_LONG_ON_TIME_MS <= BUTTON_SHORT_ON_TIME_MS #error "Button BUTTON_SHORT_ON_TIME_MS time has to be shorter than BUTTON_LONG_ON_TIME_MS" #endif /** * @brief States the puhsbutton of the rotary encoder can be in */ enum button_state {BUTTON_IDLE = 0, BUTTON_SHORT_RELEASED, BUTTON_LONG_RELEASED, BUTTON_SHORT, BUTTON_LONG}; /** * @brief Init the push button */ void button_init(); /** * @brief read if a push button event occured * @return Button event */ enum button_state button_read_event(); /** * @brief button_deinit */ void button_deinit(); /** * @brief This function overrides the button event. * @param state State to set */ void button_override_event(enum button_state state); #endif /* __BUTTON_H__ */