AceCentre / Echo

Echo is an AAC app designed for those with a visual difficulty and physical difficulty to access communication.
https://docs.acecentre.org.uk/products/v/echo
GNU General Public License v3.0
0 stars 0 forks source link

Allow the first scan loop to be fast and subsequent loops to be slower #4

Closed gavinhenderson closed 2 weeks ago

gavinhenderson commented 11 months ago

A user might want to have a really fast scan through the options but if they miss what they want they might want to do a slower second scan.

gavinhenderson commented 11 months ago

@willwade would you say this is a feature we need in v1 or something we can scope to v2?

willwade commented 11 months ago

V2

willwade commented 4 weeks ago

in settings

var allowFirstLoopFastScan: Bool = false

Maybe just adjust setNextMoveTimer and the scanning speed based on the current loop.

private func setNextMoveTimer() throws {
    if disableScanningAsHidden { return }

    let maxScanLoops = settings?.scanLoops ?? 0

    guard let siblings = hoveredNode.parent?.getChildren("setnextmovetimer") else {
        try clickNode(settings?.currentVocab?.rootNode, isStartup: true)
        throw EchoError.noSiblings
    }

    let newWorkItem = DispatchWorkItem(block: {
        do {
            try self.nextNode(siblings)
        } catch {
            self.errorHandling?.handle(error: error)
        }
    })

    workItem = newWorkItem

    // Determine the scanning speed based on the current loop and settings
    let isFirstLoop = scanLoops == 0
    let timeInterval: Double

    if isFirstLoop && settings?.allowFirstLoopFastScan == true {
        timeInterval = settings?.scanWaitTime ?? 3 / 2 // Fast scan (half the normal time)
    } else {
        timeInterval = settings?.scanWaitTime ?? 3 // Regular scan
    }

    if hoveredNode.index ?? 0 == siblings.count - 1 {
        scanLoops += 1
    }

    if scanLoops < maxScanLoops {
        DispatchQueue.main.asyncAfter(deadline: .now() + timeInterval, execute: newWorkItem)
    }
}

and in UI settings

Toggle("Allow First Loop Fast Scan", isOn: $settings.allowFirstLoopFastScan)

Doing it like this pros: No need to set speed. Cons: you cant set speed.