upython.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include <malloc.h>
  2. #include <furi.h>
  3. #include <gui/gui.h>
  4. #include <dialogs/dialogs.h>
  5. #include <storage/storage.h>
  6. #include <cli/cli.h>
  7. #include <cli/cli_vcp.h>
  8. #include <mp_flipper_runtime.h>
  9. #include <mp_flipper_compiler.h>
  10. #include "upython.h"
  11. int32_t upython(void* args) {
  12. if(args == NULL) {
  13. mp_flipper_repl_register();
  14. } else {
  15. action = ActionOpen;
  16. }
  17. do {
  18. if(args == NULL && mp_flipper_splash_screen() == ActionExit) {
  19. break;
  20. }
  21. if(action == ActionOpen) {
  22. FuriString* file_path = NULL;
  23. if(args != NULL) {
  24. file_path = furi_string_alloc_set_str(args);
  25. } else {
  26. file_path = furi_string_alloc_set_str(APP_ASSETS_PATH("upython"));
  27. }
  28. if(args != NULL || mp_flipper_select_python_file(file_path)) {
  29. mp_flipper_file_execute(file_path);
  30. }
  31. furi_string_free(file_path);
  32. }
  33. if(args != NULL) {
  34. break;
  35. }
  36. } while(true);
  37. if(args == NULL) {
  38. mp_flipper_repl_unregister();
  39. }
  40. return 0;
  41. }