add display + some refactoring

This commit is contained in:
philippe44
2020-01-10 12:32:50 -08:00
parent daef63fdea
commit 450943735b
49 changed files with 4434 additions and 58 deletions

View File

@@ -18,7 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include "squeezelite.h"
#include "bt_app_sink.h"
#include "raop_sink.h"
@@ -37,9 +38,9 @@ extern struct buffer *outputbuf;
// this is the only system-wide loglevel variable
extern log_level loglevel;
// not great to have these here, but they should not be in embedded.h
bool enable_bt_sink = false;
bool enable_airplay = false;
static bool enable_bt_sink;
static bool enable_airplay;
#define RAOP_OUTPUT_SIZE (RAOP_SAMPLE_RATE * 2 * 2 * 2 * 1.2)
#define SYNC_NB 5
@@ -300,6 +301,18 @@ static bool raop_sink_cmd_handler(raop_event_t event, void *param)
* We provide the generic codec register option
*/
void register_external(void) {
char *p;
if ((p = config_alloc_get(NVS_TYPE_STR, "enable_bt_sink")) != NULL) {
enable_bt_sink = strcmp(p,"1") == 0 || strcasecmp(p,"y") == 0;
free(p);
}
if ((p = config_alloc_get(NVS_TYPE_STR, "enable_airplay")) != NULL) {
enable_airplay = strcmp(p,"1") == 0 || strcasecmp(p,"y") == 0;
free(p);
}
if (!strcasestr(output.device, "BT ") ) {
if(enable_bt_sink){
bt_sink_init(bt_sink_cmd_handler, sink_data_handler);
@@ -308,6 +321,7 @@ void register_external(void) {
} else {
LOG_WARN("Cannot be a BT sink and source");
}
if (enable_airplay){
raop_sink_init(raop_sink_cmd_handler, raop_sink_data_handler);
LOG_INFO("Initializing AirPlay sink");

View File

@@ -50,6 +50,7 @@ sure that using rate_delay would fix that
#include "time.h"
#include "led.h"
#include "monitor.h"
#include "config.h"
#define LOCK mutex_lock(outputbuf->mutex)
#define UNLOCK mutex_unlock(outputbuf->mutex)
@@ -111,9 +112,9 @@ extern struct buffer *streambuf;
extern struct buffer *outputbuf;
extern u8_t *silencebuf;
bool jack_mutes_amp = false;
static log_level loglevel;
static bool jack_mutes_amp;
static bool running, isI2SStarted;
static i2s_config_t i2s_config;
static int bytes_per_frame;
@@ -158,7 +159,6 @@ static void (*jack_handler_chain)(bool inserted);
#define I2C_PORT 0
#define VOLUME_GPIO 14
#define JACK_GPIO 34
#define TAS575x 0x98
#define TAS578x 0x90
@@ -220,6 +220,11 @@ static void jack_handler(bool inserted) {
*/
void output_init_i2s(log_level level, char *device, unsigned output_buf_size, char *params, unsigned rates[], unsigned rate_delay, unsigned idle) {
loglevel = level;
char *p;
p = config_alloc_get_default(NVS_TYPE_STR, "jack_mutes_amp", "n", 0);
jack_mutes_amp = (strcmp(p,"1") == 0 ||strcasecmp(p,"y") == 0);
free(p);
#ifdef TAS57xx
LOG_INFO("Initializing TAS57xx ");