Auto full-combo Koibumi2000 in Taiko no Tatsujin CS5
Dependencies: fll mbed-rtos mbed
main.cpp@5:130721ce29f7, 2015-02-14 (annotated)
- Committer:
- sierra
- Date:
- Sat Feb 14 07:25:27 2015 +0000
- Revision:
- 5:130721ce29f7
- Parent:
- 4:9ee673ca05ad
- Child:
- 6:d0348b7a2f05
OrPipe!
Who changed what in which revision?
User | Revision | Line number | New 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 | 5:130721ce29f7 | 7 | class OrPipe : public Pipe { |
sierra | 5:130721ce29f7 | 8 | public: |
sierra | 5:130721ce29f7 | 9 | OrPipe(Source **srcs, int srcs_size) : Pipe(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 | 5:130721ce29f7 | 32 | Source* source0 = new Source(array0, sizeof(array0)/sizeof(button_t), true); |
sierra | 5:130721ce29f7 | 33 | Source* source1 = new Source(array1, sizeof(array1)/sizeof(button_t), true); |
sierra | 5:130721ce29f7 | 34 | Source* ss[] = {source0, source1}; |
sierra | 5:130721ce29f7 | 35 | Source* source = new OrPipe(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 | } |