mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-04-20 18:35:05 +00:00
Auto-buzz on startup
This commit is contained in:
parent
61756bf542
commit
c087d997f3
@ -18,15 +18,8 @@ bool Drv2605::init() {
|
|||||||
|
|
||||||
writeRegister(Register::RealtimePlaybackInput, 0x00); // Disable
|
writeRegister(Register::RealtimePlaybackInput, 0x00); // Disable
|
||||||
|
|
||||||
writeRegister(Register::WaveSequence1, 1); // Strong click
|
|
||||||
writeRegister(Register::WaveSequence2, 0); // End sequence
|
|
||||||
|
|
||||||
writeRegister(Register::OverdriveTimeOffset, 0); // No overdrive
|
setWaveFormForClick();
|
||||||
|
|
||||||
writeRegister(Register::SustainTimeOffsetPostivie, 0);
|
|
||||||
writeRegister(Register::SustainTimeOffsetNegative, 0);
|
|
||||||
writeRegister(Register::BrakeTimeOffset, 0);
|
|
||||||
writeRegister(Register::AudioInputLevelMax, 0x64);
|
|
||||||
|
|
||||||
// ERM open loop
|
// ERM open loop
|
||||||
|
|
||||||
@ -43,6 +36,34 @@ bool Drv2605::init() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Drv2605::setWaveFormForBuzz() {
|
||||||
|
writeRegister(Register::WaveSequence1, 1); // Strong click
|
||||||
|
writeRegister(Register::WaveSequence2, 1); // Strong click
|
||||||
|
writeRegister(Register::WaveSequence3, 1); // Strong click
|
||||||
|
writeRegister(Register::WaveSequence4, 0); // End sequence
|
||||||
|
|
||||||
|
writeRegister(Register::OverdriveTimeOffset, 0); // No overdrive
|
||||||
|
|
||||||
|
writeRegister(Register::SustainTimeOffsetPostivie, 0);
|
||||||
|
writeRegister(Register::SustainTimeOffsetNegative, 0);
|
||||||
|
writeRegister(Register::BrakeTimeOffset, 0);
|
||||||
|
|
||||||
|
writeRegister(Register::AudioInputLevelMax, 0x64);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Drv2605::setWaveFormForClick() {
|
||||||
|
writeRegister(Register::WaveSequence1, 1); // Strong click
|
||||||
|
writeRegister(Register::WaveSequence2, 0); // End sequence
|
||||||
|
|
||||||
|
writeRegister(Register::OverdriveTimeOffset, 0); // No overdrive
|
||||||
|
|
||||||
|
writeRegister(Register::SustainTimeOffsetPostivie, 0);
|
||||||
|
writeRegister(Register::SustainTimeOffsetNegative, 0);
|
||||||
|
writeRegister(Register::BrakeTimeOffset, 0);
|
||||||
|
|
||||||
|
writeRegister(Register::AudioInputLevelMax, 0x64);
|
||||||
|
}
|
||||||
|
|
||||||
void Drv2605::setWaveForm(uint8_t slot, uint8_t waveform) {
|
void Drv2605::setWaveForm(uint8_t slot, uint8_t waveform) {
|
||||||
writeRegister8(static_cast<uint8_t>(Register::WaveSequence1) + slot, waveform);
|
writeRegister8(static_cast<uint8_t>(Register::WaveSequence1) + slot, waveform);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,8 @@ class Drv2605 : public tt::hal::i2c::I2cDevice {
|
|||||||
static constexpr auto* TAG = "DRV2605";
|
static constexpr auto* TAG = "DRV2605";
|
||||||
static constexpr auto ADDRESS = 0x5A;
|
static constexpr auto ADDRESS = 0x5A;
|
||||||
|
|
||||||
|
bool autoPlayStartupBuzz;
|
||||||
|
|
||||||
// Chip IDs
|
// Chip IDs
|
||||||
enum class ChipId {
|
enum class ChipId {
|
||||||
DRV2604 = 0x04, // Has RAM. Doesn't havew licensed ROM library.
|
DRV2604 = 0x04, // Has RAM. Doesn't havew licensed ROM library.
|
||||||
@ -61,10 +63,15 @@ class Drv2605 : public tt::hal::i2c::I2cDevice {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit Drv2605(i2c_port_t port) : I2cDevice(port, ADDRESS) {
|
explicit Drv2605(i2c_port_t port, bool autoPlayStartupBuzz = true) : I2cDevice(port, ADDRESS), autoPlayStartupBuzz(autoPlayStartupBuzz) {
|
||||||
if (!init()) {
|
if (!init()) {
|
||||||
TT_LOG_E(TAG, "Failed to initialize DRV2605");
|
TT_LOG_E(TAG, "Failed to initialize DRV2605");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (autoPlayStartupBuzz) {
|
||||||
|
setWaveFormForBuzz();
|
||||||
|
startPlayback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getName() const final { return "DRV2605"; }
|
std::string getName() const final { return "DRV2605"; }
|
||||||
@ -72,6 +79,14 @@ public:
|
|||||||
|
|
||||||
bool init();
|
bool init();
|
||||||
|
|
||||||
|
void setWaveFormForBuzz();
|
||||||
|
void setWaveFormForClick();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param slot a value from 0 to 7
|
||||||
|
* @param waveform
|
||||||
|
*/
|
||||||
void setWaveForm(uint8_t slot, uint8_t waveform);
|
void setWaveForm(uint8_t slot, uint8_t waveform);
|
||||||
void selectLibrary(uint8_t library);
|
void selectLibrary(uint8_t library);
|
||||||
void startPlayback();
|
void startPlayback();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user