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.
Revision 3:05183e50a923, committed 2010-08-26
- Comitter:
- Blaze513
- Date:
- Thu Aug 26 18:25:19 2010 +0000
- Parent:
- 2:997b4057c879
- Child:
- 4:a615b75d4126
- Commit message:
Changed in this revision
--- a/MB1210.cpp Mon Aug 23 07:11:10 2010 +0000
+++ b/MB1210.cpp Thu Aug 26 18:25:19 2010 +0000
@@ -85,6 +85,15 @@
}
//hold pin high for at least 20 us to request a synchronous range reading
+void MB1210::DiscardSerialBuffer()
+{
+ while (SerialInput->readable())
+ {
+ SerialInput->getc();
+ }
+}
+ //read characters from the buffer until it is empty
+
float MB1210::Read()
{
switch (OperatingMode)
@@ -127,7 +136,7 @@
}
}
//OperatingMode switches to desired output method;
- //once gathered, the result is scaled according to voltage, the speed of sound, and desired unit
+ //the result is scaled according to voltage, the speed of sound, and desired unit
void MB1210::Read(char* Buffer)
{
if (SerialInput)
--- a/MB1210.h Mon Aug 23 07:11:10 2010 +0000
+++ b/MB1210.h Thu Aug 26 18:25:19 2010 +0000
@@ -50,8 +50,10 @@
//this tells the device to prepare a synchronous range reading;
//must be called at least 99 ms before the reading is needed;
//changes asynchronous mode to synchronous equivalent
- void DiscardBuffer();
- //empties the buffer on the serial port to sync the next reading
+ void DiscardSerialBuffer();
+ //the serial port has a buffer and only the oldest data is read from it;
+ //the buffer has limited space and, when full, the newest data is discarded;
+ //this method allows the user to empty the buffer of old data so new data is used
float Read();
//get a reading from the device in the set mode;
//RequestSyncRead() must be called at least 99 ms
--- a/PwmIn/PwmIn.cpp Mon Aug 23 07:11:10 2010 +0000
+++ b/PwmIn/PwmIn.cpp Thu Aug 26 18:25:19 2010 +0000
@@ -7,9 +7,10 @@
PwmIn::PwmIn(PinName pwi) : InterruptIn(pwi), PeriodMeasurement(0), PulseWidthMeasurement(1)
{
- rise(this, &PwmIn::PulseStart);
- fall(this, &PwmIn::PulseStop);
- start();
+ mode(PullDown);
+ rise(this, &PwmIn::PulseStart);
+ fall(this, &PwmIn::PulseStop);
+ start();
}
float PwmIn::read()