Auto full-combo Koibumi2000 in Taiko no Tatsujin CS5

Dependencies:   fll mbed-rtos mbed

Committer:
sierra
Date:
Sat Feb 14 08:02:21 2015 +0000
Revision:
6:d0348b7a2f05
Parent:
5:130721ce29f7
Child:
7:61b4825304e2
Child:
29:2f3d6d09eaac
Create base object: Producer

Who changed what in which revision?

UserRevisionLine numberNew contents of line
amutake 0:c80e972b4c59 1 #include "mbed.h"
amutake 0:c80e972b4c59 2 #include "rtos.h"
amutake 0:c80e972b4c59 3 #include "fll.h"
amutake 0:c80e972b4c59 4
amutake 0:c80e972b4c59 5 #define FRAME 1.0 / 60 // 1 frame (sec)
amutake 0:c80e972b4c59 6
sierra 6:d0348b7a2f05 7 class OrFoldFlow : public FoldFlow {
sierra 5:130721ce29f7 8 public:
sierra 6:d0348b7a2f05 9 OrFoldFlow(Producer **srcs, int srcs_size) : FoldFlow(srcs, srcs_size) {}
sierra 5:130721ce29f7 10 virtual button_t fold(button_t *bs, int bs_size) {
sierra 5:130721ce29f7 11 button_t b = 0x00;
sierra 5:130721ce29f7 12 for(int i = 0; i < bs_size; i++) {
sierra 5:130721ce29f7 13 b |= bs[i];
sierra 5:130721ce29f7 14 }
sierra 5:130721ce29f7 15 return b;
sierra 5:130721ce29f7 16 }
sierra 5:130721ce29f7 17 };
sierra 5:130721ce29f7 18
sierra 5:130721ce29f7 19 void invoke_sinkrun(const void *p) {
amutake 0:c80e972b4c59 20 ((Sink*)p)->run();
amutake 0:c80e972b4c59 21 }
amutake 0:c80e972b4c59 22 void outputrun(const void *p)
amutake 0:c80e972b4c59 23 {
amutake 0:c80e972b4c59 24 ((Output*)p)->run();
amutake 0:c80e972b4c59 25 }
amutake 0:c80e972b4c59 26
amutake 0:c80e972b4c59 27 int main(void)
amutake 0:c80e972b4c59 28 {
sierra 5:130721ce29f7 29 button_t array0[] = {R1, 0};
sierra 5:130721ce29f7 30 button_t array1[] = {B_CIRCLE, 0};
amutake 0:c80e972b4c59 31 // user must make Source
sierra 6:d0348b7a2f05 32 Producer* source0 = new RepeaterSource(array0, sizeof(array0)/sizeof(button_t));
sierra 6:d0348b7a2f05 33 Producer* source1 = new RepeaterSource(array1, sizeof(array1)/sizeof(button_t));
sierra 6:d0348b7a2f05 34 Producer* ss[] = {source0, source1};
sierra 6:d0348b7a2f05 35 Producer* source = new OrFoldFlow(ss, 2);
amutake 0:c80e972b4c59 36
amutake 0:c80e972b4c59 37 // common pattern
sierra 3:edbf31a8589f 38 Mail<button_t, MAIL_BOX_SIZE>* mail_box = new Mail<button_t, MAIL_BOX_SIZE>();
amutake 0:c80e972b4c59 39 Mutex* mutex = new Mutex();
amutake 0:c80e972b4c59 40
amutake 2:165723d41023 41 Sink* sink = new Sink(source, mail_box, mutex);
amutake 0:c80e972b4c59 42
amutake 0:c80e972b4c59 43 Ticker ticker;
amutake 2:165723d41023 44 Output* output = new Output(mail_box);
amutake 0:c80e972b4c59 45
sierra 4:9ee673ca05ad 46 Thread th(invoke_sinkrun, (void *)sink);
amutake 0:c80e972b4c59 47 ticker.attach(output, &Output::run, FRAME);
amutake 0:c80e972b4c59 48
sierra 1:1abcd83947bf 49 Thread::wait(osWaitForever);
amutake 0:c80e972b4c59 50 }