fix text set deletion
This commit is contained in:
parent
ef9c0c9261
commit
ac7659614b
3 changed files with 15 additions and 17 deletions
|
@ -89,10 +89,6 @@ private:
|
|||
class BluetoothLeUartServerCallbacks
|
||||
{
|
||||
public:
|
||||
virtual ~BluetoothLeUartServerCallbacks(){};
|
||||
|
||||
const char *test = "testlol";
|
||||
|
||||
virtual void onDeviceConnectedChanged(bool deviceConnected);
|
||||
virtual void onDataReceived(String data);
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue