mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 03:04:25 +01:00
backlogged fixes
This commit is contained in:
@@ -204,7 +204,7 @@ void drawRoundedRectangle(uint16_t xpos, uint16_t ypos, uint16_t width, uint16_t
|
||||
|
||||
framebuffer += 4;
|
||||
|
||||
uint16_t w = width - 2;
|
||||
uint16_t w = width - 1;
|
||||
uint16_t x = 1;
|
||||
while (w--) {
|
||||
framebuffer[(x / 8)] |= (uint8_t)(1 << (7 - ((uint8_t)x % 8)));
|
||||
@@ -217,7 +217,7 @@ void drawRoundedRectangle(uint16_t xpos, uint16_t ypos, uint16_t width, uint16_t
|
||||
else
|
||||
framebuffer[(widthBytes * curY) + widthBytes - 1] = 0x01;
|
||||
}
|
||||
w = width - 2;
|
||||
w = width - 1;
|
||||
x = 1;
|
||||
while (w--) {
|
||||
framebuffer[(x / 8) + ((height - 1) * widthBytes)] |= (uint8_t)(1 << (7 - ((uint8_t)x % 8)));
|
||||
|
||||
@@ -25,7 +25,7 @@ struct fwmetadata {
|
||||
|
||||
#define EEPROM_SETTINGS_SIZE 4096
|
||||
|
||||
#define BLOCKSIZE_MS 320 // was 270
|
||||
#define BLOCKSIZE_MS 225 // was 270
|
||||
|
||||
// download-stuff
|
||||
uint8_t blockbuffer[BLOCK_XFER_BUFFER_SIZE] = {0};
|
||||
@@ -199,6 +199,7 @@ static void sendAvailDataReq() {
|
||||
availreq->temperature = temperature;
|
||||
availreq->batteryMv = batteryVoltage;
|
||||
availreq->capabilities = capabilities;
|
||||
availreq->currentChannel = currentChannel;
|
||||
availreq->tagSoftwareVersion = FW_VERSION;
|
||||
addCRC(availreq, sizeof(struct AvailDataReq));
|
||||
commsTxNoCpy(outBuffer);
|
||||
@@ -282,17 +283,31 @@ static bool blockRxLoop(const uint32_t timeout) {
|
||||
bool success = false;
|
||||
radioRxEnable(true);
|
||||
t = millis() + ((timeout + 20));
|
||||
|
||||
bool blockComplete = false;
|
||||
|
||||
while (millis() < t) {
|
||||
int8_t ret = commsRxUnencrypted(inBuffer);
|
||||
if (ret > 1) {
|
||||
if (getPacketType(inBuffer) == PKT_BLOCK_PART) {
|
||||
if ((getPacketType(inBuffer) == PKT_BLOCK_PART) && pktIsUnicast(inBuffer)) {
|
||||
struct blockPart *bp = (struct blockPart *)(inBuffer + sizeof(struct MacFrameNormal) + 1);
|
||||
success = processBlockPart(bp);
|
||||
}
|
||||
blockComplete = true;
|
||||
for (uint8_t c = 0; c < BLOCK_MAX_PARTS; c++) {
|
||||
if (curBlock.requestedParts[c / 8] & (1 << (c % 8)))
|
||||
blockComplete = false;
|
||||
}
|
||||
if (blockComplete) {
|
||||
radioRxEnable(false);
|
||||
radioRxFlush();
|
||||
}
|
||||
}
|
||||
}
|
||||
radioRxEnable(false);
|
||||
radioRxFlush();
|
||||
if (blockComplete == false) {
|
||||
radioRxEnable(false);
|
||||
radioRxFlush();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
static struct blockRequestAck *continueToRX() {
|
||||
@@ -404,7 +419,7 @@ static bool validateBlockData() {
|
||||
struct blockData *bd = (struct blockData *)blockbuffer;
|
||||
// printf("expected len = %04X, checksum=%04X\n", bd->size, bd->checksum);
|
||||
if (bd->size > BLOCK_XFER_BUFFER_SIZE - sizeof(blockData)) {
|
||||
printf("Impossible data size, we abort here\n");
|
||||
printf("Impossible data size; size = %d\n");
|
||||
return false;
|
||||
}
|
||||
uint16_t t = 0;
|
||||
@@ -447,7 +462,7 @@ static uint32_t getAddressForSlot(const uint8_t s) {
|
||||
static void getNumSlots() {
|
||||
uint32_t eeSize = eepromGetSize();
|
||||
|
||||
uint16_t nSlots = (eeSize - EEPROM_SETTINGS_SIZE) / (tag.imageSize >> 8) >> 8;
|
||||
uint16_t nSlots = (eeSize - EEPROM_SETTINGS_SIZE) / (tag.imageSize >> 8) >> 8;
|
||||
if (!nSlots) {
|
||||
printf("eeprom is too small\n");
|
||||
while (1)
|
||||
@@ -460,7 +475,9 @@ static void getNumSlots() {
|
||||
printf("EEPROM reported size = %lu, %d slots\n", eeSize, imgSlots);
|
||||
}
|
||||
static uint8_t findSlotVer(uint64_t ver) {
|
||||
// return 0xFF; // remove me! This forces the tag to re-download each and every upload without checking if it's already in the eeprom somewhere
|
||||
#ifdef DEBUGBLOCKS
|
||||
return 0xFF; // remove me! This forces the tag to re-download each and every upload without checking if it's already in the eeprom somewhere
|
||||
#endif
|
||||
uint32_t markerValid = EEPROM_IMG_VALID;
|
||||
for (uint8_t c = 0; c < imgSlots; c++) {
|
||||
struct EepromImageHeader *eih = (struct EepromImageHeader *)blockbuffer;
|
||||
@@ -512,7 +529,7 @@ static void eraseUpdateBlock() {
|
||||
eepromErase(FW_LOC, (FW_METADATA_LOC + EEPROM_ERZ_SECTOR_SZ) / EEPROM_ERZ_SECTOR_SZ);
|
||||
}
|
||||
static void eraseImageBlock(const uint8_t c) {
|
||||
eepromErase(getAddressForSlot(c), tag.imageSize / EEPROM_ERZ_SECTOR_SZ);
|
||||
eepromErase(getAddressForSlot(c), tag.imageSize / EEPROM_ERZ_SECTOR_SZ);
|
||||
}
|
||||
static void saveUpdateBlockData(uint8_t blockId) {
|
||||
if (!eepromWrite(FW_LOC + (blockId * BLOCK_DATA_SIZE), blockbuffer + sizeof(struct blockData), BLOCK_DATA_SIZE))
|
||||
@@ -526,7 +543,7 @@ static void saveUpdateMetadata(uint32_t size) {
|
||||
eepromWrite(FW_METADATA_LOC, &metadata, sizeof(struct fwmetadata));
|
||||
}
|
||||
static void saveImgBlockData(const uint8_t imgSlot, const uint8_t blockId) {
|
||||
uint32_t length = tag.imageSize - (sizeof(struct EepromImageHeader) + (blockId * BLOCK_DATA_SIZE));
|
||||
uint32_t length = tag.imageSize - (sizeof(struct EepromImageHeader) + (blockId * BLOCK_DATA_SIZE));
|
||||
if (length > 4096)
|
||||
length = 4096;
|
||||
|
||||
@@ -597,22 +614,15 @@ static bool getDataBlock(const uint16_t blockSize) {
|
||||
#endif
|
||||
powerUp(INIT_RADIO);
|
||||
struct blockRequestAck *ack = performBlockRequest();
|
||||
|
||||
if (ack == NULL) {
|
||||
printf("Cancelled request\n");
|
||||
return false;
|
||||
}
|
||||
if (ack->pleaseWaitMs) { // SLEEP - until the AP is ready with the data
|
||||
if (ack->pleaseWaitMs < 35) {
|
||||
delay(ack->pleaseWaitMs);
|
||||
} else {
|
||||
doSleep(ack->pleaseWaitMs - 10);
|
||||
powerUp(INIT_UART | INIT_RADIO);
|
||||
radioRxEnable(true);
|
||||
}
|
||||
} else {
|
||||
// immediately start with the reception of the block data
|
||||
}
|
||||
|
||||
doSleep(ack->pleaseWaitMs + 50);
|
||||
powerUp(INIT_UART | INIT_RADIO);
|
||||
radioRxEnable(true);
|
||||
|
||||
blockRxLoop(BLOCKSIZE_MS); // BLOCK RX LOOP - receive a block, until the timeout has passed
|
||||
powerDown(INIT_RADIO);
|
||||
|
||||
@@ -635,6 +645,7 @@ static bool getDataBlock(const uint16_t blockSize) {
|
||||
if (curBlock.requestedParts[c / 8] & (1 << (c % 8)))
|
||||
blockComplete = false;
|
||||
}
|
||||
doSleep(30);
|
||||
|
||||
if (blockComplete) {
|
||||
#ifndef DEBUGBLOCKS
|
||||
@@ -662,6 +673,7 @@ static bool getDataBlock(const uint16_t blockSize) {
|
||||
printf("failed getting block\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint16_t dataRequestSize = 0;
|
||||
uint32_t curXferSize = 0;
|
||||
|
||||
@@ -752,7 +764,7 @@ static bool downloadImageDataToEEPROM(const struct AvailDataInfo *avail) {
|
||||
|
||||
uint8_t attempt = 5;
|
||||
while (attempt--) {
|
||||
if (eepromErase(getAddressForSlot(xferImgSlot), tag.imageSize / EEPROM_ERZ_SECTOR_SZ)) goto eraseSuccess;
|
||||
if (eepromErase(getAddressForSlot(xferImgSlot), tag.imageSize / EEPROM_ERZ_SECTOR_SZ)) goto eraseSuccess;
|
||||
}
|
||||
eepromFail:
|
||||
powerDown(INIT_RADIO);
|
||||
@@ -835,7 +847,7 @@ bool processImageDataAvail(struct AvailDataInfo *avail) {
|
||||
default: {
|
||||
uint8_t slot = findSlotDataTypeArg(avail->dataTypeArgument);
|
||||
if (slot != 0xFF) {
|
||||
eepromErase(getAddressForSlot(slot), tag.imageSize / EEPROM_ERZ_SECTOR_SZ);
|
||||
eepromErase(getAddressForSlot(slot), tag.imageSize / EEPROM_ERZ_SECTOR_SZ);
|
||||
}
|
||||
} break;
|
||||
// regular image preload, there can be multiple of this type in the EEPROM
|
||||
|
||||
@@ -42,11 +42,17 @@ void addOverlay() {
|
||||
drawMask(epd->Xres - 27, epd->Yres - 26, 22, 22, COLOR_RED);
|
||||
drawRoundedRectangle(epd->Xres - 28, epd->Yres - 26, 24, 24, COLOR_RED);
|
||||
addBufferedImage(epd->Xres - 24, epd->Yres - 19, COLOR_BLACK, rotation::ROTATE_0, battery, DRAW_NORMAL);
|
||||
|
||||
lowBatteryShown = true;
|
||||
} else {
|
||||
lowBatteryShown = false;
|
||||
}
|
||||
#ifdef DEBUGBLOCKS
|
||||
fontrender fr(&FreeSansBold18pt7b);
|
||||
drawMask(15, epd->Yres - 53, 129, 33, COLOR_BLACK);
|
||||
drawMask(15, epd->Yres - 53, 129, 33, COLOR_RED);
|
||||
drawRoundedRectangle(15, epd->Yres - 53, 129, 33, COLOR_RED);
|
||||
fr.epdPrintf(17, epd->Yres - 50, COLOR_RED, rotation::ROTATE_0, "DEBUG");
|
||||
#endif
|
||||
}
|
||||
|
||||
void afterFlashScreenSaver() {
|
||||
@@ -139,6 +145,13 @@ void showSplashScreen() {
|
||||
addQR(260, 160, 3, 7, "https://openepaperlink.eu/tag/0/%02X/%02X%02X%02X%02X%02X%02X%02X%02X/", tag.OEPLtype, mSelfMac[7], mSelfMac[6], mSelfMac[5], mSelfMac[4], mSelfMac[3], mSelfMac[2], mSelfMac[1], mSelfMac[0]);
|
||||
break;
|
||||
}
|
||||
#ifdef DEBUGBLOCKS
|
||||
drawMask(15, epd->Yres - 53, 129, 33, COLOR_BLACK);
|
||||
drawMask(15, epd->Yres - 53, 129, 33, COLOR_RED);
|
||||
drawRoundedRectangle(15, epd->Yres - 53, 129, 33, COLOR_RED);
|
||||
fr.setFont(&FreeSansBold18pt7b);
|
||||
fr.epdPrintf(17, epd->Yres - 50, COLOR_RED, rotation::ROTATE_0, "DEBUG");
|
||||
#endif
|
||||
draw();
|
||||
}
|
||||
|
||||
|
||||
@@ -295,6 +295,9 @@ def main():
|
||||
if args.altradio:
|
||||
send_cmd(CMD_SELECT_PORT, bytearray([2]))
|
||||
|
||||
send_cmd(CMD_SET_POWER, bytearray([1]))
|
||||
cmd, answer = wait_for_command()
|
||||
|
||||
if args.nrf82511:
|
||||
send_cmd(CMD_SELECT_NRF82511, bytearray([]))
|
||||
if args.zbs243:
|
||||
|
||||
Reference in New Issue
Block a user