diff --git a/getbutton.c b/getbutton.c new file mode 100644 index 0000000..5ffcce5 --- /dev/null +++ b/getbutton.c @@ -0,0 +1,16 @@ +#include "mc8051fun.h" + +uint8_t getbutton_time = 100; +int getbutton(uint8_t pinval, uint8_t *button) +{ + if ( *button & 1 != pinval){ + *button += 2; + if (*button > getbutton_time){ + *button = pinval; + return pinval; + } + return -1; + } + *button = pinval; + return -1; +}