mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-03-30 19:15:49 +00:00
- Add genericVibration class with 5-second cooldown and 1-second pulse - Integrate vibration triggers for new messages and contact discoveries - Add conditional compilation support with PIN_VIBRATION guard - Implement abstract interface for vibration in UITask system
44 lines
777 B
C++
44 lines
777 B
C++
#ifdef PIN_VIBRATION
|
|
#include "vibration.h"
|
|
|
|
void genericVibration::begin()
|
|
{
|
|
pinMode(PIN_VIBRATION, OUTPUT);
|
|
digitalWrite(PIN_VIBRATION, LOW);
|
|
duration = 0;
|
|
}
|
|
|
|
void genericVibration::trigger()
|
|
{
|
|
duration = millis();
|
|
digitalWrite(PIN_VIBRATION, HIGH);
|
|
}
|
|
|
|
void genericVibration::loop()
|
|
{
|
|
if (isVibrating()) {
|
|
if ((millis() / 1000) % 2 == 0) {
|
|
digitalWrite(PIN_VIBRATION, LOW);
|
|
} else {
|
|
digitalWrite(PIN_VIBRATION, HIGH);
|
|
}
|
|
|
|
if (millis() - duration > VIBRATION_TIMEOUT) {
|
|
stop();
|
|
}
|
|
}
|
|
}
|
|
|
|
bool genericVibration::isVibrating()
|
|
{
|
|
return duration > 0;
|
|
}
|
|
|
|
void genericVibration::stop()
|
|
{
|
|
duration = 0;
|
|
digitalWrite(PIN_VIBRATION, LOW);
|
|
}
|
|
|
|
#endif // ifdef PIN_VIBRATION
|