cfg tests

This commit is contained in:
Asaril 2025-03-19 01:48:48 +01:00
parent 3cb258c5c3
commit 29e525ae35

View file

@ -286,9 +286,10 @@ impl LedEffect for LedEffectBassSparks {
bass_color.decrease(3, 5, 5, 0);
if true /*processed.floating_max > 10100000
&& (processed.current_powers[1] > 1.35 * processed.avg_powers[1])
&& (processed.current_powers[2] > 1.35 * processed.avg_powers[2])*/
if true
/*processed.floating_max > 10100000
&& (processed.current_powers[1] > 1.35 * processed.avg_powers[1])
&& (processed.current_powers[2] > 1.35 * processed.avg_powers[2])*/
{
for _ in 0..10 {
let led_index = random_at_most(LED_COUNT as u32 - 1) as usize;
@ -331,16 +332,23 @@ fn main() -> anyhow::Result<()> {
let mic_i2s_std_cfg = i2s::config::StdConfig::new(
i2s::config::Config::new().role(i2s::config::Role::Controller),
i2s::config::StdClkConfig::new(
24.kHz().into(),
24000,
i2s::config::ClockSource::default(),
i2s::config::MclkMultiple::M256,
),
i2s::config::StdSlotConfig::msb_slot_default(
i2s::config::DataBitWidth::Bits32,
i2s::config::SlotMode::Mono,
i2s::config::SlotMode::Stereo,
)
.data_bit_width(i2s::config::DataBitWidth::Bits32)
.slot_bit_width(i2s::config::SlotBitWidth::Bits32)
.slot_mode_mask(i2s::config::SlotMode::Mono, i2s::config::StdSlotMask::Left),
.slot_mode_mask(i2s::config::SlotMode::Stereo, i2s::config::StdSlotMask::Both)
.ws_width(32)
.ws_polarity(false)
.bit_shift(true)
.left_align(true)
.big_endian(false)
.bit_order_lsb(false),
i2s::config::StdGpioConfig::new(false, false, false),
);
let mut mic_drv = i2s::I2sDriver::new_std_rx(
@ -390,18 +398,23 @@ fn main() -> anyhow::Result<()> {
mic_drv.rx_enable()?;
loop {
// let buffer: &mut [u8; AUDIO_SAMPLES_PER_BUF*4] = cast_slice_mut(&mut audio[next_audio_buf]);
let buffer = bytes_of_mut(&mut audio[next_audio_buf]);
let num_bytes_read = mic_drv.read(buffer, TickType_t::MAX)?;
// let buffer = bytes_of_mut(&mut audio[next_audio_buf]);
let mut buffer:[u8;AUDIO_SAMPLES_PER_BUF*4] = [0;AUDIO_SAMPLES_PER_BUF*4];
let num_bytes_read = mic_drv.read(buffer.as_mut_slice(), TickType_t::MAX)?;
if num_bytes_read != AUDIO_SAMPLES_PER_BUF * 4 {
log::error!("buffer underflow");
}
for i in 0..AUDIO_SAMPLES_PER_BUF {
let sample:&[u8;4] = &buffer[i*4..i*4+4].try_into().expect("bla");
audio[next_audio_buf][i] = i32::from_be_bytes(*sample);
}
// log::info!("a: {:08x}", audio[next_audio_buf][0]);
let current_fft_buf = processor.process(&audio[next_audio_buf]);
effect.render(&processor, current_fft_buf, &leds.leds);
let output_buffer = bytes_of(&leds);