Split settings into tabs; exposure and focus on the home screen
Some checks failed
CI / build-and-deploy (push) Has been cancelled
Some checks failed
CI / build-and-deploy (push) Has been cancelled
Home screen gains shutter, aperture and ISO as dropdowns plus a focus stepper (three nudge sizes each way, and AF) where the body drives focus over PTP. Those three drop out of the read-only strip rather than being shown twice. Everything is built from what the camera actually reports, so a body without one of these controls doesn't get it rather than showing something that silently fails. The 450D marks shutter and aperture readonly unless the mode dial is somewhere they apply, so the dropdowns disable themselves and say why. Focus uses the EOS manualfocusdrive steps and autofocusdrive, and warns when live view is off, which Canon bodies generally require for focus commands. The settings drawer is now tabbed: app settings stay on the first tab, and each config section the camera reports gets its own. Empty sections are dropped, and a selected section that disappears falls back to the first tab. Tabs wrap rather than scroll - a scrolled-off tab is an undiscoverable one. Reverts the automatic camera search added in the previous commit, restoring the Select camera button. Auto-connect could park with no way to reach the device chooser: WebUSB permissions are per-origin, so a grant on localhost doesn't carry to the deployed copy, and a camera that's asleep or held by another app never arrives. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QK7PKpRVoy69Fpa32R8abb
This commit is contained in:
@@ -51,7 +51,7 @@ export function configValue(config, name) {
|
||||
* simply skipped, so this stays useful on other bodies too.
|
||||
* @param {Config | undefined} config
|
||||
*/
|
||||
export function statusReadout(config) {
|
||||
export function statusReadout(config, exclude = []) {
|
||||
return [
|
||||
['Mode', 'autoexposuremode'],
|
||||
['Shutter', 'shutterspeed'],
|
||||
@@ -62,10 +62,70 @@ export function statusReadout(config) {
|
||||
['Shots left', 'availableshots'],
|
||||
['Target', 'capturetarget']
|
||||
]
|
||||
.filter(([, name]) => !exclude.includes(name))
|
||||
.map(([label, name]) => ({ label, value: configValue(config, name) }))
|
||||
.filter(({ value }) => value !== undefined && value !== '');
|
||||
}
|
||||
|
||||
/**
|
||||
* The exposure controls worth putting on the home screen, in the order a
|
||||
* photographer expects them. Only settable menus qualify - on a 450D these are
|
||||
* readonly unless the mode dial is somewhere they apply (shutter speed is fixed
|
||||
* in Av, aperture in Tv, both in the green square).
|
||||
*
|
||||
* @param {Config | undefined} config
|
||||
*/
|
||||
export function exposureControls(config) {
|
||||
return [
|
||||
{ name: 'shutterspeed', label: 'Shutter' },
|
||||
{ name: 'aperture', label: 'Aperture' },
|
||||
{ name: 'iso', label: 'ISO' }
|
||||
]
|
||||
.map(entry => ({ ...entry, node: findConfig(config, entry.name) }))
|
||||
.filter(
|
||||
entry =>
|
||||
entry.node &&
|
||||
(entry.node.type === 'menu' || entry.node.type === 'radio')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* What focus control this body exposes over PTP.
|
||||
*
|
||||
* Canon EOS bodies drive the lens through `manualfocusdrive`, a menu whose
|
||||
* choices are step sizes in each direction ("Near 1".."Far 3"); setting one
|
||||
* nudges focus and the value falls back to None. `autofocusdrive` is a
|
||||
* momentary toggle that triggers AF. Neither is guaranteed to exist, and on
|
||||
* EOS both generally need live view running.
|
||||
*
|
||||
* @param {Config | undefined} config
|
||||
*/
|
||||
export function detectFocusControls(config) {
|
||||
let drive = findConfig(config, 'manualfocusdrive');
|
||||
/** @type {{ name: string, near: string[], far: string[] } | null} */
|
||||
let manual = null;
|
||||
if (
|
||||
drive &&
|
||||
(drive.type === 'menu' || drive.type === 'radio') &&
|
||||
!drive.readonly
|
||||
) {
|
||||
// Sorted so index 0 is the smallest nudge in each direction.
|
||||
let byStep = (a, b) => (parseInt(a, 10) || 0) - (parseInt(b, 10) || 0);
|
||||
let near = drive.choices.filter(c => /near/i.test(c)).sort(byStep);
|
||||
let far = drive.choices.filter(c => /far/i.test(c)).sort(byStep);
|
||||
if (near.length && far.length) manual = { name: drive.name, near, far };
|
||||
}
|
||||
|
||||
let auto = findConfig(config, 'autofocusdrive');
|
||||
let mode = findConfig(config, 'focusmode');
|
||||
|
||||
return {
|
||||
manual,
|
||||
autofocus: auto && auto.type === 'toggle' && !auto.readonly ? auto.name : null,
|
||||
mode: mode && 'value' in mode ? mode : null
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn a gphoto2 shutter speed string ("1/250", "30", "0.3", "bulb") into
|
||||
* seconds. Returns undefined when it can't be parsed.
|
||||
|
||||
Reference in New Issue
Block a user