BT source improvment, GPIO expander intr fix, SPI display improvments

This commit is contained in:
Philippe G
2021-12-31 17:49:43 -08:00
parent 756d930912
commit 25249ce13e
9 changed files with 172 additions and 302 deletions

View File

@@ -408,35 +408,27 @@ static bool cspot_cmd_handler(cspot_event_t cmd, va_list args)
/****************************************************************************************
* We provide the generic codec register option
*/
#if defined(ESP_PLATFORM) && defined(CONFIG_BT_SINK)
void bt_delay_start(TimerHandle_t xTimer) {
xTimerDelete(xTimer, portMAX_DELAY);
bt_sink_init(bt_sink_cmd_handler, sink_data_handler);
LOG_INFO("Initializing BT sink");
}
void bt_delay_stop(TimerHandle_t xTimer) {
xTimerDelete(xTimer, portMAX_DELAY);
bt_sink_deinit();
LOG_INFO("Stopping BT sink");
}
#endif
void register_external(void) {
char *p;
#if CONFIG_BT_SINK
if ((p = config_alloc_get(NVS_TYPE_STR, "enable_bt_sink")) != NULL) {
enable_bt_sink = strcmp(p,"1") == 0 || strcasecmp(p,"y") == 0;
enable_bt_sink = !strcmp(p,"1") || !strcasecmp(p,"y");
free(p);
if (!strcasestr(output.device, "BT") && enable_bt_sink) {
bt_sink_init(bt_sink_cmd_handler, sink_data_handler);
}
}
#endif
#if CONFIG_AIRPLAY_SINK
if ((p = config_alloc_get(NVS_TYPE_STR, "enable_airplay")) != NULL) {
enable_airplay = strcmp(p,"1") == 0 || strcasecmp(p,"y") == 0;
enable_airplay = !strcmp(p,"1") || !strcasecmp(p,"y");
free(p);
if (enable_airplay){
raop_sink_init(raop_sink_cmd_handler, raop_sink_data_handler);
LOG_INFO("Initializing AirPlay sink");
}
}
#endif
@@ -447,29 +439,6 @@ void register_external(void) {
}
#endif
#if CONFIG_BT_SINK
if (!strcasestr(output.device, "BT ") ) {
if(enable_bt_sink){
#ifdef ESP_PLATFORM
// we need to delay the start because current task is in spiram
TimerHandle_t timer = xTimerCreate("delay", 1, pdFALSE, NULL, bt_delay_start);
xTimerStart(timer, portMAX_DELAY);
#else
bt_sink_init(bt_sink_cmd_handler, sink_data_handler);
#endif
}
} else {
LOG_WARN("Cannot be a BT sink and source");
}
#endif
#if CONFIG_AIRPLAY_SINK
if (enable_airplay){
raop_sink_init(raop_sink_cmd_handler, raop_sink_data_handler);
LOG_INFO("Initializing AirPlay sink");
}
#endif
#if CONFIG_CSPOT_SINK
if (enable_cspot){
cspot_sink_init(cspot_cmd_handler, sink_data_handler);
@@ -480,14 +449,8 @@ void register_external(void) {
void deregister_external(void) {
#if CONFIG_BT_SINK
if (!strcasestr(output.device, "BT ") && enable_bt_sink) {
#ifdef ESP_PLATFORM
// we need to delay the stop because current task is in spiram
TimerHandle_t timer = xTimerCreate("delay", 1, pdFALSE, NULL, bt_delay_stop);
xTimerStart(timer, portMAX_DELAY);
#else
if (!strcasestr(output.device, "BT") && enable_bt_sink) {
bt_sink_deinit();
#endif
}
#endif
@@ -503,7 +466,7 @@ void deregister_external(void) {
LOG_INFO("Stopping CSpot sink");
cspot_sink_deinit();
}
#endif
#endif
}
void decode_restore(int external) {

View File

@@ -450,7 +450,7 @@ static void server(in_addr_t ip, u16_t hport, u16_t cport) {
xSemaphoreTake(displayer.mutex, portMAX_DELAY);
sprintf(msg, "%s:%hu", inet_ntoa(ip), hport);
if (display && displayer.owned) GDS_TextPos(display, GDS_FONT_DEFAULT, GDS_TEXT_CENTERED, GDS_TEXT_CLEAR | GDS_TEXT_UPDATE, msg);
if (display && displayer.owned) GDS_TextPos(display, GDS_FONT_LINE_1, GDS_TEXT_CENTERED, GDS_TEXT_CLEAR | GDS_TEXT_UPDATE, msg);
displayer.dirty = true;
xSemaphoreGive(displayer.mutex);

View File

@@ -82,7 +82,7 @@ void output_init_embedded(log_level level, char *device, unsigned output_buf_siz
output.rate_delay = rate_delay;
#if CONFIG_BT_SINK
if (strcasestr(device, "BT ") || !strcasecmp(device, "BT")) {
if (strcasestr(device, "BT")) {
LOG_INFO("init Bluetooth");
close_cb = &output_close_bt;
output_init_bt(level, device, output_buf_size, params, rates, rate_delay, idle);