mirror of
https://github.com/jaksatomovic/esp32-clickwheel.git
synced 2025-08-26 06:48:28 -04:00
first commit
This commit is contained in:
commit
868b14f8c8
286 changed files with 59925 additions and 0 deletions
|
@ -0,0 +1,51 @@
|
|||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(ESP32)
|
||||
#error This sketch needs an ESP32
|
||||
#else
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
#include "Button2.h"
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
#define BUTTON_PIN 39
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
Button2 btn;
|
||||
hw_timer_t *timer = NULL;
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
void IRAM_ATTR onTimer() {
|
||||
btn.loop();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
void click(Button2 &b) {
|
||||
Serial.println("click");
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
btn.begin(BUTTON_PIN);
|
||||
btn.setTapHandler(click);
|
||||
|
||||
timer = timerBegin(0, 80, true);
|
||||
timerAttachInterrupt(timer, &onTimer, true);
|
||||
timerAlarmWrite(timer, 10000, true); // every 0.1 seconds
|
||||
timerAlarmEnable(timer);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
void loop() {
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
#endif
|
||||
/////////////////////////////////////////////////////////////////
|
Loading…
Add table
Add a link
Reference in a new issue