diff --git a/Esp32_radio/Esp32_radio.ino b/Esp32_radio/Esp32_radio.ino index 2766cdc..8332c2d 100644 --- a/Esp32_radio/Esp32_radio.ino +++ b/Esp32_radio/Esp32_radio.ino @@ -141,6 +141,8 @@ // 18-09-2018, ES: "uppreset" and "downpreset" for MP3 player. // 04-10-2018, ES: Fixed compile error OLED 64x128 display. // 09-10-2018, ES: Bug fix xSemaphoreTake. +// 26-11-2018, DK: Bug fix output enable +// 01-01-2019, DK: 2nd bug fix to output enable. Thanks to Pavulon87. // // // Define the version number, also used for webserver as Last-Modified header and to @@ -155,10 +157,10 @@ // Define (just one) type of display. See documentation. //#define BLUETFT // Works also for RED TFT 128x160 //#define OLED // 64x128 I2C OLED -//#define DUMMYTFT // Dummy display +#define DUMMYTFT // Dummy display //#define LCD1602I2C // LCD 1602 display with I2C backpack //#define ILI9341 // ILI9341 240*320 -#define NEXTION // Nextion display. Uses UART 2 (pin 16 and 17) +//#define NEXTION // Nextion display. Uses UART 2 (pin 16 and 17) // #include #include @@ -357,7 +359,7 @@ SemaphoreHandle_t SPIsem = NULL ; // For exclusive SPI us hw_timer_t* timer = NULL ; // For timer char timetxt[9] ; // Converted timeinfo char cmd[130] ; // Command from MQTT or Serial -uint8_t tmpbuff[6000] ; // Input buffer for mp3 or data stream +uint8_t tmpbuff[6000] ; // Input buffer for mp3 or data stream QueueHandle_t dataqueue ; // Queue for mp3 datastream QueueHandle_t spfqueue ; // Queue for special functions qdata_struct outchunk ; // Data to queue @@ -966,7 +968,7 @@ void VS1053::setTone ( uint8_t *rtone ) // Set bass/treble (4 ni void VS1053::startSong() { sdi_send_fillers ( 10 ) ; - output_enable ( true ) ; // Enable amplifier through shutdown pin(s) + output_enable ( curvol != 0 ) ; // Enable amplifier through shutdown pin(s), but only when Volume setting isn't zero } bool VS1053::playChunk ( uint8_t* data, size_t len ) @@ -2343,7 +2345,7 @@ bool connectwifi() } tftlog ( pfs ) ; // Show IP delay ( 3000 ) ; // Allow user to read this - tftlog ( "\f" ) ; // Select new page if NEXTION + tftlog ( "\f" ) ; // Select new page if NEXTION return ( localAP == false ) ; // Return result of connection } @@ -2402,7 +2404,7 @@ bool do_nextion_update ( uint32_t clength ) } k = otaclient.read ( tmpbuff, k ) ; // Read a number of bytes from the stream dbgprint ( "TFT file, read %d bytes", k ) ; - nxtserial->write ( tmpbuff, k ) ; + nxtserial->write ( tmpbuff, k ) ; while ( !nxtserial->available() ) // Any input seen? { delay ( 20 ) ; @@ -2433,7 +2435,7 @@ bool do_nextion_update ( uint32_t clength ) bool do_software_update ( uint32_t clength ) { bool res = false ; // Update result - + if ( Update.begin ( clength ) ) // Update possible? { dbgprint ( "Begin OTA update, length is %d", @@ -2485,7 +2487,7 @@ void update_software ( const char* lstmodkey, const char* updatehost, const char String line ; // Input header line String lstmod = "" ; // Last modified timestamp in NVS String newlstmod ; // Last modified from host - + updatereq = false ; // Clear update flag otastart() ; // Show something on screen stop_mp3client () ; // Stop input stream @@ -2523,7 +2525,7 @@ void update_software ( const char* lstmodkey, const char* updatehost, const char break ; // Yes, get the OTA started } // Check if the HTTP Response is 200. Any other response is an error. - if ( line.startsWith ( "HTTP/1.1" ) ) // + if ( line.startsWith ( "HTTP/1.1" ) ) // { if ( line.indexOf ( " 200 " ) < 0 ) { @@ -2542,7 +2544,7 @@ void update_software ( const char* lstmodkey, const char* updatehost, const char { dbgprint ( "No new version available" ) ; // No, show reason otaclient.flush() ; - return ; + return ; } if ( clength > 0 ) { @@ -2815,7 +2817,7 @@ String readprefs ( bool output ) String ( "/*******" ) ; } cmd = String ( "" ) ; // Do not analyze this - + } else if ( strstr ( key, "mqttpasswd" ) ) // Is it a MQTT password? { @@ -3007,7 +3009,7 @@ void scanserial2() dbgprint ( "NEXTION command seen %02X %s", cmd[0], cmd + 1 ) ; if ( cmd[0] == 0x70 ) // Button pressed? - { + { reply = analyzeCmd ( cmd + 1 ) ; // Analyze command and handle it dbgprint ( reply ) ; // Result for debugging } @@ -4528,7 +4530,7 @@ void loop() if ( updatereq ) // Software update requested? { if ( displaytype == T_NEXTION ) // NEXTION in use? - { + { update_software ( "lstmodn", // Yes, update NEXTION image from remote image UPDATEHOST, TFTFILE ) ; } @@ -5629,7 +5631,7 @@ void handle_spec() { vs1053player->setVolume ( 0 ) ; // Mute } - else + else if ( !( datamode & ( STOPREQD | STOPPED ) ) ) // Do not actually unmute if not playing { vs1053player->setVolume ( ini_block.reqvol ) ; // Unmute } @@ -5682,4 +5684,3 @@ void spftask ( void * parameter ) } //vTaskDelete ( NULL ) ; // Will never arrive here } -