Skip to content

Commit

Permalink
fix speechtext to string
Browse files Browse the repository at this point in the history
  • Loading branch information
mongonta0716 committed Nov 18, 2023
1 parent fbfc038 commit 2326638
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Avatar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void Avatar::getGaze(float *vertical, float *horizontal) {
}

void Avatar::setSpeechText(const char *speechText) {
this->speechText = speechText;
this->speechText = String(speechText);
}

void Avatar::setSpeechFont(const lgfx::IFont *speechFont) {
Expand Down
2 changes: 1 addition & 1 deletion src/Avatar.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Avatar {
float rotation;
float scale;
ColorPalette palette;
const char *speechText;
String speechText;
int colorDepth;
BatteryIconStatus batteryIconStatus;
int32_t batteryLevel;
Expand Down
4 changes: 2 additions & 2 deletions src/Balloon.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class Balloon final : public Drawable {
Balloon &operator=(const Balloon &other) = default;
void draw(M5Canvas *spi, BoundingRect rect,
DrawContext *drawContext) override {
const char *text = drawContext->getspeechText();
String text = drawContext->getspeechText();
const lgfx::IFont *font = drawContext->getSpeechFont();
if (strlen(text) == 0) {
if (text.length() == 0) {
return;
}
ColorPalette* cp = drawContext->getColorPalette();
Expand Down
6 changes: 3 additions & 3 deletions src/DrawContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ namespace m5avatar {
DrawContext::DrawContext(Expression expression, float breath,
ColorPalette* const palette, Gaze gaze,
float eyeOpenRatio, float mouthOpenRatio,
const char* speechText, BatteryIconStatus batteryIcon, int32_t batteryLevel, const lgfx::IFont* speechFont)
String speechText, BatteryIconStatus batteryIcon, int32_t batteryLevel, const lgfx::IFont* speechFont)
: DrawContext(expression, breath, palette, gaze, eyeOpenRatio, mouthOpenRatio, speechText, 0, 1, 1, BatteryIconStatus::invisible, 0, speechFont){};

DrawContext::DrawContext(Expression expression, float breath,
ColorPalette* const palette, Gaze gaze,
float eyeOpenRatio, float mouthOpenRatio,
const char* speechText, float rotation, float scale, int colorDepth, BatteryIconStatus batteryIconStatus, int32_t batteryLevel, const lgfx::IFont* speechFont)
String speechText, float rotation, float scale, int colorDepth, BatteryIconStatus batteryIconStatus, int32_t batteryLevel, const lgfx::IFont* speechFont)
: expression{expression},
breath{breath},
eyeOpenRatio{eyeOpenRatio},
Expand All @@ -42,7 +42,7 @@ float DrawContext::getRotation() const { return rotation; }

float DrawContext::getScale() const { return scale; }

const char* DrawContext::getspeechText() const { return speechText; }
String DrawContext::getspeechText() const { return speechText; }

Gaze DrawContext::getGaze() const { return gaze; }

Expand Down
8 changes: 4 additions & 4 deletions src/DrawContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DrawContext {
float mouthOpenRatio;
Gaze gaze;
ColorPalette * const palette;
const char* speechText;
String speechText;
float rotation = 0.0;
float scale = 1.0;
int colorDepth = 1;
Expand All @@ -35,10 +35,10 @@ class DrawContext {
DrawContext() = delete;
DrawContext(Expression expression, float breath, ColorPalette* const palette,
Gaze gaze, float eyeOpenRatio, float mouthOpenRatio,
const char* speechText, BatteryIconStatus batteryIconStatus, int32_t batteryLevel, const lgfx::IFont* speechFont);
String speechText, BatteryIconStatus batteryIconStatus, int32_t batteryLevel, const lgfx::IFont* speechFont);
DrawContext(Expression expression, float breath, ColorPalette* const palette,
Gaze gaze, float eyeOpenRatio, float mouthOpenRatio,
const char* speechText, float rotation, float scale, int colorDepth, BatteryIconStatus batteryIconStatus, int32_t batteryLevel, const lgfx::IFont* speechFont);
String speechText, float rotation, float scale, int colorDepth, BatteryIconStatus batteryIconStatus, int32_t batteryLevel, const lgfx::IFont* speechFont);
~DrawContext() = default;
DrawContext(const DrawContext& other) = delete;
DrawContext& operator=(const DrawContext& other) = delete;
Expand All @@ -50,7 +50,7 @@ class DrawContext {
float getRotation() const;
Gaze getGaze() const;
ColorPalette* const getColorPalette() const;
const char* getspeechText() const;
String getspeechText() const;
int getColorDepth() const;
BatteryIconStatus getBatteryIconStatus() const;
int32_t getBatteryLevel() const;
Expand Down

0 comments on commit 2326638

Please sign in to comment.