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.
USRF_MB1310.h
00001 #ifndef USRF_MB1310Library 00002 #define USRF_MB1310Library 00003 00004 #include "mbed.h" 00005 00006 class USRF_MB1310 00007 { 00008 private: 00009 AnalogIn* AnalogInput; 00010 DigitalOut* SerialOutput; 00011 Serial* SerialInput; 00012 float operatingvoltage; 00013 float unitfactor; 00014 float scalingfactor; 00015 float distance; 00016 00017 public: 00018 USRF_MB1310(PinName, PinName, PinName); 00019 //analog input, serial output, serial input; specify NC if not used 00020 void setoperatingvoltage(float); 00021 //sets expected operating voltage of scaling functions; 00022 //user responsibility to ensure operating voltage between 3.3V and 5V; 00023 //default is 3.3V 00024 void selectunit(int); 00025 //argument sets unit scaling factor; 00026 //0 for cm, 1 for m, 2 for in, 3 for ft; 00027 //default is 0 00028 void requestserialquery(); 00029 //this tells the device to prepare a serial reading; 00030 //must be done at least 99 ms before the query is read 00031 float query(); 00032 float query(int); 00033 //get a reading from the device by the mode specified in the argument; 00034 //0 for analog, 1 for serial; requestserialquery() must be called at least 00035 //99ms before query(1) can be called, otherwise it will return 0; 00036 //overloaded so default no argument is an analog reading 00037 USRF_MB1310& operator =(float); 00038 //can be used for shorthand for unit selection or for setting non included units; 00039 //the output in cm will be multiplied by the assigned float; 00040 //ex: "USRF_MB1310object = 10 will convert units to mm 00041 operator float(); 00042 //can be used as shorthand for taking an analog reading; 00043 //ex: "float reading = USRF_MB1310object;" 00044 //NOTE: STILL UNDER DEVELOPMENT, PLEASE TEST 00045 }; 00046 00047 #endif
Generated on Sun Jul 17 2022 00:19:35 by
1.7.2