sforkowany z mirror/meshtastic-firmware
#654 - Non blocking call to toggle the output.
rodzic
5e303f8a1f
commit
c524732849
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
This plugin supports:
|
This plugin supports:
|
||||||
https://github.com/meshtastic/Meshtastic-device/issues/654
|
https://github.com/meshtastic/Meshtastic-device/issues/654
|
||||||
|
|
||||||
|
|
||||||
bool ext_notification_plugin_enabled = 126;
|
bool ext_notification_plugin_enabled = 126;
|
||||||
bool ext_notification_plugin_active = 129;
|
bool ext_notification_plugin_active = 129;
|
||||||
|
@ -72,13 +72,13 @@ int32_t ExternalNotificationPlugin::runOnce()
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/*
|
if (externalCurrentState) {
|
||||||
|
|
||||||
1) If GPIO is turned on ...
|
// TODO: Test this part. Don't know if this should be greater than or less than.
|
||||||
2) Check the timer. If the timer has elapsed more time than
|
if (externalTurnedOn + EXT_NOTIFICATION_PLUGIN_OUTPUT_MS < millis()) {
|
||||||
our set limit, turn the GPIO off.
|
setExternalOff();
|
||||||
|
}
|
||||||
*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (25);
|
return (25);
|
||||||
|
@ -94,6 +94,7 @@ int32_t ExternalNotificationPlugin::runOnce()
|
||||||
void ExternalNotificationPlugin::setExternalOn()
|
void ExternalNotificationPlugin::setExternalOn()
|
||||||
{
|
{
|
||||||
externalCurrentState = 1;
|
externalCurrentState = 1;
|
||||||
|
externalTurnedOn = millis();
|
||||||
|
|
||||||
// if ext_notification_plugin_active
|
// if ext_notification_plugin_active
|
||||||
if (EXT_NOTIFICATION_PLUGIN_ACTIVE) {
|
if (EXT_NOTIFICATION_PLUGIN_ACTIVE) {
|
||||||
|
@ -140,20 +141,12 @@ bool ExternalNotificationPluginRadio::handleReceived(const MeshPacket &mp)
|
||||||
for (int i = 0; i < p.payload.size; i++) {
|
for (int i = 0; i < p.payload.size; i++) {
|
||||||
if (p.payload.bytes[i] == ASCII_BELL) {
|
if (p.payload.bytes[i] == ASCII_BELL) {
|
||||||
externalNotificationPlugin->setExternalOn();
|
externalNotificationPlugin->setExternalOn();
|
||||||
|
|
||||||
// TODO: Make this non-blocking.
|
|
||||||
delay(EXT_NOTIFICATION_PLUGIN_OUTPUT_MS);
|
|
||||||
externalNotificationPlugin->setExternalOff();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EXT_NOTIFICATION_PLUGIN_ALERT_MESSAGE) {
|
if (EXT_NOTIFICATION_PLUGIN_ALERT_MESSAGE) {
|
||||||
externalNotificationPlugin->setExternalOn();
|
externalNotificationPlugin->setExternalOn();
|
||||||
|
|
||||||
// TODO: Make this non-blocking.
|
|
||||||
delay(EXT_NOTIFICATION_PLUGIN_OUTPUT_MS);
|
|
||||||
externalNotificationPlugin->setExternalOff();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ class ExternalNotificationPlugin : private concurrency::OSThread
|
||||||
{
|
{
|
||||||
bool firstTime = 1;
|
bool firstTime = 1;
|
||||||
bool externalCurrentState = 0;
|
bool externalCurrentState = 0;
|
||||||
|
uint32_t externalTurnedOn = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ExternalNotificationPlugin();
|
ExternalNotificationPlugin();
|
||||||
|
|
Ładowanie…
Reference in New Issue