Compare commits

..

1 Commits

Author SHA1 Message Date
Mathieu 5c2d27f7dd Update README.md 2017-11-20 17:37:17 +01:00
2 changed files with 14 additions and 24 deletions

12
HIB.cpp
View File

@ -34,24 +34,17 @@ static void (*ISRList[MAX_PIN+1])() = {
};
void __timerCallback(void *data) {
Serial.printf("%s\n", __func__);
HIB *hib = static_cast<HIB *>(data);
hib->debouncing = false;
hib->invertState();
Serial.printf("New State %d \n", hib->state);
if (hib->state != digitalRead(hib->pin)){
hib->state = !hib->state;
Serial.printf("%s. Debounce failed\n", __func__);
return;
}
if(hib->state != hib->initialState){
Serial.printf("Button Pressed\n");
if(hib->state != hib->initialState)
hib->onInternalButtonPressed();
}
else{
Serial.printf("Button Released\n");
else
hib->onInternalButtonReleased();
}
}
@ -75,7 +68,6 @@ HIB::HIB(uint8_t p, uint8_t initState,
}
void HIB::IRQ_handler(){
Serial.printf("IRQ_handler on pin %d, debouncing %d\n", pin, debouncing);
if(!debouncing){
debouncing = true;
os_timer_arm(&timer, shortPressMsec, 0);

View File

@ -1,24 +1,22 @@
This library is intended to interact with button pluged on a ESP8266 using the Arduino SDK
Code Example
```Arduino
```c++
#include <HIB.h>
HIB *button ;
HIB *button2 ;
HIB *button;
HIB *button2;
void onButtonPressed(uint8_t pin){
Serial.printf("Sketch on button %d pressed \n", pin);
}
void setup() {
Serial.begin(115200);
// put your setup code here, to run once:
button = new HIB(0, HIGH, onButtonPressed);
button2 = new HIB(4, HIGH, onButtonPressed);
void onButtonPressed(uint8_t pin) { Serial.printf("Button %d pressed \n", pin); }
void setup()
{
Serial.begin(115200);
// put your setup code here, to run once:
button = new HIB(0, HIGH, onButtonPressed);
button2 = new HIB(4, HIGH, onButtonPressed);
}
void loop() {
}
void loop() {}
```