diff --git a/components/audio_renderer/audio_renderer.c b/components/audio_renderer/audio_renderer.c index f5fb0240..f993ad42 100644 --- a/components/audio_renderer/audio_renderer.c +++ b/components/audio_renderer/audio_renderer.c @@ -14,14 +14,17 @@ #define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE #include "esp_log.h" #include -#include #include "driver/gpio.h" +#include "driver/dac.h" #include "gpio.h" #include "app_main.h" #include "MerusAudio.h" - +/* #include "audio_player.h" #include "audio_renderer.h" +#include "ac101.h" +#include "audio_hal.h" +*/ #define TAG "renderer" @@ -29,10 +32,11 @@ static renderer_config_t *renderer_instance = NULL; static component_status_t renderer_status = UNINITIALIZED; //static QueueHandle_t i2s_event_queue; +//static audio_board_handle_t a101_handle = 0; static void init_i2s(renderer_config_t *config) { - i2s_mode_t mode = I2S_MODE_MASTER | I2S_MODE_TX; + i2s_mode_t mode = I2S_MODE_MASTER | I2S_MODE_TX; i2s_comm_format_t comm_fmt = I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB; int use_apll = 0; esp_chip_info_t out_info; @@ -51,6 +55,7 @@ static void init_i2s(renderer_config_t *config) comm_fmt = I2S_COMM_FORMAT_PCM | I2S_COMM_FORMAT_PCM_SHORT; } +// if ((config->output_mode == I2S)||(config->output_mode == A1S)||(config->output_mode == I2S_MERUS)) if ((config->output_mode == I2S)||(config->output_mode == I2S_MERUS)) { /* don't use audio pll on buggy rev0 chips */ @@ -61,7 +66,21 @@ static void init_i2s(renderer_config_t *config) } else ESP_LOGI(TAG, "chip revision %d, cannot enable APLL", out_info.revision); } - /* +/* + if (config->output_mode == A1S) + { + ESP_LOGI(TAG, "Start a101 codec chip"); + a101_handle = a101_board_init(); + audio_hal_ctrl_codec(a101_handle->audio_hal, AUDIO_HAL_CODEC_MODE_DECODE, AUDIO_HAL_CTRL_START); + + int player_volume; + audio_hal_get_volume(a101_handle->audio_hal, &player_volume); + + ESP_LOGI(TAG, "ac101 value: %d",player_volume ); + + } +*/ + /* * Allocate just enough to decode AAC+, which has huge frame sizes. * * Memory consumption formula: @@ -100,9 +119,13 @@ static void init_i2s(renderer_config_t *config) { i2s_config.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1; if (i2s_driver_install(config->i2s_num, &i2s_config, 0, NULL) != ESP_OK) - i2s_config.intr_alloc_flags = ESP_INTR_FLAG_LEVEL2; + { + i2s_config.intr_alloc_flags = ESP_INTR_FLAG_LEVEL2; + } if (i2s_driver_install(config->i2s_num, &i2s_config, 0, NULL) != ESP_OK) - ESP_LOGE(TAG,"i2s Error"); + { + ESP_LOGE(TAG,"i2s Error"); + } return; } ESP_LOGI(TAG,"i2s intr:%d", i2s_config.intr_alloc_flags); @@ -122,6 +145,12 @@ static void init_i2s(renderer_config_t *config) //KaraDio32 void renderer_volume(uint32_t vol) { +/* if (mod == 5) + { + audio_hal_set_volume(a101_handle->audio_hal, vol/4); + vol = 254; + } +*/ // log volume (magic) if (vol == 1) return; // volume 0 // ESP_LOGI(TAG, "Renderer vol: %d %X",vol,vol ); diff --git a/components/audio_renderer/include/audio_renderer.h b/components/audio_renderer/include/audio_renderer.h index 12c15bec..b95f6c94 100644 --- a/components/audio_renderer/include/audio_renderer.h +++ b/components/audio_renderer/include/audio_renderer.h @@ -13,7 +13,7 @@ #include "common_component.h" typedef enum { - I2S, I2S_MERUS, DAC_BUILT_IN, PDM, VS1053, BTOOTH + I2S, I2S_MERUS, DAC_BUILT_IN, PDM, VS1053, A1S } output_mode_t; diff --git a/components/bt_speaker/bt_app_av.c b/components/bt_speaker/bt_app_av.c deleted file mode 100644 index 64f1e1f4..00000000 --- a/components/bt_speaker/bt_app_av.c +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "bt_app_av.h" - -#include -#include -#include -#include -#include "esp_log.h" - -#include "esp_bt_main.h" -#include "esp_bt_device.h" -#include "esp_gap_bt_api.h" -#include "esp_a2dp_api.h" -#include "esp_avrc_api.h" -#include "bt_app_core.h" - -#include "freertos/FreeRTOS.h" -#include "driver/i2s.h" - -#include "audio_renderer.h" - -/* a2dp event handler */ -static void bt_av_hdl_a2d_evt(uint16_t event, void *p_param); -/* avrc event handler */ -static void bt_av_hdl_avrc_evt(uint16_t event, void *p_param); - - -static uint32_t m_pkt_cnt = 0; -static esp_a2d_audio_state_t m_audio_state = ESP_A2D_AUDIO_STATE_STOPPED; - -static pcm_format_t bt_buffer_fmt = { - .sample_rate = 44100, - .bit_depth = I2S_BITS_PER_SAMPLE_16BIT, - .num_channels = 2, - .buffer_format = PCM_INTERLEAVED -}; - - -/* callback for A2DP sink */ -void bt_app_a2d_cb(esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param) -{ - switch (event) { - case ESP_A2D_CONNECTION_STATE_EVT: - case ESP_A2D_AUDIO_STATE_EVT: - case ESP_A2D_AUDIO_CFG_EVT: { - bt_app_work_dispatch(bt_av_hdl_a2d_evt, event, param, sizeof(esp_a2d_cb_param_t), NULL); - break; - } - default: - ESP_LOGE(BT_AV_TAG, "a2dp invalid cb event: %d", event); - break; - } -} - -/* cb with decoded samples */ -void bt_app_a2d_data_cb(const uint8_t *data, uint32_t len) -{ - render_samples((char *)data, len, &bt_buffer_fmt); - if (++m_pkt_cnt % 100 == 0) { - ESP_LOGE(BT_AV_TAG, "audio data pkt cnt %u", m_pkt_cnt); - } -} - -void bt_app_rc_ct_cb(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t *param) -{ - switch (event) { - case ESP_AVRC_CT_CONNECTION_STATE_EVT: - case ESP_AVRC_CT_PASSTHROUGH_RSP_EVT: { - bt_app_work_dispatch(bt_av_hdl_avrc_evt, event, param, sizeof(esp_avrc_ct_cb_param_t), NULL); - break; - } - default: - ESP_LOGE(BT_AV_TAG, "avrc invalid cb event: %d", event); - break; - } -} - -static void bt_av_hdl_a2d_evt(uint16_t event, void *p_param) -{ - ESP_LOGD(BT_AV_TAG, "%s evt %d", __func__, event); - esp_a2d_cb_param_t *a2d = NULL; - switch (event) { - case ESP_A2D_CONNECTION_STATE_EVT: { - a2d = (esp_a2d_cb_param_t *)(p_param); - ESP_LOGI(BT_AV_TAG, "a2dp conn_state_cb, state %d", a2d->conn_stat.state); - break; - } - case ESP_A2D_AUDIO_STATE_EVT: { - a2d = (esp_a2d_cb_param_t *)(p_param); - ESP_LOGI(BT_AV_TAG, "a2dp audio_state_cb state %d", a2d->audio_stat.state); - m_audio_state = a2d->audio_stat.state; - if (ESP_A2D_AUDIO_STATE_STARTED == a2d->audio_stat.state) { - m_pkt_cnt = 0; - renderer_start(); - } - break; - } - case ESP_A2D_AUDIO_CFG_EVT: { - a2d = (esp_a2d_cb_param_t *)(p_param); - ESP_LOGI(BT_AV_TAG, "a2dp audio_cfg_cb , codec type %d", a2d->audio_cfg.mcc.type); - // for now only SBC stream is supported - if (a2d->audio_cfg.mcc.type == ESP_A2D_MCT_SBC) { - ESP_LOGI(BT_AV_TAG, "audio player configured"); - } - break; - } - default: - ESP_LOGE(BT_AV_TAG, "%s unhandled evt %d", __func__, event); - break; - } -} - -static void bt_av_hdl_avrc_evt(uint16_t event, void *p_param) -{ - ESP_LOGD(BT_AV_TAG, "%s evt %d", __func__, event); - esp_avrc_ct_cb_param_t *rc = (esp_avrc_ct_cb_param_t *)(p_param); - switch (event) { - case ESP_AVRC_CT_CONNECTION_STATE_EVT: { - uint8_t *bda = rc->conn_stat.remote_bda; - ESP_LOGI(BT_AV_TAG, "avrc conn_state evt: state %d, feature 0x%x, [%02x:%02x:%02x:%02x:%02x:%02x]", - rc->conn_stat.connected, rc->conn_stat.feat_mask, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]); - break; - } - case ESP_AVRC_CT_PASSTHROUGH_RSP_EVT: { - ESP_LOGI(BT_AV_TAG, "avrc passthrough rsp: key_code 0x%x, key_state %d", rc->psth_rsp.key_code, rc->psth_rsp.key_state); - break; - } - default: - ESP_LOGE(BT_AV_TAG, "%s unhandled evt %d", __func__, event); - break; - } -} diff --git a/components/bt_speaker/bt_app_av.h b/components/bt_speaker/bt_app_av.h deleted file mode 100644 index 25007242..00000000 --- a/components/bt_speaker/bt_app_av.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef __BT_APP_AV_H__ -#define __BT_APP_AV_H__ - -#include -#include "esp_a2dp_api.h" -#include "esp_avrc_api.h" - -#define BT_AV_TAG "BT_AV" - - -/** - * @brief callback function for A2DP sink - */ -void bt_app_a2d_cb(esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param); - -/** - * @brief callback function for A2DP sink audio data stream - */ -void bt_app_a2d_data_cb(const uint8_t *data, uint32_t len); - -/** - * @brief callback function for AVRCP controller - */ -void bt_app_rc_ct_cb(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t *param); - -#endif /* __BT_APP_AV_H__*/ diff --git a/components/bt_speaker/bt_app_core.c b/components/bt_speaker/bt_app_core.c deleted file mode 100644 index 093c82d8..00000000 --- a/components/bt_speaker/bt_app_core.c +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "../bt_speaker/bt_app_core.h" - -#include -#include -#include -#include "freertos/xtensa_api.h" -#include "freertos/FreeRTOSConfig.h" -#include "freertos/FreeRTOS.h" -#include "freertos/queue.h" -#include "freertos/task.h" -#include "esp_log.h" - -static void bt_app_task_handler(void *arg); -static bool bt_app_send_msg(bt_app_msg_t *msg); -static void bt_app_work_dispatched(bt_app_msg_t *msg); - -static xQueueHandle bt_app_task_queue = NULL; -static xTaskHandle bt_app_task_handle = NULL; - -bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback) -{ - ESP_LOGD(BT_APP_CORE_TAG, "%s event 0x%x, param len %d", __func__, event, param_len); - - bt_app_msg_t msg; - memset(&msg, 0, sizeof(bt_app_msg_t)); - - msg.sig = BT_APP_SIG_WORK_DISPATCH; - msg.event = event; - msg.cb = p_cback; - - if (param_len == 0) { - return bt_app_send_msg(&msg); - } else if (p_params && param_len > 0) { - if ((msg.param = malloc(param_len)) != NULL) { - memcpy(msg.param, p_params, param_len); - /* check if caller has provided a copy callback to do the deep copy */ - if (p_copy_cback) { - p_copy_cback(&msg, msg.param, p_params); - } - return bt_app_send_msg(&msg); - } - } - - return false; -} - -static bool bt_app_send_msg(bt_app_msg_t *msg) -{ - if (msg == NULL) { - return false; - } - - if (xQueueSend(bt_app_task_queue, msg, 10 / portTICK_RATE_MS) != pdTRUE) { - ESP_LOGE(BT_APP_CORE_TAG, "%s xQueue send failed", __func__); - return false; - } - return true; -} - -static void bt_app_work_dispatched(bt_app_msg_t *msg) -{ - if (msg->cb) { - msg->cb(msg->event, msg->param); - } -} - -static void bt_app_task_handler(void *arg) -{ - bt_app_msg_t msg; - for (;;) { - if (pdTRUE == xQueueReceive(bt_app_task_queue, &msg, (portTickType)portMAX_DELAY)) { - ESP_LOGI(BT_APP_CORE_TAG, "%s, sig 0x%x, 0x%x", __func__, msg.sig, msg.event); - switch (msg.sig) { - case BT_APP_SIG_WORK_DISPATCH: - bt_app_work_dispatched(&msg); - break; - default: - ESP_LOGW(BT_APP_CORE_TAG, "%s, unhandled sig: %d", __func__, msg.sig); - break; - } // switch (msg.sig) - - if (msg.param) { - free(msg.param); - } - } - } -} - -void bt_app_task_start_up(void) -{ - bt_app_task_queue = xQueueCreate(10, sizeof(bt_app_msg_t)); - xTaskCreate(bt_app_task_handler, "BtAppT", 2048, NULL, configMAX_PRIORITIES - 3, bt_app_task_handle); - return; -} - -void bt_app_task_shut_down(void) -{ - if (bt_app_task_handle) { - vTaskDelete(bt_app_task_handle); - bt_app_task_handle = NULL; - } - if (bt_app_task_queue) { - vQueueDelete(bt_app_task_queue); - bt_app_task_queue = NULL; - } -} diff --git a/components/bt_speaker/bt_app_core.h b/components/bt_speaker/bt_app_core.h deleted file mode 100644 index 0238ba4e..00000000 --- a/components/bt_speaker/bt_app_core.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef __BT_APP_CORE_H__ -#define __BT_APP_CORE_H__ - -#include -#include -#include - -#define BT_APP_CORE_TAG "BT_APP_CORE" - -#define BT_APP_SIG_WORK_DISPATCH (0x01) - -/** - * @brief handler for the dispatched work - */ -typedef void (* bt_app_cb_t) (uint16_t event, void *param); - -/* message to be sent */ -typedef struct { - uint16_t sig; /*!< signal to bt_app_task */ - uint16_t event; /*!< message event id */ - bt_app_cb_t cb; /*!< context switch callback */ - void *param; /*!< parameter area needs to be last */ -} bt_app_msg_t; - -/** - * @brief parameter deep-copy function to be customized - */ -typedef void (* bt_app_copy_cb_t) (bt_app_msg_t *msg, void *p_dest, void *p_src); - -/** - * @brief work dispatcher for the application task - */ -bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback); - -void bt_app_task_start_up(void); - -void bt_app_task_shut_down(void); - -#endif /* __BT_APP_CORE_H__ */ diff --git a/components/bt_speaker/bt_speaker.c b/components/bt_speaker/bt_speaker.c deleted file mode 100644 index 11f2f177..00000000 --- a/components/bt_speaker/bt_speaker.c +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include -#include -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "nvs.h" -#include "nvs_flash.h" -#include "esp_system.h" -#include "esp_log.h" - -#include "bt.h" -#include "esp_bt_main.h" -#include "esp_bt_device.h" -#include "esp_gap_bt_api.h" -#include "esp_a2dp_api.h" -#include "esp_avrc_api.h" -#include "../bt_speaker/bt_app_av.h" -#include "../bt_speaker/bt_app_core.h" -#include "../../main/include/bt_config.h" - -#include "audio_renderer.h" - -/* event for handler "bt_av_hdl_stack_up */ -enum { - BT_APP_EVT_STACK_UP = 0, -}; - -/* handler for bluetooth stack enabled events */ -static void bt_av_hdl_stack_evt(uint16_t event, void *p_param); - - -void bt_speaker_start(renderer_config_t *renderer_config) -{ - - esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); - if (esp_bt_controller_init(&bt_cfg) != ESP_OK) { - ESP_LOGE(BT_AV_TAG, "%s initialize controller failed\n", __func__); - return; - } - - if (esp_bt_controller_enable(ESP_BT_MODE_BTDM) != ESP_OK) { - ESP_LOGE(BT_AV_TAG, "%s enable controller failed\n", __func__); - return; - } - - if (esp_bluedroid_init() != ESP_OK) { - ESP_LOGE(BT_AV_TAG, "%s initialize bluedroid failed\n", __func__); - return; - } - - if (esp_bluedroid_enable() != ESP_OK) { - ESP_LOGE(BT_AV_TAG, "%s enable bluedroid failed\n", __func__); - return; - } - - /* init renderer */ - renderer_init(renderer_config); - - /* create application task */ - bt_app_task_start_up(); - - /* Bluetooth device name, connection mode and profile set up */ - bt_app_work_dispatch(bt_av_hdl_stack_evt, BT_APP_EVT_STACK_UP, NULL, 0, NULL); -} - - -static void bt_av_hdl_stack_evt(uint16_t event, void *p_param) -{ - ESP_LOGD(BT_AV_TAG, "%s evt %d", __func__, event); - switch (event) { - case BT_APP_EVT_STACK_UP: { - /* set up device name */ - //char *dev_name = "ESP_SPEAKER"; - esp_bt_dev_set_device_name(dev_name); - - /* initialize A2DP sink */ - esp_a2d_register_callback(&bt_app_a2d_cb); - esp_a2d_register_data_callback(bt_app_a2d_data_cb); - esp_a2d_sink_init(); - - /* initialize AVRCP controller */ - esp_avrc_ct_init(); - esp_avrc_ct_register_callback(bt_app_rc_ct_cb); - - /* set discoverable and connectable mode, wait to be connected */ - esp_bt_gap_set_scan_mode(ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE); - break; - } - default: - ESP_LOGE(BT_AV_TAG, "%s unhandled evt %d", __func__, event); - break; - } -} diff --git a/components/bt_speaker/component.mk b/components/bt_speaker/component.mk deleted file mode 100644 index c8e9a65c..00000000 --- a/components/bt_speaker/component.mk +++ /dev/null @@ -1,14 +0,0 @@ -# -# Component Makefile -# - -# if Bluetooth is disabled in menuconfig, -# the BT libs are missing from the buildpath -ifdef CONFIG_BT_SPEAKER_MODE -COMPONENT_ADD_INCLUDEDIRS := . include -COMPONENT_SRCDIRS := . -else -COMPONENT_ADD_INCLUDEDIRS := -COMPONENT_ADD_LDFLAGS := -COMPONENT_SRCDIRS := -endif diff --git a/components/bt_speaker/include/bt_speaker.h b/components/bt_speaker/include/bt_speaker.h deleted file mode 100644 index bc1c2d29..00000000 --- a/components/bt_speaker/include/bt_speaker.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * a2dp.h - * - * Created on: 07.05.2017 - * Author: michaelboeckling - */ - -#ifndef _INCLUDE_BT_SPEAKER_H_ -#define _INCLUDE_BT_SPEAKER_H_ - -void bt_speaker_start(renderer_config_t *renderer_config); - -#endif /* _INCLUDE_BT_SPEAKER_H_ */ diff --git a/components/fdk-aac-oreo-m8/libAACdec/include/aacdecoder_lib.h b/components/fdk-aac-oreo-m8/libAACdec/include/aacdecoder_lib.h index 7ab60f19..4e6e7e01 100644 --- a/components/fdk-aac-oreo-m8/libAACdec/include/aacdecoder_lib.h +++ b/components/fdk-aac-oreo-m8/libAACdec/include/aacdecoder_lib.h @@ -604,8 +604,7 @@ extern "C" * \param size Size of the buffer pointed to by buffer. * \return Error code. */ -LINKSPEC_H AAC_DECODER_ERROR -aacDecoder_AncDataInit ( HANDLE_AACDECODER self, +LINKSPEC_H AAC_DECODER_ERROR aacDecoder_AncDataInit ( HANDLE_AACDECODER self, UCHAR *buffer, int size ); @@ -618,8 +617,7 @@ aacDecoder_AncDataInit ( HANDLE_AACDECODER self, * \param size Pointer to a buffer receiving the length of the requested ancillary data element. * \return Error code. */ -LINKSPEC_H AAC_DECODER_ERROR -aacDecoder_AncDataGet ( HANDLE_AACDECODER self, +LINKSPEC_H AAC_DECODER_ERROR aacDecoder_AncDataGet ( HANDLE_AACDECODER self, int index, UCHAR **ptr, int *size ); @@ -632,8 +630,7 @@ aacDecoder_AncDataGet ( HANDLE_AACDECODER self, * \param value Parameter value. * \return Error code. */ -LINKSPEC_H AAC_DECODER_ERROR -aacDecoder_SetParam ( const HANDLE_AACDECODER self, +LINKSPEC_H AAC_DECODER_ERROR aacDecoder_SetParam ( const HANDLE_AACDECODER self, const AACDEC_PARAM param, const INT value ); @@ -644,8 +641,7 @@ aacDecoder_SetParam ( const HANDLE_AACDECODER self, * \param pFreeBytes Pointer to variable receving amount of free bytes inside decoder internal buffer * \return Error code */ -LINKSPEC_H AAC_DECODER_ERROR -aacDecoder_GetFreeBytes ( const HANDLE_AACDECODER self, +LINKSPEC_H AAC_DECODER_ERROR aacDecoder_GetFreeBytes ( const HANDLE_AACDECODER self, UINT *pFreeBytes); /** @@ -653,8 +649,7 @@ aacDecoder_GetFreeBytes ( const HANDLE_AACDECODER self, * \param transportFmt The transport type to be used * \return AAC decoder handle */ -LINKSPEC_H HANDLE_AACDECODER -aacDecoder_Open ( TRANSPORT_TYPE transportFmt, UINT nrOfLayers ); +LINKSPEC_H HANDLE_AACDECODER aacDecoder_Open ( TRANSPORT_TYPE transportFmt, UINT nrOfLayers ); /** * \brief Explicitly configure the decoder by passing a raw AudioSpecificConfig (ASC) or a StreamMuxConfig (SMC), @@ -667,8 +662,7 @@ aacDecoder_Open ( TRANSPORT_TYPE transportFmt, UINT nrOfLayers ); * \param length Length of the configuration buffer in bytes. * \return Error code. */ -LINKSPEC_H AAC_DECODER_ERROR -aacDecoder_ConfigRaw ( HANDLE_AACDECODER self, +LINKSPEC_H AAC_DECODER_ERROR aacDecoder_ConfigRaw ( HANDLE_AACDECODER self, UCHAR *conf[], const UINT length[] ); @@ -692,8 +686,7 @@ aacDecoder_ConfigRaw ( HANDLE_AACDECODER self, * The value is updated according to the amount of newly copied bytes. * \return Error code. */ -LINKSPEC_H AAC_DECODER_ERROR -aacDecoder_Fill ( HANDLE_AACDECODER self, +LINKSPEC_H AAC_DECODER_ERROR aacDecoder_Fill ( HANDLE_AACDECODER self, UCHAR *pBuffer[], const UINT bufferSize[], UINT *bytesValid ); @@ -719,8 +712,7 @@ aacDecoder_Fill ( HANDLE_AACDECODER self, * (flags & AACDEC_INTR) == 4: Input data is discontinuous. Resynchronize any internals as necessary. * \return Error code. */ -LINKSPEC_H AAC_DECODER_ERROR -aacDecoder_DecodeFrame ( HANDLE_AACDECODER self, +LINKSPEC_H AAC_DECODER_ERROR aacDecoder_DecodeFrame ( HANDLE_AACDECODER self, INT_PCM *pTimeData, const INT timeDataSize, const UINT flags ); diff --git a/components/fdk-aac-oreo-m8/libAACdec/src/aacdec_hcrs.cpp b/components/fdk-aac-oreo-m8/libAACdec/src/aacdec_hcrs.cpp index c0b2173f..8283ed70 100644 --- a/components/fdk-aac-oreo-m8/libAACdec/src/aacdec_hcrs.cpp +++ b/components/fdk-aac-oreo-m8/libAACdec/src/aacdec_hcrs.cpp @@ -399,7 +399,7 @@ static void InitNonPCWSideInformationForCurrentSet(H_HCR_INFO pHcr) int extendedSortedCodebookIdx = pHcr->sectionInfo.extendedSortedCodebookIdx; USHORT *pNumExtendedSortedSectionsInSets = pHcr->sectionInfo.pNumExtendedSortedSectionsInSets; int numExtendedSortedSectionsInSetsIdx = pHcr->sectionInfo.numExtendedSortedSectionsInSetsIdx; - FIXP_DBL *pQuantizedSpectralCoefficients = SPEC_LONG(pHcr->decInOut.pQuantizedSpectralCoefficientsBase); + //FIXP_DBL *pQuantizedSpectralCoefficients = SPEC_LONG(pHcr->decInOut.pQuantizedSpectralCoefficientsBase); int quantizedSpectralCoefficientsIdx = pHcr->decInOut.quantizedSpectralCoefficientsIdx; const UCHAR *pCbDimension = pHcr->tableInfo.pCbDimension; int iterationCounter = 0; diff --git a/components/fdk-aac-oreo-m8/libAACdec/src/aacdecoder.cpp b/components/fdk-aac-oreo-m8/libAACdec/src/aacdecoder.cpp index 579e4703..973fe794 100644 --- a/components/fdk-aac-oreo-m8/libAACdec/src/aacdecoder.cpp +++ b/components/fdk-aac-oreo-m8/libAACdec/src/aacdecoder.cpp @@ -372,13 +372,14 @@ static AAC_DECODER_ERROR CDataStreamElement_Read ( } { - PCMDMX_ERROR dmxErr = PCMDMX_OK; - + /* Move to the beginning of the data junk */ FDKpushBack(bs, dataStart-FDKgetValidBits(bs)); /* Read DMX meta-data */ - dmxErr = pcmDmx_Parse ( + //PCMDMX_ERROR dmxErr = PCMDMX_OK; + + pcmDmx_Parse ( self->hPcmUtils, bs, dseBits, @@ -512,6 +513,7 @@ AAC_DECODER_ERROR CAacDecoder_ExtPayloadParse (HANDLE_AACDECODER self, case EXT_SBR_DATA_CRC: crcFlag = 1; + /*fall through*/ case EXT_SBR_DATA: if (IS_CHANNEL_ELEMENT(previous_element)) { SBR_ERROR sbrError; @@ -653,8 +655,7 @@ AAC_DECODER_ERROR CAacDecoder_ExtPayloadParse (HANDLE_AACDECODER self, } /* Note: the fall through in case the if statement above is not taken is intentional. */ break; - } - + }/*fall through*/ case EXT_FIL: default: @@ -834,13 +835,13 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_Init(HANDLE_AACDECODER self, const CS switch (asc->m_aot) { case AOT_AAC_LC: self->streamInfo.profile = 1; - + /*fall through*/ case AOT_ER_AAC_SCAL: if (asc->m_sc.m_gaSpecificConfig.m_layer > 0) { /* aac_scalable_extension_element() currently not supported. */ return AAC_DEC_UNSUPPORTED_FORMAT; } - + /*fall through*/ case AOT_SBR: case AOT_PS: case AOT_ER_AAC_LD: diff --git a/components/fdk-aac-oreo-m8/libAACdec/src/aacdecoder_lib.cpp b/components/fdk-aac-oreo-m8/libAACdec/src/aacdecoder_lib.cpp index 94eb3c05..867711bc 100644 --- a/components/fdk-aac-oreo-m8/libAACdec/src/aacdecoder_lib.cpp +++ b/components/fdk-aac-oreo-m8/libAACdec/src/aacdecoder_lib.cpp @@ -105,6 +105,7 @@ amm-info@iis.fraunhofer.de #include "aacdec_drc.h" + #include "limiter.h" /* Decoder library info */ @@ -399,14 +400,14 @@ aacDecoder_SetParam ( const HANDLE_AACDECODER self, /*!< Handle of the decode const INT value) /*!< Parameter valued */ { AAC_DECODER_ERROR errorStatus = AAC_DEC_OK; - CConcealParams *pConcealData = NULL; + //CConcealParams *pConcealData = NULL; HANDLE_AAC_DRC hDrcInfo = NULL; HANDLE_PCM_DOWNMIX hPcmDmx = NULL; TDLimiterPtr hPcmTdl = NULL; /* check decoder handle */ if (self != NULL) { - pConcealData = &self->concealCommonData; + // pConcealData = &self->concealCommonData; hDrcInfo = self->hDrcInfo; hPcmDmx = self->hPcmUtils; hPcmTdl = self->hLimiter; diff --git a/components/fdk-aac-oreo-m8/libAACdec/src/block.cpp b/components/fdk-aac-oreo-m8/libAACdec/src/block.cpp index a19284e4..e064f0f3 100644 --- a/components/fdk-aac-oreo-m8/libAACdec/src/block.cpp +++ b/components/fdk-aac-oreo-m8/libAACdec/src/block.cpp @@ -509,7 +509,7 @@ AAC_DECODER_ERROR CBlock_ReadSpectralData(HANDLE_FDK_BITSTREAM bs, const SHORT *RESTRICT BandOffsets = GetScaleFactorBandOffsets(&pAacDecoderChannelInfo->icsInfo, pSamplingRateInfo); SPECTRAL_PTR pSpectralCoefficient = pAacDecoderChannelInfo->pSpectralCoefficient; - FIXP_DBL locMax; + // FIXP_DBL locMax; int ScaleFactorBandsTransmitted = GetScaleFactorBandsTransmitted(&pAacDecoderChannelInfo->icsInfo); @@ -550,7 +550,7 @@ AAC_DECODER_ERROR CBlock_ReadSpectralData(HANDLE_FDK_BITSTREAM bs, FIXP_DBL *mdctSpectrum = SPEC(pSpectralCoefficient, window, pAacDecoderChannelInfo->granuleLength); - locMax = (FIXP_DBL)0 ; + // locMax = (FIXP_DBL)0 ; for (index=BandOffsets[band]; index < BandOffsets[band+1]; index+=step) { @@ -680,8 +680,9 @@ void CBlock_FrequencyToTime(CAacDecoderStaticChannelInfo *pAacDecoderStaticChann const int frameOk, FIXP_DBL *pWorkBuffer1 ) { - int fr, fl, tl, nSamples, nSpec; - + int fr, fl, tl, nSpec; + //nSamples, + /* Determine left slope length (fl), right slope length (fr) and transform length (tl). USAC: The slope length may mismatch with the previous frame in case of LPD / FD transitions. The adjustment is handled by the imdct implementation. @@ -716,7 +717,8 @@ void CBlock_FrequencyToTime(CAacDecoderStaticChannelInfo *pAacDecoderStaticChann { FIXP_DBL *tmp = pAacDecoderChannelInfo->pComData->workBufferCore1->mdctOutTemp; - nSamples = imdct_block( + //nSamples = + imdct_block( &pAacDecoderStaticChannelInfo->IMdct, tmp, SPEC_LONG(pAacDecoderChannelInfo->pSpectralCoefficient), diff --git a/components/fdk-aac-oreo-m8/libAACdec/src/rvlcconceal.cpp b/components/fdk-aac-oreo-m8/libAACdec/src/rvlcconceal.cpp index cf33dd59..49386ec4 100644 --- a/components/fdk-aac-oreo-m8/libAACdec/src/rvlcconceal.cpp +++ b/components/fdk-aac-oreo-m8/libAACdec/src/rvlcconceal.cpp @@ -537,13 +537,15 @@ void StatisticalEstimation (CAacDecoderChannelInfo *pAacDecoderChannelInfo) int sumNrgFwd,sumNrgBwd; /* sum of noise energy data forward/backward */ int sumScfFwd,sumScfBwd; /* sum of scalefactor data forward/backward */ int useIsFwd,useNrgFwd,useScfFwd; /* the flags signals the elements which are used for the final result */ + /* int MaximumScaleFactorBands; if (GetWindowSequence(&pAacDecoderChannelInfo->icsInfo) == EightShortSequence) MaximumScaleFactorBands = 16; else MaximumScaleFactorBands = 64; - + */ + sumIsFwd = sumIsBwd = sumNrgFwd = sumNrgBwd = sumScfFwd = sumScfBwd = 0; useIsFwd = useNrgFwd = useScfFwd = 0; @@ -641,13 +643,15 @@ void PredictiveInterpolation ( { CErRvlcInfo *pRvlc = &pAacDecoderChannelInfo->pComData->overlay.aac.erRvlcInfo; int band,bnds,group; - int MaximumScaleFactorBands; int commonMin; +/* + int MaximumScaleFactorBands; if (GetWindowSequence(&pAacDecoderChannelInfo->icsInfo) == EightShortSequence) MaximumScaleFactorBands = 16; else MaximumScaleFactorBands = 64; + */ for (group=0; groupnumWindowGroups; group++) { for (band=0; band < pRvlc->maxSfbTransmitted; band++) { diff --git a/components/fdk-aac-oreo-m8/libAACenc/src/aacenc.cpp b/components/fdk-aac-oreo-m8/libAACenc/src/aacenc.cpp index 5e8c08d5..cde81d4a 100644 --- a/components/fdk-aac-oreo-m8/libAACenc/src/aacenc.cpp +++ b/components/fdk-aac-oreo-m8/libAACenc/src/aacenc.cpp @@ -926,8 +926,9 @@ AAC_ENCODER_ERROR FDKaacEnc_EncodeFrame( HANDLE_AAC_ENC hAacEnc, hAacEnc->qcKernel->elementBits, hAacEnc->qcOut); if (ErrorStatus != AAC_ENC_OK) - return ErrorStatus; - + { + return ErrorStatus; + } /*-------------------------------------------- */ ErrorStatus = FDKaacEnc_FinalizeBitConsumption(cm, hAacEnc->qcKernel, @@ -938,8 +939,10 @@ AAC_ENCODER_ERROR FDKaacEnc_EncodeFrame( HANDLE_AAC_ENC hAacEnc, hAacEnc->config->syntaxFlags, hAacEnc->config->epConfig); if (ErrorStatus != AAC_ENC_OK) - return ErrorStatus; - /*-------------------------------------------- */ + { + return ErrorStatus; + } + /*-------------------------------------------- */ totalBits += qcOut->totalBits; @@ -970,8 +973,10 @@ AAC_ENCODER_ERROR FDKaacEnc_EncodeFrame( HANDLE_AAC_ENC hAacEnc, hAacEnc->config->epConfig); if (ErrorStatus != AAC_ENC_OK) - return ErrorStatus; - + + { + return ErrorStatus; + } /* transportEnc_EndAccessUnit() is being called inside FDKaacEnc_WriteBitstream() */ transportEnc_GetFrame(hTpEnc, nOutBytes); diff --git a/components/fdk-aac-oreo-m8/libAACenc/src/aacenc_lib.cpp b/components/fdk-aac-oreo-m8/libAACenc/src/aacenc_lib.cpp index 64445b92..a14bf2ea 100644 --- a/components/fdk-aac-oreo-m8/libAACenc/src/aacenc_lib.cpp +++ b/components/fdk-aac-oreo-m8/libAACenc/src/aacenc_lib.cpp @@ -1780,12 +1780,14 @@ AACENC_ERROR aacEncoder_SetParam( err = AACENC_INVALID_CONFIG; goto bail; } - case AOT_SBR: + /* fall through */ + case AOT_SBR: if (!(hAacEncoder->encoder_modis & (ENC_MODE_FLAG_SBR))) { err = AACENC_INVALID_CONFIG; goto bail; } - case AOT_AAC_LC: + /* fall through */ + case AOT_AAC_LC: case AOT_ER_AAC_LD: case AOT_ER_AAC_ELD: if (!(hAacEncoder->encoder_modis & (ENC_MODE_FLAG_AAC))) { @@ -1793,6 +1795,7 @@ AACENC_ERROR aacEncoder_SetParam( goto bail; } break; + /* fall through */ default: err = AACENC_INVALID_CONFIG; goto bail; diff --git a/components/fdk-aac-oreo-m8/libFDK/include/fft.h b/components/fdk-aac-oreo-m8/libFDK/include/fft.h index 616f3508..83872727 100644 --- a/components/fdk-aac-oreo-m8/libFDK/include/fft.h +++ b/components/fdk-aac-oreo-m8/libFDK/include/fft.h @@ -121,7 +121,7 @@ void ifft(int length, FIXP_DBL *pInput, INT *scalefactor); */ LNK_SECTION_CODE_L1 -static void FORCEINLINE fft_4(FIXP_DBL *x) +static inline void fft_4(FIXP_DBL *x) { FIXP_DBL a00, a10, a20, a30, tmp0, tmp1; @@ -149,7 +149,7 @@ static void FORCEINLINE fft_4(FIXP_DBL *x) } LNK_SECTION_CODE_L1 -static void FORCEINLINE fft_8(FIXP_DBL *x) +static inline void fft_8(FIXP_DBL *x) { #define W_PiFOURTH STC(0x5a82799a) diff --git a/components/fdk-aac-oreo-m8/libFDK/src/fft.cpp b/components/fdk-aac-oreo-m8/libFDK/src/fft.cpp index 653a71ac..dda12b89 100644 --- a/components/fdk-aac-oreo-m8/libFDK/src/fft.cpp +++ b/components/fdk-aac-oreo-m8/libFDK/src/fft.cpp @@ -103,7 +103,7 @@ amm-info@iis.fraunhofer.de /* Performs the FFT of length 3 according to the algorithm after winograd. No scaling of the input vector because the scaling is already done in the rotation vector. */ -static FORCEINLINE void fft3(FIXP_DBL *RESTRICT pDat) +static inline void fft3(FIXP_DBL *RESTRICT pDat) { FIXP_DBL r1,r2; FIXP_DBL s1,s2; @@ -136,7 +136,7 @@ static FORCEINLINE void fft3(FIXP_DBL *RESTRICT pDat) #define C55 (F5C(0xb0000001)) /* FL2FXCONST_DBL(-1.25/2) */ /* performs the FFT of length 5 according to the algorithm after winograd */ -static FORCEINLINE void fft5(FIXP_DBL *RESTRICT pDat) +static inline void fft5(FIXP_DBL *RESTRICT pDat) { FIXP_DBL r1,r2,r3,r4; FIXP_DBL s1,s2,s3,s4; diff --git a/components/fdk-aac-oreo-m8/libMpegTPDec/src/tpdec_adts.cpp b/components/fdk-aac-oreo-m8/libMpegTPDec/src/tpdec_adts.cpp index c4556816..5c98bac8 100644 --- a/components/fdk-aac-oreo-m8/libMpegTPDec/src/tpdec_adts.cpp +++ b/components/fdk-aac-oreo-m8/libMpegTPDec/src/tpdec_adts.cpp @@ -169,7 +169,7 @@ TRANSPORTDEC_ERROR adtsRead_DecodeHeader( const INT ignoreBufferFullness ) { - INT crcReg; + INT crcReg = 0; INT valBits; INT cmp_buffer_fullness; diff --git a/components/fdk-aac-oreo-m8/libMpegTPDec/src/tpdec_asc.cpp b/components/fdk-aac-oreo-m8/libMpegTPDec/src/tpdec_asc.cpp index e80d0e5a..605a4765 100644 --- a/components/fdk-aac-oreo-m8/libMpegTPDec/src/tpdec_asc.cpp +++ b/components/fdk-aac-oreo-m8/libMpegTPDec/src/tpdec_asc.cpp @@ -404,6 +404,7 @@ void CProgramConfig_GetDefault( CProgramConfig *pPce, pPce->BackElementIsCpe[1] = 1; pPce->NumChannels += 1; pPce->NumEffectiveChannels += 1; + /*fall through*/ case 11: /* 3/0/3.1ch */ pPce->NumFrontChannelElements += 2; pPce->FrontElementIsCpe[0] = 0; @@ -419,25 +420,30 @@ void CProgramConfig_GetDefault( CProgramConfig *pPce, /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ case 14: /* 2/0/0-3/0/2-0.1ch front height */ pPce->FrontElementHeightInfo[2] = 1; /* Top speaker */ + /*fall through*/ case 7: /* 5/0/2.1ch front */ pPce->NumFrontChannelElements += 1; pPce->FrontElementIsCpe[2] = 1; pPce->NumChannels += 2; pPce->NumEffectiveChannels += 2; + /*fall through*/ case 6: /* 3/0/2.1ch */ pPce->NumLfeChannelElements += 1; pPce->NumChannels += 1; + /*fall through*/ case 5: /* 3/0/2.0ch */ case 4: /* 3/0/1.0ch */ pPce->NumBackChannelElements += 1; pPce->BackElementIsCpe[0] = (channelConfig>4) ? 1 : 0; pPce->NumChannels += (channelConfig>4) ? 2 : 1; pPce->NumEffectiveChannels += (channelConfig>4) ? 2 : 1; + /*fall through*/ case 3: /* 3/0/0.0ch */ pPce->NumFrontChannelElements += 1; pPce->FrontElementIsCpe[1] = 1; pPce->NumChannels += 2; pPce->NumEffectiveChannels += 2; + /*fall through*/ case 1: /* 1/0/0.0ch */ pPce->NumFrontChannelElements += 1; pPce->FrontElementIsCpe[0] = 0; @@ -661,7 +667,8 @@ int CProgramConfig_LookupElement( { case ID_CPE: isCpe = 1; - case ID_SCE: + /*fall through*/ + case ID_SCE: /* search in front channels */ for (i = 0; i < pPce->NumFrontChannelElements; i++) { int heightLayer = pPce->FrontElementHeightInfo[i]; @@ -1086,16 +1093,18 @@ static INT ld_sbr_header( const CSAudioSpecificConfig *asc, case 12: case 7: error |= cb->cbSbr(cb->cbSbrData, hBs, asc->m_samplingFrequency, asc->m_extensionSamplingFrequency, asc->m_samplesPerFrame, AOT_ER_AAC_ELD, ID_CPE, i++); - case 6: + /*fall through*/ + case 6: case 5: error |= cb->cbSbr(cb->cbSbrData, hBs, asc->m_samplingFrequency, asc->m_extensionSamplingFrequency, asc->m_samplesPerFrame, AOT_ER_AAC_ELD, ID_CPE, i++); - case 3: + /*fall through*/ + case 3: error |= cb->cbSbr(cb->cbSbrData, hBs, asc->m_samplingFrequency, asc->m_extensionSamplingFrequency, asc->m_samplesPerFrame, AOT_ER_AAC_ELD, ID_CPE, i++); - break; - + break; case 11: error |= cb->cbSbr(cb->cbSbrData, hBs, asc->m_samplingFrequency, asc->m_extensionSamplingFrequency, asc->m_samplesPerFrame, AOT_ER_AAC_ELD, ID_CPE, i++); - case 4: + /*fall through*/ + case 4: error |= cb->cbSbr(cb->cbSbrData, hBs, asc->m_samplingFrequency, asc->m_extensionSamplingFrequency, asc->m_samplesPerFrame, AOT_ER_AAC_ELD, ID_CPE, i++); error |= cb->cbSbr(cb->cbSbrData, hBs, asc->m_samplingFrequency, asc->m_extensionSamplingFrequency, asc->m_samplesPerFrame, AOT_ER_AAC_ELD, ID_SCE, i++); break; @@ -1170,7 +1179,6 @@ TRANSPORTDEC_ERROR EldSpecificConfig_Parse( /* add future eld extension configs here */ } } -bail: return (ErrorStatus); } #endif /* TP_ELD_ENABLE */ @@ -1415,7 +1423,7 @@ TRANSPORTDEC_ERROR DrmRawSdcAudioConfig_Parse( - coder field 5 bits - rfa 1 bit */ - int audioCoding, audioMode, cSamplingFreq, coderField, sfIdx, sbrFlag; + int audioCoding, audioMode, cSamplingFreq, sfIdx, sbrFlag; /* Read the SDC field */ FDKreadBits(bs,4); /* Short and Stream Id */ @@ -1426,7 +1434,7 @@ TRANSPORTDEC_ERROR DrmRawSdcAudioConfig_Parse( cSamplingFreq = FDKreadBits(bs, 3); /* audio sampling rate */ FDKreadBits(bs, 2); /* Text and enhancement flag */ - coderField = FDKreadBits(bs, 5); + FDKreadBits(bs, 5); FDKreadBits(bs, 1); /* rfa */ /* Evaluate configuration and fill the ASC */ @@ -1479,6 +1487,7 @@ TRANSPORTDEC_ERROR DrmRawSdcAudioConfig_Parse( switch (audioMode) { case 1: /* parametric stereo */ self->m_psPresentFlag = 1; + /*fall through*/ case 0: /* mono */ self->m_channelConfiguration = 1; break; diff --git a/components/fdk-aac-oreo-m8/libMpegTPDec/src/tpdec_latm.cpp b/components/fdk-aac-oreo-m8/libMpegTPDec/src/tpdec_latm.cpp index 5710d776..d2b953b8 100644 --- a/components/fdk-aac-oreo-m8/libMpegTPDec/src/tpdec_latm.cpp +++ b/components/fdk-aac-oreo-m8/libMpegTPDec/src/tpdec_latm.cpp @@ -268,10 +268,10 @@ TRANSPORTDEC_ERROR CLatmDemux_ReadStreamMuxConfig( if (pLatmDemux->m_AudioMuxVersion == 1) { FDK_BITSTREAM tmpBs; - UINT ascStartPos, ascLen=0; + UINT ascLen=0; ascLen = CLatmDemux_GetValue(bs); - ascStartPos = FDKgetValidBits(bs); + FDKgetValidBits(bs); tmpBs = *bs; FDKsyncCache(&tmpBs); tmpBs.hBitBuf.ValidBits = ascLen; diff --git a/components/fdk-aac-oreo-m8/libMpegTPDec/src/tpdec_lib.cpp b/components/fdk-aac-oreo-m8/libMpegTPDec/src/tpdec_lib.cpp index 24f755b7..382deb8b 100644 --- a/components/fdk-aac-oreo-m8/libMpegTPDec/src/tpdec_lib.cpp +++ b/components/fdk-aac-oreo-m8/libMpegTPDec/src/tpdec_lib.cpp @@ -601,7 +601,8 @@ static TRANSPORTDEC_ERROR transportDec_readHeader( hTp->parser.latm.m_audioMuxLengthBytes = syncLayerFrameBits; syncLayerFrameBits <<= 3; } - case TT_MP4_LATM_MCP1: + /*fall through*/ + case TT_MP4_LATM_MCP1: case TT_MP4_LATM_MCP0: if (hTp->numberOfRawDataBlocks <= 0) { @@ -1340,7 +1341,7 @@ TRANSPORTDEC_ERROR transportDec_CrcCheck(HANDLE_TRANSPORTDEC pTp) case TT_MP4_ADTS: if ( (pTp->parser.adts.bs.num_raw_blocks > 0) && (pTp->parser.adts.bs.protection_absent == 0) ) { - HANDLE_FDK_BITSTREAM hBs = &pTp->bitStream[0]; + //HANDLE_FDK_BITSTREAM hBs = &pTp->bitStream[0]; transportDec_AdjustEndOfAccessUnit(pTp); } diff --git a/components/fdk-aac-oreo-m8/libPCMutils/src/pcmutils_lib.cpp b/components/fdk-aac-oreo-m8/libPCMutils/src/pcmutils_lib.cpp index d14edd96..51c1a5c9 100644 --- a/components/fdk-aac-oreo-m8/libPCMutils/src/pcmutils_lib.cpp +++ b/components/fdk-aac-oreo-m8/libPCMutils/src/pcmutils_lib.cpp @@ -484,18 +484,21 @@ PCMDMX_ERROR getChannelMode ( switch (channelType[ch]) { case ACT_FRONT_TOP: chGrpIdx += numChInGrp[CH_GROUP_FRONT]; /* Append after normal plain */ - case ACT_FRONT: + /*fall through*/ + case ACT_FRONT: grpIdx = CH_GROUP_FRONT; break; #if (PCM_DMX_MAX_CHANNEL_GROUPS > 1) case ACT_SIDE_TOP: chGrpIdx += numChInGrp[CH_GROUP_SIDE]; /* Append after normal plain */ - case ACT_SIDE: + /*fall through*/ + case ACT_SIDE: grpIdx = CH_GROUP_SIDE; break; case ACT_BACK_TOP: chGrpIdx += numChInGrp[CH_GROUP_REAR]; /* Append after normal plain */ - case ACT_BACK: + /*fall through*/ + case ACT_BACK: grpIdx = CH_GROUP_REAR; break; case ACT_LFE: @@ -1986,8 +1989,7 @@ PCMDMX_ERROR pcmDmx_ApplyFrame ( if ( (pParam->expiryFrame > 0) && (++self->bsMetaData[0].expiryCount > pParam->expiryFrame) ) { /* The metadata read from bitstream is too old. */ - PCMDMX_ERROR err = pcmDmx_Reset(self, PCMDMX_RESET_BS_DATA); - FDK_ASSERT(err == PCMDMX_OK); + FDK_ASSERT(pcmDmx_Reset(self, PCMDMX_RESET_BS_DATA) == PCMDMX_OK); } FDKmemcpy(&bsMetaData, &self->bsMetaData[pParam->frameDelay], sizeof(DMX_BS_META_DATA)); /* Maintain delay line */ diff --git a/components/fdk-aac-oreo-m8/libSBRdec/src/sbrdecoder.cpp b/components/fdk-aac-oreo-m8/libSBRdec/src/sbrdecoder.cpp index f9ded541..b2ec0936 100644 --- a/components/fdk-aac-oreo-m8/libSBRdec/src/sbrdecoder.cpp +++ b/components/fdk-aac-oreo-m8/libSBRdec/src/sbrdecoder.cpp @@ -958,7 +958,7 @@ SBR_ERROR sbrDecoder_Parse( int fGlobalIndependencyFlag ) { - SBR_DECODER_ELEMENT *hSbrElement; + SBR_DECODER_ELEMENT *hSbrElement = 0; HANDLE_SBR_HEADER_DATA hSbrHeader = NULL; HANDLE_SBR_CHANNEL *pSbrChannel; diff --git a/components/fdk-aac-oreo-m8/libSBRenc/src/mh_det.cpp b/components/fdk-aac-oreo-m8/libSBRenc/src/mh_det.cpp index bc80a15b..77a00dd6 100644 --- a/components/fdk-aac-oreo-m8/libSBRenc/src/mh_det.cpp +++ b/components/fdk-aac-oreo-m8/libSBRenc/src/mh_det.cpp @@ -468,8 +468,9 @@ static INT isDetectionOfNewToneAllowed(const SBR_FRAME_INFO *pFrameInfo, *****************************************************************************/ transientFrame = 0; if(transientFlag){ - if(transientPos + transientPosOffset < pFrameInfo->borders[pFrameInfo->nEnvelopes]) + if(transientPos + transientPosOffset < pFrameInfo->borders[pFrameInfo->nEnvelopes]){ transientFrame = 1; + } if(noEstPerFrame > 1){ if(transientPos + transientPosOffset > h_sbrMissingHarmonicsDetector->timeSlots >> 1){ *pDetectionStartPos = noEstPerFrame; @@ -504,7 +505,7 @@ static INT isDetectionOfNewToneAllowed(const SBR_FRAME_INFO *pFrameInfo, if(prevTransientFrame && fixp_abs(pFrameInfo->borders[0] - (prevTransientPos + transientPosOffset - h_sbrMissingHarmonicsDetector->timeSlots)) < deltaTime) - newDetectionAllowed = 1; + {newDetectionAllowed = 1;} *pDetectionStartPos = 0; } diff --git a/components/fdk-aac-oreo-m8/libSYS/include/genericStds.h b/components/fdk-aac-oreo-m8/libSYS/include/genericStds.h index fe4dc36a..f5aa36f0 100644 --- a/components/fdk-aac-oreo-m8/libSYS/include/genericStds.h +++ b/components/fdk-aac-oreo-m8/libSYS/include/genericStds.h @@ -166,7 +166,7 @@ typedef enum { #define C_ALLOC_MEM_STATIC(name,type,num) \ static type * Get ## name(int n) { FDK_ASSERT((n) == 0); return ((type*)FDKcalloc(num, sizeof(type))); } \ static void Free ## name(type** p) { if (p != NULL) { FDKfree(*p); *p=NULL; } } \ - static UINT GetRequiredMem ## name(void) { return ALGN_SIZE_EXTRES((num) * sizeof(type)); } +// static UINT GetRequiredMem ## name(void) { return ALGN_SIZE_EXTRES((num) * sizeof(type)); } /** See #H_ALLOC_MEM for description. */ #define C_ALLOC_MEM2(name,type,n1,n2) \ @@ -389,31 +389,14 @@ float FDKatof(const char *nptr); /* FILE I/O */ -/*! - * Check platform for endianess. - * - * \return 1 if platform is little endian, non-1 if platform is big endian. - */ -#ifdef __cplusplus -inline -#else -static -#endif -int IS_LITTLE_ENDIAN(void) { - int __dummy = 1; - return ( *( (UCHAR*)(&(__dummy) ) ) ); -} -/*! - * Convert input value to little endian format. - * - * \param val Value to be converted. It may be in both big or little endian. - * \return Value in little endian format. - */ -#define TO_LITTLE_ENDIAN(val) \ - ( (IS_LITTLE_ENDIAN()) ? \ - (val) \ - : ( (((val) & 0xff) << 24) || (((val) & 0xff00)<< 8) || (((val) & 0xff0000)>>8) || (((val) & 0xff000000) >> 24) ) ) +//#ifdef __cplusplus +//inline +//#else +//static +//#endif + +// /*! @@ -432,7 +415,9 @@ int IS_LITTLE_ENDIAN(void) { * \fn UINT FDKfread(void *dst, INT size, UINT nmemb, FDKFILE *fp); * Standard fread() wrapper. */ + typedef void FDKFILE; + extern const INT FDKSEEK_SET, FDKSEEK_CUR, FDKSEEK_END; FDKFILE *FDKfopen(const char *filename, const char *mode); diff --git a/components/fdk-aac-oreo-m8/libSYS/include/machine_type.h b/components/fdk-aac-oreo-m8/libSYS/include/machine_type.h index b3289530..a9135e14 100644 --- a/components/fdk-aac-oreo-m8/libSYS/include/machine_type.h +++ b/components/fdk-aac-oreo-m8/libSYS/include/machine_type.h @@ -301,7 +301,7 @@ amm-info@iis.fraunhofer.de #endif /* for all other platforms */ - #define FDK_INLINE inline + #define FDK_INLINE __attribute__((always_inline)) inline /*! diff --git a/components/fdk-aac-oreo-m8/libSYS/src/genericStds.cpp b/components/fdk-aac-oreo-m8/libSYS/src/genericStds.cpp index 89c422cd..eccfc5ea 100644 --- a/components/fdk-aac-oreo-m8/libSYS/src/genericStds.cpp +++ b/components/fdk-aac-oreo-m8/libSYS/src/genericStds.cpp @@ -273,12 +273,11 @@ void FDKafree (void *ptr) *--------------------------------------------------------------------------*/ void *FDKcalloc_L(const UINT dim, const UINT size, MEMORY_SECTION s) { - int a_size; - + if (s == SECT_DATA_EXTERN) goto fallback; - a_size = ((dim*size+3)&0xfffffffc); /* force 4 byte alignment (1111 .... 1111 1100) */ + //int a_size = ((dim*size+3)&0xfffffffc); /* force 4 byte alignment (1111 .... 1111 1100) */ @@ -406,6 +405,21 @@ char* FDKfgets(void *dst, INT size, FDKFILE *fp) { return fgets((char *)dst, siz void FDKrewind(FDKFILE *fp) { FDKfseek((FILE*)fp,0,FDKSEEK_SET); } #endif +int IS_LITTLE_ENDIAN(void) { int __dummy = 1; return (*((UCHAR*)(&(__dummy)))); } + +/*! + + * Check platform for endianess. + * + * \return 1 if platform is little endian, non-1 if platform is big endian. + + * \Convert input value to little endian format. + * + * \param val Value to be converted. It may be in both big or little endian. + * \return Value in little endian format. + */ + #define TO_LITTLE_ENDIAN(val) ((IS_LITTLE_ENDIAN()) ? (val) : ((((val) & 0xff) << 24) || (((val) & 0xff00)<< 8) || (((val) & 0xff0000)>>8) || (((val) & 0xff000000) >> 24))) + UINT FDKfwrite_EL(void *ptrf, INT size, UINT nmemb, FDKFILE *fp) { diff --git a/components/fdk-aac-oreo-m8/libSYS/src/wav_file.cpp b/components/fdk-aac-oreo-m8/libSYS/src/wav_file.cpp index 58bcfaad..25baa664 100644 --- a/components/fdk-aac-oreo-m8/libSYS/src/wav_file.cpp +++ b/components/fdk-aac-oreo-m8/libSYS/src/wav_file.cpp @@ -241,6 +241,9 @@ INT WAV_InputOpen (HANDLE_WAV *pWav, const char *filename) return -1; } +int IS_LITTLE_ENDIAN(void) { int __dummy = 1; return (*((UCHAR*)(&(__dummy)))); } + + /*! * * \brief Read samples from a WAVEfile. The samples are automatically reorder to the native diff --git a/components/mad/align.h b/components/mad/align.h index 5032484c..d4a771ca 100644 --- a/components/mad/align.h +++ b/components/mad/align.h @@ -1,2 +1,2 @@ -char unalChar(char const *adr); -short unalShort(short const *adr); +char unalChar(const unsigned char *adr); +short unalShort(short const unsigned int *adr); diff --git a/components/mad/bit.c b/components/mad/bit.c index 532c717e..ff67461d 100644 --- a/components/mad/bit.c +++ b/components/mad/bit.c @@ -215,8 +215,10 @@ unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len, switch (len / 8) { case 3: crc = (crc << 8) ^ unalShort(&crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]); + /* fall through */ case 2: crc = (crc << 8) ^ unalShort(&crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]); + /* fall through */ case 1: crc = (crc << 8) ^ unalShort(&crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]); diff --git a/components/ucglib/csrc/CMakeLists.txt b/components/ucglib/csrc/CMakeLists.txt new file mode 100644 index 00000000..840d1130 --- /dev/null +++ b/components/ucglib/csrc/CMakeLists.txt @@ -0,0 +1,56 @@ +idf_component_register(SRCS + "ucg_bitmap.c" + "ucg_box.c" + "ucg_ccs.c" +"ucg_circle.c" +"ucg_clip.c" +"ucg_com_msg_api.c" +"ucg_dev_default_cb.c" +"ucg_dev_ic_ili9163.c" +"ucg_dev_ic_ili9325.c" +"ucg_dev_ic_ili9325_spi.c" +"ucg_dev_ic_ili9341.c" +"ucg_dev_ic_ld50t6160.c" +"ucg_dev_ic_pcf8833.c" +"ucg_dev_ic_seps225.c" +"ucg_dev_ic_ssd1289.c" +"ucg_dev_ic_ssd1331.c" +"ucg_dev_ic_ssd1351.c" +"ucg_dev_ic_st7735.c" +"ucg_dev_ic_st7735L.c" +"ucg_dev_ic_st7735S.c" +"ucg_dev_ic_st7735W.c" +"ucg_dev_ic_st7789.c" +"ucg_dev_ic_st7789_240x240.c" +"ucg_dev_msg_api.c" +"ucg_dev_oled_128x128_ft.c" +"ucg_dev_oled_128x128_ilsoft.c" +"ucg_dev_oled_128x128_univision.c" +"ucg_dev_oled_160x128_samsung.c" +"ucg_dev_oled_96x64_univision.c" +"ucg_dev_tft_128x128_ili9163.c" +"ucg_dev_tft_128x128_st7735.c" +"ucg_dev_tft_128x160_st7735.c" +"ucg_dev_tft_128x160_W_st7735.c" +"ucg_dev_tft_132x132_pcf8833.c" +"ucg_dev_tft_240x240_st7789.c" +"ucg_dev_tft_240x320_ili9325_spi.c" +"ucg_dev_tft_240x320_ili9341.c" +"ucg_dev_tft_240x320_itdb02.c" +"ucg_dev_tft_240x320_ssd1289.c" +"ucg_dev_tft_240x320_st7789.c" +"ucg_dev_tft_80x160_st7735.c" +"ucg_esp32_hal.c" +"ucg_esp32_hal.h" +"ucg_font.c" +"ucg_init.c" +"ucg_karadio32_fonts.c" +"ucg_karadio32_fonts.h" +"ucg_line.c" +"ucg_pixel.c" +"ucg_pixel_font_data.c" +"ucg_polygon.c" +"ucg_rotate.c" +"ucg_scale.c" +"ucg_vector_font_data.c") + \ No newline at end of file diff --git a/components/ucglib/csrc/ucg_dev_ic_ili9325.c b/components/ucglib/csrc/ucg_dev_ic_ili9325.c index 21bc8776..13c3c5ff 100644 --- a/components/ucglib/csrc/ucg_dev_ic_ili9325.c +++ b/components/ucglib/csrc/ucg_dev_ic_ili9325.c @@ -238,7 +238,7 @@ ucg_int_t xxxxxx_ucg_handle_ili9325_l90tc(ucg_t *ucg) /* with CmdDataSequence */ -static ucg_int_t ucg_handle_ili9325_l90tc(ucg_t *ucg) +/*static ucg_int_t ucg_handle_ili9325_l90tc(ucg_t *ucg) { if ( ucg_clip_l90tc(ucg) != 0 ) { @@ -247,8 +247,10 @@ static ucg_int_t ucg_handle_ili9325_l90tc(ucg_t *ucg) ucg_int_t i; unsigned char pixmap; uint8_t bitcnt; - ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */ - ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_seq); +*/ +// ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */ + +/* ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_seq); buf[0] = 0x001; // change to 0 (cmd mode) buf[1] = 0x020; // set x buf[2] = 0x002; // change to 1 (arg mode) @@ -331,8 +333,10 @@ static ucg_int_t ucg_handle_ili9325_l90tc(ucg_t *ucg) buf[17] = ucg->arg.pixel.rgb.color[1]; buf[19] = ucg->arg.pixel.rgb.color[2]; } +*/ //ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */ - + +/* for( i = 0; i < ucg->arg.len; i++ ) { if ( (pixmap & 128) != 0 ) @@ -361,12 +365,13 @@ static ucg_int_t ucg_handle_ili9325_l90tc(ucg_t *ucg) bitcnt = 0; } } - ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */ - return 1; + */ + //ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */ + /* return 1; } return 0; } - +*/ static ucg_int_t ucg_handle_ili9325_l90se(ucg_t *ucg) { @@ -481,4 +486,4 @@ ucg_int_t ucg_ext_ili9325_18(ucg_t *ucg, ucg_int_t msg, void *data) break; } return 1; -} \ No newline at end of file +} diff --git a/components/ucglib/csrc/ucg_dev_ic_ili9325_spi.c b/components/ucglib/csrc/ucg_dev_ic_ili9325_spi.c index ea2bf609..5beb9849 100644 --- a/components/ucglib/csrc/ucg_dev_ic_ili9325_spi.c +++ b/components/ucglib/csrc/ucg_dev_ic_ili9325_spi.c @@ -156,23 +156,27 @@ static ucg_int_t ucg_handle_ili9325_l90fx(ucg_t *ucg) */ +/*unused static const ucg_pgm_uint8_t ucg_ili9325_set_x_pos_seq[] = { - UCG_C10(0x020), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */ - UCG_C10(0x022), /* write to RAM */ - UCG_DATA(), /* change to data mode */ - UCG_END() +*/ +// UCG_C10(0x020), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */ +// UCG_C10(0x022), /* write to RAM */ +// UCG_DATA(), /* change to data mode */ +/* UCG_END() }; static const ucg_pgm_uint8_t ucg_ili9325_set_y_pos_seq[] = { - UCG_C10(0x021), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */ - UCG_C10(0x022), /* write to RAM */ - UCG_DATA(), /* change to data mode */ - UCG_END() -}; +*/ +// UCG_C10(0x021), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), /* set y position */ +// UCG_C10(0x022), /* write to RAM */ +// UCG_DATA(), /* change to data mode */ +// UCG_END() +//}; /* without CmdDataSequence */ +/* unused static ucg_int_t xxxxxx_ucg_handle_ili9325_l90tc(ucg_t *ucg) { if ( ucg_clip_l90tc(ucg) != 0 ) @@ -183,8 +187,10 @@ static ucg_int_t xxxxxx_ucg_handle_ili9325_l90tc(ucg_t *ucg) const uint8_t *seq; unsigned char pixmap; uint8_t bitcnt; - ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */ - ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_seq); +*/ +// ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */ +/* +ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_seq); switch(ucg->arg.dir) { case 0: @@ -211,8 +217,9 @@ static ucg_int_t xxxxxx_ucg_handle_ili9325_l90tc(ucg_t *ucg) buf[0] = ucg->arg.pixel.rgb.color[0]; buf[1] = ucg->arg.pixel.rgb.color[1]; buf[2] = ucg->arg.pixel.rgb.color[2]; +*/ //ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */ - +/* for( i = 0; i < ucg->arg.len; i++ ) { if ( (pixmap & 128) != 0 ) @@ -231,14 +238,18 @@ static ucg_int_t xxxxxx_ucg_handle_ili9325_l90tc(ucg_t *ucg) bitcnt = 0; } } - ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */ - return 1; +*/ + // ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */ +/* + return 1; } return 0; } +*/ /* with CmdDataSequence */ +/* unused static ucg_int_t ucg_handle_ili9325_l90tc(ucg_t *ucg) { if ( ucg_clip_l90tc(ucg) != 0 ) @@ -248,8 +259,9 @@ static ucg_int_t ucg_handle_ili9325_l90tc(ucg_t *ucg) ucg_int_t i; unsigned char pixmap; uint8_t bitcnt; - ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */ - ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_seq); +*/ +// ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */ +/* ucg_com_SendCmdSeq(ucg, ucg_ili9325_set_pos_seq); buf[0] = 0x001; // change to 0 (cmd mode) buf[1] = 0x020; // set x buf[2] = 0x002; // change to 1 (arg mode) @@ -332,8 +344,9 @@ static ucg_int_t ucg_handle_ili9325_l90tc(ucg_t *ucg) buf[17] = ucg->arg.pixel.rgb.color[1]; buf[19] = ucg->arg.pixel.rgb.color[2]; } + */ //ucg_com_SetCSLineStatus(ucg, 0); /* enable chip */ - + /* for( i = 0; i < ucg->arg.len; i++ ) { if ( (pixmap & 128) != 0 ) @@ -362,12 +375,14 @@ static ucg_int_t ucg_handle_ili9325_l90tc(ucg_t *ucg) bitcnt = 0; } } - ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */ - return 1; +*/ +// ucg_com_SetCSLineStatus(ucg, 1); /* disable chip */ +/* +return 1; } return 0; } - +*/ static ucg_int_t ucg_handle_ili9325_l90se(ucg_t *ucg) { @@ -481,4 +496,4 @@ ucg_int_t ucg_ext_ili9325_spi_18(ucg_t *ucg, ucg_int_t msg, void *data) break; } return 1; -} \ No newline at end of file +} diff --git a/components/ucglib/csrc/ucg_dev_ic_st7789_240x240.c b/components/ucglib/csrc/ucg_dev_ic_st7789_240x240.c index 29281bf4..5843da5f 100644 --- a/components/ucglib/csrc/ucg_dev_ic_st7789_240x240.c +++ b/components/ucglib/csrc/ucg_dev_ic_st7789_240x240.c @@ -43,8 +43,7 @@ const ucg_pgm_uint8_t ucg_st7789_24_set_pos_seq[] = UCG_CS(0), /* enable chip */ UCG_C11( 0x036, 0x000), UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set x position */ -// UCG_C10(0x02b), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set y position */ - UCG_C10(0x02b), UCG_VARY(0,0x00, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set y position */ + UCG_C10(0x02b), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set y position */ UCG_C10(0x02c), /* write to RAM */ UCG_DATA(), /* change to data mode */ UCG_END() @@ -61,8 +60,7 @@ const ucg_pgm_uint8_t ucg_st7789_24_set_pos_dir0_seq[] = /* 0x088 vertical deccrement (dir = 3) */ UCG_C11( 0x036, 0x000), UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set x position */ -// UCG_C10(0x02b), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set y position */ - UCG_C10(0x02b), UCG_VARY(0,0x00, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set y position */ + UCG_C10(0x02b), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set y position */ UCG_C10(0x02c), /* write to RAM */ UCG_DATA(), /* change to data mode */ @@ -78,8 +76,7 @@ const ucg_pgm_uint8_t ucg_st7789_24_set_pos_dir1_seq[] = /* 0x088 vertical deccrement (dir = 3) */ UCG_C11( 0x036, 0x000), UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */ -// UCG_C10(0x02b), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set y position */ - UCG_C10(0x02b), UCG_VARY(0,0x00, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set y position */ + UCG_C10(0x02b), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set y position */ UCG_C10(0x02c), /* write to RAM */ UCG_DATA(), /* change to data mode */ @@ -98,8 +95,7 @@ const ucg_pgm_uint8_t ucg_st7789_24_set_pos_dir2_seq[] = UCG_C11( 0x036, 0x040), UCG_C11( 0x036, 0x040), /* it seems that this command needs to be sent twice */ UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set x position */ -// UCG_C10(0x02b), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set y position */ - UCG_C10(0x02b), UCG_VARY(0,0x00, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set y position */ + UCG_C10(0x02b), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set y position */ UCG_C10(0x02c), /* write to RAM */ UCG_DATA(), /* change to data mode */ @@ -117,8 +113,7 @@ const ucg_pgm_uint8_t ucg_st7789_24_set_pos_dir3_seq[] = UCG_C11( 0x036, 0x080), UCG_C11( 0x036, 0x080), /* it seems that this command needs to be sent twice */ UCG_C10(0x02a), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), UCG_VARX(0,0x00, 0), UCG_VARX(0,0x0ff, 0), /* set x position */ -// UCG_C10(0x02b), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set y position */ - UCG_C10(0x02b), UCG_VARY(0,0x00, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set y position */ + UCG_C10(0x02b), UCG_VARY(8,0x01, 0), UCG_VARY(0,0x0ff, 0), UCG_A2(0x000, 0x0ef), /* set y position */ UCG_C10(0x02c), /* write to RAM */ UCG_DATA(), /* change to data mode */ diff --git a/components/ucglib/csrc/ucg_dev_oled_128x128_univision.c b/components/ucglib/csrc/ucg_dev_oled_128x128_univision.c index 28ce33c4..76e241f9 100644 --- a/components/ucglib/csrc/ucg_dev_oled_128x128_univision.c +++ b/components/ucglib/csrc/ucg_dev_oled_128x128_univision.c @@ -41,71 +41,71 @@ #include "ucg.h" /* the following code is from the UG2828GDEAF02 Datasheet */ -static const ucg_pgm_uint8_t aaa_ucg_univision_seps225_init_seq[] = { - UCG_CFG_CD(0,1), /* First arg: level for commands, Second arg: level for command arguments */ - UCG_RST(1), - UCG_CS(1), /* disable chip */ - UCG_DLY_MS(1), - UCG_RST(0), - UCG_DLY_MS(1), - UCG_RST(1), - UCG_DLY_MS(50), - UCG_CS(0), /* enable chip */ +//static const ucg_pgm_uint8_t aaa_ucg_univision_seps225_init_seq[] = { +// UCG_CFG_CD(0,1), /* First arg: level for commands, Second arg: level for command arguments */ +// UCG_RST(1), +// UCG_CS(1), /* disable chip */ +// UCG_DLY_MS(1), +// UCG_RST(0), +// UCG_DLY_MS(1), +// UCG_RST(1), +// UCG_DLY_MS(50), +// UCG_CS(0), /* enable chip */ - UCG_C11(0x002, 0x001), /* OSC_CTL: external resistor, internal OSC */ - UCG_C11(0x004, 0x000), /* REDUCE_CURRENT: normal operation, no current reduction */ - UCG_C11(0x003, 0x030), /* CLK_DIV: 90Hz, ratio 1 */ +// UCG_C11(0x002, 0x001), /* OSC_CTL: external resistor, internal OSC */ +// UCG_C11(0x004, 0x000), /* REDUCE_CURRENT: normal operation, no current reduction */ +// UCG_C11(0x003, 0x030), /* CLK_DIV: 90Hz, ratio 1 */ - UCG_C11(0x008, 0x000), /* Precharge time red */ - UCG_C11(0x009, 0x000), /* Precharge time green */ - UCG_C11(0x00a, 0x000), /* Precharge time blue */ +// UCG_C11(0x008, 0x000), /* Precharge time red */ +// UCG_C11(0x009, 0x000), /* Precharge time green */ +// UCG_C11(0x00a, 0x000), /* Precharge time blue */ - UCG_C11(0x00b, 0x000), /* Precharge current red */ - UCG_C11(0x00c, 0x000), /* Precharge current green */ - UCG_C11(0x00d, 0x000), /* Precharge current blue */ +// UCG_C11(0x00b, 0x000), /* Precharge current red */ +// UCG_C11(0x00c, 0x000), /* Precharge current green */ +// UCG_C11(0x00d, 0x000), /* Precharge current blue */ - UCG_C11(0x010, 0x04a), /* Driving current red */ - UCG_C11(0x011, 0x025), /* Driving current green, original value 0x011 replaced by 0x025 */ - UCG_C11(0x012, 0x02f), /* Driving current blue */ +// UCG_C11(0x010, 0x04a), /* Driving current red */ +// UCG_C11(0x011, 0x025), /* Driving current green, original value 0x011 replaced by 0x025 */ +// UCG_C11(0x012, 0x02f), /* Driving current blue */ - UCG_C11(0x013, 0x000), /* Display mode: RGB,column=0..127,column data display control=Normal Dispaly */ - UCG_C11(0x014, 0x001), /* External interface: 18 bit, MPU, Bit size does not matter if MPU is selected*/ +// UCG_C11(0x013, 0x000), /* Display mode: RGB,column=0..127,column data display control=Normal Dispaly */ +// UCG_C11(0x014, 0x001), /* External interface: 18 bit, MPU, Bit size does not matter if MPU is selected*/ //UCG_C11(0x016, 0x076), /* Memory Mode: 6bits triple transfer (would require 6bit words on SPI, 262K support, horizontal inc., vertical inc., data continuously written horizontally */ - UCG_C11(0x016, 0x066), /* Memory Mode: dual transfer (2x 8Bit), 65K support, horizontal inc., vertical inc., data continuously written horizontally */ +// UCG_C11(0x016, 0x066), /* Memory Mode: dual transfer (2x 8Bit), 65K support, horizontal inc., vertical inc., data continuously written horizontally */ /* memory window */ - UCG_C11(0x017, 0x000), /* x0 */ - UCG_C11(0x018, 0x07f), /* x1 */ - UCG_C11(0x019, 0x000), /* y0 */ - UCG_C11(0x01a, 0x07f), /* y1 */ +// UCG_C11(0x017, 0x000), /* x0 */ +// UCG_C11(0x018, 0x07f), /* x1 */ +// UCG_C11(0x019, 0x000), /* y0 */ +// UCG_C11(0x01a, 0x07f), /* y1 */ /* memory start */ - UCG_C11(0x020, 0x000), /* x */ - UCG_C11(0x021, 0x000), /* y */ +// UCG_C11(0x020, 0x000), /* x */ +// UCG_C11(0x021, 0x000), /* y */ - UCG_C11(0x028, 0x07f), /* Duty */ - UCG_C11(0x029, 0x000), /* Display start line */ +// UCG_C11(0x028, 0x07f), /* Duty */ +// UCG_C11(0x029, 0x000), /* Display start line */ /* DDRAM start */ - UCG_C11(0x02e, 0x000), /* x */ - UCG_C11(0x02f, 0x000), /* y */ +// UCG_C11(0x02e, 0x000), /* x */ +// UCG_C11(0x02f, 0x000), /* y */ - UCG_C11(0x033, 0x000), /* Display Screen Saver x0 */ - UCG_C11(0x034, 0x07f), /* Display Screen Saver x1 */ - UCG_C11(0x035, 0x000), /* Display Screen Saver y0 */ - UCG_C11(0x036, 0x07f), /* Display Screen Saver y1 */ +// UCG_C11(0x033, 0x000), /* Display Screen Saver x0 */ +// UCG_C11(0x034, 0x07f), /* Display Screen Saver x1 */ +// UCG_C11(0x035, 0x000), /* Display Screen Saver y0 */ +// UCG_C11(0x036, 0x07f), /* Display Screen Saver y1 */ - UCG_C11(0x080, 0x000), /* IREF: External */ +// UCG_C11(0x080, 0x000), /* IREF: External */ - UCG_DLY_MS(100), /* as suggested in the Univision manual */ +// UCG_DLY_MS(100), /* as suggested in the Univision manual */ - UCG_C11(0x006, 0x001), /* Display on */ +// UCG_C11(0x006, 0x001), /* Display on */ - UCG_CS(1), /* disable chip */ - UCG_END(), /* end of sequence */ -}; +// UCG_CS(1), /* disable chip */ +// UCG_END(), /* end of sequence */ +//}; /* init seq. from the .ino example from ZhangFeng, PRC. http://vfdclock.jimdo.com */ static const ucg_pgm_uint8_t ucg_univision_seps225_init_seq[] = { @@ -186,16 +186,16 @@ static const ucg_pgm_uint8_t ucg_univision_seps225_init_seq[] = { }; -static const ucg_pgm_uint8_t ucg_seps255_pos_dir0_seq[] = -{ - UCG_CS(0), /* enable chip */ - UCG_C11(0x016, 0x066), /* Memory Mode */ - UCG_C11(0x020, 0), /* set x position */ - UCG_C11(0x021, 0), /* set y position */ - UCG_C10(0x022), /* prepare for data */ - UCG_DATA(), /* change to data mode */ - UCG_END() -}; +//static const ucg_pgm_uint8_t ucg_seps255_pos_dir0_seq[] = +//{ +// UCG_CS(0), /* enable chip */ +// UCG_C11(0x016, 0x066), /* Memory Mode */ +// UCG_C11(0x020, 0), /* set x position */ +// UCG_C11(0x021, 0), /* set y position */ +// UCG_C10(0x022), /* prepare for data */ +// UCG_DATA(), /* change to data mode */ +// UCG_END() +//}; ucg_int_t ucg_dev_seps225_16x128x128_univision(ucg_t *ucg, ucg_int_t msg, void *data) { diff --git a/components/ucglib/csrc/ucg_dev_tft_132x132_pcf8833.c b/components/ucglib/csrc/ucg_dev_tft_132x132_pcf8833.c index a333b977..dd646b37 100644 --- a/components/ucglib/csrc/ucg_dev_tft_132x132_pcf8833.c +++ b/components/ucglib/csrc/ucg_dev_tft_132x132_pcf8833.c @@ -38,55 +38,56 @@ #include "ucg.h" //static const uint8_t ucg_dev_ssd1351_132x132_init_seq[] PROGMEM = { -static const ucg_pgm_uint8_t ucg_tft_132x132_pcf8833_init_seq_OBSOLETE[] = { - UCG_CFG_CD(0,1), /* DC=0 for command mode, DC=1 for data and args */ - UCG_RST(1), - UCG_CS(1), /* disable chip */ - UCG_DLY_MS(5), +//static const ucg_pgm_uint8_t ucg_tft_132x132_pcf8833_init_seq_OBSOLETE[] = { +// UCG_CFG_CD(0,1), /* DC=0 for command mode, DC=1 for data and args */ +// UCG_RST(1), +// UCG_CS(1), /* disable chip */ +/* UCG_DLY_MS(5), UCG_RST(0), UCG_DLY_MS(5), UCG_RST(1), UCG_DLY_MS(50), - UCG_CS(0), /* enable chip */ +*/ + //UCG_CS(0), /* enable chip */ - UCG_C10(0x01), /* reset */ - UCG_DLY_MS(199), + //UCG_C10(0x01), /* reset */ + //UCG_DLY_MS(199), - UCG_C10(0x011), /* sleep out */ - UCG_DLY_MS(10), + //UCG_C10(0x011), /* sleep out */ + //UCG_DLY_MS(10), - UCG_C10(0x038), /* idle mode off */ + //UCG_C10(0x038), /* idle mode off */ //UCG_C10(0x0b5), /* mirror */ //UCG_C10(0x0b7), /* mirror */ - UCG_C10(0x013), /* normal display on */ - UCG_C10(0x020), /* not inverted */ - UCG_C10(0x029), /* display on */ + //UCG_C10(0x013), /* normal display on */ + //UCG_C10(0x020), /* not inverted */ + //UCG_C10(0x029), /* display on */ - UCG_C11(0x025, 0x03f), /* set contrast -64 ... 63 */ + //UCG_C11(0x025, 0x03f), /* set contrast -64 ... 63 */ //UCG_C11(0x03a, 0x003), /* set pixel format to 12 bit per pixel */ - UCG_C11(0x03a, 0x005), + //UCG_C11(0x03a, 0x005), //UCG_C10(0x003), /* booster on */ - UCG_C10(0x023), /* all pixel on */ - UCG_DLY_MS(199), - UCG_C10(0x013), /* normal display on */ + //UCG_C10(0x023), /* all pixel on */ + //UCG_DLY_MS(199), + //UCG_C10(0x013), /* normal display on */ - UCG_C11( 0x036, 0x000), /* memory control */ + //UCG_C11( 0x036, 0x000), /* memory control */ - UCG_C12( 0x02a, 0x000, 0x07f), /* Horizontal GRAM Address Set */ - UCG_C12( 0x02b, 0x000, 0x07f), /* Vertical GRAM Address Set */ - UCG_C10( 0x02c), /* Write Data to GRAM */ + //UCG_C12( 0x02a, 0x000, 0x07f), /* Horizontal GRAM Address Set */ + //UCG_C12( 0x02b, 0x000, 0x07f), /* Vertical GRAM Address Set */ + //UCG_C10( 0x02c), /* Write Data to GRAM */ - UCG_DLY_MS(10), + //UCG_DLY_MS(10), - UCG_CS(1), /* disable chip */ - UCG_END(), /* end of sequence */ -}; + //UCG_CS(1), /* disable chip */ + //UCG_END(), /* end of sequence */ +//}; static const ucg_pgm_uint8_t ucg_tft_132x132_pcf8833_init_seq[] = { UCG_CFG_CD(0,1), /* DC=0 for command mode, DC=1 for data and args */ diff --git a/components/ucglib/csrc/ucg_dev_tft_240x320_st7789.c b/components/ucglib/csrc/ucg_dev_tft_240x320_st7789.c index 864a853f..3290f898 100644 --- a/components/ucglib/csrc/ucg_dev_tft_240x320_st7789.c +++ b/components/ucglib/csrc/ucg_dev_tft_240x320_st7789.c @@ -96,7 +96,7 @@ static const ucg_pgm_uint8_t ucg_tft_240x320_st7789_init_seq[] = { UCG_C11( 0x036, 0x000), /* memory control */ UCG_C14( 0x02a, 0x000, 0x000, 0x000, 0x0ef), /* Horizontal GRAM Address Set */ - UCG_C14( 0x02b, 0x000, 0x000, 0x001, 0x03f), /* Vertical GRAM Address Set */ + UCG_C14( 0x02b, 0x000, 0x000, 0x000, 0x03f), /* Vertical GRAM Address Set */ UCG_C10( 0x02c), /* Write Data to GRAM */ diff --git a/components/ucglib/csrc/ucg_esp32_hal.c b/components/ucglib/csrc/ucg_esp32_hal.c index a3e96082..00b64bb3 100644 --- a/components/ucglib/csrc/ucg_esp32_hal.c +++ b/components/ucglib/csrc/ucg_esp32_hal.c @@ -3,7 +3,7 @@ #define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE #include "sdkconfig.h" #include "esp_log.h" -#include "rom/ets_sys.h" +#include "esp32/rom/ets_sys.h" #include "esp_heap_caps.h" #include "freertos/FreeRTOS.h" diff --git a/components/ucglib/csrc/ucg_scale.c b/components/ucglib/csrc/ucg_scale.c index 31ee6281..75ed55e1 100644 --- a/components/ucglib/csrc/ucg_scale.c +++ b/components/ucglib/csrc/ucg_scale.c @@ -49,6 +49,7 @@ void ucg_UndoScale(ucg_t *ucg) const ucg_fntpgm_uint8_t ucg_scale_2x2[16] UCG_FONT_SECTION("ucg_scale_2x2") = { 0x00, 0x03, 0x0c, 0x0f, 0x30, 0x33, 0x3c, 0x3f, 0xc0, 0xc3, 0xcc, 0xcf, 0xf0, 0xf3, 0xfc, 0xff }; +/* unused!!! static void ucg_scale_2x2_send_next_half_byte(ucg_t *ucg, ucg_xy_t *xy, ucg_int_t msg, ucg_int_t len, ucg_int_t dir, uint8_t b) { b &= 15; @@ -92,6 +93,7 @@ const ucg_fntpgm_uint8_t ucg_scale_2x2[16] UCG_FONT_SECTION("ucg_scale_2x2") = } } +*/ ucg_int_t ucg_dev_scale2x2(ucg_t *ucg, ucg_int_t msg, void *data) { diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index 0b298d9a..172c1059 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -22,7 +22,7 @@ menu "Audio Output" choice prompt "Select Audio Output Mode" - default I2S + default AUDIO_OUTPUT_MODE_I2S help This option selects the audio output. diff --git a/main/addon.c b/main/addon.c index fbd20a05..da01f3ca 100644 --- a/main/addon.c +++ b/main/addon.c @@ -41,7 +41,6 @@ static void evtClearScreen(); -#define isColor (lcd_type&LCD_COLOR) const char *stopped = "STOPPED"; char irStr[4]; @@ -50,6 +49,9 @@ xQueueHandle event_lcd = NULL; u8g2_t u8g2; // a structure which will contain all the data for one display ucg_t ucg; static uint8_t lcd_type; + +#define isColor (lcd_type&LCD_COLOR) + static xTaskHandle pxTaskLcd; // list of screen typedef enum typeScreen {smain,svolume,sstation,snumber,stime,snull} typeScreen ; @@ -193,8 +195,9 @@ void lcd_init(uint8_t Type) lcd_type = Type; // init the gpio for backlight - LedBacklightInit(); if (lcd_type == LCD_NONE) return; + + LedBacklightInit(); if (lcd_type & LCD_COLOR) // Color one { @@ -347,7 +350,7 @@ void drawNumber() // draw the station screen void drawStation() { - char sNum[4] ; + char sNum[7] ; char* ddot; char* ptl ; struct shoutcast_info* si; diff --git a/main/addonu8g2.c b/main/addonu8g2.c index 336bcb18..0a7faf60 100644 --- a/main/addonu8g2.c +++ b/main/addonu8g2.c @@ -236,7 +236,7 @@ static void screenBottomU8g2() //TIME if (yy != 32) // not enough room { - char strsec[30]; + char strsec[73]; if (getDdmm()) sprintf(strsec,"%02d-%02d-%04d %02d:%02d:%02d",dt->tm_mday,dt->tm_mon+1,dt->tm_year+1900, dt->tm_hour, dt->tm_min,dt->tm_sec); else @@ -384,7 +384,7 @@ void drawStationU8g2(uint8_t mTscreen,char* snum,char* ddot) void drawVolumeU8g2(uint8_t mTscreen) { char vlstr[] = {"Volume"}; - char aVolume[4]; + char aVolume[6]; // volume = atoi(aVolume); sprintf(aVolume,"%d",volume); @@ -401,7 +401,7 @@ void drawVolumeU8g2(uint8_t mTscreen) void drawTimeU8g2(uint8_t mTscreen,unsigned timein) { - char strdate[23]; + char strdate[36]; char strtime[20]; // printf("DRAW TIME U8G2 mtscreen : %d\n",mTscreen); u8g2_ClearBuffer(&u8g2); @@ -527,6 +527,9 @@ void lcd_initU8g2(uint8_t *lcd_type) { gpio_get_spi_bus(&spi_no,&miso,&mosi,&sclk); gpio_get_spi_lcd(&cs ,&a0,&rstlcd); + + if(miso == GPIO_NONE || mosi == GPIO_NONE || sclk == GPIO_NONE || spi_no > 2) return; + u8g2_esp32_hal.spi_no = spi_no; u8g2_esp32_hal.clk = sclk; u8g2_esp32_hal.mosi = mosi; @@ -536,6 +539,8 @@ void lcd_initU8g2(uint8_t *lcd_type) } else //BW I2C { gpio_get_i2c(&scl,&sda,&rsti2c); + if(scl == GPIO_NONE || sda == GPIO_NONE) return; + u8g2_esp32_hal.sda = sda; u8g2_esp32_hal.scl = scl; u8g2_esp32_hal.reset = rsti2c; diff --git a/main/addonucg.c b/main/addonucg.c index c6d0f745..12b79144 100644 --- a/main/addonucg.c +++ b/main/addonucg.c @@ -78,7 +78,6 @@ void setfont(sizefont size) switch(inX) { case 320: - case 240: ucg_SetFont(&ucg,ucg_font_6x13_mf); break; case 128: @@ -98,7 +97,6 @@ void setfont(sizefont size) switch(inX) { case 320: - case 240: switch (charset){ case Cyrillic: ucg_SetFont(&ucg,ucg_font_crox5h );break; case Greek:ucg_SetFont(&ucg,ucg_font_helvR18_gr );break; @@ -150,7 +148,6 @@ void setfont(sizefont size) switch(inX) { case 320: - case 240: switch (charset){ case Cyrillic: ucg_SetFont(&ucg,ucg_font_crox5h );break; case Greek:ucg_SetFont(&ucg,ucg_font_helvR24_gr );break; @@ -195,7 +192,6 @@ void setfont(sizefont size) switch(inX) { case 320: - case 240: ucg_SetFont(&ucg,ucg_font_inr53_mf); break; case 128: @@ -548,7 +544,8 @@ int i; ucg_DrawBox(&ucg,0,0,x-1,15); for (i=0;itm_sec); setfont(text); @@ -689,7 +689,7 @@ static void drawSecond(unsigned timein) void drawTimeUcg(uint8_t mTscreen,unsigned timein) { - char strdate[23]; + char strdate[36]; char strtime[20]; sprintf(strtime,"%02d:%02d", dt->tm_hour, dt->tm_min); switch (mTscreen){ @@ -705,6 +705,7 @@ void drawTimeUcg(uint8_t mTscreen,unsigned timein) // draw ip //ucg_SetFont(&ucg,ucg_font_6x13_tf); ucg_DrawString(&ucg,4,yy-18,0,strdate); + /* fall through */ case 2: if (getDdmm()) sprintf(strdate,"%02d-%02d-%04d", dt->tm_mday, dt->tm_mon+1, dt->tm_year+1900); @@ -895,6 +896,9 @@ void lcd_initUcg(uint8_t *lcd_type) { gpio_get_spi_bus(&spi_no,&miso,&mosi,&sclk); gpio_get_spi_lcd(&cs ,&a0,&rstlcd); + if(miso == GPIO_NONE || mosi == GPIO_NONE || sclk == GPIO_NONE || spi_no > 2) return; + + ucg_esp32_hal.spi_no = spi_no; ucg_esp32_hal.clk = sclk; ucg_esp32_hal.mosi = mosi; @@ -904,6 +908,7 @@ void lcd_initUcg(uint8_t *lcd_type) } else //Color I2c (never seen this one) { gpio_get_i2c(&scl,&sda,&rsti2c); + if(scl == GPIO_NONE || sda == GPIO_NONE) return; ucg_esp32_hal.sda = sda; ucg_esp32_hal.scl = scl; ucg_esp32_hal.reset = rsti2c; diff --git a/main/app_main.c b/main/app_main.c index b618b6de..b67e2cca 100644 --- a/main/app_main.c +++ b/main/app_main.c @@ -1,19 +1,15 @@ /* KaRadio 32 A WiFi webradio player - Copyright (C) 2017 KaraWin - This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -33,7 +29,7 @@ Copyright (C) 2017 KaraWin #include "freertos/queue.h" #include "esp_system.h" #include "esp_wifi.h" -#include "esp_event_loop.h" +#include "esp_event.h" #include "esp_log.h" #include "esp_ota_ops.h" //#include "esp_heap_trace.h" @@ -41,6 +37,7 @@ Copyright (C) 2017 KaraWin #include "driver/i2s.h" #include "driver/uart.h" +#include "lwip/err.h" #include "lwip/sys.h" #include "lwip/netdb.h" #include "lwip/api.h" @@ -53,7 +50,7 @@ Copyright (C) 2017 KaraWin #include "spiram_fifo.h" #include "audio_renderer.h" //#include "bt_speaker.h" -#include "bt_config.h" +//#include "bt_config.h" //#include "mdns_task.h" #include "audio_player.h" #include @@ -67,7 +64,7 @@ Copyright (C) 2017 KaraWin ///////////////////////////////////////////////////// /////////////////////////// -#include "bt_config.h" +//#include "bt_config.h" #include "driver/gpio.h" #include "driver/i2c.h" //#include "esp_wifi.h" @@ -85,6 +82,7 @@ Copyright (C) 2017 KaraWin #include "addon.h" //#include "rda5807Task.h" + /* The event group allows multiple bits for each event*/ // are we connected to the AP with an IP? */ const int CONNECTED_BIT = 0x00000001; @@ -93,6 +91,7 @@ const int CONNECTED_AP = 0x00000010; #define TAG "main" + //Priorities of the reader and the decoder thread. bigger number = higher prio #define PRIO_READER configMAX_PRIORITIES -3 #define PRIO_MQTT configMAX_PRIORITIES - 3 @@ -121,6 +120,11 @@ static bool bigRam = false; static uint32_t ctimeVol = 0; static uint32_t ctimeMs = 0; static bool divide = false; + +esp_netif_t *ap; +esp_netif_t *sta; + + // disable 1MS timer interrupt IRAM_ATTR void noInterrupt1Ms() {timer_disable_intr(TIMERGROUP1MS, msTimer);} // enable 1MS timer interrupt @@ -130,8 +134,8 @@ IRAM_ATTR void interrupt1Ms() {timer_enable_intr(TIMERGROUP1MS, msTimer);} IRAM_ATTR char* getIp() {return (localIp);} IRAM_ATTR uint8_t getIvol() {return clientIvol;} -IRAM_ATTR void setIvol( uint8_t vol) {clientIvol = vol;ctimeVol = 0;} -IRAM_ATTR output_mode_t get_audio_output_mode() { return audio_output_mode;} +IRAM_ATTR void setIvol( uint8_t vol) {clientIvol = vol; ctimeVol = 0;} +IRAM_ATTR output_mode_t get_audio_output_mode() {return audio_output_mode;} /* IRAM_ATTR void microsCallback(void *pArg) { @@ -165,7 +169,7 @@ IRAM_ATTR void msCallback(void *pArg) { TIMERG1.hw_timer[timer_idx].config.alarm_en = 1; } -IRAM_ATTR void sleepCallback(void *pArg) { +IRAM_ATTR void sleepCallback(void *pArg) { int timer_idx = (int) pArg; queue_event_t evt; TIMERG0.int_clr_timers.t0 = 1; //isr ack @@ -175,7 +179,7 @@ IRAM_ATTR void sleepCallback(void *pArg) { xQueueSendFromISR(event_queue, &evt, NULL); TIMERG0.hw_timer[timer_idx].config.alarm_en = 0; } -IRAM_ATTR void wakeCallback(void *pArg) { +IRAM_ATTR void wakeCallback(void *pArg) { int timer_idx = (int) pArg; queue_event_t evt; @@ -313,89 +317,87 @@ uint32_t checkUart(uint32_t speed) * Parameters : * Returns : *******************************************************************************/ -static void init_hardware() +static void init_vs_hw() { if (VS1053_HW_init()) // init spi VS1053_Start(); - ESP_LOGI(TAG, "hardware initialized"); + ESP_LOGI(TAG, "VS HW initialized"); } /* event handler for pre-defined wifi events */ -static esp_err_t event_handler(void *ctx, system_event_t *event) +static void wifi_event_handler(void* arg, esp_event_base_t event_base, + int32_t event_id, void* event_data) { - EventGroupHandle_t wifi_event = ctx; + //EventGroupHandle_t wifi_event = ctx; - switch (event->event_id) - { - case SYSTEM_EVENT_STA_START: + if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) + { FlashOn = FlashOff = 100; esp_wifi_connect(); - break; - - case SYSTEM_EVENT_STA_CONNECTED: - xEventGroupSetBits(wifi_event, CONNECTED_AP); - ESP_LOGI(TAG, "Wifi connected"); - if (wifiInitDone) - { - clientSaveOneHeader("Wifi Connected.",18,METANAME); - vTaskDelay(1000); - autoPlay(); - } // retry - else wifiInitDone = true; break; - - case SYSTEM_EVENT_STA_GOT_IP: - FlashOn = 5;FlashOff = 395; - xEventGroupSetBits(wifi_event, CONNECTED_BIT); - break; - - case SYSTEM_EVENT_STA_DISCONNECTED: + } + else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) + { /* This is a workaround as ESP32 WiFi libs don't currently auto-reassociate. */ FlashOn = FlashOff = 100; - xEventGroupClearBits(wifi_event, CONNECTED_AP); - xEventGroupClearBits(wifi_event, CONNECTED_BIT); + xEventGroupClearBits(wifi_event_group, CONNECTED_AP); + xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); ESP_LOGE(TAG, "Wifi Disconnected."); - vTaskDelay(100); + vTaskDelay(10); if (!getAutoWifi()&&(wifiInitDone)) { ESP_LOGE(TAG, "reboot"); - vTaskDelay(100); + vTaskDelay(10); esp_restart(); } else { if (wifiInitDone) // a completed init done { ESP_LOGE(TAG, "Connection tried again"); -// clientDisconnect("Wifi Disconnected."); + //clientDisconnect("Wifi Disconnected."); clientSilentDisconnect(); vTaskDelay(100); - clientSaveOneHeader("Wifi Disconnected.",18,METANAME); + clientSaveOneHeader("Wifi Disconnected.",18,METANAME); vTaskDelay(100); while (esp_wifi_connect() == ESP_ERR_WIFI_SSID) vTaskDelay(10); - } else + } + else { ESP_LOGE(TAG, "Try next AP"); - vTaskDelay(100); + vTaskDelay(10); } // init failed? } - break; - - case SYSTEM_EVENT_AP_START: + } + else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_CONNECTED) + { + xEventGroupSetBits(wifi_event_group, CONNECTED_AP); + ESP_LOGI(TAG, "Wifi connected"); + if (wifiInitDone) + { + clientSaveOneHeader("Wifi Connected.",18,METANAME); + vTaskDelay(200); + autoPlay(); + } // retry + else + { + wifiInitDone = true; + } + } + else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) + { FlashOn = 5;FlashOff = 395; - xEventGroupSetBits(wifi_event, CONNECTED_AP); - xEventGroupSetBits(wifi_event, CONNECTED_BIT); + xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); + } + if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_AP_START) + { + FlashOn = 5;FlashOff = 395; + + xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); + xEventGroupSetBits(wifi_event_group, CONNECTED_AP); wifiInitDone = true; - break; - - case SYSTEM_EVENT_AP_STADISCONNECTED: - break; - - default: - break; } - return ESP_OK; } @@ -418,22 +420,36 @@ static void unParse(char* str) static void start_wifi() { - ESP_LOGI(TAG, "starting wifi"); - setAutoWifi(); -// wifi_mode_t mode; + ESP_LOGI(TAG, "Starting WiFi"); + + setAutoWifi(); + char ssid[SSIDLEN]; char pass[PASSLEN]; - - wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); - ESP_ERROR_CHECK( esp_wifi_init(&cfg) ); -// ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) ); - - tcpip_adapter_init(); - tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_STA); // Don't run a DHCP client - /* FreeRTOS event group to signal when we are connected & ready to make a request */ - wifi_event_group = xEventGroupCreate(); - ESP_ERROR_CHECK( esp_event_loop_init(event_handler, wifi_event_group) ); - + + static bool first_pass = false; + + static bool initialized = false; + if (!initialized) { + esp_netif_init(); + wifi_event_group = xEventGroupCreate(); + ESP_ERROR_CHECK(esp_event_loop_create_default()); + ap = esp_netif_create_default_wifi_ap(); + assert(ap); + sta = esp_netif_create_default_wifi_sta(); + assert(sta); + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + ESP_ERROR_CHECK( esp_wifi_init(&cfg) ); + ESP_ERROR_CHECK( esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL) ); + ESP_ERROR_CHECK( esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &wifi_event_handler, NULL) ); + ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) ); + ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_NULL) ); + //ESP_ERROR_CHECK( esp_wifi_start() ); + initialized = true; + } + ESP_LOGI(TAG, "WiFi init done!"); + + if (g_device->current_ap == APMODE) { if (strlen(g_device->ssid1) !=0) @@ -448,9 +464,10 @@ static void start_wifi() while (1) { - ESP_ERROR_CHECK( esp_wifi_stop() ); - vTaskDelay(10); - + if (first_pass) { + ESP_ERROR_CHECK(esp_wifi_stop()); + vTaskDelay(5); + } switch (g_device->current_ap) { case STA1: //ssid1 used @@ -480,19 +497,19 @@ static void start_wifi() .beacon_interval = 200 }, }; - ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &ap_config)); + ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &ap_config)); ESP_LOGE(TAG, "The default AP is WifiKaRadio. Connect your wifi to it.\nThen connect a webbrowser to 192.168.4.1 and go to Setting\nMay be long to load the first time.Be patient."); vTaskDelay(1); - ESP_ERROR_CHECK( esp_wifi_start() ); - - audio_output_mode = I2S; + ESP_ERROR_CHECK(esp_wifi_start()); } else { printf("WIFI TRYING TO CONNECT TO SSID %d\n",g_device->current_ap); - wifi_config_t wifi_config = { - .sta = { + wifi_config_t wifi_config = + { + .sta = + { .bssid_set = 0, }, }; @@ -502,13 +519,15 @@ static void start_wifi() unParse((char*)(wifi_config.sta.password)); if (strlen(ssid)/*&&strlen(pass)*/) { - esp_wifi_disconnect(); - ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config)); + if (CONNECTED_BIT > 1){ + esp_wifi_disconnect(); + } + ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config)); // ESP_LOGI(TAG, "connecting %s, %d, %s, %d",ssid,strlen((char*)(wifi_config.sta.ssid)),pass,strlen((char*)(wifi_config.sta.password))); ESP_LOGI(TAG, "connecting %s",ssid); - ESP_ERROR_CHECK( esp_wifi_start() ); -// esp_wifi_connect(); - } else + ESP_ERROR_CHECK(esp_wifi_start()); + } + else { g_device->current_ap++; g_device->current_ap %=3; @@ -519,15 +538,17 @@ static void start_wifi() printf("Wait for the AP\n"); } else + { printf("Empty AP. Try next one\n"); + } saveDeviceSettings(g_device); continue; } } - /* Wait for the callback to set the CONNECTED_BIT in the event group. */ - if ( (xEventGroupWaitBits(wifi_event_group, CONNECTED_AP,false, true, 2000) & CONNECTED_AP) ==0) + /* Wait for the callback to set the CONNECTED_AP in the event group. */ + if ( (xEventGroupWaitBits(wifi_event_group, CONNECTED_AP,false, true, 2000) & CONNECTED_AP) == 0) //timeout . Try the next AP { g_device->current_ap++; @@ -535,65 +556,72 @@ static void start_wifi() saveDeviceSettings(g_device); printf("\ndevice->current_ap: %d\n",g_device->current_ap); } else break; // + first_pass = true; } } void start_network(){ // struct device_settings *g_device; - tcpip_adapter_ip_info_t info; + + esp_netif_ip_info_t info; wifi_mode_t mode; ip4_addr_t ipAddr; ip4_addr_t mask; ip4_addr_t gate; uint8_t dhcpEn = 0; - + IP4_ADDR(&ipAddr,192,168,4,1); + IP4_ADDR(&gate,192,168,4,1); + IP4_ADDR(&mask,255,255,255,0); + + esp_netif_dhcpc_stop(sta); // Don't run a DHCP client + + switch (g_device->current_ap) { case STA1: //ssid1 used IP4_ADDR(&ipAddr, g_device->ipAddr1[0], g_device->ipAddr1[1],g_device->ipAddr1[2], g_device->ipAddr1[3]); - IP4_ADDR(&gate, g_device->gate1[0],g_device->gate1[1],g_device->gate1[2], g_device->gate1[3]); - IP4_ADDR(&mask, g_device->mask1[0], g_device->mask1[1],g_device->mask1[2], g_device->mask1[3]); + IP4_ADDR(&gate, g_device->gate1[0],g_device->gate1[1],g_device->gate1[2],g_device->gate1[3]); + IP4_ADDR(&mask, g_device->mask1[0],g_device->mask1[1],g_device->mask1[2],g_device->mask1[3]); dhcpEn = g_device->dhcpEn1; break; case STA2: //ssid2 used IP4_ADDR(&ipAddr, g_device->ipAddr2[0], g_device->ipAddr2[1],g_device->ipAddr2[2], g_device->ipAddr2[3]); - IP4_ADDR(&gate, g_device->gate2[0],g_device->gate2[1],g_device->gate2[2], g_device->gate2[3]); - IP4_ADDR(&mask, g_device->mask2[0], g_device->mask2[1],g_device->mask2[2], g_device->mask2[3]); + IP4_ADDR(&gate, g_device->gate2[0],g_device->gate2[1],g_device->gate2[2],g_device->gate2[3]); + IP4_ADDR(&mask, g_device->mask2[0],g_device->mask2[1],g_device->mask2[2],g_device->mask2[3]); dhcpEn = g_device->dhcpEn2; break; - - default: // other: AP mode - IP4_ADDR(&ipAddr, 192,168,4,1); - IPADDR2_COPY(&gate,&ipAddr); - IP4_ADDR(&mask,255,255,255,0); } - IPADDR2_COPY(&info.ip,&ipAddr); - IPADDR2_COPY(&info.gw,&gate); - IPADDR2_COPY(&info.netmask,&mask); - + ip4_addr_copy(info.ip, ipAddr); + ip4_addr_copy(info.gw, gate); + ip4_addr_copy(info.netmask, mask); + ESP_ERROR_CHECK(esp_wifi_get_mode(&mode)); + if (mode == WIFI_MODE_AP) { - xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT,false, true, 3000); - IPADDR2_COPY(&info.ip,&ipAddr); - tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_AP, &info); -// g_device->dhcpEn1 = g_device->dhcpEn2 = 1; -// IPADDR2_COPY(&g_device->mask1, &mask); -// IPADDR2_COPY(&g_device->mask2, &mask); -// saveDeviceSettings(g_device); - strcpy(localIp , ip4addr_ntoa(&info.ip)); - printf("IP: %s\n\n",ip4addr_ntoa(&info.ip)); - + xEventGroupWaitBits(wifi_event_group, CONNECTED_AP, false, true, 3000); + ip4_addr_copy(info.ip, ipAddr); + esp_netif_set_ip_info(ap, &info); + + esp_netif_ip_info_t ap_ip_info; + ap_ip_info.ip.addr = 0; + while (ap_ip_info.ip.addr == 0) + { + esp_netif_get_ip_info(ap, &ap_ip_info); + } + } else // mode STA - { - if (dhcpEn ) // check if ip is valid without dhcp - tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_STA); // run a DHCP client + { + if (dhcpEn) // check if ip is valid without dhcp + { + esp_netif_dhcpc_start(sta); // run a DHCP client + } else { - ESP_ERROR_CHECK(tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_STA, &info)); + ESP_ERROR_CHECK(esp_netif_set_ip_info(sta, &info)); dns_clear_servers(false); IP_SET_TYPE(( ip_addr_t* )&info.gw, IPADDR_TYPE_V4); // mandatory (( ip_addr_t* )&info.gw)->type = IPADDR_TYPE_V4; @@ -601,60 +629,92 @@ void start_network(){ dns_setserver(1,( ip_addr_t* ) &info.gw); // if static ip check dns } - - // wait for ip - if ( (xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT,false, true, 3000) & CONNECTED_BIT) ==0) //timeout + + // wait for ip + if ( (xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT,false, true, 3000) & CONNECTED_BIT) == 0) //timeout { // enable dhcp and restart if (g_device->current_ap ==1) - g_device->dhcpEn1 = 1; + { + g_device->dhcpEn1 = 1; + } else - g_device->dhcpEn2 = 1; - saveDeviceSettings(g_device); + { + g_device->dhcpEn2 = 1; + } + saveDeviceSettings(g_device); esp_restart(); } - - vTaskDelay(1); - // retrieve the current ip - tcpip_adapter_ip_info_t ip_info; - ip_info.ip.addr =0; - while (ip_info.ip.addr ==0) + + vTaskDelay(1); + + // retrieve the current ip + esp_netif_ip_info_t sta_ip_info; + sta_ip_info.ip.addr = 0; + while (sta_ip_info.ip.addr == 0) { - if (mode == WIFI_MODE_AP) - tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_AP, &ip_info); - else - tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info); - } - ip_addr_t ipdns0 = dns_getserver(0); -// ip_addr_t ipdns1 = dns_getserver(1); + esp_netif_get_ip_info(sta, &sta_ip_info); + } + + const ip_addr_t *ipdns0 = dns_getserver(0); printf("\nDNS: %s \n",ip4addr_ntoa(( struct ip4_addr* ) &ipdns0)); - strcpy(localIp , ip4addr_ntoa(&ip_info.ip)); - printf("IP: %s\n\n",ip4addr_ntoa(&ip_info.ip)); - + if (dhcpEn) // if dhcp enabled update fields - { - tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &info); + { + esp_netif_get_ip_info(sta, &info); switch (g_device->current_ap) { - case STA1: //ssid1 used - IPADDR2_COPY(&g_device->ipAddr1, &info.ip); - IPADDR2_COPY(&g_device->mask1, &info.netmask); - IPADDR2_COPY(&g_device->gate1, &info.gw); + case STA1: //ssid1 used + ip4_addr_copy(ipAddr, info.ip); + g_device->ipAddr1[0] = ip4_addr1_val(ipAddr); + g_device->ipAddr1[1] = ip4_addr2_val(ipAddr); + g_device->ipAddr1[2] = ip4_addr3_val(ipAddr); + g_device->ipAddr1[3] = ip4_addr4_val(ipAddr); + + ip4_addr_copy(ipAddr, info.gw); + g_device->gate1[0] = ip4_addr1_val(ipAddr); + g_device->gate1[1] = ip4_addr2_val(ipAddr); + g_device->gate1[2] = ip4_addr3_val(ipAddr); + g_device->gate1[3] = ip4_addr4_val(ipAddr); + + ip4_addr_copy(ipAddr, info.netmask); + g_device->mask1[0] = ip4_addr1_val(ipAddr); + g_device->mask1[1] = ip4_addr2_val(ipAddr); + g_device->mask1[2] = ip4_addr3_val(ipAddr); + g_device->mask1[3] = ip4_addr4_val(ipAddr); break; - case STA2: //ssid1 used - IPADDR2_COPY(&g_device->ipAddr2, &info.ip); - IPADDR2_COPY(&g_device->mask2, &info.netmask); - IPADDR2_COPY(&g_device->gate2, &info.gw); + + case STA2: //ssid1 used + ip4_addr_copy(ipAddr, info.ip); + g_device->ipAddr2[0] = ip4_addr1_val(ipAddr); + g_device->ipAddr2[1] = ip4_addr2_val(ipAddr); + g_device->ipAddr2[2] = ip4_addr3_val(ipAddr); + g_device->ipAddr2[3] = ip4_addr4_val(ipAddr); + + ip4_addr_copy(ipAddr, info.gw); + g_device->gate2[0] = ip4_addr1_val(ipAddr); + g_device->gate2[1] = ip4_addr2_val(ipAddr); + g_device->gate2[2] = ip4_addr3_val(ipAddr); + g_device->gate2[3] = ip4_addr4_val(ipAddr); + + ip4_addr_copy(ipAddr, info.netmask); + g_device->mask2[0] = ip4_addr1_val(ipAddr); + g_device->mask2[1] = ip4_addr2_val(ipAddr); + g_device->mask2[2] = ip4_addr3_val(ipAddr); + g_device->mask2[3] = ip4_addr4_val(ipAddr); break; } } - saveDeviceSettings(g_device); - tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, "karadio32"); + saveDeviceSettings(g_device); + esp_netif_set_hostname(sta, "karadio32"); } + ip4_addr_copy(ipAddr, info.ip); + strcpy(localIp , ip4addr_ntoa(&ipAddr)); + printf("IP: %s\n\n", localIp); - lcd_welcome(localIp,"IP found"); + if (g_device->lcd_type != LCD_NONE) lcd_welcome(localIp,"IP found"); vTaskDelay(10); - + } @@ -890,47 +950,52 @@ void app_main() uint8_t ddmm; option_get_ddmm(&ddmm); setDdmm(ddmm?1:0); - + //SPI init for the vs1053 and lcd if spi. - VS1053_spi_init(); + + uint8_t spi_no; + gpio_num_t miso; + gpio_num_t mosi; + gpio_num_t sclk; + gpio_num_t sda; + gpio_num_t scl; + gpio_num_t rsti2c; - init_hardware(); - ESP_LOGI(TAG, "Hardware init done..."); + uint8_t rt; + option_get_lcd_info(&g_device->lcd_type,&rt); + + gpio_get_spi_bus(&spi_no,&miso,&mosi,&sclk); + if(miso != GPIO_NONE && mosi != GPIO_NONE && sclk != GPIO_NONE && spi_no > 0 && spi_no < 3) + { + Spi_init(); + } + else + { + gpio_get_i2c(&scl,&sda,&rsti2c); + if(scl == GPIO_NONE || sda == GPIO_NONE) + { + g_device->lcd_type = LCD_NONE; + } + } + // output mode + //I2S, I2S_MERUS, DAC_BUILT_IN, PDM, VS1053, A1S + audio_output_mode = g_device->audio_output_mode; + ESP_LOGI(TAG, "audio_output_mode %d\nOne of I2S=0, I2S_MERUS, DAC_BUILT_IN, PDM, VS1053, A1S",audio_output_mode); + + if (audio_output_mode == 4) + { + init_vs_hw(); //init vs1053 if in mode sel + } //ESP_LOGE(TAG,"Corrupt1 %d",heap_caps_check_integrity(MALLOC_CAP_DMA,1)); // lcd init - uint8_t rt; - option_get_lcd_info(&g_device->lcd_type,&rt); ESP_LOGI(TAG,"LCD Type %d",g_device->lcd_type); //lcd rotation setRotat(rt) ; - lcd_init(g_device->lcd_type); -/* - // Init i2c if lcd doesn't not (spi) for rde5807= - if (g_device->lcd_type >= LCD_SPI) - { - i2c_config_t conf; - conf.mode = I2C_MODE_MASTER; - conf.sda_io_num = (g_device->lcd_type == LCD_NONE)?PIN_I2C_SDA:PIN_SI2C_SDA; - conf.sda_pullup_en = GPIO_PULLUP_ENABLE; - conf.scl_io_num = (g_device->lcd_type == LCD_NONE)?PIN_I2C_SCL:PIN_SI2C_SCL; - conf.scl_pullup_en = GPIO_PULLUP_ENABLE; - conf.master.clk_speed = I2C_MASTER_RFREQ_HZ; - //ESP_ERROR_CHECK - (i2c_param_config(I2C_MASTER_NUM, &conf)); - ESP_LOGD(TAG, "i2c_driver_install %d", I2C_MASTER_NUM); - //ESP_ERROR_CHECK - (i2c_driver_install(I2C_MASTER_NUM, conf.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0)); - } -*/ - + lcd_init(g_device->lcd_type); - // output mode - //I2S, I2S_MERUS, DAC_BUILT_IN, PDM, VS1053 - audio_output_mode = g_device->audio_output_mode; - ESP_LOGI(TAG, "audio_output_mode %d\nOne of I2S=0, I2S_MERUS, DAC_BUILT_IN, PDM, VS1053",audio_output_mode); //Initialize the SPI RAM chip communications and see if it actually retains some bytes. If it //doesn't, warn user. @@ -961,15 +1026,16 @@ void app_main() g_device->uartspeed = uspeed; saveDeviceSettings(g_device); } - - // Version infos ESP_LOGI(TAG, "Release %s, Revision %s",RELEASE,REVISION); ESP_LOGI(TAG, "SDK %s",esp_get_idf_version()); ESP_LOGI(TAG, "Heap size: %d",xPortGetFreeHeapSize()); - lcd_welcome("",""); - lcd_welcome("","STARTING"); + if (g_device->lcd_type != LCD_NONE) + { + lcd_welcome("",""); + lcd_welcome("","STARTING"); + } // volume setIvol( g_device->vol); @@ -983,16 +1049,16 @@ void app_main() ESP_LOGI(TAG, "%s task: %x","t0",(unsigned int)pxCreatedTask); -//----------------------------- -// start the network -//----------------------------- - /* init wifi & network*/ - start_wifi(); - start_network(); - -//----------------------------------------------------- -//init softwares -//----------------------------------------------------- + //----------------------------- + // start the network + //----------------------------- + /* init wifi & network*/ + start_wifi(); + start_network(); + + //----------------------------------------------------- + //init softwares + //----------------------------------------------------- clientInit(); //initialize mDNS service @@ -1028,7 +1094,7 @@ void app_main() renderer_init(create_renderer_config()); // LCD Display infos - lcd_welcome(localIp,"STARTED"); + if (g_device->lcd_type != LCD_NONE) lcd_welcome(localIp,"STARTED"); vTaskDelay(10); ESP_LOGI(TAG, "RAM left %d", esp_get_free_heap_size()); @@ -1064,4 +1130,6 @@ void app_main() //autostart autoPlay(); // All done. + + } diff --git a/main/cencode.c b/main/cencode.c index 7367135f..4c7f46b5 100644 --- a/main/cencode.c +++ b/main/cencode.c @@ -53,6 +53,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, result = (fragment & 0x0fc) >> 2; *codechar++ = base64_encode_value(result); result = (fragment & 0x003) << 4; + /* fall through */ case step_B: if (plainchar == plaintextend) { @@ -63,7 +64,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, fragment = *plainchar++; result |= (fragment & 0x0f0) >> 4; *codechar++ = base64_encode_value(result); - result = (fragment & 0x00f) << 2; + /* fall through */ case step_C: if (plainchar == plaintextend) { diff --git a/main/gpio.c b/main/gpio.c index 1c77c492..4fe35cf7 100644 --- a/main/gpio.c +++ b/main/gpio.c @@ -330,7 +330,7 @@ void gpio_get_joysticks(gpio_num_t *enca,gpio_num_t *enca1) // get the active level of buttons void gpio_get_active_buttons(bool *abtn0, bool *abtn1) { - esp_err_t err; +// esp_err_t err; nvs_handle hardware_handle; *abtn0 = 0; diff --git a/main/include/vs1053.h b/main/include/vs1053.h index 7342807e..f5f9a747 100644 --- a/main/include/vs1053.h +++ b/main/include/vs1053.h @@ -75,7 +75,7 @@ uint16_t VS1053_GetBitrate(); uint16_t VS1053_GetSampleRate(); uint16_t VS1053_GetDecodeTime(); void VS1053_flush_cancel(uint8_t mode);// 0 only fillbyte 1 before play 2 close play -void VS1053_spi_init(); +void Spi_init(); // admix plugin control void VS1053_SetVolumeLine(int16_t vol); void VS1053_Admix(bool val); diff --git a/main/interface.c b/main/interface.c index 5ec97094..9f14f76c 100644 --- a/main/interface.c +++ b/main/interface.c @@ -137,7 +137,7 @@ A command error display:\n\ uint16_t currentStation = 0; static gpio_num_t led_gpio = GPIO_NONE; static IRAM_ATTR uint32_t lcd_out = 0xFFFFFFFF; -static esp_log_level_t s_log_default_level = CONFIG_LOG_BOOTLOADER_LEVEL; +static esp_log_level_t s_log_default_level = CONFIG_LOG_BOOTLOADER_LEVEL_ERROR; extern void wsVol(char* vol); extern void playStation(char* id); void clientVol(char *s); diff --git a/main/vs1053.c b/main/vs1053.c index 1eda6f2e..831420a7 100644 --- a/main/vs1053.c +++ b/main/vs1053.c @@ -59,7 +59,7 @@ void spi_give_semaphore(xSemaphoreHandle isSPI) { } -void VS1053_spi_init(){ +void Spi_init(){ esp_err_t ret; gpio_num_t miso; gpio_num_t mosi; @@ -109,8 +109,8 @@ bool VS1053_HW_init() ESP_LOGE(TAG,"VS1053 not used"); return false; } - uint32_t freq =spi_cal_clock(APB_CLK_FREQ, 1400000, 128, NULL); -// uint32_t freq =spi_cal_clock(APB_CLK_FREQ, 1600000, 128, NULL); + uint32_t freq =spi_get_actual_clock(APB_CLK_FREQ, 1400000, 128); +// uint32_t freq =spi_get_actual_clock(APB_CLK_FREQ, 1600000, 128); ESP_LOGI(TAG,"VS1053 LFreq: %d",freq); spi_device_interface_config_t devcfg={ .clock_speed_hz=freq, //Clock out at x MHz @@ -133,7 +133,7 @@ bool VS1053_HW_init() ESP_ERROR_CHECK(spi_bus_add_device(spi_no, &devcfg, &vsspi)); //high speed - freq =spi_cal_clock(APB_CLK_FREQ, 6100000, 128, NULL); + freq =spi_get_actual_clock(APB_CLK_FREQ, 6100000, 128); ESP_LOGI(TAG,"VS1053 HFreq: %d",freq); devcfg.clock_speed_hz = freq; devcfg.spics_io_num= xdcs; //XDCS pin diff --git a/main/webclient.c b/main/webclient.c index 84c5b35b..93b3bc71 100644 --- a/main/webclient.c +++ b/main/webclient.c @@ -474,8 +474,8 @@ void wsVol(char* vol) // websocket: broadcast monitor url void wsMonitor() { - char answer[300]; - memset(answer,0,300); + char answer[540]; + memset(answer,0,540); if ((clientPath[0]!= 0)) { sprintf(answer,"{\"monitor\":\"http://%s:%d%s\"}",clientURL,clientPort,clientPath); @@ -812,6 +812,7 @@ void clientReceiveCallback(int sockfd, char *pdata, int len) break; } //no break here + /* fall through */ case C_HEADER1: // not ended { int i = 0; diff --git a/main/webserver.c b/main/webserver.c index 71bdb74b..30bf3cb7 100644 --- a/main/webserver.c +++ b/main/webserver.c @@ -524,7 +524,7 @@ static void handlePOST(char* name, char* data, int data_size, int conn) { { if ((atoi(id) >=0) && (atoi(id) < 255)) { - char ibuf [6]; + char ibuf [10]; char *buf; for(i = 0; i