Skip to content
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

Closed
wants to merge 3 commits into from
Closed

User button multi Function #78

wants to merge 3 commits into from

Conversation

gustavosinbandera1
Copy link
Contributor

plz dont accept this PR now, I need to implement the needed functions to turn on/off device

@gustavosinbandera1 gustavosinbandera1 changed the title update branch with dev User button multi Function Dec 23, 2019
@luisan00 luisan00 added Type: enhancement New feature or request Status: WIP work in progress labels Dec 23, 2019
Comment on lines +20 to +22
/**
* @brief Construct a new OneButton object but not (yet) initialize the IO pin.
*/
Copy link
Member

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.

Comment on lines +28 to +34
/**
* @brief Construct a new Button:: Button object
*
* @param gpio
* @param activeLow
* @param pullupActive
*/
Copy link
Member

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
Copy link
Member

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.

Comment on lines +40 to +44
/**
* @brief save function for click event
*
* @param newFunction callback function
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to header file.

Comment on lines +23 to +26
Button::Button()
{
_gpio_btn = static_cast<gpio_num_t>(-1);
}
Copy link
Member

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?

Copy link
Contributor Author

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);
Copy link
Member

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
Copy link
Member

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();
Copy link
Member

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)?

Comment on lines +79 to +110
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;

Copy link
Member

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 to snake_case.
  • Use doxygen comments.

Comment on lines +9 to +10
typedef void (*callbackFunction)(void);
typedef void (*parameterizedCallbackFunction)(void*);
Copy link
Member

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.

@luisan00
Copy link
Member

This needs to be resolved guys 🇳🇮 🇻🇪 🇨🇴

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: WIP work in progress Type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants