Refactor lambdas
This commit is contained in:
parent
940cd3459f
commit
9a7ba405e1
|
@ -29,27 +29,27 @@ void St7789::Init() {
|
||||||
DisplayOn();
|
DisplayOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
void St7789::EnableDataMode(bool isStart) {
|
void St7789::WriteData(uint8_t data) {
|
||||||
|
WriteData(&data, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void St7789::WriteData(const uint8_t* data, size_t size) {
|
||||||
|
WriteSpi(data, size, [pinDataCommand = pinDataCommand](bool isStart) {
|
||||||
if (isStart) {
|
if (isStart) {
|
||||||
nrf_gpio_pin_set(pinDataCommand);
|
nrf_gpio_pin_set(pinDataCommand);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void St7789::EnableCommandMode(bool isStart) {
|
|
||||||
if (isStart) {
|
|
||||||
nrf_gpio_pin_clear(pinDataCommand);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void St7789::WriteData(uint8_t data) {
|
|
||||||
WriteSpi(&data, 1, [this](bool isStart) {
|
|
||||||
EnableDataMode(isStart);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void St7789::WriteCommand(uint8_t cmd) {
|
void St7789::WriteCommand(uint8_t data) {
|
||||||
WriteSpi(&cmd, 1, [this](bool isStart) {
|
WriteCommand(&data, 1);
|
||||||
EnableCommandMode(isStart);
|
}
|
||||||
|
|
||||||
|
void St7789::WriteCommand(const uint8_t* data, size_t size) {
|
||||||
|
WriteSpi(data, size, [pinDataCommand = pinDataCommand](bool isStart) {
|
||||||
|
if (isStart) {
|
||||||
|
nrf_gpio_pin_clear(pinDataCommand);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,9 +138,7 @@ void St7789::SetAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
||||||
|
|
||||||
void St7789::WriteToRam(const uint8_t* data, size_t size) {
|
void St7789::WriteToRam(const uint8_t* data, size_t size) {
|
||||||
WriteCommand(static_cast<uint8_t>(Commands::WriteToRam));
|
WriteCommand(static_cast<uint8_t>(Commands::WriteToRam));
|
||||||
WriteSpi(data, size, [this](bool isStart) {
|
WriteData(data, size);
|
||||||
EnableDataMode(isStart);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void St7789::SetVdv() {
|
void St7789::SetVdv() {
|
||||||
|
|
|
@ -46,9 +46,8 @@ namespace Pinetime {
|
||||||
void SetAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
void SetAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
||||||
void SetVdv();
|
void SetVdv();
|
||||||
void WriteCommand(uint8_t cmd);
|
void WriteCommand(uint8_t cmd);
|
||||||
|
void WriteCommand(const uint8_t* data, size_t size);
|
||||||
void WriteSpi(const uint8_t* data, size_t size, std::function<void(bool)> TransactionHook);
|
void WriteSpi(const uint8_t* data, size_t size, std::function<void(bool)> TransactionHook);
|
||||||
void EnableDataMode(bool isStart);
|
|
||||||
void EnableCommandMode(bool isStart);
|
|
||||||
|
|
||||||
enum class Commands : uint8_t {
|
enum class Commands : uint8_t {
|
||||||
SoftwareReset = 0x01,
|
SoftwareReset = 0x01,
|
||||||
|
@ -68,6 +67,7 @@ namespace Pinetime {
|
||||||
VdvSet = 0xc4,
|
VdvSet = 0xc4,
|
||||||
};
|
};
|
||||||
void WriteData(uint8_t data);
|
void WriteData(uint8_t data);
|
||||||
|
void WriteData(const uint8_t* data, size_t size);
|
||||||
void ColumnAddressSet();
|
void ColumnAddressSet();
|
||||||
|
|
||||||
static constexpr uint16_t Width = 240;
|
static constexpr uint16_t Width = 240;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user