Skip to content

Commit 82be207

Browse files
committed
Add mixer command.
Only reads mixer values.
1 parent 4a44471 commit 82be207

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

src/commands/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ mod hardware;
1111
mod input;
1212
mod ram;
1313
mod screen;
14+
mod sound;
1415
mod timedate;
1516

1617
pub static OS_MENU: menu::Menu<Ctx> = menu::Menu {
@@ -29,6 +30,7 @@ pub static OS_MENU: menu::Menu<Ctx> = menu::Menu {
2930
&screen::CLS_ITEM,
3031
&input::KBTEST_ITEM,
3132
&hardware::SHUTDOWN_ITEM,
33+
&sound::MIXER_ITEM,
3234
],
3335
entry: None,
3436
exit: None,

src/commands/sound.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//! Sound related commands for Neotron OS
2+
3+
use crate::{osprintln, Ctx, API};
4+
5+
pub static MIXER_ITEM: menu::Item<Ctx> = menu::Item {
6+
item_type: menu::ItemType::Callback {
7+
function: mixer,
8+
parameters: &[],
9+
},
10+
command: "mixer",
11+
help: Some("Control the audio mixer"),
12+
};
13+
14+
/// Called when the "mixer" command is executed.
15+
fn mixer(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, _args: &[&str], _ctx: &mut Ctx) {
16+
let api = API.get();
17+
osprintln!("Mixers:");
18+
for mixer_id in 0u8..=255u8 {
19+
match (api.audio_mixer_channel_get_info)(mixer_id) {
20+
neotron_common_bios::FfiOption::Some(mixer_info) => {
21+
let dir_str = match mixer_info.direction {
22+
neotron_common_bios::audio::Direction::Input => "In",
23+
neotron_common_bios::audio::Direction::Loopback => "Loop",
24+
neotron_common_bios::audio::Direction::Output => "Out",
25+
};
26+
osprintln!(
27+
"#{}: {} ({}) {}/{}",
28+
mixer_id,
29+
mixer_info.name,
30+
dir_str,
31+
mixer_info.current_level,
32+
mixer_info.max_level
33+
);
34+
}
35+
neotron_common_bios::FfiOption::None => {
36+
// Run out of mixers
37+
break;
38+
}
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)