Aruna
aruna::sensor::Rain40x16 Class Reference

#include <Rain40x16.h>

Inheritance diagram for aruna::sensor::Rain40x16:
Collaboration diagram for aruna::sensor::Rain40x16:

Public Member Functions

 Rain40x16 (driver::ADC *adc)
 Rainlevel sensor 40mmx16mm DC3-5V Currently hardcoded for 3.3V. More...
 
err_t get_water_level (uint16_t &water_level_in_mm) override
 Get water level in millimeters of the sensor. More...
 
- Public Member Functions inherited from aruna::sensor::Water
 Water ()
 Water sensor. More...
 
err_t is_wet (bool &water_detected)
 Is water detected at the sensor? More...
 
sis::status_tupdate_status () override
 Perform check to see if system is secure and return updated status. More...
 
void set_sis_status_location (char *location)
 Set the location of the sensor. More...
 
- Public Member Functions inherited from aruna::sis::Performer
 Performer ()
 Performs check to see if the system is in a secure state. More...
 
 ~Performer ()
 
void set_update (bool do_update)
 Use to pauze and resume the update process. More...
 

Private Member Functions

int16_t voltage_to_mm (uint16_t mV)
 

Private Attributes

driver::ADCadc
 

Additional Inherited Members

- Public Attributes inherited from aruna::sis::Performer
uint32_t update_ms = 500
 update frequency More...
 
- Protected Member Functions inherited from aruna::sis::Performer
void update_handler ()
 
- Static Protected Member Functions inherited from aruna::sis::Performer
static void * _update_handler (void *_this)
 
- Protected Attributes inherited from aruna::sis::Performer
pthread_t thread
 
pthread_cond_t do_update_con
 
pthread_mutex_t do_update_mut
 
log::channel_tlog
 
char log_tag [10] = "SIS perf"
 
bool do_update = false
 
bool interrupt_based = false
 

Detailed Description

Definition at line 12 of file Rain40x16.h.

Constructor & Destructor Documentation

◆ Rain40x16()

aruna::sensor::Rain40x16::Rain40x16 ( driver::ADC adc)

Rainlevel sensor 40mmx16mm DC3-5V Currently hardcoded for 3.3V.

Parameters
adcADC to use for conversion

Definition at line 8 of file Rain40x16.cpp.

8  : adc(adc) {
9 
10 }
driver::ADC * adc
Definition: Rain40x16.h:14

Member Function Documentation

◆ get_water_level()

aruna::err_t aruna::sensor::Rain40x16::get_water_level ( uint16_t &  water_level_in_mm)
overridevirtual

Get water level in millimeters of the sensor.

Parameters
water_level_in_mmbuffer to store water level in
Returns
err_t::OK if water level could be retrieved

Implements aruna::sensor::Water.

Definition at line 12 of file Rain40x16.cpp.

12  {
13  int16_t mV;
14  err_t e;
15  e = adc->read_voltage(mV);
16  water_level_in_mm = voltage_to_mm(mV);
17  return e;
18 }
int16_t voltage_to_mm(uint16_t mV)
Definition: Rain40x16.cpp:20
err_t read_voltage(T &mV)
Read voltage level of input.
driver::ADC * adc
Definition: Rain40x16.h:14
Here is the call graph for this function:

◆ voltage_to_mm()

int16_t aruna::sensor::Rain40x16::voltage_to_mm ( uint16_t  mV)
private

Definition at line 20 of file Rain40x16.cpp.

20  {
21 // TODO vcc etc as parameters
22  const int16_t sensor_length_mm = 40;
23  const int16_t max_voltage_when_dry = 20;
24  const int16_t voltage_at_min = 1000;
25  const int16_t voltage_at_max = 3300;
26 
27  const int16_t voltage_diff = voltage_at_max - voltage_at_min;
28 
29  if (mV < max_voltage_when_dry)
30  return 0;
31  if (mV < voltage_at_min) {
32 // voltage is in grey space.
33  return 1;
34  }
35 // TODO this conversion is linear while in real-life it is not
36  return ceilf(((float) mV - (float) voltage_at_min) * ((float) sensor_length_mm / (float) voltage_diff));
37 
38 }
Here is the caller graph for this function:

Member Data Documentation

◆ adc

driver::ADC* aruna::sensor::Rain40x16::adc
private

Definition at line 14 of file Rain40x16.h.


The documentation for this class was generated from the following files: