Skip to content

Commit 927f9b9

Browse files
committed
drivers: people_counter: Add support for L/R pass
Signed-off-by: Pavel Hübner <[email protected]>
1 parent cd2f2fc commit 927f9b9

File tree

4 files changed

+7
-25
lines changed

4 files changed

+7
-25
lines changed

drivers/people_counter/people_counter.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* SPDX-License-Identifier: LicenseRef-HARDWARIO-5-Clause
55
*/
66

7-
#include "people_counter_reg.h"
8-
97
/* CHESTER includes */
108
#include <chester/drivers/people_counter.h>
119

@@ -77,7 +75,7 @@ static int people_counter_read_measurement_(const struct device *dev,
7775
int ret;
7876

7977
uint8_t reg = 0;
80-
uint8_t buf[18];
78+
uint8_t buf[24];
8179
ret = i2c_write_read(get_config(dev)->i2c_dev, get_config(dev)->i2c_addr, &reg, 1, buf,
8280
sizeof(buf));
8381
if (ret) {
@@ -93,6 +91,8 @@ static int people_counter_read_measurement_(const struct device *dev,
9391
measurement->total_time_adult = sys_get_le16(&buf[10]);
9492
measurement->total_time_child = sys_get_le16(&buf[12]);
9593
measurement->consumed_energy = sys_get_le32(&buf[14]);
94+
measurement->pass_counter_left = sys_get_le16(&buf[18]);
95+
measurement->pass_counter_right = sys_get_le16(&buf[22]);
9696

9797
return 0;
9898
}

drivers/people_counter/people_counter_reg.h

-22
This file was deleted.

include/chester/drivers/people_counter.h

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ struct people_counter_measurement {
3131
uint16_t total_time_adult;
3232
uint16_t total_time_child;
3333
uint32_t consumed_energy;
34+
uint16_t pass_counter_left;
35+
uint16_t pass_counter_right;
3436
};
3537

3638
/** @private */

samples/people_counter/src/main.c

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ int main(void)
5454
k_oops();
5555
} else {
5656
LOG_INF("Motion counter: %u", measurement.motion_counter);
57+
LOG_INF("Pass counter (left): %u", measurement.pass_counter_left);
58+
LOG_INF("Pass counter (right): %u", measurement.pass_counter_right);
5759
LOG_INF("Pass counter (adult): %u", measurement.pass_counter_adult);
5860
LOG_INF("Pass counter (child): %u", measurement.pass_counter_child);
5961
LOG_INF("Stay counter (adult): %u", measurement.stay_counter_adult);

0 commit comments

Comments
 (0)