69 lines
1.4 KiB
C++
69 lines
1.4 KiB
C++
#include "EPD_7in5_V2.hpp"
|
|
|
|
#include <EPD_7in5_V2.h>
|
|
|
|
namespace frame::display
|
|
{
|
|
constexpr uint32_t mWidth = EPD_7IN5_V2_WIDTH;
|
|
constexpr uint32_t mHeight = EPD_7IN5_V2_HEIGHT;
|
|
|
|
EPD_7in5_V2::EPD_7in5_V2()
|
|
: IDisplay("EPD_7in5_V2", {mWidth, mHeight})
|
|
{
|
|
}
|
|
|
|
EPD_7in5_V2::~EPD_7in5_V2()
|
|
{
|
|
Sleep();
|
|
}
|
|
|
|
bool EPD_7in5_V2::Init()
|
|
{
|
|
return EPD_7IN5_V2_Init() == 0;
|
|
}
|
|
|
|
void EPD_7in5_V2::Clear(Color color)
|
|
{
|
|
if(color == Color::WHITE)
|
|
{
|
|
EPD_7IN5_V2_Clear()
|
|
} else
|
|
{
|
|
EPD_7IN5_V2_ClearBlack();
|
|
}
|
|
}
|
|
|
|
void EPD_7in5_V2::Display(Image const& image)
|
|
{
|
|
constexpr auto bytes_width = mWidth / 8;
|
|
std::vector<uint8_t> data(bytes_with * mHeight);
|
|
|
|
uint8_t bit_counter;
|
|
|
|
for(auto y = 0; y < mHeight; ++y)
|
|
{
|
|
for(auto x = 0; x < bytes_width; ++x)
|
|
{
|
|
uint8_t byte = 0;
|
|
for(auto bit = 0; bit < 8; ++bit)
|
|
{
|
|
if(image.at(x * 8 + bit, y) > 265 / 2)
|
|
{
|
|
byte ^= 1;
|
|
}
|
|
byte << 1;
|
|
}
|
|
|
|
data[bytes_width * y + x] = byte;
|
|
}
|
|
}
|
|
|
|
EPD_7IN5_V2_Display(data.data());
|
|
}
|
|
|
|
void EPD_7in5_V2::Sleep()
|
|
{
|
|
EPD_7IN5_V2_Sleep();
|
|
}
|
|
|
|
} // namespace frame::display
|