diff --git a/binaries/Tag_FW_1.54.bin b/binaries/Tag_FW_1.54.bin index 1f2bdc2f..81211f53 100644 Binary files a/binaries/Tag_FW_1.54.bin and b/binaries/Tag_FW_1.54.bin differ diff --git a/binaries/Tag_FW_2.9-uc8151.bin b/binaries/Tag_FW_2.9-uc8151.bin index 0cdffe19..79aa26f1 100644 Binary files a/binaries/Tag_FW_2.9-uc8151.bin and b/binaries/Tag_FW_2.9-uc8151.bin differ diff --git a/binaries/Tag_FW_2.9.bin b/binaries/Tag_FW_2.9.bin index 458f6a9a..f2a04d3e 100644 Binary files a/binaries/Tag_FW_2.9.bin and b/binaries/Tag_FW_2.9.bin differ diff --git a/binaries/Tag_FW_4.2.bin b/binaries/Tag_FW_4.2.bin index e51bb0d1..58c84d1b 100644 Binary files a/binaries/Tag_FW_4.2.bin and b/binaries/Tag_FW_4.2.bin differ diff --git a/binaries/Tag_FW_Pack.bin b/binaries/Tag_FW_Pack.bin index 0b9af583..5ee75202 100644 Binary files a/binaries/Tag_FW_Pack.bin and b/binaries/Tag_FW_Pack.bin differ diff --git a/zbs243_Tag_FW/main.c b/zbs243_Tag_FW/main.c index 35344236..e888da30 100755 --- a/zbs243_Tag_FW/main.c +++ b/zbs243_Tag_FW/main.c @@ -103,7 +103,7 @@ uint8_t showChannelSelect() { // returns 0 if no accesspoints were found } } } - + uint8_t __xdata highestLqi = 0; uint8_t __xdata highestSlot = 0; for (uint8_t c = 0; c < sizeof(result); c++) { @@ -154,6 +154,19 @@ void main() { wakeUpReason = WAKEUP_REASON_FIRSTBOOT; } + switch (checkButtonOrJig()) { + case DETECT_P1_0_NOTHING: + break; + case DETECT_P1_0_BUTTON: + capabilities |= CAPABILITY_HAS_WAKE_BUTTON; + break; + case DETECT_P1_0_JIG: + // show splash screen? + break; + default: + break; + } + wdt10s(); boardGetOwnMac(mSelfMac); @@ -179,9 +192,6 @@ void main() { pr("BOOTED> %d.%d.%d%s\n", fwVersion / 100, (fwVersion % 100) / 10, (fwVersion % 10), fwVersionSuffix); -#ifdef HAS_BUTTON - capabilities |= CAPABILITY_HAS_WAKE_BUTTON; -#endif powerUp(INIT_I2C); if (i2cCheckDevice(0x55)) { powerDown(INIT_I2C); diff --git a/zbs243_Tag_FW/powermgt.c b/zbs243_Tag_FW/powermgt.c index b5a0e7ee..7e1094e2 100755 --- a/zbs243_Tag_FW/powermgt.c +++ b/zbs243_Tag_FW/powermgt.c @@ -47,6 +47,30 @@ bool __xdata eepromActive = false; bool __xdata i2cActive = false; extern int8_t adcSampleTemperature(void); // in degrees C +uint8_t checkButtonOrJig() { + P1FUNC &= ~(1 << 0); + P1DIR &= ~(1 << 0); + P1_0 = 0; + timerDelay(TIMER_TICKS_PER_MS * 10); + P1DIR |= (1 << 0); + P1PULL |= (1 << 0); + uint16_t loopcount = 0; + while (loopcount < 20000) { + if (P1_0) { + goto buttonWentHigh; + } + loopcount++; + } + pr("Jig detected (P1.0 low during boot)\n"); + return DETECT_P1_0_JIG; +buttonWentHigh: + if (loopcount > 130) { // 10nF, or thereabout + pr("Detected about %d nF capacitance on P1.0, probably a button\n", loopcount / 13); + return DETECT_P1_0_BUTTON; + } + return DETECT_P1_0_NOTHING; +} + void setupPortsInitial() { P0INTEN = 0; P1INTEN = 0; @@ -259,15 +283,15 @@ void doSleep(const uint32_t __xdata t) { uartActive = false; eepromActive = false; -#ifdef HAS_BUTTON - // Button setup on TEST pin 1.0 (input pullup) + if (capabilities & CAPABILITY_HAS_WAKE_BUTTON) { + // Button setup on TEST pin 1.0 (input pullup) P1FUNC &= ~(1 << 0); P1DIR |= (1 << 0); P1PULL |= (1 << 0); P1LVLSEL |= (1 << 0); P1INTEN = (1 << 0); P1CHSTA &= ~(1 << 0); -#endif + } if (capabilities & CAPABILITY_NFC_WAKE) { P1FUNC &= ~(1 << 3); @@ -280,18 +304,16 @@ void doSleep(const uint32_t __xdata t) { // sleepy sleepForMsec(t); -#ifdef HAS_BUTTON P1INTEN = 0; - if (P1CHSTA && (1 << 0)) { + if ((P1CHSTA & (1 << 0)) && (capabilities & CAPABILITY_HAS_WAKE_BUTTON)) { wakeUpReason = WAKEUP_REASON_GPIO; P1CHSTA &= ~(1 << 0); } - if (P1CHSTA && (1 << 3) && capabilities & CAPABILITY_NFC_WAKE) { + if ((P1CHSTA & (1 << 3)) && (capabilities & CAPABILITY_NFC_WAKE)) { wakeUpReason = WAKEUP_REASON_NFC; P1CHSTA &= ~(1 << 3); } -#endif } uint32_t getNextScanSleep(const bool increment) { diff --git a/zbs243_Tag_FW/powermgt.h b/zbs243_Tag_FW/powermgt.h old mode 100644 new mode 100755 index f9a36434..d45374c9 --- a/zbs243_Tag_FW/powermgt.h +++ b/zbs243_Tag_FW/powermgt.h @@ -9,6 +9,10 @@ #define WAKEUP_REASON_NETWORK_SCAN 0xFD #define WAKEUP_REASON_WDT_RESET 0xFE +#define DETECT_P1_0_NOTHING 0 +#define DETECT_P1_0_BUTTON 1 +#define DETECT_P1_0_JIG 2 + #define INIT_EPD_VOLTREADING 0x80 #define INIT_RADIO 0x40 #define INIT_I2C 0x20 @@ -41,6 +45,8 @@ #define INTERVAL_2_ATTEMPTS 12 // for 12 attempts (an additional day) #define INTERVAL_3_TIME 86400UL // Finally, try every day +extern uint8_t checkButtonOrJig(); + extern void setupPortsInitial(); extern void powerUp(const uint8_t parts); diff --git a/zbs243_Tag_FW/settings.h b/zbs243_Tag_FW/settings.h index 270258c6..5988f7fb 100755 --- a/zbs243_Tag_FW/settings.h +++ b/zbs243_Tag_FW/settings.h @@ -3,9 +3,8 @@ #include -#define FW_VERSION 015 // version number (max 2.5.5 :) ) -#define FW_VERSION_SUFFIX "-RF" // 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 +#define FW_VERSION 016 // version number (max 2.5.5 :) ) +#define FW_VERSION_SUFFIX "-BD" // suffix, like -RC1 or whatever. +// #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/zbs243_Tag_FW/userinterface.c b/zbs243_Tag_FW/userinterface.c index 8cb586c0..fba7bc0b 100755 --- a/zbs243_Tag_FW/userinterface.c +++ b/zbs243_Tag_FW/userinterface.c @@ -14,13 +14,13 @@ #include "lut.h" #include "powermgt.h" #include "printf.h" +#include "proto.h" #include "screen.h" #include "settings.h" #include "sleep.h" #include "spi.h" #include "syncedproto.h" // for APmac / Channel #include "timer.h" -#include "proto.h" // extern uint8_t __xdata mSelfMac[8]; // extern uint8_t __xdata currentChannel; @@ -36,12 +36,17 @@ bool __xdata lowBatteryShown = false; bool __xdata noAPShown = false; void addCapabilities() { - epdpr("Options: "); + if (capabilities) epdpr("Options: "); if (capabilities & CAPABILITY_HAS_NFC) { - epdpr("-NFC "); + epdpr("-NFC"); + if (capabilities & CAPABILITY_NFC_WAKE) { + epdpr("+WAKE"); + } else { + epdpr(" "); + } } if (capabilities & CAPABILITY_HAS_WAKE_BUTTON) { - epdpr("-WAKE BUTTON" ); + epdpr("-WAKE BUTTON"); } } @@ -112,7 +117,6 @@ void showSplashScreen() { epdpr("Starting"); epdPrintEnd(); - epdPrintBegin(64, 295, EPD_DIRECTION_Y, EPD_SIZE_SINGLE, EPD_COLOR_BLACK); addCapabilities(); epdPrintEnd(); @@ -128,7 +132,6 @@ void showSplashScreen() { 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]); @@ -210,9 +213,9 @@ void showScanningWindow() { epdPrintBegin(2, 275, EPD_DIRECTION_Y, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK); epdpr("Scanning for APs"); epdPrintEnd(); - //epdPrintBegin(40, 262, EPD_DIRECTION_Y, EPD_SIZE_SINGLE, EPD_COLOR_RED); - //epdpr("Channel - Quality"); - //epdPrintEnd(); + // epdPrintBegin(40, 262, EPD_DIRECTION_Y, EPD_SIZE_SINGLE, EPD_COLOR_RED); + // epdpr("Channel - Quality"); + // epdPrintEnd(); loadRawBitmap(receive, 36, 24, EPD_COLOR_BLACK); #endif #if (SCREEN_WIDTH == 152) // 1.54" @@ -226,9 +229,9 @@ void showScanningWindow() { epdpr("Scanning for APs"); epdPrintEnd(); - //epdPrintBegin(2, 40, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_RED); - //epdpr("Channel - Quality"); - //epdPrintEnd(); + // epdPrintBegin(2, 40, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_RED); + // epdpr("Channel - Quality"); + // epdPrintEnd(); loadRawBitmap(receive, 320, 125, EPD_COLOR_BLACK); #endif