app.cpp 1.2 KB

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