MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / BootApp

Class BootApp

Tactility/Source/app/boot/Boot.cpp:40–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40class BootApp : public App {
41
42 // Snapshot of hal::usb::isUsbBootMode(), taken before the boot thread starts and
43 // potentially clears the underlying flag via setupUsbBootMode()/resetUsbBootMode().
44 // onShow() reads this instead of the live flag to avoid a race between the two.
45 static std::atomic<bool> isUsbBootSplash;
46
47 Thread thread = Thread(
48 "boot",
49 5120,
50 [] { return bootThreadCallback(); },
51 getCpuAffinityConfiguration().system
52 );
53
54 static void setupDisplay() {
55 const auto hal_display = getHalDisplay();
56 if (hal_display == nullptr) {
57 return;
58 }
59
60 settings::display::DisplaySettings settings;
61 if (settings::display::load(settings)) {
62 if (hal_display->getGammaCurveCount() > 0) {
63 hal_display->setGammaCurve(settings.gammaCurve);
64 LOGGER.info("Gamma curve {}", settings.gammaCurve);
65 }
66 } else {
67 settings = settings::display::getDefault();
68 }
69
70 if (hal_display->supportsBacklightDuty()) {
71 LOGGER.info("Backlight {}", settings.backlightDuty);
72 hal_display->setBacklightDuty(settings.backlightDuty);
73 } else {
74 LOGGER.info("No backlight");
75 }
76 }
77
78 static bool setupUsbBootMode() {
79 if (!hal::usb::isUsbBootMode()) {
80 return false;
81 }
82
83 LOGGER.info("Rebooting into mass storage device mode");
84 auto mode = hal::usb::getUsbBootMode(); // Get mode before reset
85 hal::usb::resetUsbBootMode();
86 if (mode == hal::usb::BootMode::Flash) {
87 if (!hal::usb::startMassStorageWithFlash(true)) {
88 LOGGER.error("Unable to start flash mass storage");
89 return false;
90 }
91 } else if (mode == hal::usb::BootMode::Sdmmc) {
92 if (!hal::usb::startMassStorageWithSdmmc(true)) {
93 LOGGER.error("Unable to start SD mass storage");
94 return false;
95 }
96 }
97

Callers

nothing calls this directly

Calls 1

ThreadClass · 0.50

Tested by

no test coverage detected