Merge eeef7a062a4caefef9db0a8ce7c639b513225205 into 7d9eac5584e238a890a388a0f697c27c7391caa4

This commit is contained in:
Eric Grant 2025-09-15 21:08:55 -05:00 committed by GitHub
commit 7ca9956320
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -443,7 +443,7 @@ class Machine(val host: MachineHost) extends AbstractManagedEnvironment with mac
def isRunning(context: Context, args: Arguments): Array[AnyRef] =
result(isRunning)
@Callback(doc = """function([frequency:string or number[, duration:number]]) -- Plays a tone, useful to alert users via audible feedback.""")
@Callback(doc = """function([frequency:string or number[, duration:number[, async:boolean]]]) -- Plays a tone, useful to alert users via audible feedback.""")
def beep(context: Context, args: Arguments): Array[AnyRef] = {
if (args.count == 1 && args.isString(0)) {
beep(args.checkString(0))
@ -454,7 +454,10 @@ class Machine(val host: MachineHost) extends AbstractManagedEnvironment with mac
}
val duration = args.optDouble(1, 0.1)
val durationInMilliseconds = math.max(50, math.min(5000, (duration * 1000).toInt))
context.pause(durationInMilliseconds / 1000.0)
val async = args.optBoolean(2, false)
if (!async) {
context.pause(durationInMilliseconds / 1000.0)
}
beep(frequency.toShort, durationInMilliseconds.toShort)
}
null