Skip to content

Commit

Permalink
more tweaking..
Browse files Browse the repository at this point in the history
  • Loading branch information
s-light committed Jun 26, 2019
1 parent 092d779 commit 865f3d9
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ https://opensource.org/licenses/mit-license.php
// ------------------------------------------
// slight_ButtonInput things

bool mybutton_get_input(slight_ButtonInput *instance) {
boolean mybutton_get_input(slight_ButtonInput *instance) {
// read input + invert: button closes to GND.
return !digitalRead((*instance).pin);
}
Expand Down Expand Up @@ -108,9 +108,9 @@ slight_ButtonInput mybuttons[mybuttons_count] = {
1,
// uint8_t pin_new,
A3,
// tCbfuncGetInput cbfuncGetInput_new,
// tCallbackFunctionGetInput callbackGetInput_new,
mybutton_get_input,
// tcbfOnEvent cbfCallbackOnEvent_new,
// tCallbackFunction callbackOnEvent_new,
mybutton_event,
// const uint16_t duration_debounce_new = 20,
10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ https://opensource.org/licenses/mit-license.php
// ------------------------------------------
// slight_ButtonInput things

bool mybutton_get_input(slight_ButtonInput *instance) {
boolean mybutton_get_input(slight_ButtonInput *instance) {
// read input + invert: button closes to GND.
return !digitalRead((*instance).pin);
}
Expand Down Expand Up @@ -102,9 +102,9 @@ slight_ButtonInput mybutton1(
1,
// uint8_t pin_new,
A3,
// tCbfuncGetInput cbfuncGetInput_new,
// tCallbackFunctionGetInput callbackGetInput_new,
mybutton_get_input,
// tcbfOnEvent cbfCallbackOnEvent_new,
// tCallbackFunction callbackOnEvent_new,
mybutton_event,
// const uint16_t duration_debounce_new = 20,
10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ https://opensource.org/licenses/mit-license.php
// ------------------------------------------
// slight_ButtonInput things

bool mybutton_get_input(slight_ButtonInput *instance) {
boolean mybutton_get_input(slight_ButtonInput *instance) {
// read input + invert: button closes to GND.
return !digitalRead((*instance).pin);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ void print_info(Print &out) {
/*slight_ButtonInput(
uint8_t id_new,
uint8_t pin_new,
tCbfuncGetInput cbfuncGetInput_new,
tcbfOnEvent cbfCallbackOnEvent_new,
tCallbackFunctionGetInput callbackGetInput_new,
tCallbackFunction callbackOnEvent_new,
const uint16_t duration_debounce_new = 30,
const uint16_t duration_holddown_new = 1000,
const uint16_t duration_click_long_new = 3000,
Expand All @@ -160,8 +160,8 @@ void print_info(Print &out) {
slight_ButtonInput myButtonLeft(
42, // uint8_t id_new
A3, // uint8_t pin_new,
myInputLeft_callback_GetInput, // tCbfuncGetInput cbfuncGetInput_new,
mybutton_event, // tcbfOnEvent cbfCallbackOnEvent_new,
myInputLeft_callback_GetInput, // tCallbackFunctionGetInput callbackGetInput_new,
mybutton_event, // tCallbackFunction callbackOnEvent_new,
30, // const uint16_t duration_debounce_new = 30,
1000, // const uint16_t duration_holddown_new = 1000,
500, // const uint16_t duration_click_long_new = 3000,
Expand Down
5 changes: 1 addition & 4 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
#######################################

#Test KEYWORD1
tcbfOnEvent KEYWORD1
tCbfuncGetInput KEYWORD1
tCallbackFunction KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
Expand All @@ -17,10 +16,8 @@ tCbfuncGetInput KEYWORD1
#something KEYWORD2
begin KEYWORD2
isReady KEYWORD2
getID KEYWORD2
getState KEYWORD2
printState KEYWORD2
printState KEYWORD2
getEventLast KEYWORD2
printEventLast KEYWORD2
printEvent KEYWORD2
Expand Down
12 changes: 6 additions & 6 deletions src/slight_ButtonInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ SOFTWARE.
slight_ButtonInput::slight_ButtonInput(
uint8_t id_new,
uint8_t pin_new,
tCbfuncGetInput cbfuncGetInput_new,
tcbfOnEvent cbfCallbackOnEvent_new,
tCallbackFunctionGetInput callbackGetInput_new,
tCallbackFunction callbackOnEvent_new,
const uint16_t duration_debounce_new,
const uint16_t duration_holddown_new,
const uint16_t duration_click_long_new,
const uint16_t duration_click_double_new
) :
id(id_new),
pin(pin_new),
cbfCallbackOnEvent(cbfCallbackOnEvent_new),
cbfuncGetInput(cbfuncGetInput_new),
callbackOnEvent(callbackOnEvent_new),
callbackGetInput(callbackGetInput_new),
duration_debounce(duration_debounce_new),
duration_holddown(duration_holddown_new),
duration_click_long(duration_click_long_new),
Expand Down Expand Up @@ -301,7 +301,7 @@ void slight_ButtonInput::generateEvent(uint8_t event_new) {
event_last = event;
// call event
if (event != event_NoEvent) {
cbfCallbackOnEvent(this);
callbackOnEvent(this);
}
event = event_NoEvent;
}
Expand All @@ -314,7 +314,7 @@ uint8_t slight_ButtonInput::handle_button() {
// Serial.println(F("slight_ButtonInput::update():"));
#endif
// read input with callbackfunction
boolean input_active = cbfuncGetInput(this);
boolean input_active = callbackGetInput(this);
if (input_active == true) {
switch (state) {
case state_Standby:
Expand Down
14 changes: 6 additions & 8 deletions src/slight_ButtonInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ class slight_ButtonInput {
// typedefs:

// call back functions
typedef void (* tcbfOnEvent) (slight_ButtonInput *instance, uint8_t event);
//typedef void (* tCbfuncStateChanged) (uint8_t id, uint8_t state);

typedef boolean (* tCbfuncGetInput) (slight_ButtonInput *instance);
typedef void (* tCallbackFunction) (slight_ButtonInput *instance);
typedef boolean (* tCallbackFunctionGetInput) (slight_ButtonInput *instance);

// definitions:

Expand Down Expand Up @@ -101,8 +99,8 @@ class slight_ButtonInput {
slight_ButtonInput(
uint8_t id_new,
uint8_t pin_new,
tCbfuncGetInput cbfuncGetInput_new,
tcbfOnEvent cbfCallbackOnEvent_new,
tCallbackFunctionGetInput callbackGetInput_new,
tCallbackFunction callbackOnEvent_new,
const uint16_t duration_debounce_new = 20,
const uint16_t duration_holddown_new = 1000,
const uint16_t duration_click_long_new = 3000,
Expand Down Expand Up @@ -156,8 +154,8 @@ class slight_ButtonInput {
// event
uint8_t event;
uint8_t event_last;
const tcbfOnEvent cbfCallbackOnEvent;
const tCbfuncGetInput cbfuncGetInput;
const tCallbackFunction callbackOnEvent;
const tCallbackFunctionGetInput callbackGetInput;

// other things

Expand Down

0 comments on commit 865f3d9

Please sign in to comment.