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.
Diff: SerialCtrl/SerialCtrl.h
- Revision:
- 0:0dcd02e8aeab
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SerialCtrl/SerialCtrl.h Mon Sep 02 02:12:48 2019 +0000
@@ -0,0 +1,45 @@
+#ifndef SERIALCTRL
+#define SERIALCTRL
+
+#include "mbed.h"
+
+#define DATA_N 9
+enum {LX, LY, RX, RY, L2, R2, B1, B2, SUM};
+#define TRIANGLE 0x01
+#define CIRCLE 0x02
+#define CROSS 0x04
+#define SQUARE 0x08
+#define UP 0x10
+#define RIGHT 0x20
+#define DOWN 0x40
+#define LEFT 0x80
+
+#define L1 0x01
+#define L3 0x02
+#define R1 0x04
+#define R3 0x08
+#define SELECT 0x10
+#define START 0x20
+#define PS 0x40
+
+class SerialCtrl {
+public:
+ SerialCtrl(Serial*, Timer*);
+ unsigned char data[DATA_N];
+
+ void param(unsigned char header, unsigned char footer);
+ bool get();
+
+private:
+ unsigned char input();
+ Serial *_Serial;
+ Timer *_Timer;
+ unsigned char STX; //header data code
+ unsigned char ETX; //footer data code
+ int TIMEOUT_MS; //timeout limit
+ #define NUL 0 //dummy data
+ #define FAIL_MAX 15 //fail count
+
+};
+
+#endif //SERIALCTRL
\ No newline at end of file