Browse Source

Adapting board-specific layout but RFID with 2 SPIs not yet really working...

master
Torsten Stauder 5 years ago
parent
commit
fa3b8fe0fc
  1. 35
      platformio.ini
  2. 16
      src/main.cpp
  3. 15
      src/settings-espa1s.h
  4. 14
      src/settings-lolin32.h
  5. 76
      src/settings-lolin_d32.h
  6. 40
      src/settings.h

35
platformio.ini

@ -24,7 +24,7 @@ lib_deps_external =
; https://github.com/pschatzmann/ESP32-A2DP.git
[env:common]
build_flags = -DHAL=1
build_flags = -DHAL=1 -DHAL=3
; Don't forget to run this script if you changed the html-files provided in any way
extra_scripts =
pre:processHtml.py
@ -37,7 +37,7 @@ framework = arduino
monitor_speed = 115200
board_build.partitions = no_ota.csv
build_flags = -DHAL=2
lib_deps =
lib_deps =
https://github.com/kkloesener/MFRC522_I2C_Library.git
https://github.com/kkloesener/AC101.git
${common.lib_deps_builtin}
@ -49,11 +49,12 @@ board = lolin32
framework = arduino
monitor_speed = 115200
board_build.partitions = no_ota.csv
lib_deps =
lib_deps =
${common.lib_deps_builtin}
${common.lib_deps_external}
https://github.com/biologist79/rfid.git
https://github.com/tueddy/PN5180-Library.git
extra_scripts = ${env:common.extra_scripts}
upload_port = /dev/cu.SLAB_USBtoUART
monitor_port = /dev/cu.SLAB_USBtoUART
@ -63,7 +64,11 @@ board = lolin_d32
framework = arduino
monitor_speed = 115200
board_build.partitions = no_ota.csv
lib_deps = ${env:common.lib_deps}
lib_deps =
${common.lib_deps_builtin}
${common.lib_deps_external}
https://github.com/biologist79/rfid.git
https://github.com/tueddy/PN5180-Library.git
extra_scripts = ${env:common.extra_scripts}
upload_port = /dev/cu.SLAB_USBtoUART
monitor_port = /dev/cu.SLAB_USBtoUART
@ -74,10 +79,14 @@ board = lolin_d32_pro
framework = arduino
monitor_speed = 115200
board_build.partitions = no_ota.csv
lib_deps = ${env:common.lib_deps}
lib_deps =
${common.lib_deps_builtin}
${common.lib_deps_external}
https://github.com/biologist79/rfid.git
https://github.com/tueddy/PN5180-Library.git
extra_scripts = ${env:common.extra_scripts}
upload_port = COM6
monitor_port = COM6
upload_port = /dev/cu.SLAB_USBtoUART
monitor_port = /dev/cu.SLAB_USBtoUART
[env:nodemcu-32s]
platform = espressif32
@ -85,7 +94,11 @@ board = nodemcu-32s
framework = arduino
monitor_speed = 115200
board_build.partitions = no_ota.csv
lib_deps = ${env:common.lib_deps}
lib_deps =
${common.lib_deps_builtin}
${common.lib_deps_external}
https://github.com/biologist79/rfid.git
https://github.com/tueddy/PN5180-Library.git
extra_scripts = ${env:common.extra_scripts}
upload_port = /dev/cu.SLAB_USBtoUART
monitor_port = /dev/cu.SLAB_USBtoUART
@ -96,7 +109,11 @@ board = az-delivery-devkit-v4
framework = arduino
monitor_speed = 115200
board_build.partitions = no_ota.csv
lib_deps = ${env:common.lib_deps}
lib_deps =
${common.lib_deps_builtin}
${common.lib_deps_external}
https://github.com/biologist79/rfid.git
https://github.com/tueddy/PN5180-Library.git
extra_scripts = ${env:common.extra_scripts}
upload_port = /dev/cu.SLAB_USBtoUART
monitor_port = /dev/cu.SLAB_USBtoUART

16
src/main.cpp

@ -1,12 +1,14 @@
// !!! MAKE SURE TO EDIT settings.h !!!
#include "settings.h" // Contains all user-relevant settings
#include "settings.h" // Contains all user-relevant settings (general)
// !!! MAKE SURE TO EDIT PLATFORM SPECIFIC settings-****.h !!!
#if (HAL == 1)
#include "settings-lolin32.h" // Contains all user-relevant settings
#include "settings-lolin32.h" // Contains all user-relevant settings for Wemos Lolin32
#elif (HAL == 2)
#include "settings-espa1s.h" // Contains all user-relevant settings
#include "settings-espa1s.h" // Contains all user-relevant settings for ESP32-A1S Audiokit
#elif (HAL == 3)
#include "settings-lolin_D32.h" // Contains all user-relevant settings for Wemos Lolin D32
#endif
#include <ESP32Encoder.h>
@ -3760,17 +3762,17 @@ void setup() {
i2cBusOne.begin(IIC_DATA, IIC_CLK, 40000);
while (not ac.begin()) {
Serial.printf("AC101 Failed!\n");
Serial.println(F("AC101 Failed!"));
delay(1000);
}
Serial.printf("AC101 via I2C - OK!\n");
Serial.println(F("AC101 via I2C - OK!"));
pinMode(22, OUTPUT);
digitalWrite(22, HIGH);
pinMode(GPIO_PA_EN, OUTPUT);
digitalWrite(GPIO_PA_EN, HIGH);
Serial.printf("Built-In Amplifier enabled\n");
Serial.println(F("Built-in amplifier enabled\n"));
#endif
#ifndef SINGLE_SPI_ENABLE
@ -4121,7 +4123,7 @@ void setup() {
pinMode(PAUSEPLAY_BUTTON, INPUT_PULLUP);
pinMode(NEXT_BUTTON, INPUT_PULLUP);
pinMode(PREVIOUS_BUTTON, INPUT_PULLUP);
// Init rotary encoder
encoder.attachHalfQuad(DREHENCODER_CLK, DREHENCODER_DT);
encoder.clearCount();

15
src/settings-espa1s.h

@ -1,5 +1,15 @@
#include "Arduino.h"
//######################### INFOS ####################################
/* This is a develboard-specific config-file for *AI Tinker ESP32-A1S-AudioKit*. It's highly customized and almost certainly
not suitable for a different develboards.
Has a lot of stuff already onboard but needs some soldering rework as there are not all GPIOs exposed
PCB: Not necessary.
Infos: https://github.com/Ai-Thinker-Open/ESP32-A1S-AudioKit
Status: tested by kkloesner
*/
//################## GPIO-configuration ##############################
// uSD-card-reader (via SPI)
#define SPISD_CS 13 // GPIO for chip select (SD)
@ -53,3 +63,8 @@
#define VOLTAGE_READ_PIN 33 // GPIO used to monitor battery-voltage. Change to 35 if you're using Lolin D32 or Lolin D32 pro as it's hard-wired there!
#endif
// (optional) For measuring battery-voltage a voltage-divider is necessary. Their values need to be configured here.
#ifdef MEASURE_BATTERY_VOLTAGE
uint8_t rdiv1 = 129; // Rdiv1 of voltage-divider (kOhms) (measure exact value with multimeter!)
uint16_t rdiv2 = 389; // Rdiv2 of voltage-divider (kOhms) (measure exact value with multimeter!) => used to measure voltage via ADC!
#endif

14
src/settings-lolin32.h

@ -1,5 +1,13 @@
#include "Arduino.h"
//######################### INFOS ####################################
/* This is a develboard-specific config-file for *Wemos Lolin32*. Specific doesn't mean it's only working with this board.
Lolin32 is the predecessor of Lolin D32.
PCB: https://github.com/biologist79/Tonuino-ESP32-I2S/tree/master/PCBs/Wemos%20Lolin32
Infos: https://arduino-projekte.info/wemos-lolin32/
Status: tested (by biologist79)
*/
//################## GPIO-configuration ##############################
#ifdef SD_MMC_1BIT_MODE
// uSD-card-reader (via SD-MMC 1Bit)
@ -59,3 +67,9 @@
#ifdef MEASURE_BATTERY_VOLTAGE
#define VOLTAGE_READ_PIN 33 // GPIO used to monitor battery-voltage. Change to 35 if you're using Lolin D32 or Lolin D32 pro as it's hard-wired there!
#endif
// (optional) For measuring battery-voltage a voltage-divider is necessary. Their values need to be configured here.
#ifdef MEASURE_BATTERY_VOLTAGE
uint8_t rdiv1 = 129; // Rdiv1 of voltage-divider (kOhms) (measure exact value with multimeter!)
uint16_t rdiv2 = 389; // Rdiv2 of voltage-divider (kOhms) (measure exact value with multimeter!) => used to measure voltage via ADC!
#endif

76
src/settings-lolin_d32.h

@ -0,0 +1,76 @@
#include "Arduino.h"
//######################### INFOS ####################################
/* This is a develboard-specific config-file for *Wemos Lolin D32*. Specific doesn't mean it's only working with this board.
Lolin D32 is the successor of Lolin32 and the "little brother" of Wemos Lolin D32 pro.
PCB: https://github.com/biologist79/Tonuino-ESP32-I2S/tree/master/PCBs/Wemos%20Lolin%20D32
Infos: https://www.wemos.cc/en/latest/d32/d32.html
Status: untested
*/
//################## GPIO-configuration ##############################
#ifdef SD_MMC_1BIT_MODE
// uSD-card-reader (via SD-MMC 1Bit)
//
// SD_MMC uses fixed pins
// MOSI 15
// SCKK 14
// MISO 2 // hardware pullup may required
#else
// uSD-card-reader (via SPI)
#define SPISD_CS 15 // GPIO for chip select (SD)
#ifndef SINGLE_SPI_ENABLE
#define SPISD_MOSI 13 // GPIO for master out slave in (SD) => not necessary for single-SPI
#define SPISD_MISO 16 // GPIO for master in slave ou (SD) => not necessary for single-SPI
#define SPISD_SCK 14 // GPIO for clock-signal (SD) => not necessary for single-SPI
#endif
#endif
// RFID (via SPI)
#define RST_PIN 99 // Not necessary but has to be set anyway; so let's use a dummy-number
#define RFID_CS 21 // GPIO for chip select (RFID)
#define RFID_MOSI 23 // GPIO for master out slave in (RFID)
#define RFID_MISO 19 // GPIO for master in slave out (RFID)
#define RFID_SCK 18 // GPIO for clock-signal (RFID)
#ifdef RFID_READER_TYPE_PN5180
#define RFID_BUSY 16 // PN5180 BUSY PIN
#define RFID_RST 22 // PN5180 RESET PIN
#endif
// I2S (DAC)
#define I2S_DOUT 25 // Digital out (I2S)
#define I2S_BCLK 27 // BCLK (I2S)
#define I2S_LRC 26 // LRC (I2S)
// Rotary encoder
#define DREHENCODER_CLK 34 // If you want to reverse encoder's direction, just switch GPIOs of CLK with DT (in software or hardware)
#define DREHENCODER_DT 35 // Info: Lolin D32 / Lolin D32 pro 35 are using 35 for battery-voltage-monitoring!
#define DREHENCODER_BUTTON 32 // Button is used to switch Tonuino on and off
// Control-buttons
#define PAUSEPLAY_BUTTON 5 // GPIO to detect pause/play
#define NEXT_BUTTON 4 // GPIO to detect next
#define PREVIOUS_BUTTON 2 // GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2)
// (optional) Power-control
#define POWER 17 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep
// (optional) Neopixel
#define LED_PIN 12 // GPIO for Neopixel-signaling
// (optinal) Headphone-detection
#ifdef HEADPHONE_ADJUST_ENABLE
#define HP_DETECT 22 // GPIO that detects, if there's a plug in the headphone jack or not
#endif
// (optional) Monitoring of battery-voltage via ADC
#ifdef MEASURE_BATTERY_VOLTAGE
#define VOLTAGE_READ_PIN 35 // GPIO used to monitor battery-voltage. Change to 35 if you're using Lolin D32 or Lolin D32 pro as it's hard-wired there!
#endif
// (optional) For measuring battery-voltage. No need to change here, it's built in
#ifdef MEASURE_BATTERY_VOLTAGE
uint8_t rdiv1 = 100;
uint16_t rdiv2 = 100;
#endif

40
src/settings.h

@ -1,31 +1,44 @@
#include "Arduino.h"
//######################### INFOS ####################################
// This is the general configfile for Tonuino-configuration.
//################## HARDWARE-PLATFORM ###############################
/* Make sure to also edit the configfile, that is specific for your platform.
If in doubts (your develboard is not listed) use HAL 1
1: Wemos Lolin32 => settings-lolin32.h
2: ESP32-A1S Audiokit => settings-espa1s.h
3: Wemos Lolin D32 => settings-lolin_D32.h
more to come...
*/
#define HAL 1 // HAL 1 = LoLin32, 2 = AI AudioKit, 3 = Lolin D32
//########################## MODULES #################################
//#define MDNS_ENABLE // When enabled, you don't have to handle with Tonuino's IP-address. If hostname is set to "tonuino", you can reach it via tonuino.local
//#define MQTT_ENABLE // Make sure to configure mqtt-server and (optionally) username+pwd
//#define FTP_ENABLE // Enables FTP-server; DON'T FORGET TO ACTIVATE AFTER BOOT BY PRESSING PAUSE + NEXT-BUTTONS (IN PARALLEL)!
//#define NEOPIXEL_ENABLE // Don't forget configuration of NUM_LEDS if enabled
#define MDNS_ENABLE // When enabled, you don't have to handle with Tonuino's IP-address. If hostname is set to "tonuino", you can reach it via tonuino.local
#define MQTT_ENABLE // Make sure to configure mqtt-server and (optionally) username+pwd
#define FTP_ENABLE // Enables FTP-server; DON'T FORGET TO ACTIVATE AFTER BOOT BY PRESSING PAUSE + NEXT-BUTTONS (IN PARALLEL)!
#define NEOPIXEL_ENABLE // Don't forget configuration of NUM_LEDS if enabled
#define NEOPIXEL_REVERSE_ROTATION // Some Neopixels are adressed/soldered counter-clockwise. This can be configured here.
#define LANGUAGE 1 // 1 = deutsch; 2 = english
//#define HEADPHONE_ADJUST_ENABLE // Used to adjust (lower) volume for optional headphone-pcb (refer maxVolumeSpeaker / maxVolumeHeadphone)
#define SHUTDOWN_IF_SD_BOOT_FAILS // Will put ESP to deepsleep if boot fails due to SD. Really recommend this if there's in battery-mode no other way to restart ESP! Interval adjustable via deepsleepTimeAfterBootFails.
//#define MEASURE_BATTERY_VOLTAGE // Enables battery-measurement via GPIO (ADC) and voltage-divider
#define MEASURE_BATTERY_VOLTAGE // Enables battery-measurement via GPIO (ADC) and voltage-divider
//#define PLAY_LAST_RFID_AFTER_REBOOT // When restarting Tonuino, the last RFID that was active before, is recalled and played
//#define BLUETOOTH_ENABLE // Doesn't work currently (so don't enable) as there's not enough DRAM available
//################## select SD card mode #############################
//#define SD_MMC_1BIT_MODE // run SD card in SD-MMC 1Bit mode
//#define SINGLE_SPI_ENABLE // If only one SPI-instance should be used instead of two (not yet working!) (Works on ESP32-A1S with RFID via I2C)
//################## select RFID reader ##############################
//#define RFID_READER_TYPE_MFRC522_SPI // use MFRC522 via SPI
#define RFID_READER_TYPE_MFRC522_I2C // use MFRC522 via I2C
#define RFID_READER_TYPE_MFRC522_SPI // use MFRC522 via SPI
//#define RFID_READER_TYPE_MFRC522_I2C // use MFRC522 via I2C
//#define RFID_READER_TYPE_PN5180
//################## select Hardware Platform ##############################
// #define HAL 2 // HAL 1 = LoLin32, 2 = AI AudioKit - no need to define when using platformIO BuildProcess
//#################### Various settings ##############################
// Loglevels available (don't change!)
@ -63,6 +76,7 @@ static const char backupFile[] PROGMEM = "/backup.txt"; // File is written every
uint8_t FS_DEPTH = 5; // Max. recursion-depth of file tree
const char *DIRECTORY_INDEX_FILE = "/files.json"; // Filename of files.json index file
//#################### Settings for optional Modules##############################
// (optinal) Neopixel
#ifdef NEOPIXEL_ENABLE
@ -77,12 +91,6 @@ uint8_t voltageCheckInterval = 10; // How of battery-voltage is
float voltageIndicatorLow = 3.0; // Lower range for Neopixel-voltage-indication (0 leds) (can be changed via GUI!)
float voltageIndicatorHigh = 4.2; // Upper range for Neopixel-voltage-indication (all leds) (can be changed via GUI!)
// (optinal) For measuring battery-voltage a voltage-divider is necessary. Their values need to be configured here.
#ifdef MEASURE_BATTERY_VOLTAGE
uint8_t rdiv1 = 129; // Rdiv1 of voltage-divider (kOhms) (measure exact value with multimeter!)
uint16_t rdiv2 = 389; // Rdiv2 of voltage-divider (kOhms) (measure exact value with multimeter!) => used to measure voltage via ADC!
#endif
// (optinal) Headphone-detection (leave unchanged if in doubts...)
#ifdef HEADPHONE_ADJUST_ENABLE
uint16_t headphoneLastDetectionDebounce = 1000; // Debounce-interval in ms when plugging in headphone

Loading…
Cancel
Save