From 2a0270f3ba6eb993fb39ed3564f626d724156654 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 26 Jun 2022 17:40:36 +0200 Subject: implement battery measurement and target area switching --- shared/consts.h | 11 +++++++++++ shared/protocol.h | 1 + 2 files changed, 12 insertions(+) (limited to 'shared') diff --git a/shared/consts.h b/shared/consts.h index 9c2358f..b6be4a4 100644 --- a/shared/consts.h +++ b/shared/consts.h @@ -52,3 +52,14 @@ #define W2_BATTERY_PIN 6 /** side-facing distance sensor pinout */ #define W2_SIDE_SENSOR_PIN 7 + +/** battery voltage measurement sample count */ +#define W2_BATTERY_SAMPLES 10 +/** battery full voltage (millivolts) */ +#define W2_BATTERY_FULL 4500 +/** battery empty voltage (millivolts) */ +#define W2_BATTERY_EMPTY 3300 +/** battery measurement interval (milliseconds) */ +#define W2_BATTERY_MEAS_FREQ 10e3 +/** battery low level percentage (target charging station) */ +#define W2_BATTERY_PERCENTAGE_LOW 30 diff --git a/shared/protocol.h b/shared/protocol.h index c13e56c..83d9111 100644 --- a/shared/protocol.h +++ b/shared/protocol.h @@ -155,6 +155,7 @@ typedef struct { uint32_t uptime_s; uint8_t mode; uint16_t battery_mv; + uint8_t battery_percent; } w2_s_cmd_info_tx; typedef struct { -- cgit v1.2.3