Allow image and LUT to be located either in ram or flash
This commit is contained in:
parent
8d8369440c
commit
3d45d2a4b3
18
eink.hpp
18
eink.hpp
@ -157,9 +157,11 @@ class Eink {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto sendImageChannel = [](const auto command, const auto &image) {
|
constexpr auto sendImageChannel = [](const auto command, const auto &image) {
|
||||||
|
using image_t = std::remove_cvref_t<decltype(image)>;
|
||||||
|
|
||||||
sendCommand(command);
|
sendCommand(command);
|
||||||
for (auto j = std::size_t{0}; j < image.size(); ++j) {
|
for (auto j = std::size_t{0}; j < std::tuple_size_v<image_t>; ++j) {
|
||||||
const auto [count, data] = flash::load(image[j]);
|
const auto [count, data] = flash::loadLike<RleImage>(image[j]);
|
||||||
for (auto i = std::uint16_t{0}; i < count; ++i) {
|
for (auto i = std::uint16_t{0}; i < count; ++i) {
|
||||||
if (command == Cmd::WRITE_RAM_BLACK) {
|
if (command == Cmd::WRITE_RAM_BLACK) {
|
||||||
sendData(data);
|
sendData(data);
|
||||||
@ -170,8 +172,8 @@ class Eink {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
sendImageChannel(Cmd::WRITE_RAM_BLACK, std::get<0>(rleImage));
|
sendImageChannel(Cmd::WRITE_RAM_BLACK, std::get<0>(rleImage.value));
|
||||||
sendImageChannel(Cmd::WRITE_RAM_RED, std::get<1>(rleImage));
|
sendImageChannel(Cmd::WRITE_RAM_RED, std::get<1>(rleImage.value));
|
||||||
|
|
||||||
sendCommand(Cmd::DISPLAY_UPDATE_CONTROL_2);
|
sendCommand(Cmd::DISPLAY_UPDATE_CONTROL_2);
|
||||||
sendData(USE_ORIGINAL_LUT ? 0xF7 : 0xC7);
|
sendData(USE_ORIGINAL_LUT ? 0xF7 : 0xC7);
|
||||||
@ -210,13 +212,15 @@ class Eink {
|
|||||||
waitUntilIdle();
|
waitUntilIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writeLut(const Waveform &lut)
|
template <typename Lut>
|
||||||
|
static void writeLut(const Lut &lut)
|
||||||
{
|
{
|
||||||
const auto flashLutPtr = reinterpret_cast<const std::byte *>(&lut);
|
static_assert(sizeof(lut) == sizeof(Waveform), "Invalid LUT size");
|
||||||
|
|
||||||
sendCommand(Cmd::WRITE_LUT);
|
sendCommand(Cmd::WRITE_LUT);
|
||||||
for (auto i = std::size_t{0}; i < sizeof(lut); ++i) {
|
for (auto i = std::size_t{0}; i < sizeof(lut); ++i) {
|
||||||
const auto lutByte = flash::load(flashLutPtr[i]);
|
const auto lutByte = lut[i];
|
||||||
|
static_assert(std::is_same_v<std::byte, std::remove_cvref_t<decltype(lutByte)>>, "Invalid LUT value type");
|
||||||
sendData(static_cast<word_t>(lutByte));
|
sendData(static_cast<word_t>(lutByte));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user