This commit is contained in:
parent
bc4a087614
commit
48fe73611d
3 changed files with 22 additions and 7 deletions
|
@ -10,7 +10,9 @@
|
|||
#include "freertos/queue.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/rtc_io.h"
|
||||
|
||||
#define TAG "main"
|
||||
#define TRIGGER_PIN GPIO_NUM_12
|
||||
|
@ -82,6 +84,9 @@ void handleTrigger(void *)
|
|||
|
||||
void app_main()
|
||||
{
|
||||
rtc_gpio_pullup_en(TRIGGER_PIN);
|
||||
esp_sleep_enable_ext0_wakeup(TRIGGER_PIN, 0);
|
||||
|
||||
ESP_LOGI("main", "Starting BLE work!");
|
||||
|
||||
NimBLEDevice::init("Speed buzzer");
|
||||
|
@ -124,11 +129,14 @@ void app_main()
|
|||
for (;;)
|
||||
{
|
||||
uint64_t currentTime;
|
||||
if (xQueueReceive(triggerQueue, ¤tTime, portMAX_DELAY) == pdTRUE)
|
||||
if (xQueueReceive(triggerQueue, ¤tTime, 5 * 60 * 1000 / portTICK_PERIOD_MS) == pdTRUE)
|
||||
{
|
||||
bleLastTriggerTimeCharacteristic->setValue(currentTime);
|
||||
bleLastTriggerTimeCharacteristic->notify();
|
||||
// ESP_LOGI(TAG, "Characteristic written!");
|
||||
}
|
||||
else if (bleServer->getConnectedCount() == 0)
|
||||
{
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,16 @@
|
|||
state = 'wait';
|
||||
await delay(3000);
|
||||
state = 'ready';
|
||||
await new Audio('/sound/ok-ready-go.mp3').play();
|
||||
await delay(2600);
|
||||
timer.start();
|
||||
const audio = new Audio('/sound/ok-ready-go.mp3');
|
||||
const audioDone = new Promise<void>((resolve) => {
|
||||
audio.onended = () => {
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
|
||||
await audio.play();
|
||||
await audioDone;
|
||||
timer.start(200n);
|
||||
state = 'running';
|
||||
};
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
import { buzzerState } from '../stores';
|
||||
import { Button } from 'flowbite-svelte';
|
||||
|
||||
export const start = () => {
|
||||
timerStartedAt = BigInt(Math.floor(performance.now()));
|
||||
export const start = (offset: bigint = 0n) => {
|
||||
timerStartedAt = BigInt(Math.floor(performance.now())) - offset;
|
||||
timerStoppedAt = undefined;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue