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: fll mbed-rtos mbed
Diff: fll.h
- Revision:
- 0:c80e972b4c59
- Child:
- 1:1abcd83947bf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/fll.h Fri Feb 13 13:19:29 2015 +0000
@@ -0,0 +1,88 @@
+// Frame Level Language
+// header
+
+#include "mbed.h"
+#include "rtos.h"
+#include <stdint.h>
+#include <vector>
+
+#define R1 0x0001
+#define B_TRIANGLE 0x0002
+#define B_CIRCLE 0x0004
+#define B_CROSS 0x0008
+#define B_SQUARE 0x0010
+#define B_R2 0x0020
+#define B_START 0x0040
+#define B_ANALOG 0x0080
+#define B_SELECT 0x0100
+#define B_L2 0x0200
+#define B_UP 0x0400
+#define B_DOWN 0x0800
+#define B_LEFT 0x1000
+#define B_RIGHT 0x2000
+#define B_L1 0x4000
+
+#define QUEUE_SIZE 5
+
+typedef uint16_t button;
+
+class Source
+{
+private:
+ int i;
+ vector<button>* button_seq;
+ bool loop;
+public:
+ Source(vector<button>* bs, bool l);
+ virtual button await();
+};
+
+class Flow : Source
+{
+private:
+ vector<Source*>& sources;
+public:
+ Flow(vector<Source*> &srcs);
+ virtual button fold(vector<button> &bs);
+ virtual button await();
+};
+
+// Sink で使う。次に持ち越すキーのクラス。Option[Key] みたいな感じ
+class Carry
+{
+private:
+ button btn;
+ static const button none = 0x8000; // 1000 0000 0000 0000
+public:
+ Carry();
+ bool is_empty();
+ button get();
+ void set(button b);
+ void empty();
+};
+
+// ストリームの終端になっていて、キー入力をするスレッドに向けてキーを送る
+class Sink
+{
+private:
+ Source* source;
+ Carry* carry;
+ rtos::Mail<button, QUEUE_SIZE>* queue;
+ Mutex* queueMutex; // Main Thread と同じ Mutex でなければいけない
+public:
+ Sink(Source* src, rtos::Mail<button, QUEUE_SIZE>* q, Mutex* mut);
+ void run();
+ void reset(Source* src);
+};
+
+
+class Output
+{
+private:
+ rtos::Mail<button, QUEUE_SIZE>* queue;
+public:
+ Output(rtos::Mail<button, QUEUE_SIZE>* q);
+ void run();
+};
+
+void press(button btn);
