File daisy_patch_sm.h¶
File List > external-docs > libDaisy > src > daisy_patch_sm.h
Go to the documentation of this file
Source Code¶
#pragma once
#include "daisy.h"
namespace daisy
{
namespace patch_sm
{
enum
{
CV_1 = 0,
CV_2,
CV_3,
CV_4,
CV_5,
CV_6,
CV_7,
CV_8,
ADC_9,
ADC_10,
ADC_11,
ADC_12,
ADC_LAST,
};
enum
{
CV_OUT_BOTH = 0,
CV_OUT_1,
CV_OUT_2,
};
class DaisyPatchSM
{
public:
enum class PinBank
{
A,
B,
C,
D
};
DaisyPatchSM() {}
~DaisyPatchSM() {}
void Init();
void StartAudio(AudioHandle::AudioCallback cb);
void StartAudio(AudioHandle::InterleavingAudioCallback cb);
void ChangeAudioCallback(AudioHandle::AudioCallback cb);
void ChangeAudioCallback(AudioHandle::InterleavingAudioCallback cb);
void StopAudio();
void SetAudioBlockSize(size_t size);
void SetAudioSampleRate(float sr);
void SetAudioSampleRate(SaiHandle::Config::SampleRate sample_rate);
size_t AudioBlockSize();
float AudioSampleRate();
float AudioCallbackRate();
void StartAdc();
void StopAdc();
void ProcessAnalogControls();
void ProcessDigitalControls();
void ProcessAllControls()
{
ProcessAnalogControls();
ProcessDigitalControls();
}
float GetAdcValue(int idx);
Pin GetPin(const PinBank bank, const int idx);
void StartDac(DacHandle::DacCallback callback = nullptr);
void StopDac();
void WriteCvOut(const int channel, float voltage);
inline void Delay(uint32_t milliseconds)
{
System::Delay(milliseconds);
}
inline uint32_t GetRandomValue() { return Random::GetValue(); }
inline float GetRandomFloat(float min = 0.f, float max = 1.f)
{
return Random::GetFloat(min, max);
}
void SetLed(bool state);
template <typename... VA>
static void Print(const char* format, VA... va)
{
Log::Print(format, va...);
}
template <typename... VA>
static void PrintLine(const char* format, VA... va)
{
Log::PrintLine(format, va...);
}
static void StartLog(bool wait_for_pc = false)
{
Log::StartLog(wait_for_pc);
}
bool ValidateSDRAM();
bool ValidateQSPI(bool quick = true);
System system;
SdramHandle sdram;
QSPIHandle qspi;
AudioHandle audio;
AdcHandle adc;
UsbHandle usb;
Pcm3060 codec;
DacHandle dac;
GPIO user_led;
AnalogControl controls[ADC_LAST];
GateIn gate_in_1, gate_in_2;
GPIO gate_out_1, gate_out_2;
constexpr static Pin A1 = Pin(PORTX, 0);
constexpr static Pin A2 = Pin(PORTA, 1);
constexpr static Pin A3 = Pin(PORTA, 0);
constexpr static Pin A4 = Pin(PORTX, 0);
constexpr static Pin A5 = Pin(PORTX, 0);
constexpr static Pin A6 = Pin(PORTX, 0);
constexpr static Pin A7 = Pin(PORTX, 0);
constexpr static Pin A8 = Pin(PORTB, 14);
constexpr static Pin A9 = Pin(PORTB, 15);
constexpr static Pin A10 = Pin(PORTX, 0);
constexpr static Pin B1 = Pin(PORTX, 0);
constexpr static Pin B2 = Pin(PORTX, 0);
constexpr static Pin B3 = Pin(PORTX, 0);
constexpr static Pin B4 = Pin(PORTX, 0);
constexpr static Pin B5 = Pin(PORTC, 14);
constexpr static Pin B6 = Pin(PORTC, 13);
constexpr static Pin B7 = Pin(PORTB, 8);
constexpr static Pin B8 = Pin(PORTB, 9);
constexpr static Pin B9 = Pin(PORTG, 14);
constexpr static Pin B10 = Pin(PORTG, 13);
constexpr static Pin C1 = Pin(PORTA, 5);
constexpr static Pin C2 = Pin(PORTA, 7);
constexpr static Pin C3 = Pin(PORTA, 2);
constexpr static Pin C4 = Pin(PORTA, 6);
constexpr static Pin C5 = Pin(PORTA, 3);
constexpr static Pin C6 = Pin(PORTB, 1);
constexpr static Pin C7 = Pin(PORTC, 4);
constexpr static Pin C8 = Pin(PORTC, 0);
constexpr static Pin C9 = Pin(PORTC, 1);
constexpr static Pin C10 = Pin(PORTA, 4);
constexpr static Pin D1 = Pin(PORTB, 4);
constexpr static Pin D2 = Pin(PORTC, 11);
constexpr static Pin D3 = Pin(PORTC, 10);
constexpr static Pin D4 = Pin(PORTC, 9);
constexpr static Pin D5 = Pin(PORTC, 8);
constexpr static Pin D6 = Pin(PORTC, 12);
constexpr static Pin D7 = Pin(PORTD, 2);
constexpr static Pin D8 = Pin(PORTC, 2);
constexpr static Pin D9 = Pin(PORTC, 3);
constexpr static Pin D10 = Pin(PORTD, 3);
class Impl;
private:
using Log = Logger<LOGGER_INTERNAL>;
float callback_rate_;
Impl* pimpl_;
};
} // namespace patch_sm
} // namespace daisy