From a84c120216f5813fd9831e79e179c97ceeae7d2e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 5 Jul 2022 09:47:14 -0400 Subject: [PATCH] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 645036ce..7607cc44 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2021,10 +2021,11 @@ void pwm_interrupt_handler() { // based on code https://github.com/rgrosset/pico-pwm-audio // pwm_clear_irq(pwm_gpio_to_slice_num(AUDIO_OUT_PIN)); - if (wav_position < (WAV_DATA_LENGTH<<3) - 1) { +// if (wav_position < (WAV_DATA_LENGTH<<3) - 1) { + if (wav_position > (buffer_size - 1)) { // set pwm level // allow the pwm value to repeat for 8 cycles this is >>3 - pwm_set_gpio_level(AUDIO_OUT_PIN, buffer[wav_position>>3]); + pwm_set_gpio_level(AUDIO_OUT_PIN, buffer[wav_position]); wav_position++; } else { // reset to start