From bb500061b8b7f788f315e973f34db57df4c35d71 Mon Sep 17 00:00:00 2001 From: Masato YAMANISHI Date: Sun, 28 May 2017 20:43:58 +0900 Subject: [PATCH 1/7] Update README.md add description --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8d1c556..74c3a1b 100755 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ Modified for multi URL support by n24bass -Add web interface. +Add web interface. You can add (up to 10), change or remove URL of the internet radio station. ``` -http://address_of_ESP32/ - list stations -http://address_of_ESP32/P - change to previous station -http://address_of_ESP32/N - change to next station -http://address_of_ESP32/[0..9] - select station -http://address_of_ESP32/[0..]+URL - set station URL -http://address_of_ESP32/[0..]-URL - remove station URL +GET / - list stations +GET /P - change to previous station +GET /N - change to next station +GET /0..9 - select station +GET /0..9+URL - set station URL +GET /0..-URL - remove station URL ``` Push 'boot' switch to change next station. @@ -49,4 +49,4 @@ GPIO13 - SDA More details can be found in the original author's explanation at -https://github.com/MrBuddyCasino/ESP32_MP3_Decoder \ No newline at end of file +https://github.com/MrBuddyCasino/ESP32_MP3_Decoder From 6eb9eb1c5ba28c96fa9cd157277207305697599f Mon Sep 17 00:00:00 2001 From: Masato YAMANISHI Date: Sun, 25 Jun 2017 21:56:19 +0900 Subject: [PATCH 2/7] changed the control switch GPIO 0 to 16. start up web interface only when GPIO16 is low level at boot time. --- components/controls/controls.c | 6 +++--- main/app_main.c | 31 ++++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/components/controls/controls.c b/components/controls/controls.c index 1e1f03b..4755a6d 100755 --- a/components/controls/controls.c +++ b/components/controls/controls.c @@ -41,7 +41,7 @@ void controls_init(TaskFunction_t gpio_handler_task, const uint16_t usStackDepth //interrupt of rising edge io_conf.intr_type = GPIO_PIN_INTR_POSEDGE; //bit mask of the pins, use GPIO0 here ("Boot" button) - io_conf.pin_bit_mask = (1 << GPIO_NUM_0); + io_conf.pin_bit_mask = (1 << GPIO_NUM_16); //set as input mode io_conf.mode = GPIO_MODE_INPUT; //disable pull-down mode @@ -63,10 +63,10 @@ void controls_init(TaskFunction_t gpio_handler_task, const uint16_t usStackDepth gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT); // remove existing handler that may be present - gpio_isr_handler_remove(GPIO_NUM_0); + gpio_isr_handler_remove(GPIO_NUM_16); //hook isr handler for specific gpio pin - gpio_isr_handler_add(GPIO_NUM_0, gpio_isr_handler, (void*) GPIO_NUM_0); + gpio_isr_handler_add(GPIO_NUM_16, gpio_isr_handler, (void*) GPIO_NUM_16); } void controls_destroy() diff --git a/main/app_main.c b/main/app_main.c index ea1af3d..eb50ab7 100644 --- a/main/app_main.c +++ b/main/app_main.c @@ -62,6 +62,8 @@ const static char http_e[] = "prev nex #define MAXSTATION 10 static const char *preset_url = "http://wbgo.streamguys.net/wbgo96"; // preset station URL +// static const char *preset_url = "http://wbgo-web.streamguys.net/audio/wbgo_8000.asx"; +// static const char *preset_url = "http://wbgo.streamguys.net/thejazzstream"; /* "http://wbgo.streamguys.net/wbgo96", "http://wbgo.streamguys.net/thejazzstream", @@ -86,6 +88,9 @@ char *init_url(int d) { esp_err_t e; nvs_open(NVSNAME, NVS_READWRITE, &h); +#if 0 + nvs_erase_all(h); +#endif if (nvs_get_u8(h, key_n, &stno_max) != ESP_OK) { stno = 0; @@ -197,6 +202,14 @@ void erase_nvurl(int n) { xSemaphoreHandle print_mux; +void i2c_clear(void) +{ + SSD1306_Fill(SSD1306_COLOR_BLACK); // clear screen + SSD1306_GotoXY(40, 4); + SSD1306_Puts("ESP32", &Font_11x18, SSD1306_COLOR_WHITE); + SSD1306_UpdateScreen(); +} + void i2c_test(void) { char *url = get_url(); // play_url(); @@ -406,6 +419,8 @@ static void start_wifi() ui_queue_event(UI_CONNECTED); } +static void http_server(void *pvParameters); + static renderer_config_t *create_renderer_config() { renderer_config_t *renderer_config = calloc(1, sizeof(renderer_config_t)); @@ -453,6 +468,12 @@ static void start_web_radio() radio_config->url = get_url(); // play_url(); /* PLAY_URL; */ + xTaskCreate(&http_server, "http_server", 2048, NULL, 5, NULL); + if (gpio_get_level(GPIO_NUM_16) == 0) { + while (1) + vTaskDelay(200/portTICK_RATE_MS); + } + // start radio web_radio_init(radio_config); web_radio_start(radio_config); @@ -598,12 +619,16 @@ void app_main() bt_speaker_start(create_renderer_config()); #else start_wifi(); - start_web_radio(); -#endif i2c_example_master_init(); SSD1306_Init(); + i2c_clear(); + + start_web_radio(); + i2c_test(); +#endif ESP_LOGI(TAG, "RAM left %d", esp_get_free_heap_size()); // ESP_LOGI(TAG, "app_main stack: %d\n", uxTaskGetStackHighWaterMark(NULL)); - xTaskCreate(&http_server, "http_server", 2048, NULL, 5, NULL); + while (1) + vTaskDelay(200/portTICK_RATE_MS); } From 541061f69e49d6f2b043f597ea15e909e88eaa66 Mon Sep 17 00:00:00 2001 From: Masato YAMANISHI Date: Sun, 25 Jun 2017 22:14:56 +0900 Subject: [PATCH 3/7] add description. --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 74c3a1b..6cdef85 100755 --- a/README.md +++ b/README.md @@ -11,7 +11,9 @@ GET /0..9+URL - set station URL GET /0..-URL - remove station URL ``` -Push 'boot' switch to change next station. +Push 'GPIO-16' (chaned from 'boot') switch to change next station. + +It starts up only web interface when GPIO-16 is keeped low level at boot time. ---- From fa1ee828de13b6139f85168f9e3f2c301a7948b1 Mon Sep 17 00:00:00 2001 From: Masato YAMANISHI Date: Sun, 25 Jun 2017 23:34:34 +0900 Subject: [PATCH 4/7] referctoring --- main/app_main.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/main/app_main.c b/main/app_main.c index eb50ab7..1734fb4 100644 --- a/main/app_main.c +++ b/main/app_main.c @@ -202,15 +202,7 @@ void erase_nvurl(int n) { xSemaphoreHandle print_mux; -void i2c_clear(void) -{ - SSD1306_Fill(SSD1306_COLOR_BLACK); // clear screen - SSD1306_GotoXY(40, 4); - SSD1306_Puts("ESP32", &Font_11x18, SSD1306_COLOR_WHITE); - SSD1306_UpdateScreen(); -} - -void i2c_test(void) +void i2c_test(int mode) { char *url = get_url(); // play_url(); @@ -231,13 +223,16 @@ void i2c_test(void) #else ////////for webradio mode display//////////////// SSD1306_Puts("PCM5102A webradio", &Font_7x10, SSD1306_COLOR_WHITE); SSD1306_GotoXY(2, 30); - - SSD1306_Puts(url, &Font_7x10, SSD1306_COLOR_WHITE); - if (strlen(url) > 18) { - SSD1306_GotoXY(2, 39); - SSD1306_Puts(url + 18, &Font_7x10, SSD1306_COLOR_WHITE); + if (mode) { + SSD1306_Puts("web server is up.", &Font_7x10, SSD1306_COLOR_WHITE); + } else { + SSD1306_Puts(url, &Font_7x10, SSD1306_COLOR_WHITE); + if (strlen(url) > 18) { + SSD1306_GotoXY(2, 39); + SSD1306_Puts(url + 18, &Font_7x10, SSD1306_COLOR_WHITE); + } + SSD1306_GotoXY(16, 53); } - SSD1306_GotoXY(16, 53); tcpip_adapter_ip_info_t ip_info; tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info); @@ -621,11 +616,11 @@ void app_main() start_wifi(); i2c_example_master_init(); SSD1306_Init(); - i2c_clear(); + i2c_test(1); start_web_radio(); - i2c_test(); + i2c_test(0); #endif ESP_LOGI(TAG, "RAM left %d", esp_get_free_heap_size()); // ESP_LOGI(TAG, "app_main stack: %d\n", uxTaskGetStackHighWaterMark(NULL)); From d7591dd5e542f3ec7691ae459b682060fec44433 Mon Sep 17 00:00:00 2001 From: Masato YAMANISHI Date: Fri, 30 Jun 2017 09:40:24 +0900 Subject: [PATCH 5/7] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6cdef85..2581743 100755 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +-> [new version](https://github.com/n24bass/ESP32_MP3_Decoder) + Modified for multi URL support by n24bass Add web interface. You can add (up to 10), change or remove URL of the internet radio station. From 76b053c1a68b43301f50177440c95a04d8d6c405 Mon Sep 17 00:00:00 2001 From: Masato YAMANISHI Date: Fri, 30 Jun 2017 09:41:20 +0900 Subject: [PATCH 6/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2581743..ff45fd9 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ --> [new version](https://github.com/n24bass/ESP32_MP3_Decoder) +-> [new version](https://github.com/n24bass/ESP32_MP3_Decoder/tree/OLED_WEB) Modified for multi URL support by n24bass From 89bbdbe24778be321d7166538187317a2c071f15 Mon Sep 17 00:00:00 2001 From: Masato YAMANISHI Date: Tue, 3 Oct 2017 22:53:32 +0900 Subject: [PATCH 7/7] scrolling OLED display --- components/controls/controls.c | 2 +- main/Kconfig.projbuild | 6 +++ main/app_main.c | 87 ++++++++++++++++++++++++++-------- main/ssd1306.c | 18 +++---- main/ssd1306.h | 4 +- sdkconfig.defaults | 2 + 6 files changed, 83 insertions(+), 36 deletions(-) diff --git a/components/controls/controls.c b/components/controls/controls.c index 4755a6d..e5389e1 100755 --- a/components/controls/controls.c +++ b/components/controls/controls.c @@ -71,7 +71,7 @@ void controls_init(TaskFunction_t gpio_handler_task, const uint16_t usStackDepth void controls_destroy() { - gpio_isr_handler_remove(GPIO_NUM_0); + gpio_isr_handler_remove(GPIO_NUM_16); vTaskDelete(gpio_task); vQueueDelete(gpio_evt_queue); // TODO: free gpio_handler_param_t params diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index c2e2f5d..9582fb4 100755 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -52,4 +52,10 @@ menuconfig BT_SPEAKER_MODE Web radio streaming will be unavailable. depends on CLASSIC_BT_ENABLED + config SSD1306_6432 + help + only for Web radio mode + bool "use SSD1306_6432" + endmenu + diff --git a/main/app_main.c b/main/app_main.c index 1734fb4..8221374 100644 --- a/main/app_main.c +++ b/main/app_main.c @@ -49,10 +49,9 @@ #define I2C_EXAMPLE_MASTER_RX_BUF_DISABLE 0 /*!< I2C master do not need buffer */ #define I2C_EXAMPLE_MASTER_FREQ_HZ 100000 /*!< I2C master clock frequency */ - const static char http_html_hdr[] = "HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n"; -const static char http_t[] = "ESP32 PCM5102A webradio

Web radio station list