Skip to content

Commit

Permalink
Update: SD-Updater corresponds to jpg/json dir in bin dir.
Browse files Browse the repository at this point in the history
  • Loading branch information
lovyan03 committed Apr 1, 2019
1 parent 194a38b commit f7b8dee
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
Binary file modified LovyanLauncher/build/LovyanLauncher.bin
Binary file not shown.
11 changes: 5 additions & 6 deletions LovyanLauncher/src/CBSDUpdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ class CBSDUpdater : public MenuCallBack
M5.Lcd.drawFastHLine(0, 10 + i, M5.Lcd.width(), i << 1);
}
M5.Lcd.drawString("SD Updater : " + mi->name, 10, 10, 2);

iconName = "/jpg/" + mi->name + ".jpg";
faceName = "/jpg/" + mi->name + "_gh.jpg";
metaName = "/json/" + mi->name + ".json";

iconName = mi->getSubFilePath("jpg", ".jpg");
faceName = mi->getSubFilePath("jpg", "_gh.jpg");
metaName = mi->getSubFilePath("json", ".json");
/*
File file = SD.open( mi->path );
fileSize = file.size();
file.close();

*/
hasIcon = SD.exists(iconName.c_str());
hasMeta = SD.exists(metaName.c_str());
hasFace = SD.exists(faceName.c_str());
Expand Down
15 changes: 13 additions & 2 deletions LovyanLauncher/src/MenuItemSDUpdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void MenuItemSDUpdater::onEnter() {
if (lastBin == fn) setFocusItem(mi);
}
} else {
if (fn.endsWith("bin")) {
if (fn.startsWith("bin") || fn.endsWith("bin")) {
addItem(new MenuItemSDUpdater(fn, ptmp, true, ""));
}
}
Expand All @@ -52,9 +52,20 @@ void MenuItemSDUpdater::onEnter() {
MenuItem::onEnter();
}

String MenuItemSDUpdater::getSubFilePath(String subDir, String suffix) {
MenuItemSDUpdater* pi = static_cast<MenuItemSDUpdater*>(_parentItem);
if (pi && pi->path.length()) {
String filename = pi->path + "/" + subDir + "/" + name + suffix;
if (SD.exists(filename.c_str())) {
return filename;
}
}
return "/" + subDir + "/" + name + suffix;
}

void MenuItemSDUpdater::onFocus() {
if (name.length()) {
String filename = "/jpg/" + name + ".jpg";
String filename = getSubFilePath("jpg", ".jpg");
if (SD.exists(filename.c_str())) {
M5.Lcd.drawJpgFile(SD, filename.c_str(), 200, 40);
} else {
Expand Down
2 changes: 2 additions & 0 deletions LovyanLauncher/src/MenuItemSDUpdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class MenuItemSDUpdater : public MenuItemSD {
MenuItemSDUpdater(const String& t, const String& p, bool isdir, const String& n)
: MenuItemSD(t, p, isdir), name(n) {};

String getSubFilePath(String subDir, String suffix);

virtual void onFocus();
virtual void onDefocus();
virtual void onEnter();
Expand Down

0 comments on commit f7b8dee

Please sign in to comment.