Compare commits

...

5 Commits

Author SHA1 Message Date
s-hadinger f7e285ab11
Fixed `EthType` for Core3 (#21317) 2024-05-02 14:46:28 +02:00
Jason2866 dbafe1e167
PIO inspect for ESP32 2024-05-02 14:09:23 +02:00
Jason2866 a67f4f0c06
Make use of PIO Project Inspect possible
without the set option, Inspect tries to analyze every lib which does fail
2024-05-02 13:57:18 +02:00
Christian Baars 08c3416255
Berry example: wave file recorder (#21315) 2024-05-02 13:36:28 +02:00
Jason2866 fb78c3a796
Fix PIO Inspect
Solo1 framework does not support PSRAM
2024-05-02 13:31:34 +02:00
6 changed files with 113 additions and 28 deletions

View File

@ -27,6 +27,7 @@ All notable changes to this project will be documented in this file.
- Berry `web_add_handler` called before `Webserver` is initialized
- Put back wifi IPv6 workaround
- Berry `math.inf`, `math.isinf()` and fixed json ouput for `inf` and `nan`
- `EthType` for Core3
### Removed
- LVGL disabled vector graphics

View File

@ -39,6 +39,7 @@ monitor_speed = 115200
monitor_echo = yes
; *** Upload Serial reset method for Wemos and NodeMCU
upload_resetmethod = nodemcu
check_skip_packages = yes
extra_scripts = ${esp_defaults.extra_scripts}
lib_archive = no
lib_ldf_mode = chain

View File

@ -9,6 +9,7 @@ board = esp32
monitor_speed = ${common.monitor_speed}
monitor_echo = ${common.monitor_echo}
upload_resetmethod = ${common.upload_resetmethod}
check_skip_packages = ${common.check_skip_packages}
extra_scripts = ${esp32_defaults.extra_scripts}
monitor_filters = ${esp32_defaults.monitor_filters}
build_unflags = ${core32.build_unflags}

View File

@ -0,0 +1,73 @@
#-
- WAV recorder driver Berry - mono only
- used from command `wavrec<duration in seconds> <file_name_without_wav_suffix>`
-#
class WAVREC
var in, f
var fast
var targetSize
def init(seconds, name)
self.in=AudioInputI2S()
self.in.begin()
self.in.set_gain(60)
var r = self.in.get_rate()
var bps = self.in.get_bits_per_sample()
log(f"WAV: sample rate {r} with {bps} bits")
self.f = open(f"{name}.wav", "w")
self.targetSize = r * seconds * (bps/8)
self.writeHeader(self.targetSize,r, bps)
log(f"WAV: will record {seconds} seconds to {name}.wav")
self.fast = /->self.record()
tasmota.add_fast_loop(self.fast)
tasmota.add_driver(self)
end
def record()
var b = self.in.read_bytes()
if b == nil
return
end
self.targetSize -= size(b)
if self.targetSize > 0
self.f.write(b)
else
tasmota.remove_fast_loop(self.fast)
self.f.close()
log("WAV: closing file")
tasmota.remove_driver(self)
end
end
def writeHeader(fsize, rate, bps)
var header = bytes(44)
header.."RIFF"
header.add(fsize + 44,4)
header.."WAVE"
header.."fmt "
header.add(bps,4) #sample_bits
header..1 # PCM
header..0
header..1 # mono
header..0
header.add(rate,4) #sample_bits
header.add(rate * 2,4) #(Sample Rate * BitsPerSample * Channels) / 8
header..2 # BlockAlign
header..0
header..bps # sample bits
header..0
header.."data"
header.add(fsize,4) #sample_bits
self.f.write(header)
end
end
def wav_recorder(cmd, idx, payload, payload_json)
tasmota.resp_cmnd_done()
return WAVREC(idx, payload)
end
tasmota.add_cmd('wavrec', wav_recorder)
# use like: waverec5 /test - > record 5 seconds to /test.wav

View File

@ -576,7 +576,7 @@ extern "C" {
// `psramFound()` can return true even if no PSRAM is actually installed
// This new version also checks `esp_spiram_is_initialized` to know if the PSRAM is initialized
bool FoundPSRAM(void) {
#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || DISABLE_PSRAMCHECK
#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || DISABLE_PSRAMCHECK || CORE32SOLO1
return psramFound();
#else
return psramFound() && esp_psram_is_initialized();

View File

@ -78,7 +78,7 @@
#endif
#ifndef ETH_TYPE
#define ETH_TYPE 0 // 0 = LAN8720, 1 = TLK110/IP101, 2 = RTL8201, 3 = DP83848, 4 = RFU, 5 = KSZ8081, 6 = KSZ8041, 7 = JL1101, 8 = W5500, 9 = KSZ8851, 10 = DM9051
#define ETH_TYPE 0 // 0 = LAN8720, 1 = TLK110/IP101, 2 = RTL8201, 3 = DP83848, 4 = DM9051, 5 = KSZ8081, 6 = KSZ8041, 7 = JL1101, 8 = W5500, 9 = KSZ8851
#endif
#ifndef ETH_CLKMODE
@ -88,18 +88,30 @@
#include <ETH.h>
#define ETH_USES_SPI 0x80 // Use the highest significant bit to mark SPI Ethernet
const uint8_t eth_type_xtable[] = {
0, // 0 = LAN8720
1, // 1 = TLK110/IP101
2, // 2 = RTL8201
4, // 3 = DP83848 (is 4 in core3)
0, // 4 = RFU - Reserved for Future Use
6, // 5 = KSZ8081 (is 6 in core3)
5, // 6 = KSZ8041 (is 5 in core3)
3, // 7 = JL1101 (is 3 in core3)
8, // 8 = W5500 (is new in core3 and using SPI)
9, // 9 = KSZ8851 (is new in core3 and using SPI)
7 // 10 = DM9051 (is 7 in core3 and using SPI)
#if CONFIG_ETH_USE_ESP32_EMAC
ETH_PHY_LAN8720, // 0 = LAN8720
ETH_PHY_TLK110, // 1 = TLK110/IP101
ETH_PHY_RTL8201, // 2 = RTL8201
ETH_PHY_DP83848, // 3 = DP83848
ETH_PHY_DM9051 | ETH_USES_SPI, // 4 = 10 = DM9051
ETH_PHY_KSZ8081, // 5 = KSZ8081
ETH_PHY_KSZ8041, // 6 = KSZ8041
ETH_PHY_JL1101, // 7 = JL1101
#else
0, // 0 = LAN8720
0, // 1 = TLK110/IP101
0, // 2 = RTL8201
0, // 3 = DP83848
ETH_PHY_DM9051 | ETH_USES_SPI, // 4 = 10 = DM9051
0, // 5 = KSZ8081
0, // 6 = KSZ8041
0, // 7 = JL1101
#endif // CONFIG_ETH_USE_ESP32_EMAC
ETH_PHY_W5500 | ETH_USES_SPI, // 8 = W5500
ETH_PHY_KSZ8851 | ETH_USES_SPI, // 9 = KSZ8851
};
char eth_hostname[sizeof(TasmotaGlobal.hostname)];
uint8_t eth_config_change;
@ -187,30 +199,27 @@ void EthernetSetIp(void) {
void EthernetInit(void) {
if (!Settings->flag4.network_ethernet) { return; }
int eth_type = eth_type_xtable[Settings->eth_type];
int32_t eth_type = (Settings->eth_type < sizeof(eth_type_xtable)) ? eth_type_xtable[Settings->eth_type] : 0; // make sure we don't overflow
bool eth_uses_spi = (eth_type & ETH_USES_SPI);
eth_type = eth_type & 0x7F; // remove SPI flag
#if CONFIG_ETH_USE_ESP32_EMAC
if (WT32_ETH01 == TasmotaGlobal.module_type) {
Settings->eth_address = 1; // EthAddress
Settings->eth_type = 0; // EthType 0 = LAN8720
Settings->eth_type = ETH_PHY_LAN8720; // EthType 0 = LAN8720
Settings->eth_clk_mode = 0; // EthClockMode 0 = ETH_CLOCK_GPIO0_IN
}
#else // No CONFIG_ETH_USE_ESP32_EMAC
if (Settings->eth_type < 7) {
Settings->eth_type = 8; // Select W5500 (SPI) for non-EMAC hardware
}
eth_type = eth_type_xtable[Settings->eth_type] -7; // As No EMAC support substract EMAC enums (According ETH.cpp debug info)
#endif // CONFIG_ETH_USE_ESP32_EMAC
if (Settings->eth_type < 7) {
// CONFIG_ETH_USE_ESP32_EMAC
if (!PinUsed(GPIO_ETH_PHY_MDC) && !PinUsed(GPIO_ETH_PHY_MDIO)) { // && should be || but keep for backward compatibility
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ETH "No ETH MDC and ETH MDIO GPIO defined"));
if (eth_uses_spi) {
// Uses SPI Ethernat
if (!PinUsed(GPIO_ETH_PHY_MDC) || !PinUsed(GPIO_ETH_PHY_MDIO) || !PinUsed(GPIO_ETH_PHY_POWER)) {
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ETH "No ETH MDC (SPI CS), ETH MDIO (SPI IRQ) and ETH POWER (SPI RST) GPIO defined"));
return;
}
} else {
// ETH_SPI_SUPPORTS_CUSTOM
if (!PinUsed(GPIO_ETH_PHY_MDC) || !PinUsed(GPIO_ETH_PHY_MDIO) || !PinUsed(GPIO_ETH_PHY_POWER)) {
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ETH "No ETH MDC (SPI CS), ETH MDIO (SPI IRQ) and ETH POWER (SPI RST) GPIO defined"));
// Native ESP32
if (!PinUsed(GPIO_ETH_PHY_MDC) && !PinUsed(GPIO_ETH_PHY_MDIO)) { // && should be || but keep for backward compatibility
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ETH "No ETH MDC and ETH MDIO GPIO defined"));
return;
}
}
@ -231,7 +240,7 @@ void EthernetInit(void) {
#endif // USE_IPV6
bool init_ok = false;
if (Settings->eth_type < 7) {
if (!eth_uses_spi) {
#if CONFIG_ETH_USE_ESP32_EMAC
init_ok = (ETH.begin((eth_phy_type_t)eth_type, Settings->eth_address, eth_mdc, eth_mdio, eth_power, (eth_clock_mode_t)Settings->eth_clk_mode));
#endif // CONFIG_ETH_USE_ESP32_EMAC