Craig Evans / Mbed 2 deprecated ELEC2645_FXOS8700CQ_Library

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
eencae
Date:
Mon Jan 27 15:27:28 2020 +0000
Parent:
3:a715415d7351
Commit message:
Slight change to joystick

Changed in this revision

Gamepad2/Gamepad.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Gamepad2/Gamepad.cpp	Mon Jan 27 12:44:47 2020 +0000
+++ b/Gamepad2/Gamepad.cpp	Mon Jan 27 15:27:28 2020 +0000
@@ -281,13 +281,9 @@
     float x = 2.0f*( _horiz->read() - _x0 );
     float y = 2.0f*( _vert->read()  - _y0 );
 
-    // Note: the x value here is inverted to ensure the positive x is to the
-    // right. This is simply due to how the potentiometer on the joystick
-    // I was using was connected up. It could have been corrected in hardware
-    // by swapping the power supply pins. Instead it is done in software so may
-    // need to be changed depending on your wiring setup
+    // Note: the y value here is inverted to ensure the positive y is up
 
-    Vector2D coord = {-x,y};
+    Vector2D coord = {x,-y};
     return coord;
 }
 
@@ -301,7 +297,7 @@
     float x = coord.x*sqrt(1.0f-pow(coord.y,2.0f)/2.0f);
     float y = coord.y*sqrt(1.0f-pow(coord.x,2.0f)/2.0f);
 
-    Vector2D mapped_coord = {-x,-y};
+    Vector2D mapped_coord = {x,y};
     return mapped_coord;
 }