## 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)
83 lines
2.4 KiB
C++
83 lines
2.4 KiB
C++
#include "Drv2605.h"
|
|
|
|
bool Drv2605::init() {
|
|
uint8_t status;
|
|
if (!readRegister8(static_cast<uint8_t>(Register::Status), status)) {
|
|
TT_LOG_E(TAG, "Failed to read status");
|
|
return false;
|
|
}
|
|
status >>= 5;
|
|
|
|
ChipId chip_id = static_cast<ChipId>(status);
|
|
if (chip_id != ChipId::DRV2604 && chip_id != ChipId::DRV2604L && chip_id != ChipId::DRV2605 && chip_id != ChipId::DRV2605L) {
|
|
TT_LOG_E(TAG, "Unknown chip id %02x", chip_id);
|
|
return false;
|
|
}
|
|
|
|
writeRegister(Register::Mode, 0x00); // Get out of standby
|
|
|
|
writeRegister(Register::RealtimePlaybackInput, 0x00); // Disable
|
|
|
|
|
|
setWaveFormForClick();
|
|
|
|
// ERM open loop
|
|
|
|
uint8_t feedback;
|
|
if (!readRegister(Register::Feedback, feedback)) {
|
|
TT_LOG_E(TAG, "Failed to read feedback");
|
|
return false;
|
|
}
|
|
|
|
writeRegister(Register::Feedback, feedback & 0x7F); // N_ERM_LRA off
|
|
|
|
bitOnByIndex(static_cast<uint8_t>(Register::Control3), 5); // ERM_OPEN_LOOP on
|
|
|
|
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) {
|
|
writeRegister8(static_cast<uint8_t>(Register::WaveSequence1) + slot, waveform);
|
|
}
|
|
|
|
void Drv2605::selectLibrary(uint8_t library) {
|
|
writeRegister(Register::WaveLibrarySelect, library);
|
|
}
|
|
|
|
void Drv2605::startPlayback() {
|
|
writeRegister(Register::Go, 0x01);
|
|
}
|
|
|
|
void Drv2605::stopPlayback() {
|
|
writeRegister(Register::Go, 0x00);
|
|
}
|
|
|