-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User button multi Function #78
Conversation
/** | ||
* @brief Construct a new OneButton object but not (yet) initialize the IO pin. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to the header file.
/** | ||
* @brief Construct a new Button:: Button object | ||
* | ||
* @param gpio | ||
* @param activeLow | ||
* @param pullupActive | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to the header file.
{ | ||
} //Button | ||
|
||
// save function for click event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment repeats what is on the doc comment.
/** | ||
* @brief save function for click event | ||
* | ||
* @param newFunction callback function | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to header file.
Button::Button() | ||
{ | ||
_gpio_btn = static_cast<gpio_num_t>(-1); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this constructor exists? It creates an invalid _gpio_btn. Does it has an use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you right , I need to remove it
{ | ||
public: | ||
Button(); | ||
Button(gpio_num_t gpio, int active, bool pullupActive = true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
snakeCase
to snake_case
.
BTN_END_PROCESS, | ||
} state; | ||
|
||
class Button //: Task |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Class documentation
- Unused code? I mean
: Task
void tick(bool level, unsigned long time_now); | ||
|
||
bool isLongPressed(); | ||
int getPressedTicks(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it return TickType_t
(type safety)?
bool _updated_level; // hardware gpio number. | ||
unsigned int _debounceTicks = 200; // number of ticks for debounce times. | ||
unsigned long _clickTicks = 250; // number of ticks that have to pass by | ||
// before a click is detected. | ||
unsigned long _long_press_ticks = 1500; // number of ticks that have to pass by | ||
// before a long button press is detected | ||
|
||
int _buttonPressed; | ||
bool _isLongPressed = false; | ||
long int _timeout = 500; | ||
|
||
// These variables that hold information across the upcoming tick calls. | ||
// They are initialized once on program start and are updated every time the | ||
// tick function is called. | ||
int _state = 0; | ||
unsigned long _startTime; // will be set in state 1 | ||
unsigned long _stopTime; // will be set in state 2 | ||
|
||
// These variables will hold functions acting as event source. | ||
callbackFunction _clickFunc = NULL; | ||
parameterizedCallbackFunction _paramClickFunc = NULL; | ||
void* _clickFuncParam = NULL; | ||
|
||
callbackFunction _doubleClickFunc = NULL; | ||
parameterizedCallbackFunction _paramDoubleClickFunc = NULL; | ||
void* _doubleClickFuncParam = NULL; | ||
|
||
|
||
callbackFunction _longClickFunc = NULL; | ||
parameterizedCallbackFunction _paramLongClickFunc = NULL; | ||
void* _longClickFuncParam = NULL; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Use the m_ prefix for member variables (private).
snakeCase
tosnake_case
.- Use doxygen comments.
typedef void (*callbackFunction)(void); | ||
typedef void (*parameterizedCallbackFunction)(void*); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New types should be SnakeCase to not confuse them with a function or variable.
This needs to be resolved guys 🇳🇮 🇻🇪 🇨🇴 |
plz dont accept this PR now, I need to implement the needed functions to turn on/off device