mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps/main] Add open app option
This commit is contained in:
@@ -37,7 +37,8 @@ AppsContainer::AppsContainer() :
|
||||
m_homeSnapshot(),
|
||||
m_onBoardingSnapshot(),
|
||||
m_hardwareTestSnapshot(),
|
||||
m_usbConnectedSnapshot()
|
||||
m_usbConnectedSnapshot(),
|
||||
m_startAppSnapshot()
|
||||
{
|
||||
m_emptyBatteryWindow.setFrame(KDRect(0, 0, Ion::Display::Width, Ion::Display::Height), false);
|
||||
// #if __EMSCRIPTEN__
|
||||
@@ -346,7 +347,13 @@ void AppsContainer::run() {
|
||||
/* Normal execution. The exception checkpoint must be created before
|
||||
* switching to the first app, because the first app might create nodes on
|
||||
* the pool. */
|
||||
bool switched = switchTo(initialAppSnapshot());
|
||||
bool switched;
|
||||
if (m_startAppSnapshot != nullptr) {
|
||||
switched = switchTo(m_startAppSnapshot);
|
||||
} else {
|
||||
switched = switchTo(initialAppSnapshot());
|
||||
}
|
||||
|
||||
assert(switched);
|
||||
(void) switched; // Silence compilation warning about unused variable.
|
||||
} else {
|
||||
|
||||
@@ -59,6 +59,9 @@ public:
|
||||
// Ion::StorageDelegate
|
||||
void storageDidChangeForRecord(const Ion::Storage::Record record) override;
|
||||
void storageIsFull() override;
|
||||
#ifdef EPSILON_GETOPT
|
||||
void setStartApp(App::Snapshot * snapshot) { m_startAppSnapshot = snapshot; }
|
||||
#endif
|
||||
protected:
|
||||
Home::App::Snapshot * homeAppSnapshot() { return &m_homeSnapshot; }
|
||||
private:
|
||||
@@ -89,6 +92,9 @@ private:
|
||||
HardwareTest::App::Snapshot m_hardwareTestSnapshot;
|
||||
USB::App::Snapshot m_usbConnectedSnapshot;
|
||||
XNTLoop m_XNTLoop;
|
||||
#ifdef EPSILON_GETOPT
|
||||
App::Snapshot * m_startAppSnapshot;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "apps_container.h"
|
||||
#include "global_preferences.h"
|
||||
#include <poincare/init.h>
|
||||
#include <string.h>
|
||||
|
||||
#define DUMMY_MAIN 0
|
||||
#if DUMMY_MAIN
|
||||
@@ -50,13 +51,29 @@ void ion_main(int argc, const char * const argv[]) {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Option should be given at run-time:
|
||||
* $ ./epsilon.elf --open-app code
|
||||
*/
|
||||
const char * appNames[] = {"home", EPSILON_APPS_NAMES};
|
||||
if (strcmp(argv[i], "--open-app") == 0 && argc > i+1) {
|
||||
const char * requestedAppName = argv[i+1];
|
||||
for (int j = 0; j < AppsContainer::sharedAppsContainer()->numberOfApps(); j++) {
|
||||
App::Snapshot * snapshot = AppsContainer::sharedAppsContainer()->appSnapshotAtIndex(j);
|
||||
if (strcmp(requestedAppName, appNames[j]) == 0) {
|
||||
AppsContainer::sharedAppsContainer()->setStartApp(snapshot);
|
||||
break;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Option should be given at run-time:
|
||||
* $ ./epsilon.elf --[app_name]-[option] [arguments]
|
||||
* For example:
|
||||
* $ make -j8 PLATFORM=emscripten EPSILON_APPS=code
|
||||
* $ ./epsilon.elf --code-script hello_world.py:print("hello") --code-lock-on-console
|
||||
*/
|
||||
const char * appNames[] = {"home", EPSILON_APPS_NAMES};
|
||||
for (int j = 0; j < AppsContainer::sharedAppsContainer()->numberOfApps(); j++) {
|
||||
App::Snapshot * snapshot = AppsContainer::sharedAppsContainer()->appSnapshotAtIndex(j);
|
||||
// Compare name in order to find if the firsts chars which are different are NULL and '-'
|
||||
|
||||
Reference in New Issue
Block a user