many many small changes

switched to the new logging here and there
some cleanups
worked  on i2S
base class for files
id3 parsing
This commit is contained in:
2021-02-28 20:44:01 +01:00
parent df77490622
commit 422610c21c
18 changed files with 307 additions and 197 deletions

View File

@@ -4,7 +4,7 @@
#include "../Platforms.h"
#if ESP8266
#if IS_ESP8266
#include "fastGPIO.h"
@@ -94,7 +94,7 @@
};
#elif ESP32
#elif IS_ESP32
#include "driver/gpio.h"
@@ -178,7 +178,7 @@
};
#elif TEENSY
#elif IS_TEENSY
struct MyGPIO {

View File

@@ -49,7 +49,7 @@ template <int PIN_SDA, int PIN_SCL, bool fast> class SoftI2C {
}
void init() {
debugMod2(NAME, "init. SDA: %d, SCL: %d", PIN_SDA, PIN_SCL);
Log::addInfo(NAME, "init. SDA: %d, SCL: %d", PIN_SDA, PIN_SCL);
}
public:
@@ -151,10 +151,10 @@ public:
}
inline void queryAll() {
debugMod(NAME, "queryAll()")
Log::addInfo(NAME, "queryAll()");
for (uint8_t i = 0; i < 128; ++i) {
if (query(i)) {
debugMod1(NAME, "found %d", i)
Log::addInfo(NAME, "found %d", i);
}
waitLong();
if (i%16 == 0) {delay(10);}
@@ -179,14 +179,14 @@ public:
// select register(s) to read
ok = startWrite(addr);
if (!ok) {debugMod(NAME, "failed start read(1)"); return false;}
if (!ok) {Log::addInfo(NAME, "failed start read(1)"); return false;}
ok = writeByteAndCheck(reg);
if (!ok) {debugMod(NAME, "failed select register"); return false;}
if (!ok) {Log::addInfo(NAME, "failed select register"); return false;}
stop();
// read register(s)
ok = startRead(addr);
if (!ok) {debugMod(NAME, "failed start read(2)"); return false;}
if (!ok) {Log::addInfo(NAME, "failed start read(2)"); return false;}
readBytes(dst, len);
stop();
@@ -201,11 +201,11 @@ public:
// address the slave in write mode and select the first register to read
ok = startWrite(addr);
if (!ok) {debugMod(NAME, "failed start write"); return false;}
if (!ok) {Log::addInfo(NAME, "failed start write"); return false;}
ok = writeByteAndCheck(reg);
if (!ok) {debugMod1(NAME, "failed to select register %d", addr); return false;}
if (!ok) {Log::addInfo(NAME, "failed to select register %d", addr); return false;}
ok = writeBytesAndCheck(src, len);
if (!ok) {debugMod(NAME, "failed to write register contents"); return false;}
if (!ok) {Log::addInfo(NAME, "failed to write register contents"); return false;}
// done
stop();
@@ -322,7 +322,7 @@ namespace i2c {
#if ESP8266
// static inline void init() {
// //debugMod(NAME, "init()");
// //Log::addInfo(NAME, "init()");
// GPIO5_OUTPUT_SET; // clock is always output
// //GPIO5_INPUT_PULLUP_SET; // pullup for i2c
// //GPIO4_INPUT_PULLUP_SET; // pullup for i2c

View File

@@ -88,19 +88,19 @@ private:
public:
void IRAM_ATTR writeQuad(const uint32_t quad) {
void writeQuad(const uint32_t quad) {
writeByte((quad>>24)&0xFF);
writeByte((quad>>16)&0xFF);
writeByte((quad>> 8)&0xFF);
writeByte((quad>> 0)&0xFF);
}
void IRAM_ATTR writeWord(const uint16_t word) {
void writeWord(const uint16_t word) {
writeByte((word>>8)&0xFF);
writeByte((word>>0)&0xFF);
}
inline void IRAM_ATTR writeByte(uint8_t byte) {
inline void writeByte(uint8_t byte) {
writeBit(byte & BIT( 7));
writeBit(byte & BIT( 6));
writeBit(byte & BIT( 5));

View File

@@ -165,6 +165,8 @@ private:
// init static class members
#ifdef I2S2_IMPLEMENTATION
DMAMEM __attribute__((aligned(32))) int16_t I2S2::buffer[I2S2_BUFFER_SAMPLES];
I2S2::State I2S2::state;
//template<> DMAMEM __attribute__((aligned(32))) int16_t I2SBase<I2S2>::buffer[I2S2_BUFFER_SAMPLES];
//template<> I2SBase<I2S2>::State I2SBase<I2S2>::state;
DMAMEM __attribute__((aligned(32))) int16_t I2S2::buffer[I2S2_BUFFER_SAMPLES];
I2S2::State I2S2::state;
#endif

View File

@@ -80,7 +80,9 @@ public:
static void clearBuffer() {
memset(buffer, 0, sizeof(buffer));
state.bufferHalf[0].samplesUsed = 0;
state.bufferHalf[0].dropCache();
state.bufferHalf[1].samplesUsed = 0;
state.bufferHalf[1].dropCache();
}
/** block until the given number of samples were added to the internal buffer */
@@ -99,7 +101,7 @@ public:
BufferHalf& bh = state.fillingHalf();
// determine how many samples to add
const uint16_t addable = min(numSamples, bh.samplesFree());
const uint16_t addable = std::min(numSamples, bh.samplesFree());
// actually copy the data
uint8_t* dst = (uint8_t*) (&bh.mem[bh.samplesUsed]);