Skip to content

Commit

Permalink
codal_app/microbithal_microphone: Add hal_microphone_get_level_db().
Browse files Browse the repository at this point in the history
Signed-off-by: Damien George <[email protected]>
  • Loading branch information
dpgeorge committed Sep 9, 2024
1 parent 251bd63 commit 6fdfc3f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/codal_app/microbithal.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ int microbit_hal_compass_get_heading(void);
void microbit_hal_microphone_init(void);
void microbit_hal_microphone_set_threshold(int kind, int value);
int microbit_hal_microphone_get_level(void);
float microbit_hal_microphone_get_level_db(void);

const uint8_t *microbit_hal_get_font_data(char c);

Expand Down
7 changes: 7 additions & 0 deletions src/codal_app/microbithal_microphone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,11 @@ int microbit_hal_microphone_get_level(void) {
return value;
}

float microbit_hal_microphone_get_level_db(void) {
uBit.audio.levelSPL->setUnit(LEVEL_DETECTOR_SPL_DB);
float value = uBit.audio.levelSPL->getValue();
uBit.audio.levelSPL->setUnit(LEVEL_DETECTOR_SPL_8BIT);
return value;
}

}

0 comments on commit 6fdfc3f

Please sign in to comment.