mp_flipper_app.c 1019 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include <malloc.h>
  2. #include <furi.h>
  3. #include <dialogs/dialogs.h>
  4. #include <storage/storage.h>
  5. #include <mp_flipper_runtime.h>
  6. #include "mp_flipper_app.h"
  7. #include "py_app.h"
  8. const char* root_module_path;
  9. ViewPort* mp_flipper_view_port;
  10. FuriMessageQueue* mp_flipper_event_queue;
  11. static bool select_python_file(FuriString* file_path) {
  12. DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
  13. DialogsFileBrowserOptions browser_options;
  14. dialog_file_browser_set_basic_options(&browser_options, "py", NULL);
  15. browser_options.hide_ext = false;
  16. browser_options.base_path = STORAGE_APP_DATA_PATH_PREFIX;
  17. bool result = dialog_file_browser_show(dialogs, file_path, file_path, &browser_options);
  18. furi_record_close(RECORD_DIALOGS);
  19. return result;
  20. }
  21. int32_t mp_flipper_app(void* p) {
  22. UNUSED(p);
  23. FuriString* file_path = furi_string_alloc();
  24. if(select_python_file(file_path)) {
  25. py_app_file_execute(file_path);
  26. }
  27. furi_string_free(file_path);
  28. return 0;
  29. }