Skip to content

Commit 213031b

Browse files
Fix conversion.
1 parent e47392f commit 213031b

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/board/conversions.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ export function convertAudioBuffer(source: number, target: AudioBuffer) {
2828
return target;
2929
}
3030

31-
export function convertStringToSoundThresoldNumber(
32-
value: "low" | "high"
33-
): number {
31+
export function convertSoundThresholdNumberToString(
32+
value: number
33+
): "low" | "high" {
3434
switch (value) {
35-
case "low":
36-
return MICROBIT_HAL_MICROPHONE_SET_THRESHOLD_LOW;
37-
case "high":
38-
return MICROBIT_HAL_MICROPHONE_SET_THRESHOLD_HIGH;
35+
case MICROBIT_HAL_MICROPHONE_SET_THRESHOLD_LOW:
36+
return "low";
37+
case MICROBIT_HAL_MICROPHONE_SET_THRESHOLD_HIGH:
38+
return "high";
3939
default:
4040
throw new Error(`Invalid value ${value}`);
4141
}

src/board/microphone.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {
22
MICROBIT_HAL_MICROPHONE_EVT_THRESHOLD_HIGH,
33
MICROBIT_HAL_MICROPHONE_EVT_THRESHOLD_LOW,
44
} from "./constants";
5-
import { convertStringToSoundEventNumber } from "./conversions";
65
import { RangeSensor, State } from "./state";
76

87
type SoundLevelCallback = (v: number) => void;

src/jshal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ mergeInto(LibraryManager.library, {
207207

208208
mp_js_hal_microphone_set_threshold: function (kind, value) {
209209
board.microphone.setThreshold(
210-
conversions.convertStringToSoundThresoldNumber(kind),
210+
conversions.convertSoundThresholdNumberToString(kind),
211211
value
212212
);
213213
},

0 commit comments

Comments
 (0)