Skip to content

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

add select method for headless setup

Geo9d7bac867aa2
diff --git a/src/Selectors/HorizontalSelector.cpp b/src/Selectors/HorizontalSelector.cpp
index 8220ebd4..4a8f6e4a 100644
--- a/src/Selectors/HorizontalSelector.cpp
+++ b/src/Selectors/HorizontalSelector.cpp
@@ -38,3 +38,20 @@ int HorizontalSelector::select(
}
}
}
+
+int HorizontalSelector::selectHeadless() {
+ int selected = 1; // default
+
+ // 3 sec to press the button
+ const unsigned long timeout = millis() + 3000;
+ while (millis() < timeout) {
+ char c = input.readChar();
+ if (c == KEY_OK) {
+ selected = 0;
+ break;
+ }
+ delay(10);
+ }
+
+ return selected;
+}
\ No newline at end of file
diff --git a/src/Selectors/HorizontalSelector.h b/src/Selectors/HorizontalSelector.h
index ba083f1c..413746db 100644
--- a/src/Selectors/HorizontalSelector.h
+++ b/src/Selectors/HorizontalSelector.h
@@ -5,6 +5,7 @@
#include "Interfaces/IDeviceView.h"
#include "Interfaces/IInput.h"
#include "Inputs/CardputerInput.h"
+#include <Arduino.h>
class HorizontalSelector {
public:
@@ -17,6 +18,8 @@ public:
const std::string& description2 = ""
);
+ int selectHeadless();
+
private:
IDeviceView& display;
IInput& input;