mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 14:47:37 +03:00
## Summary Extracted some changes from https://github.com/crosspoint-reader/crosspoint-reader/pull/500 to make reviewing easier This PR adds HAL (Hardware Abstraction Layer) for display and GPIO components, making it easier to write a stub or an emulated implementation of the hardware. SD card HAL will be added via another PR, because it's a bit more tricky. --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? **NO**
52 lines
1.9 KiB
C++
52 lines
1.9 KiB
C++
#include <HalDisplay.h>
|
|
#include <HalGPIO.h>
|
|
|
|
#define SD_SPI_MISO 7
|
|
|
|
HalDisplay::HalDisplay() : einkDisplay(EPD_SCLK, EPD_MOSI, EPD_CS, EPD_DC, EPD_RST, EPD_BUSY) {}
|
|
|
|
HalDisplay::~HalDisplay() {}
|
|
|
|
void HalDisplay::begin() { einkDisplay.begin(); }
|
|
|
|
void HalDisplay::clearScreen(uint8_t color) const { einkDisplay.clearScreen(color); }
|
|
|
|
void HalDisplay::drawImage(const uint8_t* imageData, uint16_t x, uint16_t y, uint16_t w, uint16_t h,
|
|
bool fromProgmem) const {
|
|
einkDisplay.drawImage(imageData, x, y, w, h, fromProgmem);
|
|
}
|
|
|
|
EInkDisplay::RefreshMode convertRefreshMode(HalDisplay::RefreshMode mode) {
|
|
switch (mode) {
|
|
case HalDisplay::FULL_REFRESH:
|
|
return EInkDisplay::FULL_REFRESH;
|
|
case HalDisplay::HALF_REFRESH:
|
|
return EInkDisplay::HALF_REFRESH;
|
|
case HalDisplay::FAST_REFRESH:
|
|
default:
|
|
return EInkDisplay::FAST_REFRESH;
|
|
}
|
|
}
|
|
|
|
void HalDisplay::displayBuffer(HalDisplay::RefreshMode mode) { einkDisplay.displayBuffer(convertRefreshMode(mode)); }
|
|
|
|
void HalDisplay::refreshDisplay(HalDisplay::RefreshMode mode, bool turnOffScreen) {
|
|
einkDisplay.refreshDisplay(convertRefreshMode(mode), turnOffScreen);
|
|
}
|
|
|
|
void HalDisplay::deepSleep() { einkDisplay.deepSleep(); }
|
|
|
|
uint8_t* HalDisplay::getFrameBuffer() const { return einkDisplay.getFrameBuffer(); }
|
|
|
|
void HalDisplay::copyGrayscaleBuffers(const uint8_t* lsbBuffer, const uint8_t* msbBuffer) {
|
|
einkDisplay.copyGrayscaleBuffers(lsbBuffer, msbBuffer);
|
|
}
|
|
|
|
void HalDisplay::copyGrayscaleLsbBuffers(const uint8_t* lsbBuffer) { einkDisplay.copyGrayscaleLsbBuffers(lsbBuffer); }
|
|
|
|
void HalDisplay::copyGrayscaleMsbBuffers(const uint8_t* msbBuffer) { einkDisplay.copyGrayscaleMsbBuffers(msbBuffer); }
|
|
|
|
void HalDisplay::cleanupGrayscaleBuffers(const uint8_t* bwBuffer) { einkDisplay.cleanupGrayscaleBuffers(bwBuffer); }
|
|
|
|
void HalDisplay::displayGrayBuffer() { einkDisplay.displayGrayBuffer(); }
|