https://github.com/gitmasternikanjam/limitswitch_stm32
LimitSwitch/MicroSwitch library for STM32.
https://github.com/gitmasternikanjam/limitswitch_stm32
Last synced: 3 months ago
JSON representation
LimitSwitch/MicroSwitch library for STM32.
- Host: GitHub
- URL: https://github.com/gitmasternikanjam/limitswitch_stm32
- Owner: GitMasterNikanjam
- Created: 2024-12-25T09:58:41.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2025-01-16T07:52:28.000Z (4 months ago)
- Last Synced: 2025-01-16T08:59:40.208Z (4 months ago)
- Language: C++
- Homepage:
- Size: 51.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LimitSwitch Library for STM32
- This library can be used for limitswitch/microswitch touch sensor management.
> Read library header file and select your MCU.---------------------------------------------------------------------------------------
# Public Member Variables for LimitSwitch Class
```cpp
/// @brief Last error occurred for the object.
std::string errorMessage;
```# Public Member Functions for LimitSwitch Class
```cpp
/**
* @brief Constructor. Set LimitSwitch port, pin and its input mode. Not apply setting on hardware.
* @note - init() method needs after this for apply setting on hardware.
* @param port: GPIO port. It can be GPIOA, GPIOB, ...
* @param pin: GPIO pin number. It can be GPIO_PIN_0, GPIO_PIN_1, ...
* @param activeMode: Sensor active mode. 0: Active low (Default), 1: Active high.
* @param pudMode: Sensor pullup/pulldown mode. PUD_OFF:0 (Default), PUD_UP:1, PUD_DOWN:2
* @param interruptMode: is the external interrupt mode enable/disable. The true value means it is enabled.
*/
LimitSwitch(GPIO_TypeDef *port, uint16_t pin, uint8_t activeMode = 0, uint8_t pudMode = 0, bool interruptMode = false);/**
* @brief Apply setting on hardware. Start LimitSwitch action.
* @return true if successed.
*/
bool init(void);/**
* @brief Clean setting on hardware. Stop LimitSwitch action.
*/
void clean(void);/**
* @brief Read and return LimitSwitch sensor.
* @note - Update sensor state value.
* @return true if the sensor is touched or pressed.
* @return false if the sensor is not touched or pressed.
*/
bool read(void);/**
* @brief Return last state of sensor limitswitch that updated.
* @return true if the sensor is touched or pressed.
* @return false if the sensor is not touched or pressed.
* @note - This function useful when object is in interrupt mode.
*/
bool get(void) {return _state;};/**
* @brief External interrupt callback function.
* @note - This funcition must implement in the **HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)** function.
* @note - If object set in interrupt mode, then use this function, otherwise dont use.
*/
void EXTI_Callback(void);
```