I will clean this mess but for now yay for the relative
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
#include "UIString.h"
|
||||
#include "HardwareSerial.h"
|
||||
#include "UIComponent.h"
|
||||
#include <Arduino_GFX.h>
|
||||
|
||||
UIString::UIString() : UIElement(nullptr, {0, 0, 0, 0}, nullptr, (char *)"") {
|
||||
this->type = STRING;
|
||||
memset(this->value, 0, this->bufferSize);
|
||||
}
|
||||
|
||||
UIString::UIString(Arduino_GFX *d, UIDimensions dims, UIDecorations *decor,
|
||||
char *title)
|
||||
: UIElement(d, dims, decor, title) {
|
||||
this->type = STRING;
|
||||
memset(this->value, 0, this->bufferSize);
|
||||
}
|
||||
|
||||
void UIString::Update(const char *v) {
|
||||
@@ -30,13 +33,17 @@ void UIString::Update(const char *v) {
|
||||
}
|
||||
|
||||
char newVal[this->bufferSize];
|
||||
memset(newVal, 0, this->bufferSize);
|
||||
// strncpy(newVal, v, this->bufferSize - 1);
|
||||
sprintf(newVal, "%s", v);
|
||||
|
||||
char oldVal[this->bufferSize];
|
||||
memset(oldVal, 0, this->bufferSize);
|
||||
// strncpy(oldVal, v, this->bufferSize - 1);
|
||||
sprintf(oldVal, "%s", this->value);
|
||||
|
||||
// Figure out the x0 and y0 for the text
|
||||
replaceString(oldVal, newVal);
|
||||
|
||||
replaceString(oldVal, newVal); // <- It crashes here somewhere
|
||||
//
|
||||
strncpy(this->value, v, this->bufferSize);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user