Skip to content

Commit

Permalink
ESP32 DAC Support for any data type
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Nov 12, 2023
1 parent a01aad8 commit a1da00c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/AudioAnalog/AnalogAudioESP32V1.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,30 +88,32 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
// writes the data to the DAC
size_t write(const uint8_t *src, size_t size_bytes) override {
TRACED();
return io.write(src, size_bytes);
// convert any format to int16_t
return converter.write(src, size_bytes);
}

size_t readBytes(uint8_t *dest, size_t size_bytes) override {
TRACED();
// in the future we might use the converter -> for the time beeing we only support 16 bits
return io.readBytes(dest, size_bytes);
}
// is data in the ADC buffer?
int available() override { return active_rx ? DEFAULT_BUFFER_SIZE : 0; }


protected:
#ifdef HAS_ESP32_DAC
dac_continuous_handle_t dac_handle;
#endif
adc_continuous_handle_t adc_handle;
adc_cali_handle_t adc_cali_handle;
AnalogConfigESP32V1 cfg;
bool active = false;
bool active_tx = false;
bool active_rx = false;
ConverterAutoCenter auto_center;
#ifdef HAS_ESP32_DAC
dac_continuous_handle_t dac_handle;
#endif

/// writes the int16_t data to the DAC
/// conversion between int16_t and other formats
class IO16Bit : public AudioStream {
public:
IO16Bit(AnalogDriverESP32V1 *driver) { self = driver; }
Expand Down

0 comments on commit a1da00c

Please sign in to comment.