Merge pull request #15 from nlimper/development

small bugs fixed
This commit is contained in:
Nic Limper
2023-02-15 17:57:33 +01:00
committed by GitHub
4 changed files with 22 additions and 17 deletions

View File

@@ -1,6 +1,7 @@
const $ = document.querySelector.bind(document);
const WAKEUP_REASON_TIMED = 0;
const WAKEUP_REASON_BOOT = 1;
const WAKEUP_REASON_GPIO = 2;
const WAKEUP_REASON_NFC = 3;
const WAKEUP_REASON_FIRSTBOOT = 0xFC;
@@ -130,11 +131,16 @@ function processTags(tagArray) {
div.classList.remove("tagpending");
div.dataset.lastseen = element.lastseen;
div.dataset.hash = element.hash;
div.dataset.wakeupreason = element.wakeupReason;
$('#tag' + tagmac + ' .warningicon').style.display = 'none';
$('#tag' + tagmac).style.background = "inherit";
switch (element.wakeupReason) {
switch (parseInt(element.wakeupReason)) {
case WAKEUP_REASON_TIMED:
break;
case WAKEUP_REASON_BOOT:
$('#tag' + tagmac + ' .nextcheckin').innerHTML = "<font color=yellow>First boot</font>"
$('#tag' + tagmac).style.background = "#40c040";
break;
case WAKEUP_REASON_GPIO:
$('#tag' + tagmac + ' .nextcheckin').innerHTML = "GPIO wakeup"
break;
@@ -143,15 +149,15 @@ function processTags(tagArray) {
break;
case WAKEUP_REASON_FIRSTBOOT:
$('#tag' + tagmac + ' .nextcheckin').innerHTML = "<font color=yellow>First boot</font>"
$('#tag' + tagmac).style.background = "purple";
$('#tag' + tagmac).style.background = "#40c040";
break;
case WAKEUP_REASON_NETWORK_SCAN:
$('#tag' + tagmac + ' .nextcheckin').innerHTML = "<font color=yellow>Network scan</font>"
$('#tag' + tagmac).style.background = "green";
$('#tag' + tagmac).style.background = "#4040c0";
break;
case WAKEUP_REASON_WDT_RESET:
$('#tag' + tagmac + ' .nextcheckin').innerHTML = "Watchdog reset!"
$('#tag' + tagmac).style.background = "red";
$('#tag' + tagmac).style.background = "#c04040";
break;
}
$('#tag' + tagmac + ' .pendingicon').style.display = (element.pending ? 'inline-block' : 'none');
@@ -183,7 +189,7 @@ function updatecards() {
$('#tag' + tagmac + ' .lastseen').innerHTML = ""
}
if (item.dataset.nextcheckin > 1672531200) {
if (item.dataset.nextcheckin > 1672531200 && parseInt(item.dataset.wakeupreason)==0) {
let nextcheckin = item.dataset.nextcheckin - ((Date.now() / 1000) + servertimediff);
$('#tag' + tagmac + ' .nextcheckin').innerHTML = "<span>expected checkin</span>" + displayTime(Math.floor(nextcheckin));
}

View File

@@ -73,7 +73,7 @@ void drawNew(uint8_t mac[8], bool buttonPressed, tagRecord *&taginfo) {
JsonObject cfgobj = doc.as<JsonObject>();
wsLog("Updating " + dst);
taginfo->nextupdate = now + 600;
taginfo->nextupdate = now + 60;
switch (taginfo->contentMode) {
case Image:

View File

@@ -178,7 +178,7 @@ void spr2grays(TFT_eSprite &spr, long w, long h, String &fileout) {
if (dither) {
// ditherFudge = (rand() % 255 - 127) / (int)numGrays; // -64 to 64
ditherFudge = (dither_matrix[numRows % 4][c % 4] - 8) * 24 / (int)numGrays;
ditherFudge = (dither_matrix[numRows % 4][c % 4] - 8) * 16 / (int)numGrays;
}
for (i = 0; i < hdr.numColors; i++) {

View File

@@ -125,7 +125,7 @@ bool prepareDataAvail(String* filename, uint8_t dataType, uint8_t* dst, uint16_t
}
uint16_t attempts = 60 * 24;
uint8_t lut = EPD_LUT_DEFAULT;
uint8_t lut = EPD_LUT_NO_REPEATS;
uint8_t src[8];
*((uint64_t*)src) = swap64(*((uint64_t*)dst));
uint8_t mac[6];
@@ -143,12 +143,11 @@ bool prepareDataAvail(String* filename, uint8_t dataType, uint8_t* dst, uint16_t
time_t now;
time(&now);
time_t last_midnight = now - now % (24 * 60 * 60) + 3 * 3600; // somewhere in the middle of the night
if (taginfo->lastfullupdate > last_midnight) lut = EPD_LUT_NO_REPEATS; // fast updates during the day
/*
uint16_t minutesUntilNextCheckin = 0;
if (taginfo->expectedNextCheckin > now) minutesUntilNextCheckin = (taginfo->expectedNextCheckin - now) / 60;
attempts += minutesUntilNextCheckin;
*/
if (taginfo->lastfullupdate < last_midnight) {
lut = EPD_LUT_DEFAULT; // full update once a day
taginfo->lastfullupdate = now;
}
Serial.println("last midnight: "+String(last_midnight)+" last full: "+String(taginfo->lastfullupdate) + " -> lut: " + String(lut));
} else {
wsErr("Tag not found, this shouldn't happen.");
}
@@ -159,7 +158,7 @@ bool prepareDataAvail(String* filename, uint8_t dataType, uint8_t* dst, uint16_t
pending.availdatainfo.dataType = dataType;
pending.availdatainfo.dataVer = *((uint64_t*)md5bytes);
pending.availdatainfo.dataSize = file.size();
pending.availdatainfo.dataTypeArgument = EPD_LUT_NO_REPEATS;
pending.availdatainfo.dataTypeArgument = lut;
pending.availdatainfo.nextCheckIn = nextCheckin;
pending.attemptsLeft = attempts;
sendDataAvail(&pending);
@@ -282,7 +281,7 @@ void processXferComplete(struct espXferComplete* xfc) {
if (taginfo != nullptr) {
uint16_t minutesUntilNextUpdate = 0;
if (taginfo->nextupdate > now + 2) {
if (taginfo->nextupdate > now + 2 * 60) {
minutesUntilNextUpdate = (taginfo->nextupdate - now) / 60;
if (minutesUntilNextUpdate > MIN_RESPONSE_TIME) minutesUntilNextUpdate = MIN_RESPONSE_TIME;
taginfo->expectedNextCheckin = now + 60 * minutesUntilNextUpdate + 60;
@@ -343,7 +342,7 @@ void processDataReq(struct espAvailDataReq* eadr) {
taginfo->lastseen = now;
uint16_t minutesUntilNextUpdate = 0;
if (taginfo->nextupdate > now + 2) {
if (taginfo->nextupdate > now + 2 * 60) {
minutesUntilNextUpdate = (taginfo->nextupdate - now) / 60;
if (minutesUntilNextUpdate > MIN_RESPONSE_TIME) minutesUntilNextUpdate = MIN_RESPONSE_TIME;
taginfo->expectedNextCheckin = now + 60 * minutesUntilNextUpdate + 60;