summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2025-05-01 14:27:06 +0800
committerSadeep Madurange <sadeep@asciimx.com>2025-05-01 14:27:06 +0800
commit14d4c6d56c0f999bbd7d8a2331e463192155dc7e (patch)
tree188197eae88fb3e05253b8cf5491c42d7494d21b
parenta1de6ebc054c84e1f27b21998cb017ae38151a2e (diff)
downloadsmart-home-14d4c6d56c0f999bbd7d8a2331e463192155dc7e.tar.gz
Battery check for front end and increase thresh for backend.
-rw-r--r--lock/bend.c2
-rw-r--r--lock/fend.c27
2 files changed, 28 insertions, 1 deletions
diff --git a/lock/bend.c b/lock/bend.c
index 2c18996..da8f2e6 100644
--- a/lock/bend.c
+++ b/lock/bend.c
@@ -29,7 +29,7 @@
#define RX_PCMSK PCMSK2
#define RX_PCINTVEC PCINT2_vect
-#define VCC_MIN 4810 /* servo min voltage. */
+#define VCC_MIN 4900
#define LOCK_LED PC3
#define UNLOCK_LED PC4
diff --git a/lock/fend.c b/lock/fend.c
index 7177e72..39854c6 100644
--- a/lock/fend.c
+++ b/lock/fend.c
@@ -23,6 +23,14 @@
#define RX_PCMSK PCMSK2
#define RX_PCINTVEC PCINT2_vect
+#define VCC_MIN 4000
+
+#define LOCK_LED PC3
+#define UNLOCK_LED PC4
+#define BATLOW_LED PC5
+#define LED_DDR DDRC
+#define LED_PORT PORTC
+
static volatile uint8_t rxd = 0;
static volatile uint8_t sync = 0;
static volatile uint8_t islock = 0;
@@ -54,8 +62,19 @@ static inline void init_btns(void)
EIMSK = (1 << INT0) | (1 << INT1);
}
+static inline void init_leds(void)
+{
+ LED_DDR |= (1 << LOCK_LED) | (1 << UNLOCK_LED);
+ LED_DDR |= (1 << BATLOW_LED);
+
+ LED_PORT &= ~(1 << LOCK_LED);
+ LED_PORT &= ~(1 << UNLOCK_LED);
+ LED_PORT &= ~(1 << BATLOW_LED);
+}
+
int main(void)
{
+ int i;
uint8_t rxaddr[ADDRLEN] = { 194, 178, 82 };
uint8_t txaddr[ADDRLEN] = { 194, 178, 83 };
@@ -63,6 +82,7 @@ int main(void)
wdt_off();
init_rx();
+ init_leds();
init_btns();
uart_init();
@@ -99,6 +119,13 @@ int main(void)
}
if (!sync) {
+ if (getvcc() < VCC_MIN) {
+ for (i = 0; i < 5; i++) {
+ LED_PORT ^= (1 << BATLOW_LED);
+ _delay_ms(100);
+ }
+ }
+
radio_pwr_dwn();
sleep_enable();
sleep_bod_disable();