AirsoftTimer software based on mbed
Dependencies: mbed TextLCD keypad
Airsofttimer.cpp@10:afc22465169e, 2014-12-14 (annotated)
- Committer:
- sillevl
- Date:
- Sun Dec 14 11:50:19 2014 +0000
- Revision:
- 10:afc22465169e
- Parent:
- 9:b587bae22691
- Child:
- 11:50572814f73e
Added game selector skeleton + demo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sillevl | 0:4a0929f1b4fd | 1 | |
sillevl | 0:4a0929f1b4fd | 2 | #include "Airsofttimer.h" |
sillevl | 10:afc22465169e | 3 | #include "games/GameSelector.h" |
sillevl | 0:4a0929f1b4fd | 4 | |
sillevl | 4:2c91c9eccf3a | 5 | // buttonPin = P0_4; //P0.4 |
sillevl | 4:2c91c9eccf3a | 6 | // keyPin = P0_5; //P0.5 |
sillevl | 4:2c91c9eccf3a | 7 | // ledAPin = P2_4; //P2.4 |
sillevl | 4:2c91c9eccf3a | 8 | // ledBPin = P2_5; //P2.5 |
sillevl | 4:2c91c9eccf3a | 9 | // buzzerPin = P2_3; //P2.3 |
sillevl | 4:2c91c9eccf3a | 10 | // keyboardRowPins = {P0_8 , P0_9 , P0_10, P0_11}; // ROWS=P0.8 -> P0.11 |
sillevl | 4:2c91c9eccf3a | 11 | // keyboardColPins = {P0_16, P0_17, P0_18}; // COLS=P0.16 -> P0.18 |
sillevl | 4:2c91c9eccf3a | 12 | // lcdPins = {P1_31, P1_30, P0_23, P0_24, P0_23, P0_26}; // E=P1.31, RS=P1.30, D4=P0.23 -> D7=P0.26 |
sillevl | 0:4a0929f1b4fd | 13 | |
sillevl | 4:2c91c9eccf3a | 14 | Airsofttimer::Airsofttimer(Pinouts pinouts){ |
sillevl | 5:be598835bab0 | 15 | board = new Board(pinouts); |
sillevl | 4:2c91c9eccf3a | 16 | init(); |
sillevl | 8:e9fb60f5a56f | 17 | start(); |
sillevl | 4:2c91c9eccf3a | 18 | } |
sillevl | 0:4a0929f1b4fd | 19 | |
sillevl | 4:2c91c9eccf3a | 20 | const char* Airsofttimer::LOGO[16] = { |
sillevl | 4:2c91c9eccf3a | 21 | " \xFF\xFF\xFF \xFF \xFF\xFF\xFF", |
sillevl | 4:2c91c9eccf3a | 22 | " \xFF \xFF \xFF \xFF", |
sillevl | 4:2c91c9eccf3a | 23 | " \xFF\xFF\xFF \xFF \xFF", |
sillevl | 4:2c91c9eccf3a | 24 | " \xFF \xFF \xFF\xFF\xFF" |
sillevl | 4:2c91c9eccf3a | 25 | }; |
sillevl | 4:2c91c9eccf3a | 26 | |
sillevl | 4:2c91c9eccf3a | 27 | void Airsofttimer::init(){ |
sillevl | 5:be598835bab0 | 28 | board->buzzer->startupBeep(); |
sillevl | 5:be598835bab0 | 29 | board->lcd->cls(); |
sillevl | 5:be598835bab0 | 30 | board->lcd->showLogo(LOGO); |
sillevl | 5:be598835bab0 | 31 | wait(5.0); |
sillevl | 5:be598835bab0 | 32 | board->lcd->cls(); |
sillevl | 4:2c91c9eccf3a | 33 | } |
sillevl | 8:e9fb60f5a56f | 34 | |
sillevl | 8:e9fb60f5a56f | 35 | void Airsofttimer::start(){ |
sillevl | 8:e9fb60f5a56f | 36 | while(true){ |
sillevl | 8:e9fb60f5a56f | 37 | // first we need to select a game from the available games list |
sillevl | 9:b587bae22691 | 38 | int game_number = select_game(); |
sillevl | 9:b587bae22691 | 39 | Game* game = Game::create_game(board, game_number); |
sillevl | 8:e9fb60f5a56f | 40 | game->run(); |
sillevl | 8:e9fb60f5a56f | 41 | delete game; |
sillevl | 8:e9fb60f5a56f | 42 | } |
sillevl | 9:b587bae22691 | 43 | } |
sillevl | 9:b587bae22691 | 44 | |
sillevl | 9:b587bae22691 | 45 | // show a list of games, and select one |
sillevl | 9:b587bae22691 | 46 | int Airsofttimer::select_game(){ |
sillevl | 10:afc22465169e | 47 | GameSelector* selector = new GameSelector(board); |
sillevl | 10:afc22465169e | 48 | selector->run(); |
sillevl | 9:b587bae22691 | 49 | return 0; |
sillevl | 8:e9fb60f5a56f | 50 | } |