upython.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. Action action = ActionNone;
  12. FuriString* file_path = NULL;
  13. int32_t upython(void* args) {
  14. mp_flipper_cli_register(args);
  15. do {
  16. switch(action) {
  17. case ActionNone:
  18. action = mp_flipper_splash_screen();
  19. break;
  20. case ActionOpen:
  21. if(mp_flipper_select_python_file(file_path)) {
  22. action = ActionExec;
  23. } else {
  24. furi_string_set(file_path, APP_ASSETS_PATH("upython"));
  25. }
  26. break;
  27. case ActionRepl:
  28. break;
  29. case ActionExec:
  30. mp_flipper_file_execute(file_path);
  31. furi_string_set(file_path, APP_ASSETS_PATH("upython"));
  32. action = ActionNone;
  33. break;
  34. case ActionExit:
  35. break;
  36. }
  37. furi_delay_ms(1);
  38. } while(action != ActionExit);
  39. mp_flipper_cli_unregister(args);
  40. return 0;
  41. }