初始化提交

This commit is contained in:
王立帮
2024-07-20 22:09:06 +08:00
commit c247dd07a6
6876 changed files with 2743096 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////
#include "Button2.h"
/////////////////////////////////////////////////////////////////
#define BUTTON_PIN 2
/////////////////////////////////////////////////////////////////
Button2 button = Button2(BUTTON_PIN);
/////////////////////////////////////////////////////////////////
void setup() {
Serial.begin(9600);
while (!Serial) {
delay(20);
}
Serial.println("\n\nLongpress Handler Demo");
button.setLongClickHandler(longpress);
}
/////////////////////////////////////////////////////////////////
void loop() {
button.loop();
}
/////////////////////////////////////////////////////////////////
void longpress(Button2& btn) {
unsigned int time = btn.wasPressedFor();
Serial.print("You clicked ");
if (time > 1500) {
Serial.print("a really really long time.");
} else if (time > 1000) {
Serial.print("a really long time.");
} else if (time > 500) {
Serial.print("a long time.");
} else {
Serial.print("long.");
}
Serial.print(" (");
Serial.print(time);
Serial.println(" ms)");
}
/////////////////////////////////////////////////////////////////