The AudioMoth-Chime library provide support to set the time and deployment ID of an AudioMoth using an acoustic tone.
The Kotlin Android library contains two classes that must be included in the app. They define AudioMothChime and AudioMothChimeConnector objects. The latter exposes three public functions:
fun playTone(duration: Int)
fun playTime(calendar: Calendar)
fun playTimeAndDeploymentID(calendar: Calendar, deploymentID: Array<Int>)
Below is an example of their use:
val chimeButton: Button = findViewById(R.id.chimeButton)
val audioMothConnector = AudioMothChimeConnector()
chimeButton.setOnClickListener{
val calendar = Calendar.getInstance()
Thread {
audioMothConnector.playTime(calendar)
}.start()
}
The Javascript library contains two classes that must be included in the webpage. They define the global AudioMothChime and AudioMothChimeConnector objects. The latter exposes three public functions:
playTone(duration, callback);
playTime(date, callback);
playTimeAndDeploymentID(date, deploymentID, callback);
Below is an example of their use:
var audioMothChimeConnector = new AudioMothChimeConnector();
document.getElementById("chime_button").addEventListener("click", function () {
document.getElementById("chime_button").disabled = true;
var date = new Date();
audioMothChimeConnector.playTime(function () {
document.getElementById("chime_button").disabled = false;
});
});
The Swift iOS library contains two classes that must be included in the app. They define AudioMothChime and AudioMothChimeConnector objects. The latter exposes three public functions:
func playTone(duration: Int)
func playTime(date: Date, timezone: TimeZone)
func playTimeAndDeploymentID(date: Date, timezone: TimeZone, deploymentID: Array<Int>)
Below is an example of their use:
Button(action: {
let date: Date = Date()
let timezone: TimeZone = TimeZone.current
audioMothChimeConnector.playTime(date: date, timezone: timezone)
}) {
Text("Play Chime")
}
Copyright 2019 Open Acoustic Devices.