feat: beaver
This commit is contained in:
@ -192,6 +192,7 @@ private:
|
||||
void PollTouchpad() {
|
||||
static bool was_touched = false;
|
||||
static int64_t touch_start_time = 0;
|
||||
static int touch_start_x = -1;
|
||||
const int64_t TOUCH_THRESHOLD_MS = 500; // 触摸时长阈值,超过500ms视为长按
|
||||
|
||||
ft6336_->UpdateTouchPoint();
|
||||
@ -201,11 +202,14 @@ private:
|
||||
if (touch_point.num > 0 && !was_touched) {
|
||||
was_touched = true;
|
||||
touch_start_time = esp_timer_get_time() / 1000; // 转换为毫秒
|
||||
touch_start_x = touch_point.x;
|
||||
}
|
||||
// 检测触摸释放
|
||||
else if (touch_point.num == 0 && was_touched) {
|
||||
was_touched = false;
|
||||
int64_t touch_duration = (esp_timer_get_time() / 1000) - touch_start_time;
|
||||
bool beaver_mode = touch_start_x >= DISPLAY_WIDTH / 2;
|
||||
auto agent_mode = beaver_mode ? kChatAgentModeBeaver : kChatAgentModeNormal;
|
||||
|
||||
if (touch_duration < TOUCH_THRESHOLD_MS) {
|
||||
auto& app = Application::GetInstance();
|
||||
@ -213,12 +217,12 @@ private:
|
||||
EnterWifiConfigMode();
|
||||
return;
|
||||
}
|
||||
ESP_LOGI(TAG, "Touch short: text-only mode");
|
||||
app.ToggleChatState();
|
||||
ESP_LOGI(TAG, "Touch short: %s text-only mode", beaver_mode ? "beaver" : "normal");
|
||||
app.ToggleChatStateForMode(agent_mode, false);
|
||||
} else {
|
||||
auto& app = Application::GetInstance();
|
||||
ESP_LOGI(TAG, "Touch long: vision+text mode");
|
||||
app.ToggleChatStateWithVision();
|
||||
ESP_LOGI(TAG, "Touch long: %s vision+text mode", beaver_mode ? "beaver" : "normal");
|
||||
app.ToggleChatStateForMode(agent_mode, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user