app.cpp 1.2 KB

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