upython.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include <furi.h>
  2. #include <storage/storage.h>
  3. #include <mp_flipper_runtime.h>
  4. #include <mp_flipper_compiler.h>
  5. #include "upython.h"
  6. Action action = ActionNone;
  7. FuriString* file_path = NULL;
  8. void upython_reset_file_path() {
  9. furi_string_set(file_path, APP_ASSETS_PATH("upython"));
  10. }
  11. int32_t upython(void* args) {
  12. upython_cli_register(args);
  13. do {
  14. switch(action) {
  15. case ActionNone:
  16. action = upython_splash_screen();
  17. break;
  18. case ActionOpen:
  19. if(upython_select_python_file(file_path)) {
  20. action = ActionExec;
  21. } else {
  22. upython_reset_file_path();
  23. action = ActionNone;
  24. }
  25. break;
  26. case ActionRepl:
  27. break;
  28. case ActionExec:
  29. upython_file_execute(file_path);
  30. upython_reset_file_path();
  31. action = ActionNone;
  32. break;
  33. case ActionExit:
  34. action = upython_confirm_exit_action() ? ActionTerm : ActionNone;
  35. break;
  36. case ActionTerm:
  37. break;
  38. }
  39. furi_delay_ms(1);
  40. } while(action != ActionTerm);
  41. upython_cli_unregister(args);
  42. return 0;
  43. }