vdiv: Added vdiv C source.

Multiple changes related to building the vdiv c source w/c example.

    * Renamed GroveVdiv to vdiv (all cases) throughout source, examples,
    directory names, and documentation.

    * Added C source.

    * Tested C sensor code on edison

    * Updated CMakeLists.txt for examples-c to build from
    <sensorname>-c.  This was a small change to get c examples to build
    for sensors in which the C++ does NOT wrap the C.

    * Added C example for vdiv.

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck 2016-09-01 16:32:49 -07:00
parent 668aa320b9
commit b608232cb9
20 changed files with 523 additions and 66 deletions

View File

@ -21,7 +21,7 @@ groverotary.cxx GroveRotarySample.java
grovescam.cxx GROVESCAMSample.java
groveslide.cxx GroveSlideSample.java
grovespeaker.cxx GroveSpeakerSample.java
grovevdiv.cxx GroveVDivSample.java
vdiv.cxx VDivSample.java
grovewater.cxx GroveWaterSample.java
grovewfs.cxx GroveWFSSample.java
guvas12d.cxx GUVAS12DSample.java

View File

@ -146,7 +146,7 @@ add_example (grovemoisture)
add_example (groveehr)
add_example (ta12200)
add_example (grovelinefinder)
add_example (grovevdiv)
add_example (vdiv)
add_example (grovewater)
add_example (guvas12d)
add_example (mpr121)

View File

@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "grovevdiv.hpp"
#include "vdiv.hpp"
using namespace std;
@ -44,7 +44,7 @@ int main ()
//! [Interesting]
// Instantiate a Grove Voltage Divider sensor on analog pin A0
upm::GroveVDiv* vDiv = new upm::GroveVDiv(0);
upm::VDiv* vDiv = new upm::VDiv(0);
// collect data and output measured voltage according to the setting
// of the scaling switch (3 or 10)

View File

@ -38,7 +38,7 @@ macro(add_custom_example example_bin example_src example_module_list)
if (${module} STREQUAL "lcd")
set(module "i2clcd")
endif()
target_link_libraries (${example_bin} ${module})
target_link_libraries (${example_bin} ${module}-c)
endforeach()
else()
MESSAGE(INFO " Ignored ${example_bin}")
@ -94,6 +94,7 @@ add_example (urm37)
add_example (urm37-uart)
add_example (hka5)
add_example (dfrorp)
add_example (vdiv)
# Custom examples
add_custom_example (nmea_gps_i2c-example-c nmea_gps_i2c.c nmea_gps)

74
examples/c/vdiv.c Normal file
View File

@ -0,0 +1,74 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <signal.h>
#include "vdiv.h"
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a sensor on analog pin A0
vdiv_context sensor = vdiv_init(0, 5);
if (!sensor)
{
printf("vdiv_init() failed.\n");
return(1);
}
// Every half a second, sample the sensor output
while (shouldRun)
{
float raw_volts = 0.0, computed_volts = 0.0;
vdiv_get_raw_volts(sensor, &raw_volts);
vdiv_get_computed_volts(sensor, &computed_volts);
printf("Divide SW: %d ADC voltage: %0.03f Sensor voltage: %0.03f\n",
vdiv_get_divsw(sensor), raw_volts, computed_volts);
usleep(500000);
}
//! [Interesting]
printf("Exiting\n");
vdiv_close(sensor);
return 0;
}

View File

@ -52,7 +52,7 @@ add_example(GROVESCAMSample grovescam)
add_example(GroveSlideSample grove)
add_example(GroveSpeakerSample grovespeaker)
add_example(GroveTempSample grove)
add_example(GroveVDivSample grovevdiv)
add_example(VDivSample vdiv)
add_example(GroveWaterSample grovewater)
add_example(GroveWFSSample grovewfs)
add_example(GUVAS12DSample guvas12d)

View File

@ -23,14 +23,14 @@
*/
//NOT TESTED!!!
public class GroveVDivSample {
public class VDivSample {
private static final short gain3 = 3;
private static final short gain10 = 10;
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// Instantiate a Grove Voltage Divider sensor on analog pin A0
upm_grovevdiv.GroveVDiv vDiv = new upm_grovevdiv.GroveVDiv(0);
upm_vdiv.VDiv vDiv = new upm_vdiv.VDiv(0);
// collect data and output measured voltage according to the setting
// of the scaling switch (3 or 10)

View File

@ -22,9 +22,9 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var voltageDivider = require('jsupm_grovevdiv');
var voltageDivider = require('jsupm_vdiv');
// Instantiate a Grove Voltage Divider sensor on analog pin A0
var myVoltageDivider = new voltageDivider.GroveVDiv(0);
var myVoltageDivider = new voltageDivider.VDiv(0);
// collect data and output measured voltage according to the setting
// of the scaling switch (3 or 10)

View File

@ -22,22 +22,22 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import time, sys, signal, atexit
import pyupm_grovevdiv as upmGrovevdiv
import pyupm_vdiv as upmvdiv
# Instantiate a Grove Voltage Divider sensor on analog pin A0
myVoltageDivider = upmGrovevdiv.GroveVDiv(0)
# Instantiate a Voltage Divider sensor on analog pin A0
myVoltageDivider = upmvdiv.VDiv(0)
## Exit handlers ##
# This stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
raise SystemExit
# This function lets you run code on exit,
# including functions from myVoltageDivider
def exitHandler():
print "Exiting"
sys.exit(0)
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
@ -45,10 +45,10 @@ signal.signal(signal.SIGINT, SIGINTHandler)
while(1):
val = myVoltageDivider.value(100)
gain3val = myVoltageDivider.computedValue(3, val)
gain10val = myVoltageDivider.computedValue(10, val)
print "ADC value: {0} Gain 3: {1}v Gain 10: {2}v".format(
val, gain3val, gain10val)
val = myVoltageDivider.value(100)
gain3val = myVoltageDivider.computedValue(3, val)
gain10val = myVoltageDivider.computedValue(10, val)
print "ADC value: {0} Gain 3: {1}v Gain 10: {2}v".format(
val, gain3val, gain10val)
time.sleep(1)
time.sleep(1)

View File

@ -1,5 +0,0 @@
set (libname "grovevdiv")
set (libdescription "upm grove voltage divider module")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init()

View File

@ -1,8 +0,0 @@
%module jsupm_grovevdiv
%include "../upm.i"
%{
#include "grovevdiv.hpp"
%}
%include "grovevdiv.hpp"

8
src/vdiv/CMakeLists.txt Normal file
View File

@ -0,0 +1,8 @@
upm_mixed_module_init (NAME vdiv
DESCRIPTION "upm grove voltage divider module"
C_HDR vdiv.h
C_SRC vdiv.c
CPP_HDR vdiv.hpp
CPP_SRC vdiv.cxx
FTI_SRC vdiv_fti.c
REQUIRES mraa)

View File

@ -1,16 +1,16 @@
%module javaupm_grovevdiv
%module javaupm_vdiv
%include "../upm.i"
%{
#include "grovevdiv.hpp"
#include "vdiv.hpp"
%}
%include "grovevdiv.hpp"
%include "vdiv.hpp"
%pragma(java) jniclasscode=%{
static {
try {
System.loadLibrary("javaupm_grovevdiv");
System.loadLibrary("javaupm_vdiv");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. \n" + e);
System.exit(1);

8
src/vdiv/jsupm_vdiv.i Normal file
View File

@ -0,0 +1,8 @@
%module jsupm_vdiv
%include "../upm.i"
%{
#include "vdiv.hpp"
%}
%include "vdiv.hpp"

View File

@ -1,11 +1,11 @@
// Include doxygen-generated documentation
%include "pyupm_doxy2swig.i"
%module pyupm_grovevdiv
%module pyupm_vdiv
%include "../upm.i"
%feature("autodoc", "3");
%include "grovevdiv.hpp"
%include "vdiv.hpp"
%{
#include "grovevdiv.hpp"
#include "vdiv.hpp"
%}

122
src/vdiv/vdiv.c Normal file
View File

@ -0,0 +1,122 @@
/*
* Author:
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <stdlib.h>
#include "vdiv.h"
vdiv_context vdiv_init(int16_t pin, float voltage_ref)
{
vdiv_context dev = (vdiv_context)malloc(sizeof(struct _vdiv_context));
if (dev == NULL) return NULL;
/* Init aio pin */
dev->aio = mraa_aio_init(pin);
if (dev->aio == NULL) {
free(dev);
return NULL;
}
/* Set defaults */
dev->m_aRef = 5.0;
dev->m_scale = 1.0;
dev->m_offset = 0.0;
dev->m_vdiv_sw = 3;
return dev;
}
void vdiv_close(vdiv_context dev)
{
mraa_aio_close(dev->aio);
free(dev);
}
upm_result_t vdiv_set_scale(const vdiv_context dev, float scale)
{
dev->m_scale = scale;
return UPM_SUCCESS;
}
upm_result_t vdiv_set_offset(const vdiv_context dev, float offset)
{
dev->m_offset = offset;
return UPM_SUCCESS;
}
float vdiv_get_scale(const vdiv_context dev)
{
return dev->m_scale;
}
float vdiv_get_offset(const vdiv_context dev)
{
return dev->m_offset;
}
upm_result_t vdiv_set_divsw(const vdiv_context dev, int vdiv_sw)
{
dev->m_vdiv_sw = vdiv_sw;
return UPM_SUCCESS;
}
int vdiv_get_divsw(const vdiv_context dev)
{
return dev->m_vdiv_sw;
}
upm_result_t vdiv_get_raw_volts(const vdiv_context dev, float *value)
{
*value = mraa_aio_read_float(dev->aio);
if (*value < 0)
return UPM_ERROR_OPERATION_FAILED;
/* Scale by the ADC reference voltage */
*value *= dev->m_aRef;
return UPM_SUCCESS;
}
upm_result_t vdiv_get_computed_volts(const vdiv_context dev, float *value)
{
// JET - this is wrong.
*value = mraa_aio_read_float(dev->aio);
if (*value < 0)
return UPM_ERROR_OPERATION_FAILED;
/* Apply raw scale */
*value *= dev->m_scale;
/* Scale to the ADC referecen then to vdiv gain */
*value *= dev->m_aRef * dev->m_vdiv_sw;
/* Apply the offset in volts */
*value += dev->m_offset;
return UPM_SUCCESS;
}

View File

@ -26,12 +26,12 @@
#include <string>
#include <stdexcept>
#include "grovevdiv.hpp"
#include "vdiv.hpp"
using namespace upm;
using namespace std;
GroveVDiv::GroveVDiv(int pin)
VDiv::VDiv(int pin)
{
if ( !(m_aio = mraa_aio_init(pin)) )
{
@ -41,12 +41,12 @@ GroveVDiv::GroveVDiv(int pin)
}
}
GroveVDiv::~GroveVDiv()
VDiv::~VDiv()
{
mraa_aio_close(m_aio);
}
unsigned int GroveVDiv::value(unsigned int samples)
unsigned int VDiv::value(unsigned int samples)
{
unsigned int sum = 0;
@ -60,7 +60,7 @@ unsigned int GroveVDiv::value(unsigned int samples)
return (sum / samples);
}
float GroveVDiv::computedValue(uint8_t gain, unsigned int val, int vref, int res)
float VDiv::computedValue(uint8_t gain, unsigned int val, int vref, int res)
{
return ((float(gain) * float(val) * float(vref) / float(res)) / 1000.0);

139
src/vdiv/vdiv.h Normal file
View File

@ -0,0 +1,139 @@
/*
* Author:
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include "upm.h"
#include "mraa/aio.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* device context
*/
typedef struct _vdiv_context {
/* mraa aio pin context */
mraa_aio_context aio;
/* ADC voltage reference */
float m_aRef;
/* Scale */
float m_scale;
/* Offset in sensor units */
float m_offset;
/* Offset in sensor units */
int m_vdiv_sw;
} *vdiv_context;
/**
* Initialize analog sensor
* @param pin is Analog pin
* @return sensor context as void pointer
*/
vdiv_context vdiv_init(int16_t pin, float voltage_ref);
/**
* Analog sensor destructor
* @param sensor context pointer deallocate memory
*/
void vdiv_close(vdiv_context dev);
/**
* Set sensor scale. This scale is applied to the return value:
* counts = counts * scale
* @param dev sensor context pointer
* @param scale count scale value used
* @return Function result code
*/
upm_result_t vdiv_set_scale(const vdiv_context dev, float scale);
/**
* Set sensor offset. This offset is applied to the return value:
* counts = counts + offset
* @param dev sensor context pointer
* @param offset count offset value used
* @return Function result code
*/
upm_result_t vdiv_set_offset(const vdiv_context dev, float offset);
/**
* Get sensor scale
* @param dev sensor context pointer
* @return Sensor scale
*/
float vdiv_get_scale(const vdiv_context dev);
/**
* Get sensor offset
* @param dev sensor context pointer
* @return Sensor offset
*/
float vdiv_get_offset(const vdiv_context dev);
/**
* Set sensor divide switch value
* @param dev sensor context pointer
* @param vdiv_sw Divide switch value
* @return Function result code
*/
upm_result_t vdiv_set_divsw(const vdiv_context dev, int vdiv_sw);
/**
* Get divide switch value
* @param dev sensor context pointer
* @return Sensor divide switch value
*/
int vdiv_get_divsw(const vdiv_context dev);
/**
* Read raw voltage from the sensor
* @param dev sensor context pointer
* @param *value Raw sensor voltage
* @return Function result code
*/
upm_result_t vdiv_get_raw_volts(const vdiv_context dev, float *value);
/**
* Gets the true voltage value from the sensor. Voltage divides by 3 or 10,
* depending on the toggle switch on the board. The dynamic range of the
* vdiv sensor is listed below.
*
* ADC Ref SW max VOL in
* ------- --- ----------
* 3.3v 3 8.5v
* 3.3v 10 28.4v
* 5.0v 3 12.9v
* 5.0v 10 43.0v
*
* @param dev sensor context pointer
* @param *value Voltage (v)
* @return Function result code
*/
upm_result_t vdiv_get_computed_volts(const vdiv_context dev, float *value);
#ifdef __cplusplus
}
#endif

View File

@ -29,47 +29,47 @@
#include <mraa/aio.h>
// reference voltage in millivolts
#define GROVEVDIV_VREF 4980
#define VDIV_VREF 4980
// default ADC resolution
#define GROVEVDIV_ADC_RES 1024
#define VDIV_ADC_RES 1024
namespace upm {
/**
* @brief Grove Voltage Divider Sensor library
* @defgroup grovevdiv libupm-grovevdiv
* @brief Voltage Divider Sensor library
* @defgroup vdiv libupm-vdiv
* @ingroup seeed analog electric robok
*/
/**
* @library grovevdiv
* @sensor grovevdiv
* @comname Grove Voltage Divider
* @library vdiv
* @sensor vdiv
* @comname Voltage Divider
* @type electric
* @man seeed
* @con analog
* @kit robok
*
* @brief API for the Grove Voltage Divider Sensor
* @brief API for the Voltage Divider Sensor
*
* UPM module for the Grove Voltage Divider sensor
* UPM module for the Voltage Divider sensor
*
* @image html grovevdiv.jpg
* @snippet grovevdiv.cxx Interesting
* @image html vdiv.jpg
* @snippet vdiv.cxx Interesting
*/
class GroveVDiv {
class VDiv {
public:
/**
* Grove Voltage Divider sensor constructor
* Voltage Divider sensor constructor
*
* @param pin Analog pin to use
*/
GroveVDiv(int pin);
VDiv(int pin);
/**
* Grove Voltage Divider destructor
* Voltage Divider destructor
*/
~GroveVDiv();
~VDiv();
/**
* Gets the conversion value from the sensor
@ -82,15 +82,15 @@ namespace upm {
/**
* Computes the measured voltage
*
* @param gain Gain switch, either 3 or 10 for Grove
* @param gain Gain switch, example: either 3 or 10 grove vdiv
* @param val Measured voltage (from value())
* @param vref Reference voltage in millivolts
* @param res ADC resolution
*
* @return Measured voltage
*/
float computedValue(uint8_t gain, unsigned int val, int vref=GROVEVDIV_VREF,
int res=GROVEVDIV_ADC_RES);
float computedValue(uint8_t gain, unsigned int val, int vref=VDIV_VREF,
int res=VDIV_ADC_RES);
private:
mraa_aio_context m_aio;

118
src/vdiv/vdiv_fti.c Normal file
View File

@ -0,0 +1,118 @@
/*
* Author:
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <stdlib.h>
#include "vdiv.h"
#include "fti/upm_sensor.h"
#include "fti/upm_voltage.h"
/**
* This file implements the Function Table Interface (FTI) for this sensor
*/
const char upm_vdiv_name[] = "VDIV";
const char upm_vdiv_description[] = "Analog voltage divider sensor";
const upm_protocol_t upm_vdiv_protocol[] = {UPM_ANALOG};
const upm_sensor_t upm_vdiv_category[] = {UPM_VOLTAGE};
// forward declarations
const void* upm_vdiv_get_ft(upm_sensor_t sensor_type);
void* upm_vdiv_init_str(const char* protocol, const char* params);
void upm_vdiv_close(void* dev);
const upm_sensor_descriptor_t upm_vdiv_get_descriptor();
upm_result_t upm_vdiv_set_offset(const void* dev, float offset);
upm_result_t upm_vdiv_set_scale(const void* dev, float scale);
upm_result_t upm_vdiv_get_value(const void* dev, float *value);
/* This sensor implementes 2 function tables */
/* 1. Generic base function table */
static const upm_sensor_ft ft_gen =
{
.upm_sensor_init_name = &upm_vdiv_init_str,
.upm_sensor_close = &upm_vdiv_close,
.upm_sensor_get_descriptor = &upm_vdiv_get_descriptor
};
/* 2. VOLTAGE function table */
static const upm_voltage_ft ft_voltage =
{
.upm_voltage_set_offset = &upm_vdiv_set_offset,
.upm_voltage_set_scale = &upm_vdiv_set_scale,
.upm_voltage_get_value = &upm_vdiv_get_value
};
const void* upm_vdiv_get_ft(upm_sensor_t sensor_type)
{
switch(sensor_type)
{
case UPM_SENSOR:
return &ft_gen;
case UPM_VOLTAGE:
return &ft_voltage;
default:
return NULL;
}
}
void* upm_vdiv_init_str(const char* protocol, const char* params)
{
fprintf(stderr, "String initialization - not implemented, using ain0: %s\n", __FILENAME__);
return vdiv_init(0, 5.0);
}
void upm_vdiv_close(void* dev)
{
vdiv_close((vdiv_context)dev);
}
const upm_sensor_descriptor_t upm_vdiv_get_descriptor()
{
/* Fill in the descriptor */
upm_sensor_descriptor_t usd;
usd.name = upm_vdiv_name;
usd.description = upm_vdiv_description;
usd.protocol_size = 1;
usd.protocol = upm_vdiv_protocol;
usd.category_size = 1;
usd.category = upm_vdiv_category;
return usd;
}
upm_result_t upm_vdiv_set_offset(const void* dev, float offset)
{
return vdiv_set_offset((vdiv_context)dev, offset);
}
upm_result_t upm_vdiv_set_scale(const void* dev, float scale)
{
return vdiv_set_scale((vdiv_context)dev, scale);
}
upm_result_t upm_vdiv_get_value(const void* dev, float *value)
{
return vdiv_get_computed_volts((vdiv_context)dev, value);
}