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.cpp
- Revision:
- 7:61b4825304e2
- Parent:
- 6:d0348b7a2f05
- Child:
- 8:d16a0fcc2735
--- a/fll.cpp Sat Feb 14 08:02:21 2015 +0000
+++ b/fll.cpp Sat Feb 14 16:39:53 2015 +0000
@@ -4,14 +4,14 @@
#include "mbed.h"
#include "rtos.h"
#include <stdint.h>
-#include <vector>
#include "fll.h"
-Serial pc(USBTX, USBRX);
+// if you want to debug by `printf`, uncomment next line and put `pc.printf("...", ...);` into certain position.
+// Serial pc(USBTX, USBRX);
-// ------
+// --------------
// RepeaterSource
-// ------
+// --------------
RepeaterSource::RepeaterSource(button_t *bs, int s)
{
button_seq = bs;
@@ -29,9 +29,9 @@
return button_seq[i++];
}
-// ----
+// --------
// FoldFlow
-// ----
+// --------
FoldFlow::FoldFlow(Producer **srcs, int srcs_size) {
sources = srcs;
sources_size = srcs_size;
@@ -78,7 +78,7 @@
void Sink::reset(Producer* src)
{
mutex->lock();
- // queue を空にする
+ // consume current (and actually old) buffer
osEvent e;
do {
e = mail_box->get(0);
@@ -86,7 +86,7 @@
mail_box->free((button_t*)e.value.p);
}
} while (e.status == osEventMail);
- // source の更新
+ // update source
source = src;
mutex->unlock();
}
@@ -102,38 +102,18 @@
void Output::run()
{
osEvent e = mail_box->get(0);
- if (e.status == osEventMail) {
+ if (e.status == osEventMail) { // getting is success
button_t b = *(button_t*)(e.value.p);
mail_box->free((button_t*)e.value.p);
press(b);
} else {
- press(0); // Mail になかった
+ press(0); // if mail box is empty
}
}
-// fll_keymap.cpp
-//
-// | uint16 bit | button_t | mbed pin | low/high |
-// +------------+--------+----------+----------+
-// | 0x0000 | | | |
-// | 0x0000 | | | |
-// | 0x0000 | | | |
-// | 0x0000 | | | |
-// | 0x0000 | | | |
-// | 0x0000 | | | |
-// | 0x0000 | | | |
-// | 0x0000 | | | |
-// | 0x0000 | | | |
-// | 0x0000 | | | |
-// | 0x0000 | | | |
-// | 0x0000 | | | |
-// | 0x0000 | | | |
-// | 0x0000 | | | |
-// +------------+--------+----------+----------+
-//
-// Examples:
-// 0000 0000 0000 0000 === nothing is pressed
-// 0010 0100 1000 0001 === ?, ?, ? and ? are pressed
+// --------------------
+// button_t -> mbed pin
+// --------------------
typedef struct _table {
button_t mask; // 0000 0000 0000 0001 ~ 0010 0000 0000 0000
DigitalOut *pin; // pin5~pin19
@@ -156,27 +136,25 @@
DigitalOut pinL1(p19);
DigitalOut pinL2(p14);
+// button-pin mapping table
table tables[] = {
{ R1, &pinR1, 0 },
- { B_TRIANGLE, &pinTriangle, 0 },
- { B_CIRCLE, &pinCircle, 0 },
- { B_CROSS, &pinCross, 0 },
- { B_SQUARE, &pinSquare, 0 },
- { B_R2, &pinR2, 0 },
- { B_START, &pinStart, 0 },
- { B_ANALOG, &pinAnalog, 0 },
- { B_SELECT, &pinSelect, 0 },
- { B_L2, &pinL2, 0 },
- { B_UP, &pinUp, 0 },
- { B_DOWN, &pinDown, 0 },
- { B_LEFT, &pinLeft, 0 },
- { B_RIGHT, &pinRight, 0 },
- { B_L1, &pinL1, 0 }
+ { TRIANGLE, &pinTriangle, 0 },
+ { CIRCLE, &pinCircle, 0 },
+ { CROSS, &pinCross, 0 },
+ { SQUARE, &pinSquare, 0 },
+ { R2, &pinR2, 0 },
+ { START, &pinStart, 0 },
+ { ANALOG, &pinAnalog, 0 },
+ { SELECT, &pinSelect, 0 },
+ { L2, &pinL2, 0 },
+ { UP, &pinUp, 0 },
+ { DOWN, &pinDown, 0 },
+ { LEFT, &pinLeft, 0 },
+ { RIGHT, &pinRight, 0 },
+ { L1, &pinL1, 0 }
};
-// pc.printf("0x%02x\n", btn);
-
-// 押されるボタンを押す
void press(button_t btn)
{
table t;
