sensor_hx71x: Update Sensors to report to load_cell_probe

Signed-off-by: Gareth Farrington <gareth@waves.ky>
This commit is contained in:
Gareth Farrington
2024-06-15 19:10:08 -07:00
committed by Kevin O'Connor
parent 42c9031c81
commit 69507a0354
4 changed files with 45 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
#include "command.h" // DECL_COMMAND
#include "sched.h" // sched_add_timer
#include "sensor_bulk.h" // sensor_bulk_report
#include "load_cell_probe.h" // load_cell_probe_report_sample
#include <stdbool.h>
#include <stdint.h>
@@ -24,6 +25,7 @@ struct hx71x_adc {
struct gpio_in dout; // pin used to receive data from the hx71x
struct gpio_out sclk; // pin used to generate clock for the hx71x
struct sensor_bulk sb;
struct load_cell_probe *lce;
};
enum {
@@ -175,6 +177,11 @@ hx71x_read_adc(struct hx71x_adc *hx71x, uint8_t oid)
counts = hx71x->last_error;
}
// probe is optional, report if enabled
if (hx71x->last_error == 0 && hx71x->lce) {
load_cell_probe_report_sample(hx71x->lce, counts);
}
// Add measurement to buffer
add_sample(hx71x, oid, counts, false);
}
@@ -198,6 +205,15 @@ command_config_hx71x(uint32_t *args)
DECL_COMMAND(command_config_hx71x, "config_hx71x oid=%c gain_channel=%c"
" dout_pin=%u sclk_pin=%u");
void
hx71x_attach_load_cell_probe(uint32_t *args) {
uint8_t oid = args[0];
struct hx71x_adc *hx71x = oid_lookup(oid, command_config_hx71x);
hx71x->lce = load_cell_probe_oid_lookup(args[1]);
}
DECL_COMMAND(hx71x_attach_load_cell_probe, "hx71x_attach_load_cell_probe oid=%c"
" load_cell_probe_oid=%c");
// start/stop capturing ADC data
void
command_query_hx71x(uint32_t *args)