improve networking stufff and stop I2S when DSP turned off.

This commit is contained in:
msp 2022-10-26 13:41:23 -04:00
parent da0a1784c8
commit 2525a0dd11
3 changed files with 26 additions and 7 deletions

View file

@ -26,6 +26,7 @@
#include "periph_sdcard.h"
#include "nvs.h"
#include "nvs_flash.h"
#include "esp_timer.h"
static const char *TAG = "ESPD";
#define TEST_I2S_NUM I2S_NUM_0
@ -104,13 +105,11 @@ static int audiostate;
void sys_set_audio_state(int onoff)
{
/*
if (onoff && !audiostate)
i2s_start(I2S_NUM_0);
else if (!onoff && audiostate)
i2s_stop(I2S_NUM_0);
audiostate = onoff;
*/
}
@ -237,3 +236,25 @@ void sd_init( void)
audio_board_sdcard_init(set, SD_MODE_1_LINE);
ESP_LOGI(TAG, "[ 1b ] done starting network");
}
static void espd_printtimediff( void)
{
static int64_t whensent;
int64_t newtime = esp_timer_get_time();
int elapsed = (newtime - whensent)/1000;
char msg[80];
whensent = newtime;
sprintf(msg, "elapsed msec %d\n", elapsed);
pdmain_print(msg);
}
#define t_floatarg float
void glob_foo(void *dummy, t_floatarg f)
{
if (f == 0)
trymem(0);
else if (f == 1)
espd_printtimediff();
}

View file

@ -17,6 +17,7 @@ void pd_init(void);
void glob_open(t_pd *ignore, t_symbol *name, t_symbol *dir, t_floatarg f);
void pdmain_print( const char *s);
void espd_printtimediff( void);
#if 0
static const char patchfile[] = "\
@ -100,10 +101,7 @@ void pdmain_tick( void)
t_class *glob_pdobject;
static void glob_foo(void *dummy, t_floatarg f)
{
trymem(0);
}
void glob_foo(void *dummy, t_floatarg f);
static void glob_beginnew(void *dummy, t_symbol *pname, t_symbol *pdir)
{

View file

@ -38,7 +38,7 @@ void tcpreceivertask(void *z)
ESP_LOGI(TAG, "connecting...");
while (err = connect(newsocket, &dest_addr, sizeof(dest_addr)) < 0)
{
ESP_LOGE(TAG, "Socket unable to bind: errno %d - retrying", errno);
ESP_LOGE(TAG, "Socket unable to connect: errno %d - retrying", errno);
close(newsocket);
vTaskDelay(2000 / portTICK_PERIOD_MS);
newsocket = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);