From d799448c97443ba40252a8bc2cf3758aad5836c8 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Mon, 11 Nov 2019 05:32:41 +0100 Subject: [PATCH] Changed from ESP8266 to ESP32. Works much better. HTTP server is disabled (for now). --- .vscode/c_cpp_properties.json | 275 +++++++++++++++++++++++----------- .vscode/launch.json | 8 +- README.md | 37 +++-- include/config.h | 48 +++--- include/controller.h | 4 +- include/http_server.h | 2 + include/mqtt_client.h | 2 +- include/player.h | 3 +- include/spi_master.h | 5 +- include/tools.h | 8 - platformio.ini | 12 +- src/controller.cpp | 5 +- src/http_server.cpp | 2 + src/main.cpp | 40 ++--- src/player.cpp | 26 ++-- 15 files changed, 273 insertions(+), 204 deletions(-) delete mode 100644 include/tools.h diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 9ea30ec..44527b6 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -9,46 +9,96 @@ "includePath": [ "/Users/fabian/Documents/PlatformIO/Projects/esmp3/include", "/Users/fabian/Documents/PlatformIO/Projects/esmp3/src", - "/Users/fabian/Documents/PlatformIO/Projects/esmp3/lib/pubsubclient/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266mDNS/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WebServer/src", - "/Users/fabian/Documents/PlatformIO/Projects/esmp3/.pio/libdeps/esp12e/MFRC522_ID63/src", - "/Users/fabian/Documents/PlatformIO/Projects/esmp3/lib/esp8266FTPServer", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/SD/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/SDFS/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266SdFat/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/SPI", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi/src", "/Users/fabian/.platformio/lib/Adafruit MCP23017 Arduino Library_ID334", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/Wire", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/tools/sdk/include", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/tools/sdk/libc/xtensa-lx106-elf/include", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/cores/esp8266", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/tools/sdk/lwip2/include", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/variants/nodemcu", - "/Users/fabian/Documents/PlatformIO/Projects/esmp3/.pio/libdeps/esp12e/MCP23S17", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src", + "/Users/fabian/Documents/PlatformIO/Projects/esmp3/lib/pubsubclient/src", + "/Users/fabian/Documents/PlatformIO/Projects/esmp3/lib/esp8266FTPServer", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/SD/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/SPIFFS/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/FS/src", + "/Users/fabian/Documents/PlatformIO/Projects/esmp3/.pio/libdeps/esp32/MFRC522_ID63/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/SPI/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/config", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/app_trace", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/app_update", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/asio", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/bootloader_support", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/bt", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/coap", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/console", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/driver", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp-tls", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp32", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_adc_cal", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_event", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_http_client", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_http_server", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_https_ota", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_ringbuf", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/ethernet", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/expat", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/fatfs", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/freemodbus", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/freertos", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/heap", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/idf_test", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/jsmn", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/json", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/libsodium", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/log", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/lwip", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/mbedtls", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/mdns", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/micro-ecc", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/mqtt", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/newlib", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/nghttp", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/nvs_flash", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/openssl", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/protobuf-c", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/protocomm", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/pthread", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/sdmmc", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/smartconfig_ack", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/soc", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/spi_flash", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/spiffs", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/tcp_transport", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/tcpip_adapter", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/ulp", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/vfs", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/wear_levelling", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/wifi_provisioning", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/wpa_supplicant", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/xtensa-debug-module", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp32-camera", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp-face", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/fb_gfx", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/cores/esp32", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/variants/esp32", "/Users/fabian/.platformio/lib/FastLED_ID126", "/Users/fabian/.platformio/lib/PubSubClient_ID89/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ArduinoOTA", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/DNSServer/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/EEPROM", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266AVRISP/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPUpdateServer/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266LLMNR", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266NetBIOS", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266SSDP", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFiMesh/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266httpUpdate/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/Ethernet/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/GDBStub/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/Hash/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/SPISlave/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/Servo/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/SoftwareSerial/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/TFT_Touch_Shield_V2", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/Ticker", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/esp8266/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/ArduinoOTA/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/AsyncUDP/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/AzureIoT/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/BLE/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/DNSServer/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/EEPROM/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/ESP32/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/ESPmDNS/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/FFat/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/HTTPUpdate/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/NetBIOS/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/Preferences/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/SD_MMC/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/SimpleBLE/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/Ticker/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/Update/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src", "/Users/fabian/.platformio/packages/tool-unity", "" ], @@ -57,74 +107,119 @@ "path": [ "/Users/fabian/Documents/PlatformIO/Projects/esmp3/include", "/Users/fabian/Documents/PlatformIO/Projects/esmp3/src", - "/Users/fabian/Documents/PlatformIO/Projects/esmp3/lib/pubsubclient/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266mDNS/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WebServer/src", - "/Users/fabian/Documents/PlatformIO/Projects/esmp3/.pio/libdeps/esp12e/MFRC522_ID63/src", - "/Users/fabian/Documents/PlatformIO/Projects/esmp3/lib/esp8266FTPServer", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/SD/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/SDFS/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266SdFat/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/SPI", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi/src", "/Users/fabian/.platformio/lib/Adafruit MCP23017 Arduino Library_ID334", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/Wire", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/tools/sdk/include", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/tools/sdk/libc/xtensa-lx106-elf/include", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/cores/esp8266", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/tools/sdk/lwip2/include", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/variants/nodemcu", - "/Users/fabian/Documents/PlatformIO/Projects/esmp3/.pio/libdeps/esp12e/MCP23S17", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src", + "/Users/fabian/Documents/PlatformIO/Projects/esmp3/lib/pubsubclient/src", + "/Users/fabian/Documents/PlatformIO/Projects/esmp3/lib/esp8266FTPServer", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/SD/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/SPIFFS/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/FS/src", + "/Users/fabian/Documents/PlatformIO/Projects/esmp3/.pio/libdeps/esp32/MFRC522_ID63/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/SPI/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/config", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/app_trace", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/app_update", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/asio", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/bootloader_support", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/bt", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/coap", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/console", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/driver", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp-tls", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp32", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_adc_cal", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_event", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_http_client", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_http_server", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_https_ota", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_ringbuf", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/ethernet", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/expat", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/fatfs", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/freemodbus", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/freertos", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/heap", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/idf_test", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/jsmn", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/json", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/libsodium", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/log", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/lwip", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/mbedtls", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/mdns", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/micro-ecc", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/mqtt", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/newlib", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/nghttp", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/nvs_flash", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/openssl", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/protobuf-c", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/protocomm", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/pthread", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/sdmmc", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/smartconfig_ack", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/soc", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/spi_flash", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/spiffs", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/tcp_transport", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/tcpip_adapter", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/ulp", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/vfs", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/wear_levelling", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/wifi_provisioning", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/wpa_supplicant", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/xtensa-debug-module", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp32-camera", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp-face", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/fb_gfx", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/cores/esp32", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/variants/esp32", "/Users/fabian/.platformio/lib/FastLED_ID126", "/Users/fabian/.platformio/lib/PubSubClient_ID89/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ArduinoOTA", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/DNSServer/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/EEPROM", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266AVRISP/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPUpdateServer/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266LLMNR", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266NetBIOS", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266SSDP", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFiMesh/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266httpUpdate/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/Ethernet/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/GDBStub/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/Hash/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/SPISlave/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/Servo/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/SoftwareSerial/src", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/TFT_Touch_Shield_V2", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/Ticker", - "/Users/fabian/.platformio/packages/framework-arduinoespressif8266/libraries/esp8266/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/ArduinoOTA/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/AsyncUDP/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/AzureIoT/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/BLE/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/DNSServer/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/EEPROM/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/ESP32/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/ESPmDNS/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/FFat/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/HTTPUpdate/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/NetBIOS/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/Preferences/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/SD_MMC/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/SimpleBLE/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/Ticker/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/Update/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src", + "/Users/fabian/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src", "/Users/fabian/.platformio/packages/tool-unity", "" ] }, "defines": [ "PLATFORMIO=40100", - "ESP8266", - "ARDUINO_ARCH_ESP8266", - "ARDUINO_ESP8266_ESP12", - "VERSION=\"0.1-9-g88655b5-dirty\"", - "F_CPU=80000000L", - "__ets__", - "ICACHE_FLASH", + "ARDUINO_ESP32_DEV", + "VERSION=\"0.1-10-g2ea2ec4-dirty\"", + "ESP32", + "ESP_PLATFORM", + "F_CPU=240000000L", + "HAVE_CONFIG_H", + "MBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\"", "ARDUINO=10805", - "ARDUINO_BOARD=\"PLATFORMIO_ESP12E\"", - "FLASHMODE_DIO", - "LWIP_OPEN_SRC", - "NONOSDK221=1", - "TCP_MSS=536", - "LWIP_FEATURES=1", - "LWIP_IPV6=0", - "VTABLES_IN_FLASH", + "ARDUINO_ARCH_ESP32", + "ARDUINO_VARIANT=\"esp32\"", + "ARDUINO_BOARD=\"Espressif ESP-WROVER-KIT\"", "" ], "intelliSenseMode": "clang-x64", "cStandard": "c99", "cppStandard": "c++11", - "compilerPath": "\"/Users/fabian/.platformio/packages/toolchain-xtensa/bin/xtensa-lx106-elf-gcc\" -mlongcalls -mtext-section-literals" + "compilerPath": "\"/Users/fabian/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gcc\" -mlongcalls" } ], "version": 4 diff --git a/.vscode/launch.json b/.vscode/launch.json index d800219..e861304 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,8 +12,8 @@ "type": "platformio-debug", "request": "launch", "name": "PIO Debug", - "executable": "/Users/fabian/Documents/PlatformIO/Projects/esmp3/.pio/build/esp12e/firmware.elf", - "toolchainBinDir": "/Users/fabian/.platformio/packages/toolchain-xtensa/bin", + "executable": "/Users/fabian/Documents/PlatformIO/Projects/esmp3/.pio/build/esp32/firmware.elf", + "toolchainBinDir": "/Users/fabian/.platformio/packages/toolchain-xtensa32/bin", "preLaunchTask": { "type": "PlatformIO", "task": "Pre-Debug" @@ -24,8 +24,8 @@ "type": "platformio-debug", "request": "launch", "name": "PIO Debug (skip Pre-Debug)", - "executable": "/Users/fabian/Documents/PlatformIO/Projects/esmp3/.pio/build/esp12e/firmware.elf", - "toolchainBinDir": "/Users/fabian/.platformio/packages/toolchain-xtensa/bin", + "executable": "/Users/fabian/Documents/PlatformIO/Projects/esmp3/.pio/build/esp32/firmware.elf", + "toolchainBinDir": "/Users/fabian/.platformio/packages/toolchain-xtensa32/bin", "internalConsoleOptions": "openOnSessionStart" } ] diff --git a/README.md b/README.md index aa3b598..d0c7a7c 100644 --- a/README.md +++ b/README.md @@ -2,24 +2,23 @@ | Device | Port | Connected to | | ------ | ---- | ------------ | -| ESP | D0 | NFC: SDA | -| ESP | D1 | MCP: SCK (12) | -| ESP | D2 | MCP: SDA (13) | -| ESP | D3 | --free-- | -| ESP | D4 | --free-- | -| ESP | D5 | SCK | -| ESP | D6 | MISO | -| ESP | D7 | MOSI | -| ESP | D8 | MP3: XCS | -| MCP | B7 | MP3: XRESET -| MCP | B6 | AMP1: SD -| MCP | B5 | AMP2: SD -| MCP | B4 | MP3: XDCS -| MCP | B3 | MP3: CS -| MCP | B2 | MP3: DREQ -| MCP | A0 | BTN_PREV -| MCP | A1 | BTN_VOL_UP -| MCP | A2 | BTN_VOL_DOWN -| MCP | A3 | BTN_NEXT +| VS1053 | CS | 16 | +| VS1053 | MISO | 19 | +| VS1053 | MOSI | 23 | +| VS1053 | SCK | 18 | +| VS1053 | XCS | 4 | +| VS1053 | XRESET | 0 | +| VS1053 | XDCS | 2 | +| VS1053 | DREQ | 15 | +| RC522 | SDA | 17 | +| RC522 | SCK | 18 | +| RC522 | MOSI | 23 | +| RC522 | MISO | 19 | +| AMP_L | SD | 27 | +| AMP_R | SD | 26 | +| BTN_PREV | | 22 | +| BTN_NEXT | | 33 | +| BTN_VOL_UP | | 21 | +| BTN_VOL_DOWN | | 32 | Buttons pull to GND if pushed -> Internal Pull-Up needed! diff --git a/include/config.h b/include/config.h index 43181f4..26bc1db 100644 --- a/include/config.h +++ b/include/config.h @@ -48,41 +48,41 @@ #define VS1053_SLEEP_DELAY 5000 #define MQTT_REPORT_INTERVAL 10000 -#define PIN_SD_CS(x) (_mcp->digitalWrite(GPB3, x)) -#define PIN_SD_CS_SETUP() (_mcp->pinMode(GPB3, OUTPUT)) +#define PIN_SD_CS(x) (digitalWrite(16, x)) +#define PIN_SD_CS_SETUP() (pinMode(16, OUTPUT)) -#define PIN_VS1053_XCS(x) (digitalWrite(D8, x)) -#define PIN_VS1053_XCS_SETUP() (pinMode(D8, OUTPUT)) +#define PIN_VS1053_XCS(x) (digitalWrite(4, x)) +#define PIN_VS1053_XCS_SETUP() (pinMode(4, OUTPUT)) -#define PIN_VS1053_XRESET(x) (_mcp->digitalWrite(GPB7, x)) -#define PIN_VS1053_XRESET_SETUP() (_mcp->pinMode(GPB7, OUTPUT)) +#define PIN_VS1053_XRESET(x) (digitalWrite(0, x)) +#define PIN_VS1053_XRESET_SETUP() (pinMode(0, OUTPUT)) -#define PIN_VS1053_XDCS(x) (digitalWrite(D3, x)) -#define PIN_VS1053_XDCS_SETUP() (pinMode(D3, OUTPUT)) +#define PIN_VS1053_XDCS(x) (digitalWrite(2, x)) +#define PIN_VS1053_XDCS_SETUP() (pinMode(2, OUTPUT)) -#define PIN_VS1053_DREQ() (_mcp->digitalRead(GPB2)) -#define PIN_VS1053_DREQ_SETUP() (_mcp->pinMode(GPB2, INPUT)) +#define PIN_VS1053_DREQ() (digitalRead(15)) +#define PIN_VS1053_DREQ_SETUP() (pinMode(15, INPUT)) -#define PIN_RC522_CS(x) (digitalWrite(D0, x)) -#define PIN_RC522_CS_SETUP() (pinMode(D0, OUTPUT)) +#define PIN_RC522_CS(x) (digitalWrite(17, x)) +#define PIN_RC522_CS_SETUP() (pinMode(17, OUTPUT)) -#define PIN_SPEAKER_L(x) (_mcp->digitalWrite(GPB5, x)) -#define PIN_SPEAKER_L_SETUP() (_mcp->pinMode(GPB5, OUTPUT)) +#define PIN_SPEAKER_L(x) (digitalWrite(27, x)) +#define PIN_SPEAKER_L_SETUP() (pinMode(27, OUTPUT)) -#define PIN_SPEAKER_R(x) (_mcp->digitalWrite(GPB6, x)) -#define PIN_SPEAKER_R_SETUP() (_mcp->pinMode(GPB6, OUTPUT)) +#define PIN_SPEAKER_R(x) (digitalWrite(26, x)) +#define PIN_SPEAKER_R_SETUP() (pinMode(26, OUTPUT)) -#define BTN_PREV() ( ! _mcp->digitalRead(GPA0)) -#define BTN_PREV_SETUP() {_mcp->pinMode(GPA0, INPUT); _mcp->pullUp(GPA0, HIGH);} +#define BTN_PREV() ( ! digitalRead(22)) +#define BTN_PREV_SETUP() (pinMode(22, INPUT_PULLUP)) -#define BTN_VOL_UP() ( ! _mcp->digitalRead(GPA1)) -#define BTN_VOL_UP_SETUP() {_mcp->pinMode(GPA1, INPUT); _mcp->pullUp(GPA1, HIGH);} +#define BTN_VOL_UP() ( ! digitalRead(21)) +#define BTN_VOL_UP_SETUP() (pinMode(21, INPUT_PULLUP)) -#define BTN_VOL_DOWN() ( ! _mcp->digitalRead(GPA2)) -#define BTN_VOL_DOWN_SETUP() {_mcp->pinMode(GPA2, INPUT); _mcp->pullUp(GPA2, HIGH);} +#define BTN_VOL_DOWN() ( ! digitalRead(32)) +#define BTN_VOL_DOWN_SETUP() (pinMode(32, INPUT_PULLUP)) -#define BTN_NEXT() ( ! _mcp->digitalRead(GPA3)) -#define BTN_NEXT_SETUP() {_mcp->pinMode(GPA3, INPUT); _mcp->pullUp(GPA3, HIGH);} +#define BTN_NEXT() ( ! digitalRead(33)) +#define BTN_NEXT_SETUP() (pinMode(33, INPUT_PULLUP)) #define MCP_I2C_ADDR 7 diff --git a/include/controller.h b/include/controller.h index 3df0266..87ba72e 100644 --- a/include/controller.h +++ b/include/controller.h @@ -5,12 +5,10 @@ #include "player.h" #include "mqtt_client.h" #include -#include class Controller { private: MFRC522* _rfid; - Adafruit_MCP23017* _mcp; SPIMaster* _spi; MQTTClient* _mqtt_client; bool _rfid_enabled = true; @@ -32,7 +30,7 @@ private: unsigned long _last_mqtt_report_at = 0; void _send_mqtt_report(); public: - Controller(Player* p, Adafruit_MCP23017* m, SPIMaster* s); + Controller(Player* p, SPIMaster* s); void set_mqtt_client(MQTTClient* m); String get_status_json(); void loop(); diff --git a/include/http_server.h b/include/http_server.h index 779a3aa..a94c928 100644 --- a/include/http_server.h +++ b/include/http_server.h @@ -1,3 +1,4 @@ +/* #pragma once #include #include "player.h" @@ -25,3 +26,4 @@ public: HTTPServer(Player* p, Controller* c); void loop(); }; +*/ \ No newline at end of file diff --git a/include/mqtt_client.h b/include/mqtt_client.h index f059dfd..dc5509b 100644 --- a/include/mqtt_client.h +++ b/include/mqtt_client.h @@ -2,7 +2,7 @@ #include "config.h" #include -#include +#include class MQTTClient { private: diff --git a/include/player.h b/include/player.h index c4fefd0..1a5baf5 100644 --- a/include/player.h +++ b/include/player.h @@ -77,11 +77,10 @@ private: uint8_t _volume; uint16_t _stop_delay; uint32_t _skip_to; - Adafruit_MCP23017* _mcp; SPIMaster* _spi; unsigned long _stopped_at; public: - Player(Adafruit_MCP23017* m, SPIMaster* s); + Player(SPIMaster* s); void vol_up(); void vol_down(); void track_next(); diff --git a/include/spi_master.h b/include/spi_master.h index 73c6b46..16b0541 100644 --- a/include/spi_master.h +++ b/include/spi_master.h @@ -5,11 +5,8 @@ #include "config.h" class SPIMaster { -private: - Adafruit_MCP23017* _mcp; public: - SPIMaster(Adafruit_MCP23017* m) { - _mcp = m; + SPIMaster() { PIN_SD_CS_SETUP(); PIN_VS1053_XCS_SETUP(); PIN_VS1053_XDCS_SETUP(); diff --git a/include/tools.h b/include/tools.h deleted file mode 100644 index 745ee89..0000000 --- a/include/tools.h +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include "config.h" - -void print_mcp_status(Adafruit_MCP23017* mcp) { - DEBUG(" AAAAAAAA BBBBBBBB\n"); - DEBUG(" 76543210 76543210\n"); - DEBUG("State of MCP pins: %08s %08s\n", String(mcp->readGPIO(0), 2).c_str(), String(mcp->readGPIO(1), 2).c_str()); -} \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index c36e1fe..75c1281 100644 --- a/platformio.ini +++ b/platformio.ini @@ -8,13 +8,13 @@ ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html -[env:esp12e] -platform = espressif8266 -board = esp12e +[env:esp32] +platform = espressif32 +board = esp-wrover-kit framework = arduino upload_speed = 512000 build_flags=!./build_version.sh -lib_deps = Adafruit MCP23017 Arduino Library -upload_port = /dev/cu.wchusbserial1420 +lib_deps = MFRC522 +upload_port = /dev/cu.SLAB_USBtoUART monitor_speed = 74480 -monitor_port = /dev/cu.wchusbserial1420 \ No newline at end of file +;monitor_port = /dev/cu.wchusbserial1420 \ No newline at end of file diff --git a/src/controller.cpp b/src/controller.cpp index 9d78dee..418c9ca 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -2,11 +2,10 @@ #include "spi_master.h" #include "config.h" -Controller::Controller(Player* p, Adafruit_MCP23017* m, SPIMaster* s) { +Controller::Controller(Player* p, SPIMaster* s) { _player = p; - _mcp = m; _spi = s; - _rfid = new MFRC522(D0, MFRC522::UNUSED_PIN); + _rfid = new MFRC522(17, MFRC522::UNUSED_PIN); BTN_NEXT_SETUP(); BTN_PREV_SETUP(); diff --git a/src/http_server.cpp b/src/http_server.cpp index cb3f9bd..40372c7 100644 --- a/src/http_server.cpp +++ b/src/http_server.cpp @@ -1,3 +1,4 @@ +/* #include "http_server.h" HTTPServer::HTTPServer(Player* p, Controller* c) { @@ -121,3 +122,4 @@ void HTTPServer::loop() { _http_server->handleClient(); MDNS.update(); } +*/ \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 975a8bb..18cd21d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,8 +1,7 @@ #include #include #include -#include -#include +#include #include "config.h" #include "controller.h" #include "player.h" @@ -13,8 +12,7 @@ Controller* controller; Player* player; -Adafruit_MCP23017* mcp; -HTTPServer* http_server; +//HTTPServer* http_server; FtpServer* ftp_server; MQTTClient* mqtt_client; unsigned long last_mqtt_report = 0; @@ -22,7 +20,7 @@ unsigned long last_mqtt_report = 0; void setup() { delay(500); Serial.begin(74880); - /*Serial.println("Starting..."); + Serial.println("Starting..."); Serial.println("Started."); INFO("Starting.\n"); #ifdef VERSION @@ -32,30 +30,10 @@ void setup() { #endif INFO("Initializing...\n"); - DEBUG("Setting up MCP...\n");*/ - Wire.begin(); - Wire.setClock(1700000); - - uint8_t addr = MCP23017_ADDRESS + MCP_I2C_ADDR; - while(true) { - Wire.beginTransmission(addr); - byte status = Wire.endTransmission(); - if (status==0) { - DEBUG("I2C device found."); - break; - } - DEBUG("No I2C device found."); - delay(100); - } - - mcp = new Adafruit_MCP23017(); - mcp->begin(MCP_I2C_ADDR); - INFO("MCP initialized.\n"); - DEBUG("Setting up SPI...\n"); SPI.begin(); SPI.setHwCs(false); - SPIMaster* spi = new SPIMaster(mcp); + SPIMaster* spi = new SPIMaster(); INFO("SPI initialized.\n"); DEBUG("Setting up SD card...\n"); @@ -68,8 +46,8 @@ void setup() { spi->select_sd(false); DEBUG("Initializing Player and Controller...\n"); - player = new Player(mcp, spi); - controller = new Controller(player, mcp, spi); + player = new Player(spi); + controller = new Controller(player, spi); INFO("Player and controller initialized.\n"); DEBUG("Connecting to wifi \"%s\"...\n", WIFI_SSID); @@ -83,12 +61,12 @@ void setup() { INFO("WiFi connected.\n"); mqtt_client = new MQTTClient(); - MDNS.begin("esmp3"); + //MDNS.begin("esmp3"); controller->set_mqtt_client(mqtt_client); DEBUG("Setting up WiFi and web server...\n"); - http_server = new HTTPServer(player, controller); + //http_server = new HTTPServer(player, controller); ftp_server = new FtpServer(); ftp_server->begin("user", "pass"); @@ -101,7 +79,7 @@ void loop() { if (more_data_needed) return; controller->loop(); - http_server->loop(); + //http_server->loop(); ftp_server->handleFTP(); mqtt_client->loop(); if ((last_mqtt_report + 10000 < millis()) || last_mqtt_report > millis()) { diff --git a/src/player.cpp b/src/player.cpp index 9f8840d..72f16c2 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -2,12 +2,10 @@ #include "player.h" #include "spi_master.h" -#include "tools.h" //Player::_spi_settings -Player::Player(Adafruit_MCP23017* m, SPIMaster* s) { - _mcp = m; +Player::Player(SPIMaster* s) { _spi = s; PIN_VS1053_XRESET_SETUP(); PIN_VS1053_XRESET(HIGH); @@ -288,7 +286,8 @@ String Player::_find_album_dir(String id) { File entry; String result = String(""); while ((result.length()==0) && (entry = root.openNextFile())) { - String name = entry.name(); + String name = entry.name() + 1; + TRACE("Checking if '%s' startsWith '%s'...\n", name.c_str(), id.c_str()); if (entry.isDirectory() && (name.startsWith(id_with_divider) || name.equals(id))) { result = name; } @@ -301,15 +300,20 @@ String Player::_find_album_dir(String id) { std::list Player::_files_in_dir(String path) { _spi->select_sd(); - DEBUG("Examining folder %s...\n", path.c_str()); + TRACE("Examining folder %s...\n", path.c_str()); if (!path.startsWith("/")) path = String("/") + path; - if (!path.endsWith("/")) path.concat("/"); + //if (!path.endsWith("/")) path.concat("/"); std::list result; - if (!SD.exists(path)) return result; + if (!SD.exists(path)) { + DEBUG("Could not open path '%s'.\n", path.c_str()); + _spi->select_sd(false); + return result; + } File dir = SD.open(path); File entry; while (entry = dir.openNextFile()) { String filename = entry.name(); + filename = filename.substring(path.length() + 1); if (!entry.isDirectory() && !filename.startsWith(".") && ( filename.endsWith(".mp3") || @@ -317,8 +321,8 @@ std::list Player::_files_in_dir(String path) { filename.endsWith(".wma") || filename.endsWith(".mp4") || filename.endsWith(".mpa"))) { - TRACE(" Adding entry %s\n", filename.c_str()); - result.push_back(path + filename); + TRACE(" Adding entry %s\n", entry.name()); + result.push_back(entry.name()); } else { TRACE(" Ignoring entry %s\n", filename.c_str()); } @@ -410,11 +414,13 @@ void Player::_play_file(String file, uint32_t file_offset) { _write_control_register(SCI_STATUS, _read_control_register(SCI_STATUS) & ~SS_DO_NOT_JUMP); delay(100); + _spi->select_sd(); if (file_offset == 0) { _file.seek(_id3_tag_offset(_file)); } _refills = 0; _current_play_position = _file.position(); + _spi->select_sd(false); _skip_to = file_offset; if (_skip_to>0) _mute(); else _speaker_on(); @@ -541,7 +547,9 @@ void Player::_refill() { if ((status & SS_DO_NOT_JUMP) == 0) { DEBUG("Skipping to %d.\n", _skip_to); _flush(2048, _get_endbyte()); + _spi->select_sd(); _file.seek(_skip_to); + _spi->select_sd(false); _skip_to = 0; _unmute(); }