| 37 | } |
| 38 | |
| 39 | bool initBoot() { |
| 40 | LOGGER.info(LOG_MESSAGE_POWER_ON_START); |
| 41 | if (!powerOn()) { |
| 42 | LOGGER.error(LOG_MESSAGE_POWER_ON_FAILED); |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | /* 32 Khz and higher gives an issue where the screen starts dimming again above 80% brightness |
| 47 | * when moving the brightness slider rapidly from a lower setting to 100%. |
| 48 | * This is not a slider bug (data was debug-traced) */ |
| 49 | if (!driver::pwmbacklight::init(GPIO_NUM_42, 30000)) { |
| 50 | LOGGER.error("Backlight init failed"); |
| 51 | return false; |
| 52 | } |
| 53 | |
| 54 | tt::kernel::subscribeSystemEvent(tt::kernel::SystemEvent::BootSplash, [](tt::kernel::SystemEvent event) { |
| 55 | auto gps_service = tt::service::gps::findGpsService(); |
| 56 | if (gps_service != nullptr) { |
| 57 | std::vector<tt::hal::gps::GpsConfiguration> gps_configurations; |
| 58 | gps_service->getGpsConfigurations(gps_configurations); |
| 59 | if (gps_configurations.empty()) { |
| 60 | if (gps_service->addGpsConfiguration(tt::hal::gps::GpsConfiguration {.uartName = "uart0", .baudRate = 38400, .model = tt::hal::gps::GpsModel::UBLOX10})) { |
| 61 | LOGGER.info("Configured internal GPS"); |
| 62 | } else { |
| 63 | LOGGER.error("Failed to configure internal GPS"); |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | }); |
| 68 | |
| 69 | tt::kernel::subscribeSystemEvent(tt::kernel::SystemEvent::BootSplash, [](tt::kernel::SystemEvent event) { |
| 70 | auto kbBacklight = tt::hal::findDevice("Keyboard Backlight"); |
| 71 | if (kbBacklight != nullptr) { |
| 72 | LOGGER.info("{} starting", kbBacklight->getName()); |
| 73 | auto kbDevice = std::static_pointer_cast<KeyboardBacklightDevice>(kbBacklight); |
| 74 | if (kbDevice->start()) { |
| 75 | LOGGER.info("{} started", kbBacklight->getName()); |
| 76 | } else { |
| 77 | LOGGER.error("{} start failed", kbBacklight->getName()); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | auto trackball = tt::hal::findDevice("Trackball"); |
| 82 | if (trackball != nullptr) { |
| 83 | LOGGER.info("{} starting", trackball->getName()); |
| 84 | auto tbDevice = std::static_pointer_cast<TrackballDevice>(trackball); |
| 85 | if (tbDevice->start()) { |
| 86 | LOGGER.info("{} started", trackball->getName()); |
| 87 | } else { |
| 88 | LOGGER.error("{} start failed", trackball->getName()); |
| 89 | } |
| 90 | } |
| 91 | }); |
| 92 | |
| 93 | return true; |
| 94 | } |
nothing calls this directly
no test coverage detected