Implement basic font rendering

This commit is contained in:
BlackMark 2022-06-04 13:24:31 +02:00
parent 3599979cc4
commit a2060c3ab5
3 changed files with 64 additions and 8 deletions

@ -1 +1 @@
Subproject commit 3d45d2a4b393724f3eb618d49936adc7ee168d1b Subproject commit e62a7ed49800dfae0337f5d62d12e1fcae8431fb

View File

@ -224,6 +224,9 @@
<Compile Include="eink\eink.hpp"> <Compile Include="eink\eink.hpp">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="eink\font.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="eink\otp.hpp"> <Compile Include="eink\otp.hpp">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>

View File

@ -217,12 +217,24 @@ static inline consteval auto createFastWaveformLut(const flash::Wrapper<eink::Wa
{ {
auto fastWaveformLut = original.value; auto fastWaveformLut = original.value;
for (auto &timing : fastWaveformLut.timings) { for (auto i = std::size_t{0}; i < std::size(fastWaveformLut.timings) - 1; ++i) {
timing.repeatSubPhaseAB = 0; fastWaveformLut.timings[i].frameCountPhaseA = 0;
timing.repeatSubPhaseCD = 0; fastWaveformLut.timings[i].frameCountPhaseB = 0;
timing.repeat = 0; fastWaveformLut.timings[i].repeatSubPhaseAB = 0;
fastWaveformLut.timings[i].frameCountPhaseC = 0;
fastWaveformLut.timings[i].frameCountPhaseD = 0;
fastWaveformLut.timings[i].repeatSubPhaseCD = 0;
fastWaveformLut.timings[i].repeat = 0;
} }
fastWaveformLut.timings[11].frameCountPhaseA = 4;
fastWaveformLut.timings[11].frameCountPhaseB = 5;
fastWaveformLut.timings[11].repeatSubPhaseAB = 2;
fastWaveformLut.timings[11].frameCountPhaseC = 5;
fastWaveformLut.timings[11].frameCountPhaseD = 1;
fastWaveformLut.timings[11].repeatSubPhaseCD = 2;
fastWaveformLut.timings[11].repeat = 4;
return flash::Wrapper{fastWaveformLut}; return flash::Wrapper{fastWaveformLut};
} }
@ -269,17 +281,58 @@ int main()
serial << F("e-Paper init") << F("\r\n"); serial << F("e-Paper init") << F("\r\n");
einkDisplay.init(); einkDisplay.init();
serial << F("e-Paper dump OTP") << F("\r\n");
dumpOTP(einkDisplay, serial);
serial << F("e-Paper clear") << F("\r\n"); serial << F("e-Paper clear") << F("\r\n");
einkDisplay.clear(); einkDisplay.clear();
serial << F("e-Paper update") << F("\r\n");
einkDisplay.update();
serial << F("e-Paper draw fast") << F("\r\n"); serial << F("e-Paper draw fast") << F("\r\n");
einkDisplay.draw(RLE_IMAGE, FAST_WAVEFORM_LUT); einkDisplay.draw(RLE_IMAGE);
serial << F("e-Paper update") << F("\r\n");
einkDisplay.update(FAST_WAVEFORM_LUT);
serial << F("e-Paper clear") << F("\r\n");
einkDisplay.clear();
serial << F("e-Paper update") << F("\r\n");
einkDisplay.update();
serial << F("e-Paper draw") << F("\r\n"); serial << F("e-Paper draw") << F("\r\n");
einkDisplay.draw(RLE_IMAGE); einkDisplay.draw(RLE_IMAGE);
serial << F("e-Paper update") << F("\r\n");
einkDisplay.update();
serial << F("e-Paper dump OTP") << F("\r\n"); serial << F("e-Paper clear") << F("\r\n");
dumpOTP(einkDisplay, serial); einkDisplay.clear();
serial << F("e-Paper update") << F("\r\n");
einkDisplay.update();
serial << F("e-Paper draw text") << F("\r\n");
const auto startX = 16;
const auto startY = 58;
einkDisplay.drawText({startX, startY}, "B->B: ", eink_t::Color::BLACK, eink_t::Color::WHITE);
einkDisplay.drawText({startX + 6 * 8, startY}, "Black on black", eink_t::Color::BLACK, eink_t::Color::BLACK);
einkDisplay.drawText({startX, startY + 10}, "B->R: ", eink_t::Color::BLACK, eink_t::Color::WHITE);
einkDisplay.drawText({startX + 6 * 8, startY + 10}, "Black on red", eink_t::Color::BLACK, eink_t::Color::RED);
einkDisplay.drawText({startX, startY + 20}, "B->W: ", eink_t::Color::BLACK, eink_t::Color::WHITE);
einkDisplay.drawText({startX + 6 * 8, startY + 20}, "Black on white", eink_t::Color::BLACK, eink_t::Color::WHITE);
einkDisplay.drawText({startX, startY + 30}, "R->B: ", eink_t::Color::BLACK, eink_t::Color::WHITE);
einkDisplay.drawText({startX + 6 * 8, startY + 30}, "Red on black", eink_t::Color::RED, eink_t::Color::BLACK);
einkDisplay.drawText({startX, startY + 40}, "R->R: ", eink_t::Color::BLACK, eink_t::Color::WHITE);
einkDisplay.drawText({startX + 6 * 8, startY + 40}, "Red on red", eink_t::Color::RED, eink_t::Color::RED);
einkDisplay.drawText({startX, startY + 50}, "R->W: ", eink_t::Color::BLACK, eink_t::Color::WHITE);
einkDisplay.drawText({startX + 6 * 8, startY + 50}, "Red on white", eink_t::Color::RED, eink_t::Color::WHITE);
einkDisplay.drawText({startX, startY + 60}, "W->B: ", eink_t::Color::BLACK, eink_t::Color::WHITE);
einkDisplay.drawText({startX + 6 * 8, startY + 60}, "White on black", eink_t::Color::WHITE, eink_t::Color::BLACK);
einkDisplay.drawText({startX, startY + 70}, "W->R: ", eink_t::Color::BLACK, eink_t::Color::WHITE);
einkDisplay.drawText({startX + 6 * 8, startY + 70}, "White on red", eink_t::Color::WHITE, eink_t::Color::RED);
einkDisplay.drawText({startX, startY + 80}, "W->W: ", eink_t::Color::BLACK, eink_t::Color::WHITE);
einkDisplay.drawText({startX + 6 * 8, startY + 80}, "White on white", eink_t::Color::WHITE, eink_t::Color::WHITE);
serial << F("e-Paper update") << F("\r\n");
einkDisplay.update();
serial << F("e-Paper sleep") << F("\r\n"); serial << F("e-Paper sleep") << F("\r\n");
einkDisplay.sleep(); einkDisplay.sleep();