forked from Blendman974/faceclaw
G1: Microphone, light sensor, accelerometer, bandwidth benchmark, wear detection
This commit is contained in:
1 parent
67aff19923
commit
345ba36c33
11 files changed
+635
-32
No files matched your search
@@ -10,6 +10,7 @@ import {
|
||||
type CompassDiagnostics,
|
||||
} from "../../native/compass";
|
||||
import { wrapText } from "../../graphics/textwrap";
|
||||
import { glassesTypeSetting } from "../../ui/dashboard-settings";
|
||||
import { type InputEvent } from "../../ui/gestures";
|
||||
import { type Layer, type LayerContext } from "../../ui/layers";
|
||||
import { lineStep } from "../../ui/metrics";
|
||||
@@ -151,6 +152,7 @@ class CompassLayer implements Layer {
|
||||
}
|
||||
|
||||
private statusText(): string {
|
||||
if (noCompassSensor()) return "These glasses have no compass sensor";
|
||||
if (this.firmwareStatus !== null) return this.firmwareStatus;
|
||||
if (!this.enabled) return "Compass paused";
|
||||
if (this.rawHeading === null) return "Waiting for compass data…";
|
||||
@@ -206,8 +208,10 @@ class CompassLayer implements Layer {
|
||||
image.drawText(small, Math.round(cx - small.measureText(line) / 2), y, line, 125);
|
||||
y += smallStep;
|
||||
}
|
||||
const accuracyText = magneticAccuracyText(this.diagnostics);
|
||||
image.drawText(small, width - ACCURACY_RIGHT_PAD - small.measureText(accuracyText), ACCURACY_TOP_PAD, accuracyText, 175);
|
||||
if (!noCompassSensor()) {
|
||||
const accuracyText = magneticAccuracyText(this.diagnostics);
|
||||
image.drawText(small, width - ACCURACY_RIGHT_PAD - small.measureText(accuracyText), ACCURACY_TOP_PAD, accuracyText, 175);
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
@@ -216,10 +220,15 @@ class CompassLayer implements Layer {
|
||||
// "Uncalibrated" prompt advertises, and re-calibrating is a normal thing to
|
||||
// want once the glasses have been taken off and put back on.
|
||||
handleInput(event: InputEvent, ctx: LayerContext): void {
|
||||
if (event.type === "click") this.openCalibration(ctx);
|
||||
if (event.type === "click" && !noCompassSensor()) this.openCalibration(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
/** A G1 has an accelerometer and a gyroscope, but no magnetometer. */
|
||||
function noCompassSensor(): boolean {
|
||||
return glassesTypeSetting.get() === "g1";
|
||||
}
|
||||
|
||||
export function createCompassAppWindow(options: InProcessAppOptions): InProcessWindow {
|
||||
let requestRender = () => {};
|
||||
const layer = new CompassLayer(() => requestRender());
|
||||
@@ -231,7 +240,7 @@ export function createCompassAppWindow(options: InProcessAppOptions): InProcessW
|
||||
icon: "compass",
|
||||
closeable: true,
|
||||
actions: options.actions,
|
||||
menuItems: () => [
|
||||
menuItems: () => noCompassSensor() ? [] : [
|
||||
{
|
||||
label: "Calibrate",
|
||||
onSelect: (ctx) => {
|
||||
|
||||
@@ -8,6 +8,12 @@ const PREVIOUS_DEFAULT_CURVE = "0:0,1:10,10:30,100:65,1000:100";
|
||||
*/
|
||||
export const RAYNEO_IO_BRIGHTNESS_CURVE = "0:0,3:11,10:26,200:26,300:41,600:56,1000:70,4000:93,5000:100";
|
||||
|
||||
/**
|
||||
* An Even G1's OPT3007 also reads lux (centilux on the wire). These knots are the stock firmware's table: levels 0, 10, 25,
|
||||
* 41 and 42 of 42 at 0, 50, 200, 1000 and 2000 lux (g1_firmware/docs/VM.md §6.7).
|
||||
*/
|
||||
export const G1_BRIGHTNESS_CURVE = "0:0,50:24,200:60,1000:98,2000:100";
|
||||
|
||||
/** Percent of the configured range; defaults (20–100) give 20/26/46/100. */
|
||||
export function brightnessCurveError(value: string): string | null {
|
||||
const pairs = value.split(",").map(part => part.trim().split(":"));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { normalizeNightscoutThreshold, type NightscoutThresholds } from "../apps/nightscout/nightscout-alerts";
|
||||
import { GESTURE_DOUBLE_CLICK, InputEvent } from "./gestures";
|
||||
import { DEFAULT_BRIGHTNESS_CURVE, RAYNEO_IO_BRIGHTNESS_CURVE, normalizeBrightnessCurve, brightnessCurveError } from "../g2/brightness-curve";
|
||||
import { DEFAULT_BRIGHTNESS_CURVE, G1_BRIGHTNESS_CURVE, RAYNEO_IO_BRIGHTNESS_CURVE, normalizeBrightnessCurve, brightnessCurveError } from "../g2/brightness-curve";
|
||||
import {
|
||||
getBooleanSetting,
|
||||
getStringSetting,
|
||||
@@ -600,7 +600,10 @@ export const autoBrightnessMaxSetting = new ConfigSettingEnum({
|
||||
export const autoBrightnessCurveSetting = new ConfigSettingString({
|
||||
id: "autoBrightnessCurve", label: "Auto light curve", storageKey: "display.autoBrightnessCurve",
|
||||
defaultValue: DEFAULT_BRIGHTNESS_CURVE, normalize: normalizeBrightnessCurve, validate: brightnessCurveError,
|
||||
dynamicDefault: () => (glassesTypeSetting.get() === "rayneo-io" ? RAYNEO_IO_BRIGHTNESS_CURVE : undefined),
|
||||
dynamicDefault: () => {
|
||||
const glasses = glassesTypeSetting.get();
|
||||
return glasses === "rayneo-io" ? RAYNEO_IO_BRIGHTNESS_CURVE : glasses === "g1" ? G1_BRIGHTNESS_CURVE : undefined;
|
||||
},
|
||||
description: "2–16 lux:percent pairs, separated by commas. Percent is within your minimum–maximum range. Start at 0:0, end at 100%, and increase lux without decreasing percent. Incomplete edits stay in the preview; brightness keeps using the last valid curve.",
|
||||
});
|
||||
/** The screen on/off fade at Normal speed. */
|
||||
|
||||
Reference in new issue
Block a user