| 327 | } |
| 328 | |
| 329 | void run(const Configuration& config, Module* dtsModules[], DtsDevice dtsDevices[]) { |
| 330 | LOGGER.info("Tactility v{} on {} ({})", TT_VERSION, CONFIG_TT_DEVICE_NAME, CONFIG_TT_DEVICE_ID); |
| 331 | |
| 332 | assert(config.hardware); |
| 333 | |
| 334 | LOGGER.info("Initializing kernel"); |
| 335 | if (kernel_init(dtsModules, dtsDevices) != ERROR_NONE) { |
| 336 | LOGGER.error("Failed to initialize kernel"); |
| 337 | return; |
| 338 | } |
| 339 | |
| 340 | // hal-device-module |
| 341 | check(module_construct_add_start(&hal_device_module) == ERROR_NONE); |
| 342 | |
| 343 | // Assign early so starting services can use it |
| 344 | config_instance = &config; |
| 345 | |
| 346 | #ifdef ESP_PLATFORM |
| 347 | initEsp(); |
| 348 | #endif |
| 349 | file::setFindLockFunction(file::findLock); |
| 350 | settings::initTimeZone(); |
| 351 | hal::init(*config.hardware); |
| 352 | network::ntp::init(); |
| 353 | bluetooth::systemStart(); |
| 354 | |
| 355 | registerAndStartPrimaryServices(); |
| 356 | |
| 357 | lvgl_module_configure((LvglModuleConfig) { |
| 358 | .on_start = lvgl::attachDevices, |
| 359 | .on_stop = lvgl::detachDevices, |
| 360 | .task_priority = THREAD_PRIORITY_HIGHER, |
| 361 | /** Minimum seems to be about 3500. In some scenarios, the WiFi app crashes at 8192, |
| 362 | * so we now have 9120 to run in a stable manner. We should figure out a way to avoid this. |
| 363 | * Perhaps we can give apps their own stack space and deal with lvgl callback handlers in a clever way. */ |
| 364 | .task_stack_size = 9120, |
| 365 | #ifdef ESP_PLATFORM |
| 366 | .task_affinity = getCpuAffinityConfiguration().graphics |
| 367 | #endif |
| 368 | }); |
| 369 | check(module_construct(&lvgl_module) == ERROR_NONE); |
| 370 | check(module_add(&lvgl_module) == ERROR_NONE); |
| 371 | lvgl::start(); |
| 372 | |
| 373 | registerAndStartSecondaryServices(); |
| 374 | |
| 375 | LOGGER.info("Core systems ready"); |
| 376 | |
| 377 | LOGGER.info("Starting boot app"); |
| 378 | // The boot app takes care of registering system apps, user services and user apps |
| 379 | addAppManifest(app::boot::manifest); |
| 380 | app::start(app::boot::manifest.appId); |
| 381 | |
| 382 | LOGGER.info("Main dispatcher ready"); |
| 383 | while (true) { |
| 384 | mainDispatcher.consume(); |
| 385 | } |
| 386 | } |