Skip to content

Commit

Permalink
Fix headphone playback
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikNatanael committed Sep 24, 2024
1 parent fc2e888 commit bc79471
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <ESP32SPISlave.h>
// #include <SPI.h>

#define TAG_ID 1

// SPI to Daisy
static const int spiClk = 1000000; // 1 MHz
#define HSPI_MISO 12
Expand Down Expand Up @@ -35,7 +37,6 @@ const uint8_t PIN_SS = 4; // spi select pin
#define TX_ANT_DLY 16385
#define RX_ANT_DLY 16385

#define TAG_ID 0

#define POLL_MSG_TAG_ADDR0 7
#define POLL_MSG_TAG_ADDR1 8
Expand Down Expand Up @@ -137,7 +138,8 @@ static void send_tx_poll_msg(void) {
dwt_starttx(DWT_START_TX_IMMEDIATE);

/* Poll DW IC until TX frame sent event set. See NOTE 8 below. */
while (!(dwt_read32bitreg(SYS_STATUS_ID) & SYS_STATUS_TXFRS_BIT_MASK)) {};
unsigned int c = 0;
while (!(dwt_read32bitreg(SYS_STATUS_ID) & SYS_STATUS_TXFRS_BIT_MASK) && c < 2000) {c++;};

/* Clear TXFRS event. */
dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_TXFRS_BIT_MASK);
Expand Down Expand Up @@ -242,7 +244,7 @@ void setup() {
pinMode(DATA_READY, OUTPUT);
digitalWrite(DATA_READY, LOW);

Serial.begin(115200);
Serial.println("Setup done!");
}

void loop() {
Expand Down Expand Up @@ -332,7 +334,7 @@ void loop() {
distances_to_anchors[anchor_selection] = distance;

/* Display computed distance on LCD. */
//snprintf(dist_str, sizeof(dist_str), "%u:%3.2f", anchor_selection, distance);
//snprintf(dist_str, sizeof(dist_str), "%u:%3.2f\n", anchor_selection, distance);
// test_run_info((unsigned char *)dist_str);
//Serial.print(dist_str);

Expand Down
2 changes: 2 additions & 0 deletions code/myriad/daisy_loam_headphones/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ mod app {
// };
// let sig = s.next();
let (l, r) = voice_player.next_frame();
let l = (l * 3.0).clamp(-1.0, 1.0);
let r = (r * 3.0).clamp(-1.0, 1.0);
audio.push_stereo((l, r)).unwrap();
}
}
Expand Down
2 changes: 1 addition & 1 deletion code/myriad/daisy_loam_headphones/src/voice_playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl Anchors {
// There were new anchors, replace the largest distance in buffer_anchors
let mut largest_dist = 0.0;
let mut largest_index = 0;
for (i, (id, dist)) in self.buffer_anchors.iter().enumerate() {
for (i, (_id, dist)) in self.buffer_anchors.iter().enumerate() {
if *dist > largest_dist {
largest_index = i;
largest_dist = *dist;
Expand Down

0 comments on commit bc79471

Please sign in to comment.