improve networking stufff and stop I2S when DSP turned off.
This commit is contained in:
parent
da0a1784c8
commit
2525a0dd11
3 changed files with 26 additions and 7 deletions
25
main/espd.c
25
main/espd.c
|
|
@ -26,6 +26,7 @@
|
||||||
#include "periph_sdcard.h"
|
#include "periph_sdcard.h"
|
||||||
#include "nvs.h"
|
#include "nvs.h"
|
||||||
#include "nvs_flash.h"
|
#include "nvs_flash.h"
|
||||||
|
#include "esp_timer.h"
|
||||||
|
|
||||||
static const char *TAG = "ESPD";
|
static const char *TAG = "ESPD";
|
||||||
#define TEST_I2S_NUM I2S_NUM_0
|
#define TEST_I2S_NUM I2S_NUM_0
|
||||||
|
|
@ -104,13 +105,11 @@ static int audiostate;
|
||||||
|
|
||||||
void sys_set_audio_state(int onoff)
|
void sys_set_audio_state(int onoff)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if (onoff && !audiostate)
|
if (onoff && !audiostate)
|
||||||
i2s_start(I2S_NUM_0);
|
i2s_start(I2S_NUM_0);
|
||||||
else if (!onoff && audiostate)
|
else if (!onoff && audiostate)
|
||||||
i2s_stop(I2S_NUM_0);
|
i2s_stop(I2S_NUM_0);
|
||||||
audiostate = onoff;
|
audiostate = onoff;
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -237,3 +236,25 @@ void sd_init( void)
|
||||||
audio_board_sdcard_init(set, SD_MODE_1_LINE);
|
audio_board_sdcard_init(set, SD_MODE_1_LINE);
|
||||||
ESP_LOGI(TAG, "[ 1b ] done starting network");
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ void pd_init(void);
|
||||||
void glob_open(t_pd *ignore, t_symbol *name, t_symbol *dir, t_floatarg f);
|
void glob_open(t_pd *ignore, t_symbol *name, t_symbol *dir, t_floatarg f);
|
||||||
|
|
||||||
void pdmain_print( const char *s);
|
void pdmain_print( const char *s);
|
||||||
|
void espd_printtimediff( void);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static const char patchfile[] = "\
|
static const char patchfile[] = "\
|
||||||
|
|
@ -100,10 +101,7 @@ void pdmain_tick( void)
|
||||||
|
|
||||||
t_class *glob_pdobject;
|
t_class *glob_pdobject;
|
||||||
|
|
||||||
static void glob_foo(void *dummy, t_floatarg f)
|
void glob_foo(void *dummy, t_floatarg f);
|
||||||
{
|
|
||||||
trymem(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void glob_beginnew(void *dummy, t_symbol *pname, t_symbol *pdir)
|
static void glob_beginnew(void *dummy, t_symbol *pname, t_symbol *pdir)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ void tcpreceivertask(void *z)
|
||||||
ESP_LOGI(TAG, "connecting...");
|
ESP_LOGI(TAG, "connecting...");
|
||||||
while (err = connect(newsocket, &dest_addr, sizeof(dest_addr)) < 0)
|
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);
|
close(newsocket);
|
||||||
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||||
newsocket = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
|
newsocket = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue