Ken Van Hoeylandt 50007ea9ed
Merge develop into main (#307)
## Launcher

- Launcher now has optional power button to show
- Launcher layout improvements
- Removed text from Launcher (translations with larger amounts of text did not fit small device formats)

## T-Lora Pager

- Implement power off (created `BQ25896` driver)
- Implemented haptics (created `DRV2605` driver project) and buzz on startup
- Reversed scroll wheel
- Created `TloraEncoder` device and relocated its logic from `TloraKeyboard`
- Disabled SPIRAM test to save 0.5 seconds of boot time (current boot time is very slow)
- Update `ST7796` esp_lcd driver to v1.3.4
- Fixed keyboard bug: delete queue in destructor
- Fixed driver dependencies: Avoiding usage of global static shared_ptr. Properly constructor-inject everywhere, or use `tt::hal::findDevices()`
- I2C configuration is now immutable (you cannot disable it anymore from the I2C Settings app, as it would break crucial drivers)
- Renamed I2C and UART subsystems to "Internal"

## Drivers

- On/off interface added to `PowerDevice`
- Created `tt::hal::Configuration.createDevices`, which is intended to replace all custom create calls for display, keyboard, etc.
- Created `EncoderDevice` as a `Device` subtype

## Other Improvements

- Changed `findDevices(type, function)` into a templatized function.
- Improved SD card mounting

## Fixes

- Show Screenshot app again
- Fixed Statusbar: some updates were allowed to time out and fail silently: When the Statusbar service would do a state update, the LVGL statusbar would never get updated due to this timeout.
- Fixed memory leaks in all `createSdCard()` functions (in most board implementations)
2025-08-30 21:54:55 +02:00

95 lines
2.7 KiB
C++

#pragma once
#include <Tactility/hal/i2c/I2cDevice.h>
class Drv2605 : public tt::hal::i2c::I2cDevice {
static constexpr auto* TAG = "DRV2605";
static constexpr auto ADDRESS = 0x5A;
bool autoPlayStartupBuzz;
// Chip IDs
enum class ChipId {
DRV2604 = 0x04, // Has RAM. Doesn't havew licensed ROM library.
DRV2605 = 0x03, // Has licensed ROM library. Doesn't have RAM.
DRV2604L = 0x06, // Low-voltage variant of the DRV2604.
DRV2605L = 0x07 // Low-voltage variant of the DRV2605.
};
enum class Register {
Status = 0x00,
Mode = 0x01,
RealtimePlaybackInput = 0x02,
WaveLibrarySelect = 0x03,
WaveSequence1 = 0x04,
WaveSequence2 = 0x05,
WaveSequence3 = 0x06,
WaveSequence4 = 0x07,
WaveSequence5 = 0x08,
WaveSequence6 = 0x09,
WaveSequence7 = 0x0A,
WaveSequence8 = 0x0B,
Go = 0x0C,
OverdriveTimeOffset = 0x0D,
SustainTimeOffsetPostivie = 0x0E,
SustainTimeOffsetNegative = 0x0F,
BrakeTimeOffset = 0x10,
AudioControl = 0x11,
AudioInputLevelMin = 0x12,
AudioInputLevelMax = 0x13,
AudioOutputLevelMin = 0x14,
AudioOutputLevelMax = 0x15,
RatedVoltage = 0x16,
OverdriveClampVoltage = 0x17,
AutoCalibrationCompensation = 0x18,
AutoCalibrationBackEmf = 0x19,
Feedback = 0x1A,
Control1 = 0x1B,
Control2 = 0x1C,
Control3 = 0x1D,
Control4 = 0x1E,
Vbat = 0x21,
LraResonancePeriod = 0x22,
};
bool writeRegister(Register reg, const uint8_t value) const {
return writeRegister8(static_cast<uint8_t>(reg), value);
}
bool readRegister(Register reg, uint8_t& value) const {
return readRegister8(static_cast<uint8_t>(reg), value);
}
public:
explicit Drv2605(i2c_port_t port, bool autoPlayStartupBuzz = true) : I2cDevice(port, ADDRESS), autoPlayStartupBuzz(autoPlayStartupBuzz) {
if (!init()) {
TT_LOG_E(TAG, "Failed to initialize DRV2605");
}
if (autoPlayStartupBuzz) {
setWaveFormForBuzz();
startPlayback();
}
}
std::string getName() const final { return "DRV2605"; }
std::string getDescription() const final { return "Haptic driver for ERM/LRA with waveform library & auto-resonance tracking"; }
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 selectLibrary(uint8_t library);
void startPlayback();
void stopPlayback();
};