app.cpp 1.1 KB

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