Added remote debugging/monitoring, helper libraries for power relay/DAC reset, volume control pot (both motorised and non-motorised) and also includes common events such as lock acquisition and automute detection to make writing custom implementations easy.
https://github.com/possum64/BuffaloDACBelow is all the code you need to implement a dual mono setup with volume control and lock detection:
// Arduino analog pins
const byte VOL_ANALOG_INPUT_PIN = 0;
// Arduino digital pins
const byte POWER_RELAY = 3;
const byte DAC_RESET = 13;
#define NO_OF_ES9028_DACS 2
ES9028 leftDAC = ES9028("Left Channel", ES9028::MonoLeft);
ES9028 rightDAC = ES9028("Right Channel", ES9028::MonoRight);
ES9028 es9028dacs[NO_OF_ES9028_DACS] = {leftDAC, rightDAC};
DACControl dacCtrl = DACControl(es9028dacs, NO_OF_ES9028_DACS);
DACVolumeControl dacVolCtrl = DACVolumeControl(&dacCtrl, VOL_ANALOG_INPUT_PIN);
bool configDAC(ES9028* dac)
{
dac->mute();
dac->setSerialBits(ES9028::Bits_24);
dac->setInputSelect(ES9028::InputSelect_SPDIF);
dac->setAutoSelect(ES9028::AutoSelect_Disable);
dac->setFilterShape(ES9028::Filter_Hybrid);
dac->setAutoMute(ES9028::AutoMute_MuteAndRampToGnd);
dac->setAutomuteTime(100);
dac->setGPIO1(ES9028::GPIO_Automute);
dac->setGPIO2(ES9028::GPIO_StandardInput);
dac->setGPIO3(ES9028::GPIO_StandardInput);
dac->setGPIO4(ES9028::GPIO_Lock);
dac->setDpllBandwidthSerial(ES9028::DPLL_Lowest);
dac->setVolumeMode(ES9028::Volume_UseChannel1);
dac->setAttenuation(25);
return true;
}
void eventLocked()
{
digitalWrite(LED_BUILTIN, true); // turn the LED on if both DACs locked
}
void eventNoLock()
{
digitalWrite(LED_BUILTIN, false); // turn the LED off if either DAC not locked
}
void setup() {
// initialize digital pin LED_BUILTIN as the DAC lock light.
pinMode(LED_BUILTIN, OUTPUT);
dacCtrl.initES9028(configDAC);
dacCtrl.setPinPowerRelay(POWER_RELAY);
dacCtrl.setPinDACReset(DAC_RESET);
dacCtrl.onLock(eventLocked);
dacCtrl.onNoLock(eventNoLock);
dacCtrl.powerOn();
}
void loop() {
dacCtrl.loop();
dacVolCtrl.loop();
delay(10);
}
Edited by user Tuesday, May 4, 2021 9:59:23 PM(UTC)
| Reason: Not specified