app.cpp 928 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "flipper.h"
  2. #include <stdio.h>
  3. extern "C" {
  4. #include "startup.h"
  5. #include "furi.h"
  6. #include "log.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. FuriApp* handlers[sizeof(FLIPPER_STARTUP) / sizeof(FLIPPER_STARTUP[0])];
  15. for(size_t i = 0; i < sizeof(FLIPPER_STARTUP) / sizeof(FLIPPER_STARTUP[0]); i++) {
  16. handlers[i] = furiac_start(FLIPPER_STARTUP[i].app, FLIPPER_STARTUP[i].name, NULL);
  17. }
  18. bool is_alive = false;
  19. do {
  20. is_alive = false;
  21. for(size_t i = 0; i < sizeof(FLIPPER_STARTUP) / sizeof(FLIPPER_STARTUP[0]); i++) {
  22. if(handlers[i]->handler != NULL) {
  23. is_alive = true;
  24. }
  25. }
  26. delay(500);
  27. // TODO add deferred event queue here
  28. } while(is_alive);
  29. }