Repository navigation
Conversation
The phone draws about 4 W in use, and the panel stays wherever the slider was left: 85 % in a room of about 85 lux on my Pixel 7 Pro. The AoC's light sensor already reaches the system bus through omamobile-sensor-proxy (LightLevel in lux), but nothing read it. omamobile-autobrightness is a user service in the manner of omamobile-autorotate. While the screen is on it claims the light sensor and sets the backlight from a log-log curve: 3 nits in the dark, 25 at 10 lux, 110 at 100, 300 at 1000, the panel's 600 from 10000. That puts 85 lux at level 336 (99 nits) instead of 1740. The panel's range is the board's (PANELS): cheetah's from DISPLAY-PLAN 2.4, levels 4-2047 for about 2-600 nits, HBM above that left alone. Another board gets the same nits over its whole range, with a line in the journal, until it has an entry or a "panel" in ~/.config/omamobile/autobrightness.json. - Smoothing and hysteresis: a median of three readings drops a lone spike, then a log-domain average (up in about 1 s, down in about 3 s). The level moves only once the average and the median have both stayed beyond +26 % for 1.5 s, or beyond -29 % for 10 s. The sensor is under the panel, and a hand shades it in use: in a dim room it read 1-7 lux instead of about 14 for 7-8 s at a time, a few seconds apart, which a 5 s wait before dimming turned into a dim and a brighten again. - Ramps on a perceptual scale: up in a third of a second, down over about three seconds; the first reading after a wake applies at once. - A level the daemon didn't write (the quick-settings slider, brightnessctl) stops it at once: every write notifies actual_brightness, and it reads the level before each of its own writes. After 2 s the level becomes the user's point on the curve, Android-style: a gamma (1/3-3) on the panel's perceptual range bends the curve through it, blending over a decade where the gamma can't reach. The level stays where the user put it, the preference carries over to other light, daylight stays at the maximum, and the point is saved. A zero, a change from zero, a change while the panel is off and the first second after a wake (the power key's and the lock's) teach nothing. - A write that fails (logind refuses it or doesn't answer in 2 s) changes nothing the daemon believes: the panel's level stays, nothing is learned from it, and it tries again 5 s later. A timed-out write that lands after all is recognised as its own. - Screen off (bl_power not 0, or DSI DPMS not On; read once a second on GLib's whole-second timer, since neither is signalled): the light claim is released and nothing is written. - Writes go through logind's SetBrightness, as brightnessctl's do (2-10 ms each on the phone). With no backlight the service exits with status 78, which its unit doesn't restart. omamobile-toggle-autobrightness [toggle|on|off|status|reset] switches the service, as Omarchy's toggles do; status says whether there is a light sensor and a backlight. It is off by default, like auto-rotate. Tests: test/autobrightness.py, 27 unit tests on a fake clock: the curve and the user's point, the filter (with the phone's own readings of a hand over the sensor, and a burst of light that went away), the ramps, manual levels (also one the daemon wasn't told about, and one just after a wake), failed and late writes, the screen going off and on, a saved point, the board's panel range. Each test written for a fix fails without it. test/all also runs the toggle against stand-ins for systemctl and busctl, and a D-Bus round trip through the proxy's test backend with a directory standing in for the backlight. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n and a tile omamobile-sensors 0.2.2 adds omamobile-autobrightness, a user service that sets the backlight from the light sensor. Quick settings switch it the way the rotation lock tile switches auto-rotate: - the brightness row's icon (until now it did nothing on a tap) turns it on and off through omamobile-toggle-autobrightness, and shows the auto glyph while it runs; - an Auto brightness tile does the same. It is in the catalog, under "Add tiles", not in the default layout, so nobody's pages move. "Not installed" without the command, "No sensor" without a light sensor or a backlight. The slider keeps writing the backlight through brightnessctl while automatic brightness runs: the daemon takes a level set there as the user's point on its curve instead of undoing it. That needs nothing from the shell, so the slider's code is unchanged. omamobile-sensors is an optional dependency. The sheet reads the switch's state in its staggered open refresh (derekross#518), right after the brightness. Tests: test/all checks the icon, the toggle command, the status read and its wording, and the backend; tiles-model.js lists the new tile under "Add tiles"; quicksettings-refresh has the new step in its order. On the phone, test/quicksettings-render (pointed at the phone's own Omarchy shell and themes instead of the container's) drew the sheet with the tile first, off and on, with no QML errors: 184 checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
How omamobile-autobrightness (omamobile-sensors 0.2.2) was tested on a Pixel 7 Pro, run from the branch and not installed, with the daemon's version for each run: the light sensor through the proxy, writes through logind from a user service, the screen-off path, a dry run through a wake and three minutes of use (which found the hand over the sensor and changed the filter), and an attended run that wrote the backlight. The panel's own light didn't reach the lux; the slider's level stuck; display off and on released and claimed the sensor. What the review fixed after that ran in the unit tests only. Still to do: the installed packages, the icon and tile in the live shell, and a day of use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, @jkjoplin, this is a careful piece of work: the read-before-write so the slider always wins, the rule that changes to or from zero and changes around a wake teach nothing (I walked It merges onto today's main with only the version file to resolve. Both this and #635 say omamobile-shell 0.2.116, which main has used since this afternoon (it's at 0.2.117), so I'll set the number myself at merge; no need to renumber. Before I merge, I'll run the installed packages on my Pixel 7 Pro, since the head's daemon and the unit started from the toggle haven't run on a phone yet: off by default, a dry run, on from the icon, the slider, a dark room, a hand over the sensor, the power key (also during a dimming ramp), fingerprint unlock in the dark, a call, a sleep and a reboot. Things I'd like your view on meanwhile:
|
What and why
Nothing reads the AoC's light sensor, so the panel stays wherever the slider was left. My Pixel 7 Pro sat at 85 % (level 1740) in a room of about 85 lux and drew about 4 W in use. The sensor already reaches the system bus through
omamobile-sensor-proxy(LightLevelin lux, AOC-PLAN C6), so this adds the missing loop:omamobile-autobrightness, a user service inomamobile-sensorsmodelled onomamobile-autorotate, and a switch for it in the quick settings.The curve. The target luminance is interpolated in log-log space between (lux, nits) points, so equal ratios of light give equal steps of perceived brightness. The level comes from the panel's range in DISPLAY-PLAN 2.4 (levels 4-2047 for about 2-600 nits, taken as linear between them; 0 turns the pixels off, so 4 is the floor, and HBM above 2047 is left alone if a kernel ever offers it):
So 85 lux gets level 336 instead of 1740. The panel range is looked up by the board's compatible string (
PANELS; only cheetah has an entry). The Pixel 6 Pro also installsomamobile-sensorsand has a light sensor, so it gets the tile too; there the same nits are spread over its whole backlight range from level 1, with a line in the journal, until it has an entry or a"panel"in~/.config/omamobile/autobrightness.json. I don't know raven's panel range.Smoothing, hysteresis, ramps. A median of the last three readings drops a lone spike; a log-domain average (up in about 1 s, down in about 3 s) follows. The level moves only when the average and the median have both stayed beyond +26 % for 1.5 s, or beyond -29 % for 10 s. The long wait before dimming is because the sensor is under the panel and a hand shades it in use (below). The backlight then moves on a perceptual scale: up in about a third of a second, down over about three seconds; the first reading after a wake applies at once.
A manual change is a preference, not a fight. Any write the daemon didn't make (the slider's
brightnessctl, anything else) stops it at once: every brightness write notifiesactual_brightness, and it reads the level again before each of its own writes. After 2 s the level becomes the user's point on the curve, in the manner of Android's auto-brightness adjustment: a gamma (1/3-3) on the panel's perceptual range bends the curve through it, and where the gamma can't reach, the curve blends into the point over a decade of lux. The level stays exactly where the user put it, the preference carries over to other light, the panel's ends stay put (daylight is still the maximum), and the point is saved in~/.local/state/omamobile/autobrightness.json. The power key's and the lock's changes teach nothing: a zero, a change from zero (omamobile-keysputs 40 % back when a wake finds the panel at 0), a change while the panel is off, and anything in the first second after a wake.Writes go through logind's
SetBrightnessonsession/auto, asbrightnessctldoes for the slider:brightnessis root's, onlybl_poweris the video group's. A write that fails (logind refusing, or no answer in 2 s) changes nothing the daemon believes: the panel keeps its level, nothing is learned from it, and it retries 5 s later; a timed-out write that lands after all is recognised as its own.Screen off.
bl_powernot 0, or the DSI connector's DPMS not On. Neither is signalled (Hyprland 0.57 has no DPMS event on its socket, and neither sysfs file notifies), so it reads both once a second, on GLib's whole-second timer. While the panel is off it releases the light claim, so the proxy stops the sensor, and writes nothing. With no backlight at all the service exits with status 78, which its unit doesn't restart.Switching it.
omamobile-toggle-autobrightness [toggle|on|off|status|reset], in the manner of Omarchy's toggles. In the quick settings, the brightness row's icon (which did nothing on a tap) switches it and shows while it runs, and an "Auto brightness" tile does the same; the tile is in the catalog under "Add tiles", not in the default layout, so nobody's pages move. It says "Not installed" without the toggle and "No sensor" without a light sensor or a backlight. The sheet reads its state as a new step in #518's staggered open refresh, right after the brightness. The slider's code is unchanged: with the service on, its level becomes the daemon's point. The service is off by default, like auto-rotate; whether new installs should get it on is your call.Device and build
uname -r):7.3.0-rc6-omamobile-g2219cc6cda77Checks (no phone needed)
tools/pr-check origin/mainpassestests/allpasses, except three parts that need a kernel build setup, which the phone I ran them on doesn't have:tests/kernel-pr-check("the kernel config doesn't configure", then "a new board with a sibling's message"),tests/boot-method("display-msm should log not stamping on empty tree") andtests/release("asks for the boot record of the exact release"). All three fail the same way in a clean checkout oforigin/mainon the same phone, and this change touches none of what they test. I ran every part afterkernel-pr-checkseparately, sincetests/allstops at the first failure.tests/packagespasses, 30 of 31 suites, omamobile-sensors and omamobile-shell among them. The one that fails is omamobile-settings: its test builds the app withmake, which the phone I ran it on doesn't have ("make: command not found"), and this change doesn't touch that package.versionbumped, and the new version is in the commit subjectCo-Authored-By:orAssisted-by:trailer, never aSigned-off-by:test/autobrightness.py(27 unit tests on a fake clock, needing no D-Bus or phone) covers the curve and the user's point (exact at every lux and level on a grid, monotonic, the gamma within its limits, daylight staying at the maximum, a saved gamma held to its range), the board's panel range, the filter (steady-room noise, steps up and down, a spike, flicker, a reading that is never repeated), the ramps, and the controller: a slider level becoming the user's point with no writes while it settles and none afterwards, the slider winning during a ramp, a change the daemon wasn't told about, a slider moved just after a wake, writes that fail or land late, the screen going off and on, a wake from level 0, and a saved point coming back. Each test written for a fix fails against the code before it: I ran them against the previous version, and the one for the check before each write against a copy without that check.test/allalso runs the toggle against stand-ins forsystemctlandbusctl(with and without a backlight), and a D-Bus round trip through the proxy's test backend with a directory standing in for the backlight: it follows the light, releases the sensor whilebl_poweris 4, claims it again, and keeps a level written by hand. For the shell,test/allchecks the icon, the toggle command, the status read and its wording, and the backend;tiles-model.jslists the new tile under "Add tiles";quicksettings-refreshhas the new step in its order.On the phone
lib/autobrightness.pyran there: the first filter (blobbd01d3f, or a copy made three minutes before it that differed in one log line) and the second (4cc0459). Times are the phone's (-0700). Details are in the NOTES entry this adds.systemd-run --userunit took 2.1-9.6 ms, and each woke apoll()onactual_brightness.--dry-run --verbose, writes nothing;bd01d3f) through a wake at 16:44:18 and three minutes of use in a dim room. It found that a hand shades the sensor under the panel: at about 14 lux it read 1-7 lux for 7-8 s at a time, a few seconds apart. With 5 s before dimming the level would have moved 11 times in 2.3 minutes, four of them a dim and a brighten seconds apart, and a "brighten" decided on the lagging average once set a darker reading (12.8 to 11.0 lux).4cc0459fixed both (10 s before dimming; the median must agree). Replaying the same 330 readings through it gave 4 moves, all real. The replay isn't in the repository; a 64 s stretch of the shaded readings is, as a unit test, with the brighten that went away.4cc0459): started at level 716 in 52 lux, it claimed the sensor in 17 ms and set 245 within 0.1 s, then held it.brightnessctl set 50%was seen 13 ms later, became my point 2.0 s later (1024 at 52 lux) and stayed for the 20 s after.--reseteased it back to 311 (76 lux) within 8 s.omarchy-brightness-display offreleased the sensor within about a second;onclaimed it again and applied 61 lux (level 271) at once. 1.0 s of CPU over the 59 s run. Level 300 against 1500 at a steady 40 lux read 40.2 and 40.0 lux: the panel's own light doesn't reach the proxy's reading.max_brightness. The fixes (a8718c8, the head's daemon) ran in the unit tests only.test/quicksettings-renderpointed at the phone's own Omarchy shell and themes (instead of the container's mounts), with the tile first in the layout, three times: with the branch's toggle onPATH(the tile reads "Off"), without it ("Not installed", dimmed), and with a stand-in that reports it on ("On" with , as the slider's icon then shows). 184 checks each, no QML errors. No screenshots attached, because the shots show my Wi-Fi network's name.omamobile-toggle-autobrightness on, at a login and after a reboot; the icon and tile in the live shell (that needs omamobile-shell installed and the shell restarted); the head's daemon on the phone; a day of use with it on; a fingerprint unlock more than a second after a wake (whether LHBM changesbrightness, which the daemon would then take as the user's); any other phone, raven included. The panel's level-to-nits mapping is taken as linear between DISPLAY-PLAN's two points, not measured. If you'd like a run of the installed packages on a 7 Pro before merging (the shell restarted, the icon and tile on and off,toggleTile auto-brightness, a reboot with it on), I can do it.userdata, weakens the storage guard, or reads registers from userspace (AGENTS.md §1)The NOTES entry goes on top of
device/cheetah/NOTES.md; if #554 lands first, whichever comes second needs a rebase there.tools/phone-smokereportphone-smoke: cheetah
Kernel
7.3.0-rc6-omamobile-g2219cc6cda77, tools at52f5200, 2026-11-10T05:28Z.Packages: hyprland 0.57.0-3.1, libcamera 0.7.2-4.22, mesa 1:26.2.4-1.4, omacam 0.3.3-1, omamessages 0.2.2-1, omamobile-apps 0.2.2-1, omamobile-audio 0.5.13-1, omamobile-boot-update 0.1.0-1, omamobile-device-cheetah 0.1.44-1, omamobile-fingerprint 0.1.15-1, omamobile-firstboot 0.1.3-1, omamobile-gnss 0.2.7-1, omamobile-keyring 20261026-1, omamobile-mirror 0.1.1-1, omamobile-modem 0.1.16-1, omamobile-omarchy 0.1.36-1, omamobile-owl-widgets 0.1.2-1, omamobile-sensors 0.2.1-1, omamobile-shell 0.2.100-1, omaphone 0.2.3-1, omarchy 4.5.0-3, omatel-agent 0.2.4-2, quickshell 0.3.2.r7.g2b4501a-1
Run on the phone itself as my user (
--here, withSMOKE_DEVICEandSMOKE_REPOset as the laptop wrapper sets them), not as root over SSH. The two "not ok" lines aren't from this change, which isn't installed: the CMA line is at 0.000000 s, the kernel's first memory reservation at boot, and as my user libcamera lists no cameras (my earlier reports, as root, listed four). The thermal reading followstests/packageson the phone.🤖 Generated with Claude Code