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.
Dependencies: SimpleMapSerialization serial_communication
Revision 4:24d383b68566, committed 2016-04-04
- Comitter:
- inst
- Date:
- Mon Apr 04 07:43:32 2016 +0000
- Parent:
- 3:41100e52d11d
- Child:
- 5:b1573848235e
- Commit message:
Changed in this revision
| communication.cpp | Show annotated file Show diff for this revision Revisions of this file |
| communication.hpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/communication.cpp Sun Apr 03 14:18:39 2016 +0000
+++ b/communication.cpp Mon Apr 04 07:43:32 2016 +0000
@@ -7,6 +7,7 @@
communication* communication::instance_ = NULL;
const int communication::velocity_offset_ = 32767;
+const float communication::analog_stick_lower_limit_ = 0.2f;
communication::communication() {}
@@ -20,39 +21,30 @@
serial_communication::instance()->get("stkLY")
};
- // 受信データは [0, 65535] の範囲であるので [-1, 1] に変換する
if ((iv[0] == velocity_offset_) && (iv[1] == velocity_offset_)) {
return vector2f();
}
vector2f v;
+ // 受信データは [0, 65535] の範囲であるので [-1, 1] に変換する
for (uint32_t i = 0; i < 2; ++i) {
v[i] = iv[i];
v[i] -= velocity_offset_;
v[i] /= velocity_offset_;
- /*
- switch(iv[i]) {
- case 0:
- v[i] = 0.0f;
- break;
-
- case 1:
- v[i] = 1.0f;
-
- break;
-
- case 2:
- v[i] = -1.0f;
- break;
- }
- */
}
if (v.length() > 1.0f) {
return v.unit();
}
+ if (v.length() < analog_stick_lower_limit_) {
+ return vector2f(); // しきい値以下なら移動操作無しとみなす
+ }
+
+
+
+
return v;
/*
--- a/communication.hpp Sun Apr 03 14:18:39 2016 +0000
+++ b/communication.hpp Mon Apr 04 07:43:32 2016 +0000
@@ -33,6 +33,7 @@
communication(const communication& s);
static communication* instance_;
+ static const float analog_stick_lower_limit_;
};
#endif