diff options
author | Gareth Farrington <gareth@waves.ky> | 2024-06-15 19:10:08 -0700 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2025-05-29 19:07:49 -0400 |
commit | 69507a0354e88d68d57671b3bab8aca278f2cefb (patch) | |
tree | 65dff8910c24a194dc98fec919a99fe3bd2776b1 /src | |
parent | 42c9031c8119adc0d2f881aac9c5d222c1beab91 (diff) | |
download | kutter-69507a0354e88d68d57671b3bab8aca278f2cefb.tar.gz kutter-69507a0354e88d68d57671b3bab8aca278f2cefb.tar.xz kutter-69507a0354e88d68d57671b3bab8aca278f2cefb.zip |
sensor_hx71x: Update Sensors to report to load_cell_probe
Signed-off-by: Gareth Farrington <gareth@waves.ky>
Diffstat (limited to 'src')
-rw-r--r-- | src/sensor_ads1220.c | 16 | ||||
-rw-r--r-- | src/sensor_hx71x.c | 16 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/sensor_ads1220.c b/src/sensor_ads1220.c index ea33379a..f51dc355 100644 --- a/src/sensor_ads1220.c +++ b/src/sensor_ads1220.c @@ -11,6 +11,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 "spicmds.h" // spidev_transfer #include <stdint.h> @@ -21,6 +22,7 @@ struct ads1220_adc { struct spidev_s *spi; uint8_t pending_flag, data_count; struct sensor_bulk sb; + struct load_cell_probe *lce; }; // Flag types @@ -94,6 +96,11 @@ ads1220_read_adc(struct ads1220_adc *ads1220, uint8_t oid) if (counts & 0x800000) counts |= 0xFF000000; + // endstop is optional, report if enabled and no errors + if (ads1220->lce) { + load_cell_probe_report_sample(ads1220->lce, counts); + } + add_sample(ads1220, oid, counts); } @@ -111,6 +118,15 @@ command_config_ads1220(uint32_t *args) DECL_COMMAND(command_config_ads1220, "config_ads1220 oid=%c" " spi_oid=%c data_ready_pin=%u"); +void +ads1220_attach_load_cell_probe(uint32_t *args) { + uint8_t oid = args[0]; + struct ads1220_adc *ads1220 = oid_lookup(oid, command_config_ads1220); + ads1220->lce = load_cell_probe_oid_lookup(args[1]); +} +DECL_COMMAND(ads1220_attach_load_cell_probe, + "ads1220_attach_load_cell_probe oid=%c load_cell_probe_oid=%c"); + // start/stop capturing ADC data void command_query_ads1220(uint32_t *args) diff --git a/src/sensor_hx71x.c b/src/sensor_hx71x.c index f20d8807..74575eec 100644 --- a/src/sensor_hx71x.c +++ b/src/sensor_hx71x.c @@ -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) |