mirror of
https://github.com/m5stack/StackChan.git
synced 2026-05-20 11:49:45 -07:00
update firmware v1.3.1
This commit is contained in:
@@ -21,8 +21,9 @@
|
||||
static const char* _tag = "HAL_BRIDGE";
|
||||
|
||||
static constexpr std::string_view _xiaozhi_config_nvs_ns = "xiaozhi";
|
||||
static constexpr std::string_view _xiaozhi_config_idle_shutdown_time_key = "idle_shutdown";
|
||||
static constexpr std::string_view _xiaozhi_config_allow_shutdown_when_charging_key = "shutdown_charge";
|
||||
static constexpr std::string_view _xiaozhi_config_idle_shutdown_time_key = "idle_sec";
|
||||
static constexpr std::string_view _xiaozhi_config_allow_shutdown_when_charging_key = "ext_pwr";
|
||||
static constexpr std::string_view _xiaozhi_config_idle_random_movement_key = "idle_lv";
|
||||
|
||||
namespace hal_bridge {
|
||||
|
||||
@@ -126,6 +127,8 @@ XiaozhiConfig_t get_xiaozhi_config()
|
||||
static_cast<int>(config.idleShutdownTimeSeconds));
|
||||
config.allowShutdownWhenCharging =
|
||||
settings.GetBool(_xiaozhi_config_allow_shutdown_when_charging_key.data(), config.allowShutdownWhenCharging);
|
||||
config.idleRandomMovementLevel =
|
||||
settings.GetInt(_xiaozhi_config_idle_random_movement_key.data(), config.idleRandomMovementLevel);
|
||||
|
||||
return config;
|
||||
}
|
||||
@@ -135,6 +138,7 @@ void set_xiaozhi_config(const XiaozhiConfig_t& config)
|
||||
Settings settings(_xiaozhi_config_nvs_ns.data(), true);
|
||||
settings.SetInt(_xiaozhi_config_idle_shutdown_time_key.data(), config.idleShutdownTimeSeconds);
|
||||
settings.SetBool(_xiaozhi_config_allow_shutdown_when_charging_key.data(), config.allowShutdownWhenCharging);
|
||||
settings.SetInt(_xiaozhi_config_idle_random_movement_key.data(), config.idleRandomMovementLevel);
|
||||
}
|
||||
|
||||
void app_play_sound(const std::string_view& sound)
|
||||
|
||||
@@ -27,6 +27,7 @@ struct Data_t {
|
||||
struct XiaozhiConfig_t {
|
||||
uint32_t idleShutdownTimeSeconds = 600;
|
||||
bool allowShutdownWhenCharging = false;
|
||||
uint8_t idleRandomMovementLevel = 2;
|
||||
};
|
||||
|
||||
void lock();
|
||||
|
||||
@@ -272,6 +272,9 @@ void StackChanAvatarDisplay::SetupUI()
|
||||
|
||||
// GetHAL().startStackChanAutoUpdate(24);
|
||||
|
||||
auto config = hal_bridge::get_xiaozhi_config();
|
||||
idle_motion_level_ = config.idleRandomMovementLevel;
|
||||
|
||||
ESP_LOGI(TAG, "Avatar created and started");
|
||||
}
|
||||
|
||||
@@ -287,6 +290,27 @@ void StackChanAvatarDisplay::LvglUnlock()
|
||||
Unlock();
|
||||
}
|
||||
|
||||
void StackChanAvatarDisplay::CreateIdleMotionModifier()
|
||||
{
|
||||
auto& stackchan = GetStackChan();
|
||||
|
||||
switch (idle_motion_level_) {
|
||||
case 0:
|
||||
idle_motion_modifier_id_ = -1;
|
||||
return;
|
||||
case 1:
|
||||
idle_motion_modifier_id_ = stackchan.addModifier(std::make_unique<IdleMotionModifier>(8000, 12000));
|
||||
return;
|
||||
case 3:
|
||||
idle_motion_modifier_id_ = stackchan.addModifier(std::make_unique<IdleMotionModifier>(2000, 4000));
|
||||
return;
|
||||
case 2:
|
||||
default:
|
||||
idle_motion_modifier_id_ = stackchan.addModifier(std::make_unique<IdleMotionModifier>());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void StackChanAvatarDisplay::SetEmotion(const char* emotion)
|
||||
{
|
||||
auto& stackchan = GetStackChan();
|
||||
@@ -505,7 +529,9 @@ void StackChanAvatarDisplay::SetStatus(const char* status)
|
||||
// Start idle motion
|
||||
ESP_LOGW(TAG, "Start idle motion");
|
||||
if (idle_motion_modifier_id_ < 0) {
|
||||
idle_motion_modifier_id_ = stackchan.addModifier(std::make_unique<IdleMotionModifier>());
|
||||
if (idle_motion_level_ > 0) {
|
||||
CreateIdleMotionModifier();
|
||||
}
|
||||
idle_expression_modifier_id_ = stackchan.addModifier(std::make_unique<IdleExpressionModifier>());
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,14 @@ private:
|
||||
int idle_expression_modifier_id_ = -1;
|
||||
int blink_modifier_id_ = -1;
|
||||
bool is_sleeping_ = false;
|
||||
uint8_t idle_motion_level_ = 2;
|
||||
|
||||
lv_obj_t* preview_image_ = nullptr;
|
||||
esp_timer_handle_t preview_timer_ = nullptr;
|
||||
std::unique_ptr<LvglImage> preview_image_cached_ = nullptr;
|
||||
|
||||
void CreateIdleMotionModifier();
|
||||
|
||||
protected:
|
||||
virtual bool Lock(int timeout_ms = 0) override;
|
||||
virtual void Unlock() override;
|
||||
|
||||
@@ -208,6 +208,7 @@ XiaozhiConfig_t Hal::getXiaozhiConfig()
|
||||
return XiaozhiConfig_t{
|
||||
.idleShutdownTimeSeconds = bridge_config.idleShutdownTimeSeconds,
|
||||
.allowShutdownWhenCharging = bridge_config.allowShutdownWhenCharging,
|
||||
.idleRandomMovementLevel = bridge_config.idleRandomMovementLevel,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -216,6 +217,7 @@ void Hal::setXiaozhiConfig(XiaozhiConfig_t config)
|
||||
hal_bridge::set_xiaozhi_config({
|
||||
.idleShutdownTimeSeconds = config.idleShutdownTimeSeconds,
|
||||
.allowShutdownWhenCharging = config.allowShutdownWhenCharging,
|
||||
.idleRandomMovementLevel = config.idleRandomMovementLevel,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -117,6 +117,7 @@ struct UserAccountInfo_t {
|
||||
struct XiaozhiConfig_t {
|
||||
uint32_t idleShutdownTimeSeconds = 600;
|
||||
bool allowShutdownWhenCharging = false;
|
||||
uint8_t idleRandomMovementLevel = 2;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -180,7 +180,7 @@ void Hal::servo_init()
|
||||
ServoConfig_t pitch_servo_config;
|
||||
pitch_servo_config.id = 2;
|
||||
pitch_servo_config.defaultZeroPos = 620;
|
||||
pitch_servo_config.angleLimit = Vector2i(0, 900);
|
||||
pitch_servo_config.angleLimit = Vector2i(30, 870);
|
||||
pitch_servo_config.rawPosLimit = Vector2i(0, 1000);
|
||||
pitch_servo_config.settingNs = "servo";
|
||||
pitch_servo_config.settingZeroPositionKey = "zero_pos_2";
|
||||
|
||||
Reference in New Issue
Block a user