improved bmp draw spd, fixed bug if AP rejects req

This commit is contained in:
Jelmer
2023-02-20 21:00:49 +01:00
parent be75019086
commit 287cf0520b
6 changed files with 41 additions and 18 deletions

View File

@@ -215,7 +215,9 @@ static void drawPrvDecodeImageOnce(void) {
uint16_t __xdata bitpoolOut = 0;
#endif
// get a row
epdDeselect();
eepromRead(mathPrvMul16x16(er, mDrawInfo.stride) + mDrawInfo.dataAddr, rowBuf, mDrawInfo.stride);
epdSelect();
// convert to our format
c = mDrawInfo.effectiveW;
do {
@@ -329,16 +331,13 @@ void ByteDecode(uint8_t byte) {
prev |= (mColorMap[mPassNo][byte >> 4] << 1) | mColorMap[mPassNo][byte & 0x0f];
if (++step == 4) {
step = 0;
epdSelect();
epdSend(prev);
epdDeselect();
}
}
void drawImageAtAddress(uint32_t addr, uint8_t lut) {
struct EepromImageHeader* __xdata eih = (struct EepromImageHeader*)mClutMap;
eepromRead(addr, mClutMap, sizeof(struct EepromImageHeader));
switch (eih->dataType) {
case DATATYPE_IMG_RAW_1BPP:
pr("Doing raw 1bpp\n");
@@ -392,7 +391,7 @@ void drawImageAtAddress(uint32_t addr, uint8_t lut) {
break;
case DATATYPE_IMG_BMP:;
uint32_t __xdata clutAddr;
pr("sending to EPD - ");
pr("sending BMP to EPD - ");
clutAddr = drawPrvParseHeader(addr);
if (!clutAddr)
return;

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -111,7 +111,7 @@ static void configEEPROM(const bool setup) {
powerDown(INIT_RADIO);
powerUp(INIT_EPD);
showNoEEPROM();
powerDown(INIT_EEPROM | INIT_EPD | INIT_GPIO);
powerDown(INIT_EEPROM | INIT_EPD);
doSleep(-1);
wdtDeviceReset();
}

View File

@@ -373,7 +373,7 @@ static void sendXferCompletePacket() {
static void sendXferComplete() {
radioRxEnable(true, true);
for (uint8_t c = 0; c < 8; c++) {
for (uint8_t c = 0; c < 16; c++) {
sendXferCompletePacket();
uint32_t __xdata start = timerGet();
while ((timerGet() - start) < (TIMER_TICKS_PER_MS * 6UL)) {
@@ -617,8 +617,21 @@ static bool downloadImageDataToEEPROM(const struct AvailDataInfo *__xdata avail)
nextImgSlot++;
if (nextImgSlot >= imgSlots) nextImgSlot = 0;
curImgSlot = nextImgSlot;
pr("Saving to image slot %d\n", curImgSlot);
drawWithLut = avail->dataTypeArgument;
eepromErase(getAddressForSlot(curImgSlot), EEPROM_IMG_EACH / EEPROM_ERZ_SECTOR_SZ);
powerUp(INIT_EEPROM);
uint8_t __xdata attempt = 5;
while (attempt--) {
if (eepromErase(getAddressForSlot(curImgSlot), EEPROM_IMG_EACH / EEPROM_ERZ_SECTOR_SZ)) goto eraseSuccess;
}
eepromFail:
powerDown(INIT_RADIO);
powerUp(INIT_EPD);
showNoEEPROM();
powerDown(INIT_EEPROM | INIT_EPD);
doSleep(-1);
wdtDeviceReset();
eraseSuccess:
pr("new download, writing to slot %d\n", curImgSlot);
// start, or restart the transfer. Copy data from the AvailDataInfo struct, and the struct intself. This forces a new transfer
@@ -643,6 +656,7 @@ static bool downloadImageDataToEEPROM(const struct AvailDataInfo *__xdata avail)
// succesfully downloaded datablock, save to eeprom
powerUp(INIT_EEPROM);
saveImgBlockData(curImgSlot, curBlock.blockId);
powerDown(INIT_EEPROM);
curBlock.blockId++;
curDataInfo.dataSize -= dataRequestSize;
} else {
@@ -650,6 +664,7 @@ static bool downloadImageDataToEEPROM(const struct AvailDataInfo *__xdata avail)
return false;
}
}
// no more data, download complete
// borrow the blockXferBuffer temporarily
struct EepromImageHeader __xdata *eih = (struct EepromImageHeader __xdata *)blockXferBuffer;
@@ -658,12 +673,11 @@ static bool downloadImageDataToEEPROM(const struct AvailDataInfo *__xdata avail)
eih->id = ++curHighSlotId;
eih->size = imageSize;
eih->dataType = curDataInfo.dataType;
eepromWrite(getAddressForSlot(curImgSlot), eih, sizeof(struct EepromImageHeader));
powerUp(INIT_RADIO);
sendXferComplete();
powerDown(INIT_RADIO);
// no more data, download complete
powerUp(INIT_EEPROM);
eepromWrite(getAddressForSlot(curImgSlot), eih, sizeof(struct EepromImageHeader));
powerDown(INIT_EEPROM);
return true;
}
@@ -707,14 +721,24 @@ bool processAvailDataInfo(const struct AvailDataInfo *__xdata avail) {
return true;
} else {
// not found in cache, prepare to download
pr("downloading to imgslot\n");
drawWithLut = avail->dataTypeArgument;
powerUp(INIT_EEPROM);
downloadImageDataToEEPROM(avail);
wdt60s();
powerUp(INIT_EPD);
drawImageFromEeprom(curImgSlot);
powerDown(INIT_EPD | INIT_EEPROM);
return true;
if (downloadImageDataToEEPROM(avail)) {
pr("download complete!\n");
powerUp(INIT_RADIO);
sendXferComplete();
powerDown(INIT_RADIO);
wdt60s();
powerUp(INIT_EPD | INIT_EEPROM);
drawImageFromEeprom(curImgSlot);
powerDown(INIT_EPD | INIT_EEPROM);
return true;
} else {
powerDown(INIT_EEPROM);
return false;
}
}
break;
case DATATYPE_FW_UPDATE: