diff --git a/tag_fw/drawing.c b/tag_fw/drawing.c index 1e0d577a..1211384b 100644 --- a/tag_fw/drawing.c +++ b/tag_fw/drawing.c @@ -334,7 +334,24 @@ void ByteDecode(uint8_t byte) { epdSend(prev); } } - +#if (SCREEN_WIDTH == 152) +void drawImageFromBuffer(uint8_t* buffer, const uint8_t lut) { + pr("Doing raw 1bpp\n"); + epdSetup(); + if (lut) selectLUT(lut); + beginFullscreenImage(); + clearScreen(); + beginWriteFramebuffer(EPD_COLOR_BLACK); + epdSelect(); + for (uint16_t c = 0; c < (SCREEN_HEIGHT * (SCREEN_WIDTH / 8)); c++) { + epdSend(buffer[c]); + } + epdDeselect(); + endWriteFramebuffer(); + addOverlay(); + drawWithSleep(); +} +#endif void drawImageAtAddress(uint32_t addr, uint8_t lut) { struct EepromImageHeader* __xdata eih = (struct EepromImageHeader*)mClutMap; eepromRead(addr, mClutMap, sizeof(struct EepromImageHeader)); diff --git a/tag_fw/drawing.h b/tag_fw/drawing.h index cdd1c939..8ed12e96 100644 --- a/tag_fw/drawing.h +++ b/tag_fw/drawing.h @@ -8,6 +8,6 @@ void set_offline(__bit state); #pragma callee_saves drawImageAtAddress void drawImageAtAddress(uint32_t addr, uint8_t lut); - +void drawImageFromBuffer(uint8_t* buffer, const uint8_t lut); #endif diff --git a/tag_fw/fw154.bin b/tag_fw/fw154.bin index 840f1840..9282512b 100644 Binary files a/tag_fw/fw154.bin and b/tag_fw/fw154.bin differ diff --git a/tag_fw/syncedproto.c b/tag_fw/syncedproto.c index 7ffc3113..2e29b241 100644 --- a/tag_fw/syncedproto.c +++ b/tag_fw/syncedproto.c @@ -23,6 +23,7 @@ #include "timer.h" #include "userinterface.h" #include "wdt.h" +#include "screen.h" // download-stuff uint8_t __xdata blockXferBuffer[BLOCK_XFER_BUFFER_SIZE] = {0}; @@ -681,8 +682,38 @@ static bool downloadImageDataToEEPROM(const struct AvailDataInfo *__xdata avail) return true; } -bool processAvailDataInfo(const struct AvailDataInfo *__xdata avail) { +bool processAvailDataInfo(struct AvailDataInfo *__xdata avail) { switch (avail->dataType) { +#if (SCREEN_WIDTH == 152) + // the 1.54" screen is pretty small, we can write an entire 1bpp image from the block transfer buffer directly to the EPD buffer + case DATATYPE_IMG_RAW_1BPP_DIRECT: + pr("Direct draw image received\n"); + if (curDataInfo.dataSize == 0 && xMemEqual((const void *__xdata) & avail->dataVer, (const void *__xdata) & curDataInfo.dataVer, 8)) { + // we've downloaded this already, we're guessing it's already displayed + pr("currently shown image, send xfc\n"); + powerUp(INIT_RADIO); + sendXferComplete(); + powerDown(INIT_RADIO); + return true; + } + xMemCopyShort(&curDataInfo, (void *)avail, sizeof(struct AvailDataInfo)); + if (avail->dataSize > 4096) avail->dataSize = 4096; + + if (getDataBlock(avail->dataSize)) { + powerUp(INIT_RADIO); + sendXferComplete(); + powerDown(INIT_RADIO); + + curDataInfo.dataSize = 0; // mark as transfer not pending + powerUp(INIT_EPD); + drawImageFromBuffer(blockXferBuffer, drawWithLut); + powerDown(INIT_EPD); + drawWithLut = 0; // default back to the regular ol' stock/OTP LUT + return true; + } + return false; + break; +#endif case DATATYPE_IMG_BMP: case DATATYPE_IMG_DIFF: case DATATYPE_IMG_RAW_1BPP: diff --git a/tag_fw/syncedproto.h b/tag_fw/syncedproto.h index b5bd6139..fe39ec87 100644 --- a/tag_fw/syncedproto.h +++ b/tag_fw/syncedproto.h @@ -17,7 +17,7 @@ extern void killRadio(void); extern struct AvailDataInfo *__xdata getAvailDataInfo(); extern struct AvailDataInfo *__xdata getShortAvailDataInfo(); extern void drawImageFromEeprom(const uint8_t imgSlot); -extern bool processAvailDataInfo(const struct AvailDataInfo *__xdata avail); +extern bool processAvailDataInfo(struct AvailDataInfo *__xdata avail); extern void initializeProto(); extern uint8_t detectAP(const uint8_t channel);