mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-28 06:07:53 +01:00
Removed button option in settings.h, firmware now checks for its presence
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
6
zbs243_Tag_FW/powermgt.h
Normal file → Executable file
6
zbs243_Tag_FW/powermgt.h
Normal file → Executable file
@@ -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);
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#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
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user