Skip to content

Commit

Permalink
Load stored text/icon at start to view.
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueAndi committed Sep 12, 2024
1 parent 4cd132d commit 6fc3830
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
24 changes: 20 additions & 4 deletions lib/IconTextLampPlugin/src/IconTextLampPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ bool IconTextLampPlugin::getTopic(const String& topic, JsonObject& value) const

isSuccessful = true;
}
else if (0U != topic.startsWith(String(TOPIC_LAMP) + "/"))
else if (true == topic.startsWith(String(TOPIC_LAMP) + "/"))
{
uint32_t indexBeginLampId = topic.lastIndexOf("/") + 1U;
String lampIdStr = topic.substring(indexBeginLampId);
Expand Down Expand Up @@ -209,7 +209,7 @@ bool IconTextLampPlugin::setTopic(const String& topic, const JsonObjectConst& va
}
}
}
else if (0U != topic.startsWith(String(TOPIC_LAMP) + "/"))
else if (true == topic.startsWith(String(TOPIC_LAMP) + "/"))
{
uint32_t indexBeginLampId = topic.lastIndexOf("/") + 1U;
String lampIdStr = topic.substring(indexBeginLampId);
Expand Down Expand Up @@ -265,7 +265,7 @@ bool IconTextLampPlugin::hasTopicChanged(const String& topic)
hasTopicChanged = m_hasTopicLampsChanged;
m_hasTopicLampsChanged = false;
}
else if (0U != topic.startsWith(String(TOPIC_LAMP) + "/"))
else if (true == topic.startsWith(String(TOPIC_LAMP) + "/"))
{
uint32_t indexBeginLampId = topic.lastIndexOf("/") + 1U;
String lampIdStr = topic.substring(indexBeginLampId);
Expand All @@ -291,11 +291,27 @@ bool IconTextLampPlugin::hasTopicChanged(const String& topic)

void IconTextLampPlugin::start(uint16_t width, uint16_t height)
{
MutexGuard<MutexRecursive> guard(m_mutex);
String iconFullPath;
MutexGuard<MutexRecursive> guard(m_mutex);

m_view.init(width, height);

PluginWithConfig::start(width, height);

m_view.setFormatText(m_formatTextStored);

if (false == FileMgrService::getInstance().getFileFullPathById(iconFullPath, m_iconFileId))
{
LOG_WARNING("Unknown file id %u.", m_iconFileId);
}
else if (false == m_view.loadIcon(iconFullPath))
{
LOG_ERROR("Icon not found: %s", iconFullPath.c_str());
}
else
{
;
}
}

void IconTextLampPlugin::stop()
Expand Down
18 changes: 17 additions & 1 deletion lib/IconTextPlugin/src/IconTextPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,27 @@ bool IconTextPlugin::hasTopicChanged(const String& topic)

void IconTextPlugin::start(uint16_t width, uint16_t height)
{
MutexGuard<MutexRecursive> guard(m_mutex);
String iconFullPath;
MutexGuard<MutexRecursive> guard(m_mutex);

m_view.init(width, height);

PluginWithConfig::start(width, height);

m_view.setFormatText(m_formatTextStored);

if (false == FileMgrService::getInstance().getFileFullPathById(iconFullPath, m_iconFileId))
{
LOG_WARNING("Unknown file id %u.", m_iconFileId);
}
else if (false == m_view.loadIcon(iconFullPath))
{
LOG_ERROR("Icon not found: %s", iconFullPath.c_str());
}
else
{
;
}
}

void IconTextPlugin::stop()
Expand Down
3 changes: 2 additions & 1 deletion lib/JustTextPlugin/src/JustTextPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
*****************************************************************************/
#include "JustTextPlugin.h"

#include <FileSystem.h>
#include <Logging.h>
#include <ArduinoJson.h>

Expand Down Expand Up @@ -185,6 +184,8 @@ void JustTextPlugin::start(uint16_t width, uint16_t height)
m_view.init(width, height);

PluginWithConfig::start(width, height);

m_view.setFormatText(m_formatTextStored);
}

void JustTextPlugin::stop()
Expand Down

0 comments on commit 6fc3830

Please sign in to comment.