Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Lcm101.h
- Committer:
- megrootens
- Date:
- 2016-08-24
- Revision:
- 0:116acb03eb85
File content as of revision 0:116acb03eb85:
#ifndef _LCM101_H_
#define _LCM101_H_
#include "mbed.h"
/**
* Simple class to read out an LCM101 S-beam force sensor connected to an analog
* input.
*/
class Lcm101 {
public:
/**
* @param pin_a_in PinName of analog input
* @param offset of analog value (calibration data)
* @param factor multiplication factor for analog value (calibration data)
*/
Lcm101(PinName pin_a_in, float offset, float factor) :
analog_in_(pin_a_in),
kOffset_(offset),
kFactor_(factor)
{
}
/**
* @return unscaled analog input value
*/
float getForceRaw()
{
return analog_in_.read();
}
/**
* @return force value kOffset_ + kFactor_ * getForceRaw();
*/
float getForce()
{
return kOffset_ + kFactor_ * getForceRaw();
}
/**
* @return ffset of analog value
*/
float get_offset() { return kOffset_; }
/**
* @return factor multiplication factor for analog value
*/
float get_factor() { return kFactor_; }
private:
AnalogIn analog_in_;
const float kOffset_;
const float kFactor_;
};
#endif