mirror of
https://github.com/m5stack/StackChan.git
synced 2026-04-27 19:12:40 +00:00
update firmware source code to v0.18 (#9)
This commit is contained in:
@@ -157,6 +157,9 @@ static FeatureKeyframe parse_feature(ArduinoJson::JsonObject jsonObject)
|
||||
if (jsonObject["weight"].is<int>()) {
|
||||
kf.weight = jsonObject["weight"];
|
||||
}
|
||||
if (jsonObject["size"].is<int>()) {
|
||||
kf.size = jsonObject["size"];
|
||||
}
|
||||
return kf;
|
||||
}
|
||||
|
||||
@@ -210,6 +213,12 @@ KeyframeSequence parse_sequence_from_json(const char* jsonContent)
|
||||
if (kfObj["pitchServo"].is<ArduinoJson::JsonObject>()) {
|
||||
kf.pitchServo = parse_servo(kfObj["pitchServo"]);
|
||||
}
|
||||
if (kfObj["leftRgbColor"].is<const char*>()) {
|
||||
kf.leftRgbColor = kfObj["leftRgbColor"].as<std::string>();
|
||||
}
|
||||
if (kfObj["rightRgbColor"].is<const char*>()) {
|
||||
kf.rightRgbColor = kfObj["rightRgbColor"].as<std::string>();
|
||||
}
|
||||
if (kfObj["durationMs"].is<int>()) {
|
||||
kf.durationMs = kfObj["durationMs"];
|
||||
}
|
||||
@@ -221,3 +230,35 @@ KeyframeSequence parse_sequence_from_json(const char* jsonContent)
|
||||
}
|
||||
|
||||
} // namespace stackchan::animation
|
||||
|
||||
namespace stackchan::addon {
|
||||
|
||||
void update_neon_light_from_json(NeonLight* left, NeonLight* right, const char* jsonContent)
|
||||
{
|
||||
if (!left || !right || !jsonContent) {
|
||||
return;
|
||||
}
|
||||
|
||||
ArduinoJson::JsonDocument doc;
|
||||
auto error = ArduinoJson::deserializeJson(doc, jsonContent);
|
||||
if (error) {
|
||||
mclog::tagError(_tag, "deserializeJson failed: {}", error.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (doc["leftRgbDuration"].is<float>()) {
|
||||
left->setDuration(doc["leftRgbDuration"].as<float>());
|
||||
}
|
||||
if (doc["leftRgbColor"].is<std::string>()) {
|
||||
left->setColor(doc["leftRgbColor"].as<std::string>());
|
||||
}
|
||||
|
||||
if (doc["rightRgbDuration"].is<float>()) {
|
||||
right->setDuration(doc["rightRgbDuration"].as<float>());
|
||||
}
|
||||
if (doc["rightRgbColor"].is<std::string>()) {
|
||||
right->setColor(doc["rightRgbColor"].as<std::string>());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace stackchan::addon
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "../avatar/avatar.h"
|
||||
#include "../motion/motion.h"
|
||||
#include "../animation/animation.h"
|
||||
#include "../addons/neon_light/neon_light.h"
|
||||
|
||||
namespace stackchan {
|
||||
|
||||
@@ -22,4 +23,8 @@ namespace animation {
|
||||
KeyframeSequence parse_sequence_from_json(const char* jsonContent);
|
||||
}
|
||||
|
||||
namespace addon {
|
||||
void update_neon_light_from_json(NeonLight* left, NeonLight* right, const char* jsonContent);
|
||||
}
|
||||
|
||||
} // namespace stackchan
|
||||
|
||||
Reference in New Issue
Block a user