grove: sliding potentiometer

Signed-off-by: Mihai Tudor Panu <mihai.t.panu@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Mihai Tudor Panu
2014-11-06 10:24:56 -08:00
committed by Brendan Le Foll
parent b2ffcdd9ea
commit cebc339d91
7 changed files with 215 additions and 0 deletions

View File

@@ -160,3 +160,36 @@ float GroveRotary::rel_rad()
{
return GroveRotary::rel_deg() * M_PI / 180.0;
}
//// GroveSlide ////
GroveSlide::GroveSlide(unsigned int pin, float ref_voltage)
{
mraa_init();
m_aio = mraa_aio_init(pin);
m_ref_voltage = ref_voltage;
m_name = "Slide Potentiometer";
}
GroveSlide::~GroveSlide()
{
mraa_aio_close(m_aio);
}
float GroveSlide::raw_value()
{
return (float) mraa_aio_read(m_aio);
}
float GroveSlide::voltage_value()
{
// conversion to Volts
float a = GroveSlide::raw_value();
a = m_ref_voltage * a / 1023.0 ;
return a;
}
float GroveSlide::ref_voltage()
{
return m_ref_voltage;
}