diff --git a/tag_fw/bitmaps.h b/tag_fw/bitmaps.h index d16feecf..430faf8e 100644 --- a/tag_fw/bitmaps.h +++ b/tag_fw/bitmaps.h @@ -4,6 +4,8 @@ // images generated by https://lvgl.io/tools/imageconverter, prepended with width, height. "CF_INDEXED_1_BIT"-mode, little-endian #include +#include "screen.h" + static const uint8_t __code solum[] = { 128, 26, 0x00, 0x00, 0x07, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -207,4 +209,96 @@ static const uint8_t __code failed[] = { 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00, }; +#if (SCREEN_WIDTH != 128) +static const uint8_t __code ant[] = { + 16, 16, + 0x00, 0x40, + 0x02, 0x20, + 0x01, 0x20, + 0x11, 0x20, + 0x11, 0x20, + 0x12, 0x20, + 0x28, 0x40, + 0x28, 0x00, + 0x28, 0x00, + 0x44, 0x00, + 0x44, 0x00, + 0x44, 0x00, + 0x44, 0x00, + 0x82, 0x00, + 0x82, 0x00, + 0xfe, 0x00, +}; +#else +static const uint8_t __code ant[] = { + // rotated 90 degrees + 16,16, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x7c, 0x00, + 0x82, 0x00, + 0x00, 0x00, + 0x38, 0x00, + 0x44, 0x07, + 0x00, 0x79, + 0x03, 0x81, + 0x1c, 0x01, + 0x03, 0x81, + 0x00, 0x79, + 0x00, 0x07, +}; +#endif +static const uint8_t __code cross[] = { + 8,8, + 0x00, + 0x63, + 0x77, + 0x3e, + 0x1c, + 0x3e, + 0x77, + 0x63 +}; + +#if (SCREEN_WIDTH != 128) +static const uint8_t __code battery[] = { + 16,10, + 0x00, 0x00, + 0x7f, 0xfc, + 0x40, 0x04, + 0x58, 0x06, + 0x58, 0x06, + 0x58, 0x06, + 0x58, 0x06, + 0x40, 0x04, + 0x7f, 0xfc, + 0x00, 0x00, +}; +#else +// this battery symbol is rotated 90' +static const uint8_t __code battery[] = { +16,16, + 0x00, 0x00, + 0x03, 0xc0, + 0x0f, 0xf0, + 0x08, 0x10, + 0x08, 0x10, + 0x08, 0x10, + 0x08, 0x10, + 0x08, 0x10, + 0x08, 0x10, + 0x08, 0x10, + 0x08, 0x10, + 0x0b, 0xd0, + 0x0b, 0xd0, + 0x08, 0x10, + 0x0f, 0xf0, + 0x00, 0x00, +}; + +#endif + #endif \ No newline at end of file diff --git a/tag_fw/board/zbs154v033/screen.h b/tag_fw/board/zbs154v033/screen.h index 6d1d4997..034fd430 100644 --- a/tag_fw/board/zbs154v033/screen.h +++ b/tag_fw/board/zbs154v033/screen.h @@ -21,7 +21,5 @@ #define SCREEN_DATA_PASSES 2 -#define SCREEN_LUT_LENGTH 10 - #endif \ No newline at end of file diff --git a/tag_fw/board/zbs29v033/screen.h b/tag_fw/board/zbs29v033/screen.h index 101e5339..a7352485 100644 --- a/tag_fw/board/zbs29v033/screen.h +++ b/tag_fw/board/zbs29v033/screen.h @@ -21,7 +21,4 @@ #define SCREEN_DATA_PASSES 2 -#define SCREEN_LUT_LENGTH 7 - - #endif \ No newline at end of file diff --git a/tag_fw/board/zbs42v033/screen.h b/tag_fw/board/zbs42v033/screen.h index 5f7891ff..96501a0e 100644 --- a/tag_fw/board/zbs42v033/screen.h +++ b/tag_fw/board/zbs42v033/screen.h @@ -21,7 +21,5 @@ #define SCREEN_DATA_PASSES 2 -#define SCREEN_LUT_LENGTH 7 - #endif \ No newline at end of file diff --git a/tag_fw/drawing.c b/tag_fw/drawing.c index 4ed967b9..6ee193b4 100644 --- a/tag_fw/drawing.c +++ b/tag_fw/drawing.c @@ -11,6 +11,7 @@ #include "screen.h" #include "timer.h" +#include "userinterface.h" // for addIcons #define COMPRESSION_BITPACKED_3x5_to_7 0x62700357 // 3 pixels of 5 possible colors in 7 bits #define COMPRESSION_BITPACKED_5x3_to_8 0x62700538 // 5 pixels of 3 possible colors in 8 bits #define COMPRESSION_BITPACKED_3x6_to_8 0x62700368 // 3 pixels of 6 possible colors in 8 bits @@ -333,7 +334,7 @@ void ByteDecode(uint8_t byte) { } } -void drawImageAtAddress(uint32_t addr) { +void drawImageAtAddress(uint32_t addr, uint8_t lut) { uint32_t __xdata clutAddr; pr("sending to EPD - "); clutAddr = drawPrvParseHeader(addr); @@ -342,6 +343,7 @@ void drawImageAtAddress(uint32_t addr) { drawPrvLoadAndMapClut(clutAddr); epdSetup(); + if(lut)selectLUT(lut); mPassNo = 0; beginFullscreenImage(); beginWriteFramebuffer(EPD_COLOR_BLACK); @@ -358,6 +360,6 @@ void drawImageAtAddress(uint32_t addr) { endWriteFramebuffer(); pr(" complete.\n"); - + addOverlay(); drawWithSleep(); } diff --git a/tag_fw/drawing.h b/tag_fw/drawing.h index 4e216e9e..cdd1c939 100644 --- a/tag_fw/drawing.h +++ b/tag_fw/drawing.h @@ -7,7 +7,7 @@ void set_offline(__bit state); #pragma callee_saves drawImageAtAddress -void drawImageAtAddress(uint32_t addr); +void drawImageAtAddress(uint32_t addr, uint8_t lut); #endif diff --git a/tag_fw/epd.c b/tag_fw/epd.c index a9b32a29..36fe5e28 100644 --- a/tag_fw/epd.c +++ b/tag_fw/epd.c @@ -11,6 +11,7 @@ #include "lut.h" #include "printf.h" #include "screen.h" +#include "settings.h" #include "sleep.h" #include "spi.h" #include "timer.h" @@ -73,16 +74,14 @@ static uint8_t __xdata rbuffer[32]; // used to rotate bits around static uint16_t __xdata fontCurXpos = 0; // current X value we're working with static uint16_t __xdata fontCurYpos = 0; // current Y value we're working with static uint8_t __xdata currentLut = 0; +static uint8_t __xdata dispLutSize = 0; static bool __xdata isInited = false; -uint8_t waveformbuffer[120]; -#if (SCREEN_LUT_LENGTH == 10) -struct waveform10* __xdata waveform = (struct waveform10*)waveformbuffer; // holds the LUT/waveform -#endif -#if (SCREEN_LUT_LENGTH == 7) -struct waveform* __xdata waveform = (struct waveform*)waveformbuffer; // holds the LUT/waveform -#endif +#define LUT_BUFFER_SIZE 128 +uint8_t waveformbuffer[LUT_BUFFER_SIZE]; +struct waveform10* __xdata waveform10 = (struct waveform10*)waveformbuffer; // holds the LUT/waveform +struct waveform* __xdata waveform7 = (struct waveform*)waveformbuffer; // holds the LUT/waveform #pragma callee_saves epdBusySleep #pragma callee_saves epdBusyWait @@ -239,7 +238,6 @@ static uint8_t epdGetStatus() { return sta; } uint16_t epdGetBattery(void) { - uint16_t voltage = 2600; uint8_t val; @@ -283,7 +281,7 @@ void loadFixedTempOTPLUT() { } static void writeLut() { commandBegin(CMD_WRITE_LUT); - for (uint8_t i = 0; i < (SCREEN_LUT_LENGTH * 10); i++) + for (uint8_t i = 0; i < (dispLutSize * 10); i++) epdSend(waveformbuffer[i]); commandEnd(); } @@ -292,24 +290,56 @@ static void readLut() { uint16_t checksum = 0; uint16_t ident = 0; uint16_t shortl = 0; - for (uint16_t c = 0; c < ((SCREEN_LUT_LENGTH * 10) + 6); c++) { + for (uint16_t c = 0; c < LUT_BUFFER_SIZE; c++) { waveformbuffer[c] = epdReadByte(); } commandReadEnd(); } +static uint8_t getLutSize() { + uint8_t ref = 0; + for (uint8_t c = (LUT_BUFFER_SIZE - 4); c > 16; c--) { + uint8_t check = waveformbuffer[c]; + for (uint8_t d = 1; d < 4; d++) { + if (waveformbuffer[c + d] != check) { + ref = c; + goto end; + } + } + } +end:; + return ref + 1; +} static void lutGroupDisable(uint8_t group) { - memset(&(waveform->group[group]), 0x00, 5); + if (dispLutSize == 7) { + memset(&(waveform7->group[group]), 0x00, 5); + } else { + memset(&(waveform10->group[group]), 0x00, 5); + } } static void lutGroupSpeedup(uint8_t group, uint8_t speed) { - for (uint8_t i = 0; i < 4; i++) { - waveform->group[group].phaselength[i] = 1 + (waveform->group[group].phaselength[i] / speed); + if (dispLutSize == 7) { + for (uint8_t i = 0; i < 4; i++) { + waveform7->group[group].phaselength[i] = 1 + (waveform7->group[group].phaselength[i] / speed); + } + } else { + for (uint8_t i = 0; i < 4; i++) { + waveform10->group[group].phaselength[i] = 1 + (waveform10->group[group].phaselength[i] / speed); + } } } static void lutGroupRepeat(uint8_t group, uint8_t repeat) { - waveform->group[group].repeat = repeat; + if (dispLutSize == 7) { + waveform7->group[group].repeat = repeat; + } else { + waveform10->group[group].repeat = repeat; + } } static void lutGroupRepeatReduce(uint8_t group, uint8_t factor) { - waveform->group[group].repeat = waveform->group[group].repeat / factor; + if (dispLutSize == 7) { + waveform7->group[group].repeat = waveform7->group[group].repeat / factor; + } else { + waveform10->group[group].repeat = waveform10->group[group].repeat / factor; + } } void selectLUT(uint8_t lut) { if (currentLut == lut) { @@ -333,6 +363,15 @@ void selectLUT(uint8_t lut) { // download the current LUT from the waveform buffer readLut(); + if (dispLutSize == 0) { + dispLutSize = getLutSize(); + dispLutSize /= 10; + pr("lut size = %d\n", dispLutSize); +#ifdef PRINT_LUT + dump(waveformbuffer, LUT_BUFFER_SIZE); +#endif + } + switch (lut) { case EPD_LUT_NO_REPEATS: lutGroupDisable(LUTGROUP_NEGATIVE); @@ -358,7 +397,7 @@ void selectLUT(uint8_t lut) { lutGroupDisable(LUTGROUP_NEGATIVE); lutGroupDisable(LUTGROUP_FASTBLINK); lutGroupDisable(LUTGROUP_SLOWBLINK); - lutGroupRepeat(LUTGROUP_SET, 0); + lutGroupRepeat(LUTGROUP_SET, 1); lutGroupSpeedup(LUTGROUP_SET, 2); lutGroupDisable(LUTGROUP_IMPROVE_SHARPNESS); lutGroupDisable(LUTGROUP_IMPROVE_REDS); @@ -366,12 +405,12 @@ void selectLUT(uint8_t lut) { break; } -#if (SCREEN_LUT_LENGTH == 10) - lutGroupDisable(LUTGROUP_UNUSED); - lutGroupDisable(LUTGROUP_UNKNOWN); - lutGroupDisable(LUTGROUP_UNUSED3); - lutGroupDisable(LUTGROUP_UNUSED4); -#endif + if (dispLutSize == 10) { + lutGroupDisable(LUTGROUP_UNUSED); + lutGroupDisable(LUTGROUP_UNKNOWN); + lutGroupDisable(LUTGROUP_UNUSED3); + lutGroupDisable(LUTGROUP_UNUSED4); + } writeLut(); } @@ -746,9 +785,4 @@ void readRam() { epdSend(blockXferBuffer[c]); } commandEnd(); -} - -void lutTest() { - readLut(); - dump((uint8_t*)&waveform, 96); -} +} \ No newline at end of file diff --git a/tag_fw/fw154.bin b/tag_fw/fw154.bin index 4d7904aa..8544a147 100644 Binary files a/tag_fw/fw154.bin and b/tag_fw/fw154.bin differ diff --git a/tag_fw/fw29.bin b/tag_fw/fw29.bin index 18c0e8b9..b50803e4 100644 Binary files a/tag_fw/fw29.bin and b/tag_fw/fw29.bin differ diff --git a/tag_fw/fw42.bin b/tag_fw/fw42.bin index 7d76b092..5927fc98 100644 Binary files a/tag_fw/fw42.bin and b/tag_fw/fw42.bin differ diff --git a/tag_fw/lut.h b/tag_fw/lut.h index 9a09d3ca..4f9eba67 100644 --- a/tag_fw/lut.h +++ b/tag_fw/lut.h @@ -10,11 +10,10 @@ #define LUTGROUP_IMPROVE_REDS 5 #define LUTGROUP_UNUSED 6 -#if (SCREEN_LUT_LENGTH == 10) #define LUTGROUP_UNKNOWN 7 #define LUTGROUP_UNUSED3 8 #define LUTGROUP_UNUSED4 9 -#endif + struct vgroup { uint8_t A : 2; diff --git a/tag_fw/main.c b/tag_fw/main.c index 1133fd91..43a4eba9 100644 --- a/tag_fw/main.c +++ b/tag_fw/main.c @@ -71,6 +71,14 @@ void displayLoop() { wdtOn(); wdt30s(); + pr("Longterm sleep screen\n"); + powerUp(INIT_EPD); + showLongTermSleep(); + timerDelay(TIMER_TICKS_PER_SECOND * 4); + + wdtOn(); + wdt30s(); + pr("NO EEPROM\n"); powerUp(INIT_EPD); showNoEEPROM(); @@ -216,6 +224,20 @@ void mainProtocolLoop(void) { } voltageCheckCounter++; + // check if the battery level is below minimum, and force a redraw of the screen + if ((lowBattery && !lowBatteryShown) || (noAPShown)) { + powerUp(INIT_EPD); + // Check if we were already displaying an image + if (curImgSlot != 0xFF) { + powerUp(INIT_EEPROM); + drawImageFromEeprom(); + powerDown(INIT_EEPROM); + } else { + showAPFound(); + powerDown(INIT_EPD); + } + } + avail = getAvailDataInfo(); if (avail != NULL) { longDataReqCounter = 0; @@ -270,13 +292,32 @@ void mainProtocolLoop(void) { } else { // not associated - powerUp(INIT_BASE | INIT_RADIO); // || INIT_GPIO | INIT_UART - + if (((scanAttempts != 0) && (scanAttempts % VOLTAGEREADING_DURING_SCAN_INTERVAL == 0)) || (scanAttempts > (INTERVAL_1_ATTEMPTS + INTERVAL_2_ATTEMPTS))) { + powerUp(INIT_BASE | INIT_EPD_VOLTREADING | INIT_RADIO); + } else { + powerUp(INIT_BASE | INIT_RADIO); // || INIT_GPIO | INIT_UART + } // try to find a working channel powerUp(INIT_RADIO); wdt30s(); currentChannel = channelSelect(); - powerDown(INIT_RADIO | INIT_GPIO); + powerDown(INIT_RADIO); + if ((!currentChannel && !noAPShown) || (lowBattery && !lowBatteryShown) || (scanAttempts == (INTERVAL_1_ATTEMPTS + INTERVAL_2_ATTEMPTS - 1))) { + powerUp(INIT_EPD); + if (curImgSlot != 0xFF) { + powerUp(INIT_EEPROM); + drawImageFromEeprom(); + powerDown(INIT_EEPROM); + } else if ((scanAttempts >= (INTERVAL_1_ATTEMPTS + INTERVAL_2_ATTEMPTS - 1))) { + showLongTermSleep(); + powerDown(INIT_EPD); + } else { + showNoAP(); + powerDown(INIT_EPD); + } + } + + powerDown(INIT_GPIO); // did we find a working channel? if (currentChannel) { diff --git a/tag_fw/powermgt.c b/tag_fw/powermgt.c index ab588160..37a8e9b1 100644 --- a/tag_fw/powermgt.c +++ b/tag_fw/powermgt.c @@ -34,6 +34,7 @@ uint8_t __xdata scanAttempts = 0; int8_t __xdata temperature = 0; uint16_t __xdata batteryVoltage = 0; +bool __xdata lowBattery = false; uint16_t __xdata longDataReqCounter = 0; uint16_t __xdata voltageCheckCounter = 0; @@ -70,6 +71,11 @@ void powerUp(uint8_t parts) { if (!(parts & INIT_GPIO)) boardInit(); batteryVoltage = epdGetBattery(); + if(batteryVoltage -#define FW_VERSION 013 // version number (max 2.5.5 :) ) -#define FW_VERSION_SUFFIX "-rf99" // suffix, like -RC1 or whatever. -#define HAS_BUTTON // uncomment to enable reading a push button (connect between 'TEST' en 'GND' on the tag, along with a 100nF capacitor in parallel). -#define DEBUGBLOCKS // uncomment to enable extra debug information on the block transfers - +#define FW_VERSION 014 // version number (max 2.5.5 :) ) +#define FW_VERSION_SUFFIX "-lutje" // suffix, like -RC1 or whatever. +#define HAS_BUTTON // uncomment to enable reading a push button (connect between 'TEST' en 'GND' on the tag, along with a 100nF capacitor in parallel). +#define DEBUGBLOCKS // uncomment to enable extra debug information on the block transfers +//#define PRINT_LUT // uncomment if you want the tag to print the LUT for the current temperature bracket #endif \ No newline at end of file diff --git a/tag_fw/syncedproto.c b/tag_fw/syncedproto.c index b023e372..6398c60a 100644 --- a/tag_fw/syncedproto.c +++ b/tag_fw/syncedproto.c @@ -33,11 +33,11 @@ uint16_t __xdata dataRemaining = 0; // since the targeted solum tags don't have bool __xdata curXferComplete = false; bool __xdata requestPartialBlock = false; -// uint8_t __xdata *tempBuffer = blockXferBuffer; -uint8_t __xdata curImgSlot = 0; +uint8_t __xdata curImgSlot = 0xFF; uint32_t __xdata curHighSlotId = 0; uint8_t __xdata nextImgSlot = 0; uint8_t __xdata imgSlots = 0; +uint8_t __xdata drawWithLut = 0; // doDownload persistent variables bool __xdata lastBlock = false; @@ -456,7 +456,9 @@ void drawImageFromEeprom() { // enable WDT, to make sure de tag resets if it's for some reason unable to draw the image wdtSetResetVal(0xFFFFFFFF - 0x38C340); wdtOn(); - drawImageAtAddress(getAddressForSlot(curImgSlot)); + + drawImageAtAddress(getAddressForSlot(curImgSlot), drawWithLut); + drawWithLut = 0; // default back to the regular ol' stock/OTP LUT powerDown(INIT_EPD); } uint32_t getHighSlotId() { @@ -519,7 +521,7 @@ bool doDataDownload(struct AvailDataInfo *__xdata avail) { // mark as completed and draw from EEPROM curXferComplete = true; xMemCopyShort(&curDataInfo, (void *)avail, sizeof(struct AvailDataInfo)); - + drawWithLut = avail->dataTypeArgument; drawImageFromEeprom(); return true; } else { @@ -528,7 +530,7 @@ bool doDataDownload(struct AvailDataInfo *__xdata avail) { nextImgSlot++; if (nextImgSlot >= imgSlots) nextImgSlot = 0; curImgSlot = nextImgSlot; - + drawWithLut = avail->dataTypeArgument; eepromErase(getAddressForSlot(curImgSlot), EEPROM_IMG_EACH / EEPROM_ERZ_SECTOR_SZ); pr("new download, writing to slot %d\n", curImgSlot); // continue! diff --git a/tag_fw/syncedproto.h b/tag_fw/syncedproto.h index 6224fe42..cfe869c8 100644 --- a/tag_fw/syncedproto.h +++ b/tag_fw/syncedproto.h @@ -8,12 +8,15 @@ extern uint8_t __xdata mSelfMac[]; extern uint8_t __xdata currentChannel; extern uint8_t __xdata APmac[]; +extern uint8_t __xdata curImgSlot; + extern void setupRadio(void); extern void killRadio(void); extern struct AvailDataInfo *__xdata getAvailDataInfo(); extern struct AvailDataInfo *__xdata getShortAvailDataInfo(); +extern void drawImageFromEeprom(); extern bool doDataDownload(struct AvailDataInfo *__xdata avail); extern void initializeProto(); extern uint8_t detectAP(uint8_t channel); diff --git a/tag_fw/userinterface.c b/tag_fw/userinterface.c index a77e134c..9ad691a1 100644 --- a/tag_fw/userinterface.c +++ b/tag_fw/userinterface.c @@ -13,6 +13,7 @@ #include "epd.h" #include "font.h" #include "lut.h" +#include "powermgt.h" #include "printf.h" #include "screen.h" #include "settings.h" @@ -21,13 +22,48 @@ #include "syncedproto.h" // for APmac / Channel #include "timer.h" -extern uint8_t __xdata mSelfMac[8]; -extern uint8_t __xdata currentChannel; -extern uint8_t __xdata APmac[]; +// extern uint8_t __xdata mSelfMac[8]; +// extern uint8_t __xdata currentChannel; +// extern uint8_t __xdata APmac[]; +// extern uint16_t __xdata batteryVoltage; const uint8_t __code fwVersion = FW_VERSION; const char __code fwVersionSuffix[] = FW_VERSION_SUFFIX; +bool __xdata lowBatteryShown = false; +bool __xdata noAPShown = false; + +void addOverlay() { + if (currentChannel == 0) { +#if (SCREEN_WIDTH == 152) + loadRawBitmap(ant, SCREEN_WIDTH - 16, 0, EPD_COLOR_BLACK); + loadRawBitmap(cross, SCREEN_WIDTH - 8, 7, EPD_COLOR_RED); +#elif (SCREEN_WIDTH == 128) + loadRawBitmap(ant, 0, 0, EPD_COLOR_BLACK); + loadRawBitmap(cross, 8, 0, EPD_COLOR_RED); +#elif (SCREEN_WIDTH == 400) + loadRawBitmap(ant, SCREEN_WIDTH - 24, 6, EPD_COLOR_BLACK); + loadRawBitmap(cross, SCREEN_WIDTH - 16, 13, EPD_COLOR_RED); +#endif + noAPShown = true; + } else { + noAPShown = false; + } + + if (batteryVoltage != 2600) { +#if (SCREEN_WIDTH == 152) + loadRawBitmap(battery, SCREEN_WIDTH - 16, SCREEN_HEIGHT - 10, EPD_COLOR_BLACK); +#elif (SCREEN_WIDTH == 400) + loadRawBitmap(battery, SCREEN_WIDTH - 24, SCREEN_HEIGHT - 16, EPD_COLOR_BLACK); +#elif (SCREEN_WIDTH == 128) + loadRawBitmap(battery, 112, 0, EPD_COLOR_BLACK); +#endif + lowBatteryShown = true; + } else { + lowBatteryShown = false; + } +} + void showSplashScreen() { selectLUT(EPD_LUT_NO_REPEATS); clearScreen(); @@ -109,7 +145,8 @@ void showSplashScreen() { spr(buffer + 4, "%02X%02X", mSelfMac[5], mSelfMac[4]); spr(buffer + 8, "%02X%02X", mSelfMac[3], mSelfMac[2]); spr(buffer + 12, "%02X%02X", mSelfMac[1], mSelfMac[0]); - printBarcode(buffer, 392, 286); + printBarcode(buffer, 392, 264); + printBarcode(buffer, 384, 264); #endif drawWithSleep(); @@ -169,7 +206,6 @@ void showScanningWindow() { loadRawBitmap(receive, 320, 125, EPD_COLOR_BLACK); #endif - draw(); selectLUT(EPD_LUT_FAST); resultcounter = 0; @@ -180,11 +216,11 @@ void addScanResult(uint8_t channel, uint8_t lqi) { #if (SCREEN_WIDTH == 128) // 2.9" epdPrintBegin(56 + ((resultcounter % 4) * 16), 282 - (47 * (resultcounter / 4)), EPD_DIRECTION_Y, EPD_SIZE_SINGLE, EPD_COLOR_BLACK); #endif -#if (SCREEN_WIDTH ==150) // 1.54" +#if (SCREEN_WIDTH == 152) // 1.54" epdPrintBegin(4 + (47 * (resultcounter / 8)), 31 + (15 * (resultcounter % 8)), EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_BLACK); #endif #if (SCREEN_WIDTH == 400) // 4.2" - epdPrintBegin(4 + (47 * (resultcounter / 8)), 50 + (15 * (resultcounter % 8)), EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_BLACK); + epdPrintBegin(4 + (47 * (resultcounter / 8)), 58 + (15 * (resultcounter % 8)), EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_BLACK); #endif epdpr("%d-%d", channel, lqi); epdPrintEnd(); @@ -260,13 +296,48 @@ void showAPFound() { epdpr("%02X%02X", mSelfMac[1], mSelfMac[0]); epdPrintEnd(); #endif +#if (SCREEN_WIDTH == 400) + epdPrintBegin(10, 10, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK); + epdpr("Waiting for data..."); + epdPrintEnd(); + epdPrintBegin(48, 80, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_BLACK); + epdpr("Found the following AP:"); + epdPrintEnd(); + epdPrintBegin(48, 96, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_BLACK); + epdpr("AP MAC: %02X:%02X", APmac[7], APmac[6]); + epdpr(":%02X:%02X", APmac[5], APmac[4]); + epdpr(":%02X:%02X", APmac[3], APmac[2]); + epdpr(":%02X:%02X", APmac[1], APmac[0]); + epdPrintEnd(); + epdPrintBegin(48, 112, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_BLACK); + epdpr("Ch: %d RSSI: %d LQI: %d", currentChannel, mLastRSSI, mLastLqi); + epdPrintEnd(); + + epdPrintBegin(366, 258, EPD_DIRECTION_Y, EPD_SIZE_SINGLE, EPD_COLOR_BLACK); + epdpr("Tag MAC: %02X:%02X", mSelfMac[7], mSelfMac[6]); + epdpr(":%02X:%02X", mSelfMac[5], mSelfMac[4]); + epdpr(":%02X:%02X", mSelfMac[3], mSelfMac[2]); + epdpr(":%02X:%02X", mSelfMac[1], mSelfMac[0]); + epdPrintEnd(); + + uint8_t __xdata buffer[17]; + spr(buffer, "%02X%02X", mSelfMac[7], mSelfMac[6]); + spr(buffer + 4, "%02X%02X", mSelfMac[5], mSelfMac[4]); + spr(buffer + 8, "%02X%02X", mSelfMac[3], mSelfMac[2]); + spr(buffer + 12, "%02X%02X", mSelfMac[1], mSelfMac[0]); + printBarcode(buffer, 392, 253); + printBarcode(buffer, 384, 253); + loadRawBitmap(receive, 100, 170, EPD_COLOR_BLACK); +#endif + addOverlay(); drawWithSleep(); } void showNoAP() { selectLUT(EPD_LUT_NO_REPEATS); + setColorMode(EPD_MODE_NORMAL, EPD_MODE_INVERT); clearScreen(); -#if (SCREEN_WIDTH == 128) // 1.54" +#if (SCREEN_WIDTH == 128) // 2,9" epdPrintBegin(0, 285, EPD_DIRECTION_Y, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK); epdpr("No AP found :("); epdPrintEnd(); @@ -294,9 +365,36 @@ void showNoAP() { epdpr("a little while"); epdPrintEnd(); #endif +#if (SCREEN_WIDTH == 400) // 4.2" + epdPrintBegin(10, 10, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK); + epdpr("No AP found :("); + epdPrintEnd(); + epdPrintBegin(10, 274, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_BLACK); + epdpr("We'll try again in a little while"); + epdPrintEnd(); + loadRawBitmap(receive, 76, 120, EPD_COLOR_BLACK); + loadRawBitmap(failed, 82, 122, EPD_COLOR_RED); +#endif + addOverlay(); drawWithSleep(); } +void showLongTermSleep() { + selectLUT(EPD_LUT_NO_REPEATS); + setColorMode(EPD_MODE_NORMAL, EPD_MODE_INVERT); + clearScreen(); +#if (SCREEN_WIDTH == 128) // 2.9" + epdPrintBegin(0, 295, EPD_DIRECTION_Y, EPD_SIZE_SINGLE, EPD_COLOR_BLACK); + epdpr("zZ"); + epdPrintEnd(); +#else + epdPrintBegin(2, SCREEN_HEIGHT - 16, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_BLACK); + epdpr("zZ"); + epdPrintEnd(); +#endif + addOverlay(); + drawWithSleep(); +} void showNoEEPROM() { selectLUT(EPD_LUT_NO_REPEATS); clearScreen(); @@ -322,6 +420,15 @@ void showNoEEPROM() { epdPrintBegin(3, 136, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_BLACK); epdpr("Sleeping forever :'("); epdPrintEnd(); +#endif +#if (SCREEN_WIDTH == 400) // 4.2" + epdPrintBegin(50 , 3, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK); + epdpr("EEPROM FAILED :("); + epdPrintEnd(); + loadRawBitmap(failed, 176, 126, EPD_COLOR_RED); + epdPrintBegin(100, 284, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_BLACK); + epdpr("Sleeping forever :'("); + epdPrintEnd(); #endif drawWithSleep(); } @@ -351,7 +458,7 @@ void showNoMAC() { epdpr("Sleeping forever :'("); epdPrintEnd(); #endif -#if (SCREEN_WIDTH == 400) // 1.54" +#if (SCREEN_WIDTH == 400) // 4.2" epdPrintBegin(100, 3, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK); epdpr("NO MAC SET :("); epdPrintEnd(); diff --git a/tag_fw/userinterface.h b/tag_fw/userinterface.h index fa674cc2..2149de35 100644 --- a/tag_fw/userinterface.h +++ b/tag_fw/userinterface.h @@ -2,16 +2,21 @@ #define _UI_H_ #include +void addOverlay(); + void showSplashScreen(); void showApplyUpdate(); void showScanningWindow(); void addScanResult(uint8_t channel, uint8_t lqi); void showAPFound(); void showNoAP(); +void showLongTermSleep(); void showNoEEPROM(); void showNoMAC(); - extern const uint8_t __code fwVersion; extern const char __code fwVersionSuffix[]; +extern bool __xdata lowBatteryShown; +extern bool __xdata noAPShown; + #endif \ No newline at end of file