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.
Dependents: mbed_ES200_Tester_SERVOGEN mbed_ES20X_Thread_Test
Revision 3:edc18509ff11, committed 2014-09-29
- Comitter:
- jebradshaw
- Date:
- Mon Sep 29 16:47:31 2014 +0000
- Parent:
- 2:44766ee77ce0
- Commit message:
- Added operator accessible read/writes to simplify use; J Bradshaw 20140929
Changed in this revision
| SERVOGEN.cpp | Show annotated file Show diff for this revision Revisions of this file |
| SERVOGEN.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/SERVOGEN.cpp Sun Sep 28 18:57:11 2014 +0000
+++ b/SERVOGEN.cpp Mon Sep 29 16:47:31 2014 +0000
@@ -60,4 +60,26 @@
_sCycle=1;
}
} //pulse != 0 (OFF)
+}
+
+void SERVOGEN::write(int pulse){
+ pulse_us = pulse;
+}
+
+int SERVOGEN::read(){
+ return pulse_us;
+}
+
+SERVOGEN& SERVOGEN::operator= (int pulse_us) {
+ write(pulse_us);
+ return *this;
+}
+
+SERVOGEN& SERVOGEN::operator= (SERVOGEN& rhs) {
+ write(rhs.read());
+ return *this;
+}
+
+SERVOGEN::operator int() {
+ return read();
}
\ No newline at end of file
--- a/SERVOGEN.h Sun Sep 28 18:57:11 2014 +0000
+++ b/SERVOGEN.h Mon Sep 29 16:47:31 2014 +0000
@@ -1,4 +1,4 @@
-// J. Bradshaw 20140925
+// J. Bradshaw 20140929
/** SERVOGEN Class for Generating servo pulses on single output pin
* Copyright (c) 2014, jbradshaw (http://mbed.org)
*
@@ -70,6 +70,14 @@
int pulse_us; //determines the pulse width in microseconds (default is 0 = OFF)
int pulseMin; //minimum pulse width (default is 900 microseconds)
int pulseMax; //maximum pulse width (default is 2100 microseconds)
+
+ void write(int pulse); //
+ int read(void);
+
+ /** Shorthand for the write and read functions */
+ SERVOGEN& operator= (int pulse_us);
+ SERVOGEN& operator= (SERVOGEN& rhs);
+ operator int();
private:
void tickFunct(void); //Function that takes care of the servo pulse generation