mirror of
https://github.com/m5stack/StackChan.git
synced 2026-06-14 18:20:27 +00:00
update firmware v1.2.6
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# CMakeLists in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
set(PROJECT_VER "1.2.4")
|
||||
set(PROJECT_VER "1.2.6")
|
||||
add_definitions(-DFIRMWARE_VERSION=\"${PROJECT_VER}\")
|
||||
|
||||
# Add this line to disable the specific warning
|
||||
|
||||
@@ -41,6 +41,7 @@ lv_disp_t* display_get_lvgl_display();
|
||||
void xiaozhi_board_init();
|
||||
void start_xiaozhi_app();
|
||||
bool is_xiaozhi_ready();
|
||||
bool is_xiaozhi_idle();
|
||||
|
||||
i2c_master_bus_handle_t board_get_i2c_bus();
|
||||
StackChanCamera* board_get_camera();
|
||||
|
||||
@@ -183,12 +183,29 @@ public:
|
||||
delete[] read_buffer_;
|
||||
}
|
||||
|
||||
void UpdateTouchPoint()
|
||||
bool UpdateTouchPoint()
|
||||
{
|
||||
ReadRegs(0x02, read_buffer_, 6);
|
||||
tp_.num = read_buffer_[0] & 0x0F;
|
||||
tp_.x = ((read_buffer_[1] & 0x0F) << 8) | read_buffer_[2];
|
||||
tp_.y = ((read_buffer_[3] & 0x0F) << 8) | read_buffer_[4];
|
||||
auto err = TryReadRegs(0x02, read_buffer_, 6);
|
||||
if (err != ESP_OK) {
|
||||
tp_.num = 0;
|
||||
tp_.x = -1;
|
||||
tp_.y = -1;
|
||||
|
||||
consecutive_failures_++;
|
||||
int64_t now_us = esp_timer_get_time();
|
||||
if (last_error_log_us_ == 0 || (now_us - last_error_log_us_) >= 1000 * 1000) {
|
||||
ESP_LOGW(TAG, "FT6336 read failed (%s), skipped %lu sample(s)", esp_err_to_name(err),
|
||||
static_cast<unsigned long>(consecutive_failures_));
|
||||
last_error_log_us_ = now_us;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
consecutive_failures_ = 0;
|
||||
tp_.num = read_buffer_[0] & 0x0F;
|
||||
tp_.x = ((read_buffer_[1] & 0x0F) << 8) | read_buffer_[2];
|
||||
tp_.y = ((read_buffer_[3] & 0x0F) << 8) | read_buffer_[4];
|
||||
return true;
|
||||
}
|
||||
|
||||
inline const TouchPoint_t& GetTouchPoint()
|
||||
@@ -199,6 +216,8 @@ public:
|
||||
private:
|
||||
uint8_t* read_buffer_ = nullptr;
|
||||
TouchPoint_t tp_;
|
||||
int64_t last_error_log_us_ = 0;
|
||||
uint32_t consecutive_failures_ = 0;
|
||||
};
|
||||
|
||||
class M5StackCoreS3Board : public WifiBoard {
|
||||
@@ -283,7 +302,9 @@ private:
|
||||
|
||||
void PollTouchpad()
|
||||
{
|
||||
ft6336_->UpdateTouchPoint();
|
||||
if (!ft6336_->UpdateTouchPoint()) {
|
||||
return;
|
||||
}
|
||||
auto& touch_point = ft6336_->GetTouchPoint();
|
||||
|
||||
// Update hal touch point
|
||||
|
||||
@@ -119,7 +119,8 @@ StackChanAvatarDisplay::StackChanAvatarDisplay(esp_lcd_panel_io_handle_t panel_i
|
||||
|
||||
ESP_LOGI(TAG, "Initialize LVGL port");
|
||||
lvgl_port_cfg_t port_cfg = ESP_LVGL_PORT_INIT_CONFIG();
|
||||
port_cfg.task_priority = 20;
|
||||
// port_cfg.task_priority = 20;
|
||||
port_cfg.task_priority = 3;
|
||||
#if CONFIG_SOC_CPU_CORES_NUM > 1
|
||||
port_cfg.task_affinity = 1;
|
||||
#endif
|
||||
@@ -435,10 +436,15 @@ void StackChanAvatarDisplay::SetTheme(Theme* theme)
|
||||
|
||||
#include <hal/board/hal_bridge.h>
|
||||
static bool _is_xiaozhi_ready = false;
|
||||
static bool _is_xiaozhi_idle = false;
|
||||
bool hal_bridge::is_xiaozhi_ready()
|
||||
{
|
||||
return _is_xiaozhi_ready;
|
||||
}
|
||||
bool hal_bridge::is_xiaozhi_idle()
|
||||
{
|
||||
return _is_xiaozhi_idle;
|
||||
}
|
||||
|
||||
void StackChanAvatarDisplay::SetStatus(const char* status)
|
||||
{
|
||||
@@ -486,7 +492,7 @@ void StackChanAvatarDisplay::SetStatus(const char* status)
|
||||
|
||||
} else if (strcmp(status, Lang::Strings::SPEAKING) == 0) {
|
||||
if (speaking_modifier_id_ < 0) {
|
||||
speaking_modifier_id_ = stackchan.addModifier(std::make_unique<SpeakingModifier>());
|
||||
speaking_modifier_id_ = stackchan.addModifier(std::make_unique<SpeakingModifier>(0, 180, false));
|
||||
}
|
||||
|
||||
GetHAL().setRgbColor(0, 0, 0, 50);
|
||||
@@ -502,6 +508,8 @@ void StackChanAvatarDisplay::SetStatus(const char* status)
|
||||
idle_motion_modifier_id_ = stackchan.addModifier(std::make_unique<IdleMotionModifier>());
|
||||
idle_expression_modifier_id_ = stackchan.addModifier(std::make_unique<IdleExpressionModifier>());
|
||||
}
|
||||
|
||||
_is_xiaozhi_idle = true;
|
||||
} else {
|
||||
// Stop idle motion
|
||||
ESP_LOGW(TAG, "Stop idle motion");
|
||||
@@ -517,6 +525,8 @@ void StackChanAvatarDisplay::SetStatus(const char* status)
|
||||
// motion.pitchServo().moveWithSpeed(200, 350);
|
||||
// motion.yawServo().moveWithSpeed(0, 350);
|
||||
// }
|
||||
|
||||
_is_xiaozhi_idle = false;
|
||||
}
|
||||
|
||||
// Clear sleep state
|
||||
|
||||
@@ -144,20 +144,22 @@ void Hal::xiaozhi_board_init()
|
||||
|
||||
static void _stackchan_update_task(void* param)
|
||||
{
|
||||
bool is_xiaozhi_ready = false;
|
||||
bool is_setup_done = false;
|
||||
bool is_setup_done = false;
|
||||
|
||||
while (1) {
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
vTaskDelay(pdMS_TO_TICKS(20));
|
||||
|
||||
tools::update_reminders();
|
||||
|
||||
LvglLockGuard lock;
|
||||
|
||||
if (!hal_bridge::is_xiaozhi_idle()) {
|
||||
vTaskDelay(pdMS_TO_TICKS(100));
|
||||
}
|
||||
|
||||
GetStackChan().update();
|
||||
|
||||
if (!is_xiaozhi_ready) {
|
||||
is_xiaozhi_ready = hal_bridge::is_xiaozhi_ready();
|
||||
if (!hal_bridge::is_xiaozhi_ready()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -195,7 +197,7 @@ void Hal::startXiaozhi()
|
||||
});
|
||||
|
||||
// Start stackchan update task
|
||||
xTaskCreatePinnedToCore(_stackchan_update_task, "stackchan", 4096, NULL, 5, NULL, 1);
|
||||
xTaskCreatePinnedToCore(_stackchan_update_task, "stackchan", 4096, NULL, 3, NULL, 1);
|
||||
|
||||
hal_bridge::start_xiaozhi_app();
|
||||
}
|
||||
|
||||
@@ -158,5 +158,7 @@ void Hal::head_touch_init()
|
||||
si12t_init(&si12t_cfg, &si12t);
|
||||
si12t_setup(si12t, SI12T_TYPE_LOW, SI12T_SENSITIVITY_LEVEL_3);
|
||||
|
||||
xTaskCreateWithCaps(_head_touch_update_task, "headtouch", 1024 * 6, si12t, 5, NULL, MALLOC_CAP_SPIRAM);
|
||||
// xTaskCreateWithCaps(_head_touch_update_task, "headtouch", 1024 * 6, si12t, 2, NULL, MALLOC_CAP_SPIRAM);
|
||||
xTaskCreatePinnedToCoreWithCaps(_head_touch_update_task, "headtouch", 1024 * 6, si12t, 2, NULL, 1,
|
||||
MALLOC_CAP_SPIRAM);
|
||||
}
|
||||
|
||||
@@ -53,5 +53,6 @@ void Hal::imu_init()
|
||||
}
|
||||
mclog::tagInfo(_tag, "BMI270 init ok");
|
||||
|
||||
xTaskCreateWithCaps(_imu_task, "imu", 4096, NULL, 5, NULL, MALLOC_CAP_SPIRAM);
|
||||
// xTaskCreateWithCaps(_imu_task, "imu", 4096, NULL, 2, NULL, MALLOC_CAP_SPIRAM);
|
||||
xTaskCreatePinnedToCoreWithCaps(_imu_task, "imu", 4096, NULL, 2, NULL, 1, MALLOC_CAP_SPIRAM);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <ctime>
|
||||
#include <settings.h>
|
||||
#include <esp_log.h>
|
||||
|
||||
static const std::string_view _tag = "HAL-RTC";
|
||||
|
||||
@@ -103,10 +104,10 @@ void Hal::syncSystemTimeToRtc()
|
||||
time.seconds = tm_curr.tm_sec;
|
||||
|
||||
if (_pcf8563->setDateTime(&date, &time)) {
|
||||
mclog::tagInfo(_tag, "system synced to rtc (UTC): {:04d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}", date.year,
|
||||
date.month, date.date, time.hours, time.minutes, time.seconds);
|
||||
ESP_LOGI(_tag.data(), "system synced to rtc (UTC): %04d-%02d-%02d %02d:%02d:%02d", date.year, date.month,
|
||||
date.date, time.hours, time.minutes, time.seconds);
|
||||
} else {
|
||||
mclog::tagError(_tag, "failed to write rtc");
|
||||
ESP_LOGE(_tag.data(), "failed to write rtc");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
|
||||
_websocket->OnDisconnected([this]() {
|
||||
ESP_LOGI(_tag.c_str(), "Disconnected!");
|
||||
GetHAL().onWsLog.emit(CommonLogLevel::Error, "Server disconnected");
|
||||
// GetHAL().onWsLog.emit(CommonLogLevel::Error, "Server disconnected");
|
||||
});
|
||||
|
||||
_websocket->OnData([this](const char* data, size_t len, bool binary) {
|
||||
|
||||
@@ -245,3 +245,29 @@ index 3692e0c..7bfbc5c 100644
|
||||
|
||||
// Strategy instance
|
||||
std::unique_ptr<AssetStrategy> strategy_;
|
||||
diff --git a/main/boards/common/i2c_device.cc b/main/boards/common/i2c_device.cc
|
||||
index 835997d..ea50d51 100644
|
||||
--- a/main/boards/common/i2c_device.cc
|
||||
+++ b/main/boards/common/i2c_device.cc
|
||||
@@ -32,4 +32,8 @@ uint8_t I2cDevice::ReadReg(uint8_t reg) {
|
||||
|
||||
void I2cDevice::ReadRegs(uint8_t reg, uint8_t* buffer, size_t length) {
|
||||
ESP_ERROR_CHECK(i2c_master_transmit_receive(i2c_device_, ®, 1, buffer, length, 100));
|
||||
+}
|
||||
+
|
||||
+esp_err_t I2cDevice::TryReadRegs(uint8_t reg, uint8_t* buffer, size_t length, int timeout_ms) {
|
||||
+ return i2c_master_transmit_receive(i2c_device_, ®, 1, buffer, length, timeout_ms);
|
||||
}
|
||||
\ No newline at end of file
|
||||
diff --git a/main/boards/common/i2c_device.h b/main/boards/common/i2c_device.h
|
||||
index 7bc917b..874b137 100644
|
||||
--- a/main/boards/common/i2c_device.h
|
||||
+++ b/main/boards/common/i2c_device.h
|
||||
@@ -13,6 +13,7 @@ protected:
|
||||
void WriteReg(uint8_t reg, uint8_t value);
|
||||
uint8_t ReadReg(uint8_t reg);
|
||||
void ReadRegs(uint8_t reg, uint8_t* buffer, size_t length);
|
||||
+ esp_err_t TryReadRegs(uint8_t reg, uint8_t* buffer, size_t length, int timeout_ms = 100);
|
||||
};
|
||||
|
||||
#endif // I2C_DEVICE_H
|
||||
|
||||
Reference in New Issue
Block a user