|
pico-scale
|
#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include "pico/time.h"#include "mass.h"#include "scale_adaptor.h"Go to the source code of this file.
Data Structures | |
| struct | scale_options_t |
| struct | scale_t |
Enumerations | |
| enum | strategy_type_t { strategy_type_samples = 0 , strategy_type_time } |
| enum | read_type_t { read_type_median = 0 , read_type_average } |
Functions | |
| void | scale_options_get_default (scale_options_t *const opt) |
| Fill options will default values. More... | |
| void | scale_init (scale_t *const sc, scale_adaptor_t *const adaptor, const mass_unit_t unit, const int32_t ref_unit, const int32_t offset) |
| Initialise the scale with a hx711_t. More... | |
| bool | scale_normalise (const scale_t *const sc, const double *const raw, double *const normalised) |
| Adjusts a raw value to a normalised value according to the scale's reference unit and offset. Returns true if the operation succeeded. More... | |
| bool | scale_get_values_samples (scale_t *const sc, int32_t *const arr, const size_t len) |
| Fills arr with len number of samples from the scale. Returns true if the operation succeeded. More... | |
| bool | scale_get_values_timeout (scale_t *const sc, int32_t *const arr, const size_t arrlen, size_t *const len, const uint timeout) |
| Fills arr with as many number of samples as possible up to the timeout. Returns true if the operation succeeded. More... | |
| bool | scale_read (scale_t *const sc, double *const val, const scale_options_t *const opt) |
| Obtains a value from the scale according to the given options. Returns true if the operation succeeded. More... | |
| bool | scale_zero (scale_t *const sc, const scale_options_t *const opt) |
| Zeros the scale (tare) by adjusting its offset from 0 according to the given options. Returns true if the operation succeeded. More... | |
| bool | scale_weight (scale_t *const sc, mass_t *const m, const scale_options_t *const opt) |
| Obtains a weight from the scale according to the given options. Returns true if the operation succeeded. More... | |
Variables | |
| static const scale_options_t | SCALE_DEFAULT_OPTIONS |
| enum read_type_t |
| enum strategy_type_t |
| bool scale_get_values_samples | ( | scale_t *const | sc, |
| int32_t *const | arr, | ||
| const size_t | len | ||
| ) |
Fills arr with len number of samples from the scale. Returns true if the operation succeeded.
| sc | |
| arr | |
| len |
Definition at line 76 of file scale.c.
References scale_t::_adaptor, and scale_adaptor::get_value.
Referenced by scale_read().
| bool scale_get_values_timeout | ( | scale_t *const | sc, |
| int32_t *const | arr, | ||
| const size_t | arrlen, | ||
| size_t *const | len, | ||
| const uint | timeout | ||
| ) |
Fills arr with as many number of samples as possible up to the timeout. Returns true if the operation succeeded.
| sc | |
| arr | buffer |
| arrlen | Size of buffer |
| len | Will be set to the number of samples obtained |
| timeout | Microseconds |
Definition at line 95 of file scale.c.
References scale_t::_adaptor, and scale_adaptor::get_value_timeout.
Referenced by scale_read().
| void scale_init | ( | scale_t *const | sc, |
| scale_adaptor_t *const | adaptor, | ||
| const mass_unit_t | unit, | ||
| const int32_t | ref_unit, | ||
| const int32_t | offset | ||
| ) |
Initialise the scale with a hx711_t.
| sc | Pointer to scale_t |
| hx | Pointer to hx711_t |
| unit | The mass_unit_t to output mass_t's in |
| ref_unit | The reference unit to use (see: calibration) |
| offset | The offset from 0 (see: calibration) |
Definition at line 39 of file scale.c.
References scale_t::_adaptor, scale_t::offset, scale_t::ref_unit, and scale_t::unit.
| bool scale_normalise | ( | const scale_t *const | sc, |
| const double *const | raw, | ||
| double *const | normalised | ||
| ) |
Adjusts a raw value to a normalised value according to the scale's reference unit and offset. Returns true if the operation succeeded.
| sc | |
| raw | |
| normalised |
Definition at line 57 of file scale.c.
References scale_t::offset, and scale_t::ref_unit.
Referenced by scale_weight().
| void scale_options_get_default | ( | scale_options_t *const | opt | ) |
Fill options will default values.
| opt |
Definition at line 33 of file scale.c.
References SCALE_DEFAULT_OPTIONS.
| bool scale_read | ( | scale_t *const | sc, |
| double *const | val, | ||
| const scale_options_t *const | opt | ||
| ) |
Obtains a value from the scale according to the given options. Returns true if the operation succeeded.
| sc | |
| val | |
| opt |
Definition at line 153 of file scale.c.
References scale_options_t::buffer, scale_options_t::bufflen, scale_options_t::read, read_type_average, read_type_median, scale_options_t::samples, scale_get_values_samples(), scale_get_values_timeout(), scale_options_t::strat, strategy_type_samples, strategy_type_time, scale_options_t::timeout, util_average(), and util_median().
Referenced by scale_weight(), and scale_zero().
| bool scale_weight | ( | scale_t *const | sc, |
| mass_t *const | m, | ||
| const scale_options_t *const | opt | ||
| ) |
Obtains a weight from the scale according to the given options. Returns true if the operation succeeded.
| sc | |
| m | |
| opt |
Definition at line 231 of file scale.c.
References mass_init(), scale_normalise(), scale_read(), and scale_t::unit.
| bool scale_zero | ( | scale_t *const | sc, |
| const scale_options_t *const | opt | ||
| ) |
Zeros the scale (tare) by adjusting its offset from 0 according to the given options. Returns true if the operation succeeded.
| sc | |
| opt |
Definition at line 206 of file scale.c.
References scale_t::offset, scale_t::ref_unit, and scale_read().
|
static |
Definition at line 56 of file scale.h.
Referenced by scale_options_get_default().