app.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include <stdio.h>
  2. extern "C" {
  3. #include "flipper.h"
  4. #include "log.h"
  5. #include "applications.h"
  6. #include "tty_uart.h"
  7. }
  8. // for testing purpose
  9. uint32_t exitcode = 0;
  10. extern "C" void set_exitcode(uint32_t _exitcode) {
  11. exitcode = _exitcode;
  12. }
  13. extern "C" int app() {
  14. register_tty_uart();
  15. FuriRecordSubscriber* log = get_default_log();
  16. fuprintf(log, "\n=== Welcome to Flipper Zero! ===\n\n");
  17. // FURI startup
  18. const size_t flipper_app_count = sizeof(FLIPPER_STARTUP) / sizeof(FLIPPER_STARTUP[0]);
  19. FuriApp* handlers[flipper_app_count];
  20. for(size_t i = 0; i < flipper_app_count; i++) {
  21. // TODO create a dependency tree and run tasks in the desired order
  22. furiac_wait_libs(&FLIPPER_STARTUP[i].libs);
  23. handlers[i] = furiac_start(FLIPPER_STARTUP[i].app, FLIPPER_STARTUP[i].name, NULL);
  24. }
  25. bool is_alive = false;
  26. do {
  27. is_alive = false;
  28. for(size_t i = 0; i < flipper_app_count; i++) {
  29. if(handlers[i]->handler != NULL) {
  30. is_alive = true;
  31. }
  32. }
  33. delay(500);
  34. } while(is_alive);
  35. fuprintf(log, "\n=== Bye from Flipper Zero! ===\n\n");
  36. return (int)exitcode;
  37. }