Skip to content

A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol

add input for stampS3

Geoc694250377b1
diff --git a/src/Inputs/StampS3Input.cpp b/src/Inputs/StampS3Input.cpp
new file mode 100644
index 00000000..73926d6e
--- /dev/null
+++ b/src/Inputs/StampS3Input.cpp
@@ -0,0 +1,36 @@
+#ifdef DEVICE_M5STAMPS3
+
+#include "Inputs/StampS3Input.h"
+#include "Inputs/InputKeys.h"
+
+StampS3Input::StampS3Input() {
+ M5.begin();
+}
+
+char StampS3Input::mapButton() {
+ M5.update();
+
+ if (M5.BtnA.wasPressed()) return KEY_OK;
+
+ return KEY_NONE;
+}
+
+char StampS3Input::readChar() {
+ return mapButton();
+}
+
+char StampS3Input::handler() {
+ char c = KEY_NONE;
+ while ((c = mapButton()) == KEY_NONE) {
+ delay(10);
+ }
+ return c;
+}
+
+void StampS3Input::waitPress() {
+ while (mapButton() == KEY_NONE) {
+ delay(10);
+ }
+}
+
+#endif
diff --git a/src/Inputs/StampS3Input.h b/src/Inputs/StampS3Input.h
new file mode 100644
index 00000000..fb6bb23d
--- /dev/null
+++ b/src/Inputs/StampS3Input.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#ifdef DEVICE_M5STAMPS3
+
+#include "Interfaces/IInput.h"
+#include <M5Unified.h>
+
+class StampS3Input : public IInput {
+public:
+ StampS3Input();
+
+ char readChar() override;
+ char handler() override;
+ void waitPress() override;
+
+private:
+ char mapButton();
+};
+
+#endif
\ No newline at end of file