Skip to content

Commit

Permalink
Small runtime improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueAndi committed Dec 14, 2023
1 parent f57898d commit b0990b0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
12 changes: 7 additions & 5 deletions lib/IconTextLampPlugin/src/IconTextLampPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,18 +445,20 @@ void IconTextLampPlugin::start(uint16_t width, uint16_t height)

void IconTextLampPlugin::stop()
{
MutexGuard<MutexRecursive> guard(m_mutex);
String bitmapFullPath = getFileName(FILE_EXT_BITMAP);
String spriteSheetFullPath = getFileName(FILE_EXT_SPRITE_SHEET);
MutexGuard<MutexRecursive> guard(m_mutex);

/* Remove icon which is specific for the plugin instance. */
if (false != FILESYSTEM.remove(getFileName(FILE_EXT_BITMAP)))
if (false != FILESYSTEM.remove(bitmapFullPath))
{
LOG_INFO("File %s removed", getFileName(FILE_EXT_BITMAP).c_str());
LOG_INFO("File %s removed", bitmapFullPath.c_str());
}

/* Remove spritesheet which is specific for the plugin instance. */
if (false != FILESYSTEM.remove(getFileName(FILE_EXT_SPRITE_SHEET)))
if (false != FILESYSTEM.remove(spriteSheetFullPath))
{
LOG_INFO("File %s removed", getFileName(FILE_EXT_SPRITE_SHEET).c_str());
LOG_INFO("File %s removed", spriteSheetFullPath.c_str());
}
}

Expand Down
12 changes: 7 additions & 5 deletions lib/IconTextPlugin/src/IconTextPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,18 +322,20 @@ void IconTextPlugin::start(uint16_t width, uint16_t height)

void IconTextPlugin::stop()
{
MutexGuard<MutexRecursive> guard(m_mutex);
String bitmapFullPath = getFileName(FILE_EXT_BITMAP);
String spriteSheetFullPath = getFileName(FILE_EXT_SPRITE_SHEET);
MutexGuard<MutexRecursive> guard(m_mutex);

/* Remove icon which is specific for the plugin instance. */
if (false != FILESYSTEM.remove(getFileName(FILE_EXT_BITMAP)))
if (false != FILESYSTEM.remove(bitmapFullPath))
{
LOG_INFO("File %s removed", getFileName(FILE_EXT_BITMAP).c_str());
LOG_INFO("File %s removed", bitmapFullPath.c_str());
}

/* Remove spritesheet which is specific for the plugin instance. */
if (false != FILESYSTEM.remove(getFileName(FILE_EXT_SPRITE_SHEET)))
if (false != FILESYSTEM.remove(spriteSheetFullPath))
{
LOG_INFO("File %s removed", getFileName(FILE_EXT_SPRITE_SHEET).c_str());
LOG_INFO("File %s removed", spriteSheetFullPath.c_str());
}
}

Expand Down
27 changes: 16 additions & 11 deletions lib/ThreeIconPlugin/src/ThreeIconPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ void ThreeIconPlugin::start(uint16_t width, uint16_t height)

for(iconId = 0U; iconId < MAX_ICONS; ++iconId)
{
int16_t x = (ICON_WIDTH + DISTANCE) * iconId + DISTANCE;
int16_t x = (ICON_WIDTH + DISTANCE) * iconId + DISTANCE;
String bitmapFullPath = getFileName(iconId, FILE_EXT_BITMAP);
String spriteSheetFullPath = getFileName(iconId, FILE_EXT_SPRITE_SHEET);

(void)m_threeIconCanvas.addWidget(m_bitmapWidgets[iconId]);
m_bitmapWidgets[iconId].move(x, 0);
Expand All @@ -364,17 +366,17 @@ void ThreeIconPlugin::start(uint16_t width, uint16_t height)
m_iconPaths[iconId].clear();
m_spriteSheetPaths[iconId].clear();

if (false == m_bitmapWidgets[iconId].loadSpriteSheet(FILESYSTEM, getFileName(iconId, FILE_EXT_SPRITE_SHEET), getFileName(iconId, FILE_EXT_BITMAP)))
if (false == m_bitmapWidgets[iconId].loadSpriteSheet(FILESYSTEM, spriteSheetFullPath, bitmapFullPath))
{
if (true == m_bitmapWidgets[iconId].load(FILESYSTEM, getFileName(iconId, FILE_EXT_BITMAP)))
if (true == m_bitmapWidgets[iconId].load(FILESYSTEM, bitmapFullPath))
{
m_iconPaths[iconId] = getFileName(iconId, FILE_EXT_BITMAP);
m_iconPaths[iconId] = bitmapFullPath;
}
}
else
{
m_iconPaths[iconId] = getFileName(iconId, FILE_EXT_BITMAP);
m_spriteSheetPaths[iconId] = getFileName(iconId, FILE_EXT_SPRITE_SHEET);
m_iconPaths[iconId] = bitmapFullPath;
m_spriteSheetPaths[iconId] = spriteSheetFullPath;
}
}
}
Expand All @@ -385,15 +387,18 @@ void ThreeIconPlugin::stop()
MutexGuard<MutexRecursive> guard(m_mutex);

for(iconId = 0U; iconId < MAX_ICONS; ++iconId)
{
if (false != FILESYSTEM.remove(getFileName(iconId, FILE_EXT_BITMAP)))
{
String bitmapFullPath = getFileName(iconId, FILE_EXT_BITMAP);
String spriteSheetFullPath = getFileName(iconId, FILE_EXT_SPRITE_SHEET);

if (false != FILESYSTEM.remove(bitmapFullPath))
{
LOG_INFO("File %s removed", getFileName(iconId, FILE_EXT_BITMAP).c_str());
LOG_INFO("File %s removed", bitmapFullPath.c_str());
}

if (false != FILESYSTEM.remove(getFileName(iconId, FILE_EXT_SPRITE_SHEET)))
if (false != FILESYSTEM.remove(spriteSheetFullPath))
{
LOG_INFO("File %s removed", getFileName(iconId, FILE_EXT_SPRITE_SHEET).c_str());
LOG_INFO("File %s removed", spriteSheetFullPath.c_str());
}
}
}
Expand Down

0 comments on commit b0990b0

Please sign in to comment.