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

Method tick

Tactility/Source/service/displayidle/DisplayIdle.cpp:126–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126void DisplayIdleService::tick() {
127 if (!lvgl::lock(100)) {
128 return;
129 }
130 if (lv_display_get_default() == nullptr) {
131 lvgl::unlock();
132 return;
133 }
134
135 // Check for settings reload request (thread-safe)
136 if (settingsReloadRequested.exchange(false, std::memory_order_acquire)) {
137 cachedDisplaySettings = settings::display::loadOrGetDefault();
138 }
139
140 uint32_t inactive_ms = 0;
141
142 inactive_ms = lv_display_get_inactive_time(nullptr);
143
144 // Only update if not stopping (prevents lag on touch)
145 if (displayDimmed && screensaverOverlay && !stopScreensaverRequested.load(std::memory_order_acquire)) {
146 // Check if screensaver should auto-off after 5 minutes
147 if (!backlightOff) {
148 screensaverActiveCounter++;
149 if (screensaverActiveCounter >= SCREENSAVER_AUTO_OFF_TICKS) {
150 // Stop screensaver animation and turn off backlight
151 if (screensaver) {
152 screensaver->stop();
153 screensaver.reset();
154 }
155 auto display = getDisplay();
156 if (display) {
157 display->setBacklightDuty(0);
158 }
159 backlightOff = true;
160 } else {
161 updateScreensaver();
162 }
163 }
164 }
165
166 lvgl::unlock();
167
168 // Check stop request early for faster response
169 if (stopScreensaverRequested.load(std::memory_order_acquire)) {
170 stopScreensaver();
171 return;
172 }
173
174 auto display = getDisplay();
175 if (display != nullptr && display->supportsBacklightDuty()) {
176 if (!cachedDisplaySettings.backlightTimeoutEnabled || cachedDisplaySettings.backlightTimeoutMs == 0) {
177 if (displayDimmed) {
178 display->setBacklightDuty(cachedDisplaySettings.backlightDuty);
179 displayDimmed = false;
180 }
181 } else {
182 if (!displayDimmed && inactive_ms >= cachedDisplaySettings.backlightTimeoutMs) {
183 if (!lvgl::lock(100)) {

Callers 1

onStartMethod · 0.95

Calls 9

getDisplayFunction · 0.85
loadMethod · 0.80
lockFunction · 0.50
unlockFunction · 0.50
loadOrGetDefaultFunction · 0.50
stopMethod · 0.45
resetMethod · 0.45
setBacklightDutyMethod · 0.45
supportsBacklightDutyMethod · 0.45

Tested by

no test coverage detected