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: PS3_sample Nucleo_NHK_2018_syudo_wheel kourobo kourobo5 ... more
Diff: PS3.h
- Revision:
- 0:fc5f65cdaaa8
- Child:
- 1:7bd8296e6908
diff -r 000000000000 -r fc5f65cdaaa8 PS3.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/PS3.h Thu Aug 30 06:04:11 2018 +0000
@@ -0,0 +1,56 @@
+#ifndef PS3_H
+#define PS3_H
+
+#include "mbed.h"
+#include <vector>
+
+#define PS3_BUFFER_SIZE 22
+#define PS3_HEADER0 'R'
+#define PS3_HEADER1 'B'
+#define PS3_HEADER2 'N'
+#define LEFT_X 0
+#define LEFT_Y 1
+#define RIGHT_X 2
+#define RIGHT_Y 3
+#define L2 0
+#define R2 1
+#define UP 0
+#define DOWN 1
+#define LEFT 2
+#define RIGHT 3
+#define TRIANGLE 4
+#define CROSS 5
+#define SQUARE 6
+#define CIRCLE 7
+#define L1 8
+#define R1 9
+#define L3 10
+#define R3 11
+#define PS 12
+#define SELECT 13
+#define START 14
+
+class PS3 : public RawSerial
+{
+public :
+ PS3(PinName tx, PinName rx);
+
+ bool getButton(int n);
+ uint8_t getStick(int n);
+ uint8_t getTrigger(int n);
+ std::vector<unsigned char> buf;
+ // Thread thread;
+
+private :
+ void receiveByte();
+ void assemble();
+ void assembleLoop();
+
+ Ticker assembleTicker;
+
+ bool button[15];
+ uint8_t stick[4];
+ uint8_t trigger[2];
+};
+
+#endif
\ No newline at end of file