fix text set deletion

This commit is contained in:
Dorian Zedler 2020-10-15 12:50:50 +02:00
parent ef9c0c9261
commit ac7659614b
Signed by: dorian
GPG key ID: D3B255CB8BC7CD37
3 changed files with 15 additions and 17 deletions

View file

@ -89,10 +89,6 @@ private:
class BluetoothLeUartServerCallbacks
{
public:
virtual ~BluetoothLeUartServerCallbacks(){};
const char *test = "testlol";
virtual void onDeviceConnectedChanged(bool deviceConnected);
virtual void onDataReceived(String data);
};

View file

@ -101,6 +101,7 @@ private:
} sets_t;
// storage variables
const text_set_t defaultTextSet {"", false, 0, "", AlignCenter, false, 0, 0};
sets_t text_sets;
// storage control

View file

@ -194,8 +194,19 @@ LedDisplayController::GetSetTextSetParameterExitCode LedDisplayController::getSe
switch (parameter)
{
case TextParameter:
if (set)
strncpy(currentTextSet->text, value->c_str(), sizeof(currentTextSet->text));
if (set) {
if(*value == "")
// delete the index
for (int i = index; i < this->maximumTextSets; i++)
{
if(i > this->maximumTextSets - 1)
this->text_sets.sets[i] = this->text_sets.sets[i+1];
else
this->text_sets.sets[i] = this->defaultTextSet;
}
else
strncpy(currentTextSet->text, value->c_str(), sizeof(currentTextSet->text));
}
else
returnValue = String(currentTextSet->text);
break;
@ -320,17 +331,7 @@ bool LedDisplayController::loadTextSets()
for (int i = 0; i < this->maximumTextSets; i++)
{
text_set_t defaultTextSet{
"",
false,
0,
"",
AlignCenter,
false,
0,
0};
defaultTextSets.sets[i] = defaultTextSet;
defaultTextSets.sets[i] = this->defaultTextSet;
}
this->text_sets = defaultTextSets;