forked from Blendman974/faceclaw
Revert "feat: add shared tilt-down hide and current-angle measurement"
This reverts commit f029e3ce91.
This commit is contained in:
21 files changed
+24
-356
No files matched your search
@@ -514,13 +514,6 @@ class BleProtocol {
|
||||
)
|
||||
)
|
||||
|
||||
/** Settings read: restored calibration is signed, proto3 omits a zero value. */
|
||||
@JvmStatic
|
||||
fun parseHeadUpCalibration(pb: ByteArray): Int? {
|
||||
val request = readFieldBytes(stripTrailingCrc(pb), 4) ?: return null
|
||||
return readVarintFieldValue(request, 9, 0)
|
||||
}
|
||||
|
||||
/** Enable the firmware's wear detector (DeviceReceiveInfoFromAPP field 5). */
|
||||
@JvmStatic
|
||||
fun buildSetWearDetection(magic: Int, enabled: Boolean): ByteArray {
|
||||
|
||||
+15
-50
@@ -306,10 +306,6 @@ class GlassesSessionCore(
|
||||
internal var brightnessDemoPolling = false
|
||||
internal var headUpPreferences: Pair<Int, Int>? = null
|
||||
internal var headUpSent: Pair<Int, Int>? = null
|
||||
internal var headAngleMeasuring = false
|
||||
internal var imuRequestedEnabled = false
|
||||
internal var imuRequestedPace = 200
|
||||
internal var headUpCalibration: Int? = null
|
||||
internal var cfwCleanupDelivered = false
|
||||
internal var lastCfwCleanupAckMagic = 0
|
||||
|
||||
@@ -861,50 +857,19 @@ class GlassesSessionCore(
|
||||
*/
|
||||
fun setImuReportEnabled(enable: Boolean, reportFrq: Int) {
|
||||
monitor.withLock {
|
||||
imuRequestedEnabled = enable
|
||||
imuRequestedPace = reportFrq
|
||||
queueSharedImuLocked()
|
||||
if (!running || !sessionReady) {
|
||||
logLine("skip IMU " + (if (enable) "enable" else "disable") + "; session not ready")
|
||||
return
|
||||
}
|
||||
clearMessagesOfKindLocked("imu-control")
|
||||
val message = messageBuilder.enableOrDisableImu(enable, reportFrq)
|
||||
message.onTimeout = MessageCallback { logLine("IMU control ack timeout") }
|
||||
pendingMessages.addFirst(message)
|
||||
logLine("queue IMU " + (if (enable) "enable freq=$reportFrq" else "disable"))
|
||||
}
|
||||
interruptibleSleep.interrupt()
|
||||
}
|
||||
|
||||
private fun queueSharedImuLocked() {
|
||||
if (!running || !sessionReady) return
|
||||
val enabled = imuRequestedEnabled || headAngleMeasuring
|
||||
val pace = if (headAngleMeasuring) {
|
||||
if (imuRequestedEnabled) minOf(imuRequestedPace, 200) else 200
|
||||
} else imuRequestedPace
|
||||
clearMessagesOfKindLocked("imu-control")
|
||||
val message = messageBuilder.enableOrDisableImu(enabled, pace)
|
||||
message.onTimeout = MessageCallback { logLine("IMU control ack timeout") }
|
||||
pendingMessages.addFirst(message)
|
||||
}
|
||||
|
||||
/** Temporary IMU lease; application requests made meanwhile are restored on release. */
|
||||
fun beginHeadAngleMeasurement(): Boolean {
|
||||
val started = monitor.withLock {
|
||||
if (!running || !sessionReady || shutdownRequested || chargingMode || headAngleMeasuring) return@withLock false
|
||||
headAngleMeasuring = true
|
||||
headUpCalibration = null
|
||||
queueSharedImuLocked()
|
||||
pendingMessages.addFirst(createBatteryQueryMessageLocked())
|
||||
true
|
||||
}
|
||||
if (started) interruptibleSleep.interrupt()
|
||||
return started
|
||||
}
|
||||
|
||||
fun endHeadAngleMeasurement() {
|
||||
monitor.withLock {
|
||||
if (!headAngleMeasuring) return
|
||||
headAngleMeasuring = false
|
||||
queueSharedImuLocked()
|
||||
}
|
||||
interruptibleSleep.interrupt()
|
||||
}
|
||||
|
||||
fun getHeadUpCalibration(): Double = monitor.withLock { headUpCalibration?.toDouble() ?: Double.NaN }
|
||||
|
||||
/**
|
||||
* Enable/disable the stock compass through CFW image-handler mode 10. The
|
||||
* desired state is retained across reconnects; headings arrive through
|
||||
@@ -2027,16 +1992,18 @@ class GlassesSessionCore(
|
||||
} else if (decoded != null
|
||||
&& "sys-event" == decoded.kind
|
||||
&& decoded.eventType == BleProtocol.EVENT_HEAD_DOWN) {
|
||||
// A lifecycle gesture, never ordinary user activity. TS consumes
|
||||
// it before the shell's activity/wake handling.
|
||||
logLine("head-down forwarded by CFW")
|
||||
// Faceclaw/38 also forwards the head coming back down. Nothing
|
||||
// uses it yet; as an unknown input it would count as activity
|
||||
// and keep the screen awake, so drop it here.
|
||||
logLine("head-down forwarded by CFW (ignored)")
|
||||
decoded = null
|
||||
}
|
||||
event = decoded
|
||||
if (decoded != null) {
|
||||
// Pure IMU samples arrive continuously; don't let them count
|
||||
// as user input (which would starve battery polling).
|
||||
val pureImuSample = "sys-event" == decoded.kind
|
||||
&& (decoded.eventType == BleProtocol.EVENT_IMU_DATA_REPORT || decoded.eventType == BleProtocol.EVENT_HEAD_DOWN)
|
||||
&& decoded.eventType == BleProtocol.EVENT_IMU_DATA_REPORT
|
||||
if (!pureImuSample) {
|
||||
lastConnectionOrInputAtMs = lastIncomingAtMs
|
||||
if (decoded.eventSource == BleProtocol.EVENT_SOURCE_RING) {
|
||||
@@ -2277,8 +2244,6 @@ class GlassesSessionCore(
|
||||
fixedLayoutCreated = false
|
||||
clearAllMessagesLocked("session ready")
|
||||
headUpSent = null
|
||||
headUpCalibration = null
|
||||
headAngleMeasuring = false
|
||||
displayedFingerprint = ""
|
||||
lastAckAtMs = now()
|
||||
lastIncomingAtMs = lastAckAtMs
|
||||
|
||||
-1
@@ -1054,7 +1054,6 @@ internal fun GlassesSessionCore.createBatteryQueryMessageLocked(): OutboundMessa
|
||||
ringBattery = if (ring == null) -1 else ring.battery
|
||||
ringCharging = if (ring == null) -1 else ring.charging
|
||||
if (ringBattery >= 0) releaseRingFromGlassesLocked("glasses report the ring connected")
|
||||
headUpCalibration = BleProtocol.parseHeadUpCalibration(message.ackPayload)
|
||||
val snapshot = BleProtocol.parseSettingsBattery(message.ackPayload)
|
||||
if (snapshot != null) {
|
||||
headsetBattery = snapshot.battery
|
||||
|
||||
Reference in new issue
Block a user