summaryrefslogtreecommitdiff
path: root/src/tangara/tts
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-05-29 14:45:49 +1000
committerjacqueline <me@jacqueline.id.au>2024-05-29 14:45:49 +1000
commit2ff8eac022f397bb1aed28aca376fbe422fc8b3c (patch)
treeae80d0d89a212b1badf1d971fc67e701a9e4e962 /src/tangara/tts
parentef812a53e5a84665e74be8c46cb983edaa712b3f (diff)
downloadtangara-fw-2ff8eac022f397bb1aed28aca376fbe422fc8b3c.tar.gz
Start on TTS support by logging the data that will become TTS lines
Includes some misc cleanup of haptic double-triggering (or non-triggering), since those cases all end up being TTS event double-reporting, which to me crosses the threshold from "annoying" to "usability issue"
Diffstat (limited to 'src/tangara/tts')
-rw-r--r--src/tangara/tts/events.hpp41
-rw-r--r--src/tangara/tts/provider.cpp38
-rw-r--r--src/tangara/tts/provider.hpp23
3 files changed, 102 insertions, 0 deletions
diff --git a/src/tangara/tts/events.hpp b/src/tangara/tts/events.hpp
new file mode 100644
index 00000000..21199db1
--- /dev/null
+++ b/src/tangara/tts/events.hpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2024 jacqueline <me@jacqueline.id.au>
+ *
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+#pragma once
+
+#include <optional>
+#include <string>
+#include <variant>
+
+namespace tts {
+
+/*
+ * 'Simple' TTS events are events that do not have any extra event-specific
+ * details.
+ */
+enum class SimpleEvent {
+ /*
+ * Indicates that the screen's content has substantially changed. e.g. a new
+ * screen has been pushed.
+ */
+ kContextChanged,
+};
+
+/*
+ * Event indicating that the currently selected LVGL object has changed.
+ */
+struct SelectionChanged {
+ struct Selection {
+ std::optional<std::string> description;
+ bool is_interactive;
+ };
+
+ std::optional<Selection> new_selection;
+};
+
+using Event = std::variant<SimpleEvent, SelectionChanged>;
+
+} // namespace tts
diff --git a/src/tangara/tts/provider.cpp b/src/tangara/tts/provider.cpp
new file mode 100644
index 00000000..7d33bae6
--- /dev/null
+++ b/src/tangara/tts/provider.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2024 jacqueline <me@jacqueline.id.au>
+ *
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+#include "tts/provider.hpp"
+
+#include <optional>
+#include <string>
+#include <variant>
+
+#include "esp_log.h"
+
+#include "tts/events.hpp"
+
+namespace tts {
+
+[[maybe_unused]] static constexpr char kTag[] = "tts";
+
+Provider::Provider() {}
+
+auto Provider::feed(const Event& e) -> void {
+ if (std::holds_alternative<SimpleEvent>(e)) {
+ // ESP_LOGI(kTag, "context changed");
+ } else if (std::holds_alternative<SelectionChanged>(e)) {
+ auto ev = std::get<SelectionChanged>(e);
+ if (!ev.new_selection) {
+ // ESP_LOGI(kTag, "no selection");
+ } else {
+ // ESP_LOGI(kTag, "new selection: '%s', interactive? %i",
+ // ev.new_selection->description.value_or("").c_str(),
+ // ev.new_selection->is_interactive);
+ }
+ }
+}
+
+} // namespace tts
diff --git a/src/tangara/tts/provider.hpp b/src/tangara/tts/provider.hpp
new file mode 100644
index 00000000..59f61a6c
--- /dev/null
+++ b/src/tangara/tts/provider.hpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2024 jacqueline <me@jacqueline.id.au>
+ *
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+#pragma once
+
+#include <optional>
+#include <string>
+#include <variant>
+
+#include "tts/events.hpp"
+
+namespace tts {
+
+class Provider {
+ public:
+ Provider();
+ auto feed(const Event&) -> void;
+};
+
+} // namespace tts