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 18:e0a4f15a7750, committed 2017-03-05
- Comitter:
- eencae
- Date:
- Sun Mar 05 19:28:14 2017 +0000
- Parent:
- 17:cf1e1ffcf773
- Child:
- 19:c2bb79a10b3c
- Commit message:
- Added const to led method.
Changed in this revision
| Gamepad.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Gamepad.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Gamepad.cpp Sun Mar 05 19:01:31 2017 +0000
+++ b/Gamepad.cpp Sun Mar 05 19:28:14 2017 +0000
@@ -90,8 +90,16 @@
_led6->write(val);
}
-void Gamepad::led(int n,float val)
+void Gamepad::led(int n,float val) const
{
+ // ensure they are within vlaid range
+ if (val < 0.0f) {
+ val = 0.0f;
+ }
+ if (val > 1.0f) {
+ val = 1.0f;
+ }
+
switch (n) {
// check for valid LED number and set value
--- a/Gamepad.h Sun Mar 05 19:01:31 2017 +0000
+++ b/Gamepad.h Sun Mar 05 19:28:14 2017 +0000
@@ -124,7 +124,7 @@
*@param led number (0 to 5)
*@param value in range 0.0 to 1.0
*/
- void led(int n,float val);
+ void led(int n,float val) const;
/** Read potentiometer
*@returns potentiometer value in range 0.0 to 1.0