diff --git a/components/display/SSD132x.c b/components/display/SSD132x.c index db324d0c..12749177 100644 --- a/components/display/SSD132x.c +++ b/components/display/SSD132x.c @@ -168,7 +168,7 @@ static void Update1( struct GDS_Device* Device ) { } // in 1 bit mode, SSD1326 has a different memory map than SSD1306 and SH1106 -static void IRAM_ATTR DrawPixel1FastLocal( struct GDS_Device* Device, int X, int Y, int Color ) { +static void IRAM_ATTR _DrawPixel1Fast( struct GDS_Device* Device, int X, int Y, int Color ) { uint32_t XBit = ( X & 0x07 ); uint8_t* FBOffset = Device->Framebuffer + ( ( Y * Device->Width + X ) >> 3 ); @@ -188,12 +188,12 @@ static void ClearWindow( struct GDS_Device* Device, int x1, int y1, int x2, int for (int r = y1; r <= y2; r++) { int c = x1; // for a row that is not on a boundary, not column opt can be done, so handle all columns on that line - while (c & 0x07 && c <= x2) DrawPixel1FastLocal( Device, c++, r, Color ); + while (c & 0x07 && c <= x2) _DrawPixel1Fast( Device, c++, r, Color ); // at this point we are aligned on column boundary int chunk = (x2 - c + 1) >> 3; memset(optr + Width * r + (c >> 3), _Color, chunk ); c += chunk * 8; - while (c <= x2) DrawPixel1FastLocal( Device, c++, r, Color ); + while (c <= x2) _DrawPixel1Fast( Device, c++, r, Color ); } } @@ -320,7 +320,7 @@ static const struct GDS_Device SSD132x = { struct GDS_Device* SSD132x_Detect(char *Driver, struct GDS_Device* Device) { uint8_t Model; int Depth; - + if (strcasestr(Driver, "SSD1326")) Model = SSD1326; else if (strcasestr(Driver, "SSD1327")) Model = SSD1327; else return NULL; @@ -328,13 +328,14 @@ struct GDS_Device* SSD132x_Detect(char *Driver, struct GDS_Device* Device) { if (!Device) Device = calloc(1, sizeof(struct GDS_Device)); *Device = SSD132x; - ((struct PrivateSpace*) Device->Private)->Model = Model; + struct PrivateSpace *Private = (struct PrivateSpace*) Device->Private; + Private->Model = Model; sscanf(Driver, "%*[^:]:%u", &Depth); if (Model == SSD1326 && Depth == 1) { Device->Update = Update1; - Device->DrawPixelFast = DrawPixel1FastLocal; + Device->DrawPixelFast = _DrawPixel1Fast; Device->DrawBitmapCBR = DrawBitmapCBR; Device->ClearWindow = ClearWindow; Device->Depth = 1; diff --git a/components/display/SSD1675.c b/components/display/SSD1675.c index c458b068..5b421ea0 100644 --- a/components/display/SSD1675.c +++ b/components/display/SSD1675.c @@ -118,7 +118,7 @@ static void Update( struct GDS_Device* Device ) { } // remember that for these ELD drivers W and H are "inverted" -static inline void DrawPixelLocal( struct GDS_Device* Device, int X, int Y, int Color ) { +static inline void _DrawPixel( struct GDS_Device* Device, int X, int Y, int Color ) { uint32_t YBit = ( Y & 0x07 ); Y>>= 3; @@ -129,7 +129,7 @@ static inline void DrawPixelLocal( struct GDS_Device* Device, int X, int Y, int static void ClearWindow( struct GDS_Device* Device, int x1, int y1, int x2, int y2, int Color ) { for (int r = y1; r <= y2; r++) { for (int c = x1; c <= x2; c++) { - DrawPixelLocal( Device, c, r, Color ); + _DrawPixel( Device, c, r, Color ); } } } @@ -228,7 +228,7 @@ static bool Init( struct GDS_Device* Device ) { static const struct GDS_Device SSD1675 = { .DrawBitmapCBR = DrawBitmapCBR, .ClearWindow = ClearWindow, - .DrawPixelFast = DrawPixelLocal, + .DrawPixelFast = _DrawPixel, .Update = Update, .Init = Init, .Mode = GDS_MONO, .Depth = 1, .Alloc = GDS_ALLOC_NONE, diff --git a/components/display/ST77xx.c b/components/display/ST77xx.c index 8c21dbf5..3deaee2a 100644 --- a/components/display/ST77xx.c +++ b/components/display/ST77xx.c @@ -282,8 +282,9 @@ struct GDS_Device* ST77xx_Detect(char *Driver, struct GDS_Device* Device) { if (!Device) Device = calloc(1, sizeof(struct GDS_Device)); *Device = ST77xx; - ((struct PrivateSpace*) Device->Private)->Model = Model; sscanf(Driver, "%*[^:]:%u", &Depth); + struct PrivateSpace* Private = (struct PrivateSpace*) Device->Private; + Private->Model = Model; if (Depth == 18) { Device->Mode = GDS_RGB666; diff --git a/components/display/display.c b/components/display/display.c index 3fb30081..d260c8ed 100644 --- a/components/display/display.c +++ b/components/display/display.c @@ -384,7 +384,11 @@ void displayer_control(enum displayer_cmd_e cmd, ...) { bool display_is_valid_driver(char * driver){ return display_conf_get_driver_name(driver)!=NULL; } -char * display_conf_get_driver_name(char * driver){ + +/**************************************************************************************** + * + */ +const char *display_conf_get_driver_name(char * driver){ for(uint8_t i=0;known_drivers[i]!=NULL && strlen(known_drivers[i])>0;i++ ){ if(strcasestr(driver,known_drivers[i])){ return known_drivers[i]; diff --git a/components/display/display.h b/components/display/display.h index a8805645..b0f7bea3 100644 --- a/components/display/display.h +++ b/components/display/display.h @@ -31,7 +31,7 @@ enum displayer_time_e { DISPLAYER_ELAPSED, DISPLAYER_REMAINING }; enum display_bus_cmd_e { DISPLAY_BUS_TAKE, DISPLAY_BUS_GIVE }; bool (*display_bus)(void *from, enum display_bus_cmd_e cmd); -char * display_conf_get_driver_name(char * driver); +const char *display_conf_get_driver_name(char * driver); bool display_is_valid_driver(char * driver); void displayer_scroll(char *string, int speed, int pause); diff --git a/components/platform_console/cmd_system.c b/components/platform_console/cmd_system.c index 1ddd7e4c..1d396252 100644 --- a/components/platform_console/cmd_system.c +++ b/components/platform_console/cmd_system.c @@ -268,6 +268,7 @@ static int free_mem(int argc, char **argv) return 0; } +/* static struct { struct arg_str *a2dp_dev_name; struct arg_str *a2dp_sink_name; @@ -276,9 +277,10 @@ static struct { struct arg_str *enable_bt_sink; struct arg_end *end; } set_btsource_args; +*/ -static int do_set_btsource(int argc, char **argv) -{ +//static int do_set_btsource(int argc, char **argv) +//{ // a2dp_dev_name; // a2dp_sink_name; // wakeup_gpio_level; @@ -317,8 +319,8 @@ static int do_set_btsource(int argc, char **argv) // } // rtc_gpio_isolate(GPIO_NUM_12); // esp_deep_sleep_start(); - return 0; -} +//return 0; +//} diff --git a/components/platform_console/cmd_wifi.c b/components/platform_console/cmd_wifi.c index f2175757..eeaad2f0 100644 --- a/components/platform_console/cmd_wifi.c +++ b/components/platform_console/cmd_wifi.c @@ -39,7 +39,7 @@ extern bool bypass_wifi_manager; extern EventGroupHandle_t wifi_event_group; extern const int CONNECTED_BIT; -static const char * TAG = "cmd_wifi"; +//static const char * TAG = "cmd_wifi"; /** Arguments used by 'join' function */ static struct { struct arg_int *timeout; @@ -130,9 +130,8 @@ static bool wifi_join(const char *ssid, const char *pass, int timeout_ms) return (bits & CONNECTED_BIT) != 0; } - -static int set_auto_connect(int argc, char **argv) -{ +//static int set_auto_connect(int argc, char **argv) +//{ // int nerrors = arg_parse(argc, argv, (void **) &join_args); // if (nerrors != 0) { // arg_print_errors(stderr, join_args.end, argv[0]); @@ -154,8 +153,9 @@ static int set_auto_connect(int argc, char **argv) // return 1; // } // ESP_LOGI(__func__, "Connected"); - return 0; -} +// return 0; +//} + static int connect(int argc, char **argv) { int nerrors = arg_parse_msg(argc, argv,(struct arg_hdr **)&join_args); diff --git a/components/platform_console/platform_console.c b/components/platform_console/platform_console.c index c3281b55..7dcdbf74 100644 --- a/components/platform_console/platform_console.c +++ b/components/platform_console/platform_console.c @@ -12,23 +12,20 @@ #include #include #include -#include "esp_system.h" #include "esp_log.h" #include "esp_console.h" #include "esp_vfs_dev.h" #include "driver/uart.h" #include "linenoise/linenoise.h" #include "argtable3/argtable3.h" -#include "nvs.h" +#include "nvs.h" #include "nvs_flash.h" #include "pthread.h" #include "platform_esp32.h" -#include "esp_pthread.h" #include "cmd_decl.h" -#include "wifi_manager.h" #include "trace.h" #include "platform_config.h" -#include "telnet.h" +#include "telnet.h" #include "messaging.h" diff --git a/components/raop/raop.c b/components/raop/raop.c index e8cbe175..b49fac0b 100644 --- a/components/raop/raop.c +++ b/components/raop/raop.c @@ -89,7 +89,13 @@ extern struct mdnsd* glmDNSServer; extern log_level raop_loglevel; static log_level *loglevel = &raop_loglevel; +#ifdef WIN32 static void* rtsp_thread(void *arg); +static void* search_remote(void *args); +#else +static void rtsp_thread(void *arg); +static void search_remote(void *args); +#endif static void cleanup_rtsp(raop_ctx_t *ctx, bool abort); static bool handle_rtsp(raop_ctx_t *ctx, int sock); @@ -97,7 +103,7 @@ static char* rsa_apply(unsigned char *input, int inlen, int *outlen, int mode); static int base64_pad(char *src, char **padded); static int base64_encode(const void *data, int size, char **str); static int base64_decode(const char *str, void *data); -static void* search_remote(void *args); + extern char private_key[]; enum { RSA_MODE_KEY, RSA_MODE_AUTH }; @@ -352,7 +358,11 @@ bool raop_cmd(struct raop_ctx_s *ctx, raop_event_t event, void *param) { } /*----------------------------------------------------------------------------*/ +#ifdef WIN32 static void *rtsp_thread(void *arg) { +#else +static void rtsp_thread(void *arg) { +#endif raop_ctx_t *ctx = (raop_ctx_t*) arg; int sock = -1; @@ -397,9 +407,9 @@ static void *rtsp_thread(void *arg) { #ifndef WIN32 xTaskNotifyGive(ctx->joiner); vTaskSuspend(NULL); +#else + return NULL; #endif - - return NULL; } @@ -708,7 +718,7 @@ static void* search_remote(void *args) { #else /*----------------------------------------------------------------------------*/ -static void* search_remote(void *args) { +static void search_remote(void *args) { raop_ctx_t *ctx = (raop_ctx_t*) args; bool found = false; @@ -741,8 +751,6 @@ static void* search_remote(void *args) { // can't use xNotifyGive as it seems LWIP is using it as well xSemaphoreGive(ctx->active_remote.destroy_mutex); vTaskSuspend(NULL); - - return NULL; } #endif diff --git a/components/raop/rtp.c b/components/raop/rtp.c index 9fd5d07e..b2b7acfe 100644 --- a/components/raop/rtp.c +++ b/components/raop/rtp.c @@ -159,8 +159,12 @@ static void buffer_reset(abuf_t *audio_buffer); static void buffer_push_packet(rtp_t *ctx); static bool rtp_request_resend(rtp_t *ctx, seq_t first, seq_t last); static bool rtp_request_timing(rtp_t *ctx); -static void* rtp_thread_func(void *arg); static int seq_order(seq_t a, seq_t b); +#ifdef WIN32 +static void *rtp_thread_func(void *arg); +#else +static void rtp_thread_func(void *arg); +#endif /*---------------------------------------------------------------------------*/ static struct alac_codec_s* alac_init(int fmtp[32]) { @@ -566,7 +570,11 @@ static void buffer_push_packet(rtp_t *ctx) { /*---------------------------------------------------------------------------*/ +#ifdef WIN32 static void *rtp_thread_func(void *arg) { +#else +static void rtp_thread_func(void *arg) { +#endif fd_set fds; int i, sock = -1; int count = 0; @@ -621,8 +629,9 @@ static void *rtp_thread_func(void *arg) { case 0x56: { pktp += 4; plen -= 4; - } - + } + // fall through + // data packet case 0x60: { seqno = ntohs(*(u16_t*)(pktp+2)); @@ -696,7 +705,6 @@ static void *rtp_thread_func(void *arg) { // NTP timing packet case 0x53: { - u64_t expected; u32_t reference = ntohl(*(u32_t*)(pktp+12)); // only low 32 bits in our case u64_t remote =(((u64_t) ntohl(*(u32_t*)(pktp+16))) << 32) + ntohl(*(u32_t*)(pktp+20)); u32_t roundtrip = gettime_ms() - reference; @@ -713,8 +721,8 @@ static void *rtp_thread_func(void *arg) { The expected elapsed remote time should be exactly the same as elapsed local time between the two request, corrected by the drifting + u64_t expected = ctx->timing.remote + MS2NTP(reference - ctx->timing.local); */ - expected = ctx->timing.remote + MS2NTP(reference - ctx->timing.local); ctx->timing.remote = remote; ctx->timing.local = reference; @@ -741,9 +749,9 @@ static void *rtp_thread_func(void *arg) { #ifndef WIN32 xTaskNotifyGive(ctx->joiner); vTaskSuspend(NULL); -#endif - +#else return NULL; +#endif } /*---------------------------------------------------------------------------*/ diff --git a/components/services/accessors.c b/components/services/accessors.c index db55dab1..8715e720 100644 --- a/components/services/accessors.c +++ b/components/services/accessors.c @@ -17,8 +17,8 @@ #include "display.h" static const char *TAG = "services"; -static char *i2c_name="I2C"; -static char *spi_name="SPI"; +static const char *i2c_name="I2C"; +static const char *spi_name="SPI"; #define min(a,b) (((a) < (b)) ? (a) : (b)) @@ -37,15 +37,9 @@ esp_err_t config_i2c_set(const i2c_config_t * config, int port){ return ESP_OK; } -void config_display_free(display_config_t ** disp ){ - if(disp && *disp){ - free((*disp)->drivername); - free((*disp)->type); - free(*disp); - *disp=NULL; - } -} - +/**************************************************************************************** + * + */ const display_config_t * config_display_get(){ static display_config_t dstruct; char *config = config_alloc_get(NVS_TYPE_STR, "display_config"); diff --git a/components/services/accessors.h b/components/services/accessors.h index 20cd3987..3c5f8484 100644 --- a/components/services/accessors.h +++ b/components/services/accessors.h @@ -19,8 +19,8 @@ typedef struct { int address; int CS_pin; int speed; - char *drivername; - char *type; + const char *drivername; + const char *type; bool hflip; bool vflip; bool rotate; diff --git a/components/squeezelite/ac101/ac101.c b/components/squeezelite/ac101/ac101.c index bb76d457..e3bac89d 100644 --- a/components/squeezelite/ac101/ac101.c +++ b/components/squeezelite/ac101/ac101.c @@ -63,7 +63,6 @@ static void ac101_start(ac_module_t mode); static void ac101_stop(void); static void ac101_set_earph_volume(uint8_t volume); static void ac101_set_spk_volume(uint8_t volume); -static int ac101_get_spk_volume(void); static int i2c_port; @@ -268,13 +267,6 @@ void set_sample_rate(int rate) { i2c_write_reg(I2S_SR_CTRL, rate); } -/**************************************************************************************** - * Get normalized (0..100) speaker volume - */ -static int ac101_get_spk_volume(void) { - return ((i2c_read_reg(SPKOUT_CTRL) & 0x1f) * 100) / 0x1f; -} - /**************************************************************************************** * Set normalized (0..100) volume */ @@ -285,13 +277,6 @@ static void ac101_set_spk_volume(uint8_t volume) { i2c_write_reg(SPKOUT_CTRL, value); } -/**************************************************************************************** - * Get normalized (0..100) earphone volume - */ -static int ac101_get_earph_volume(void) { - return (((i2c_read_reg(HPOUT_CTRL) >> 4) & 0x3f) * 100) / 0x3f; -} - /**************************************************************************************** * Set normalized (0..100) earphone volume */ @@ -302,6 +287,21 @@ static void ac101_set_earph_volume(uint8_t volume) { i2c_write_reg(HPOUT_CTRL, value); } +#if 0 +/**************************************************************************************** + * Get normalized (0..100) speaker volume + */ +static int ac101_get_spk_volume(void) { + return ((i2c_read_reg(SPKOUT_CTRL) & 0x1f) * 100) / 0x1f; +} + +/**************************************************************************************** + * Get normalized (0..100) earphone volume + */ +static int ac101_get_earph_volume(void) { + return (((i2c_read_reg(HPOUT_CTRL) >> 4) & 0x3f) * 100) / 0x3f; +} + /**************************************************************************************** * */ @@ -330,6 +330,27 @@ static void ac101_set_output_mixer_gain(ac_output_mixer_gain_t gain,ac_output_mi i2c_write_reg(OMIXER_BST1_CTRL,regval); } +/**************************************************************************************** + * + */ +static void ac101_deinit(void) { + i2c_write_reg(CHIP_AUDIO_RS, 0x123); //soft reset +} + +/**************************************************************************************** + * Don't know when this one is supposed to be called + */ +static void ac101_i2s_config_clock(ac_i2s_clock_t *cfg) { + uint16_t regval=0; + regval = i2c_read_reg(I2S1LCK_CTRL); + regval &= 0xe03f; + regval |= (cfg->bclk_div << 9); + regval |= (cfg->lclk_div << 6); + i2c_write_reg(I2S1LCK_CTRL, regval); +} + +#endif + /**************************************************************************************** * */ @@ -362,21 +383,3 @@ static void ac101_stop(void) { i2c_write_reg(PLL_CTRL2, value); } -/**************************************************************************************** - * - */ -static void ac101_deinit(void) { - i2c_write_reg(CHIP_AUDIO_RS, 0x123); //soft reset -} - -/**************************************************************************************** - * Don't know when this one is supposed to be called - */ -static void ac101_i2s_config_clock(ac_i2s_clock_t *cfg) { - uint16_t regval=0; - regval = i2c_read_reg(I2S1LCK_CTRL); - regval &= 0xe03f; - regval |= (cfg->bclk_div << 9); - regval |= (cfg->lclk_div << 6); - i2c_write_reg(I2S1LCK_CTRL, regval); -} diff --git a/components/squeezelite/buffer.c b/components/squeezelite/buffer.c index 53d77f96..d8bb48f4 100644 --- a/components/squeezelite/buffer.c +++ b/components/squeezelite/buffer.c @@ -21,7 +21,9 @@ // fifo bufffers +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include "squeezelite.h" diff --git a/components/squeezelite/output_i2s.c b/components/squeezelite/output_i2s.c index 081b570a..4a7aa394 100644 --- a/components/squeezelite/output_i2s.c +++ b/components/squeezelite/output_i2s.c @@ -102,7 +102,7 @@ DECLARE_ALL_MIN_MAX; static int _i2s_write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t gainR, s32_t cross_gain_in, s32_t cross_gain_out, ISAMPLE_T **cross_ptr); static void *output_thread_i2s(void *arg); -static void *output_thread_i2s_stats(void *arg); +static void output_thread_i2s_stats(void *arg); static void spdif_convert(ISAMPLE_T *src, size_t frames, u32_t *dst, size_t *count); static void (*jack_handler_chain)(bool inserted); @@ -502,13 +502,13 @@ static void *output_thread_i2s(void *arg) { // this does not work well as set_sample_rates resets the fifos (and it's too early) if (i2s_config.sample_rate != output.current_sample_rate) { LOG_INFO("changing sampling rate %u to %u", i2s_config.sample_rate, output.current_sample_rate); - /* - if (synced) + if (synced) { + /* // can sleep for a buffer_queue - 1 and then eat a buffer (discard) if we are synced usleep(((DMA_BUF_COUNT - 1) * DMA_BUF_LEN * BYTES_PER_FRAME * 1000) / 44100 * 1000); discard = DMA_BUF_COUNT * DMA_BUF_LEN * BYTES_PER_FRAME; + */ } - */ i2s_config.sample_rate = output.current_sample_rate; i2s_set_sample_rates(CONFIG_I2S_NUM, spdif ? i2s_config.sample_rate * 2 : i2s_config.sample_rate); i2s_zero_dma_buffer(CONFIG_I2S_NUM); @@ -552,7 +552,7 @@ static void *output_thread_i2s(void *arg) { /**************************************************************************************** * Stats output thread */ -static void *output_thread_i2s_stats(void *arg) { +static void output_thread_i2s_stats(void *arg) { while (1) { // no need to lock output_state state = output.state; @@ -579,7 +579,7 @@ static void *output_thread_i2s_stats(void *arg) { } vTaskDelay( pdMS_TO_TICKS( STATS_PERIOD_MS ) ); } - return NULL; + return; } /**************************************************************************************** diff --git a/components/squeezelite/stream.c b/components/squeezelite/stream.c index 9561f339..f9247e11 100644 --- a/components/squeezelite/stream.c +++ b/components/squeezelite/stream.c @@ -21,7 +21,9 @@ // stream thread +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include "squeezelite.h" diff --git a/components/wifi-manager/http_server_handlers.c b/components/wifi-manager/http_server_handlers.c index 725ce19c..799d0ba5 100644 --- a/components/wifi-manager/http_server_handlers.c +++ b/components/wifi-manager/http_server_handlers.c @@ -41,21 +41,19 @@ function to process requests, decode URLs, serve files, etc. etc. #include #include #include "cJSON.h" -#include "config.h" #include "esp_system.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "platform_config.h" #include "sys/param.h" #include "esp_vfs.h" -#include "lwip/ip_addr.h" #include "messaging.h" #include "platform_esp32.h" #include "trace.h" #include "esp_console.h" #include "argtable3/argtable3.h" #include "platform_console.h" - + #define HTTP_STACK_SIZE (5*1024) const char str_na[]="N/A"; #define STR_OR_NA(s) s?s:str_na @@ -490,8 +488,8 @@ esp_err_t console_cmd_get_handler(httpd_req_t *req){ esp_err_t console_cmd_post_handler(httpd_req_t *req){ char success[]="{}"; ESP_LOGD_LOC(TAG, "serving [%s]", req->uri); - bool bOTA=false; - char * otaURL=NULL; + //bool bOTA=false; + //char * otaURL=NULL; esp_err_t err = post_handler_buff_receive(req); if(err!=ESP_OK){ return err; diff --git a/components/wifi-manager/wifi_manager_http_server.c b/components/wifi-manager/wifi_manager_http_server.c index 865bdb62..dfbfd13e 100644 --- a/components/wifi-manager/wifi_manager_http_server.c +++ b/components/wifi-manager/wifi_manager_http_server.c @@ -29,7 +29,6 @@ #include "esp_system.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" -#include "config.h" #include "messaging.h" #include "platform_esp32.h" static const char TAG[] = "http_server"; diff --git a/main/esp_app_main.c b/main/esp_app_main.c index 03aadb4a..c5d7dc6f 100644 --- a/main/esp_app_main.c +++ b/main/esp_app_main.c @@ -34,7 +34,6 @@ #include "wifi_manager.h" #include "squeezelite-ota.h" #include -#include "config.h" #include "audio_controls.h" #include "platform_config.h" #include "telnet.h"