AirsoftTimer software based on mbed
Dependencies: mbed TextLCD keypad
Airsofttimer.cpp@27:f29805113454, 2017-02-09 (annotated)
- Committer:
- sillevl
- Date:
- Thu Feb 09 12:28:56 2017 +0000
- Revision:
- 27:f29805113454
- Parent:
- 20:b89791ecceec
ARCHIVE WIP, not working (crashes, cause unknown)
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 | 17:19dbb1dbb640 | 31 | wait(3.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 | 14:e0bfee0a5e66 | 39 | Game* game = GameFactory::create(board, game_number); |
sillevl | 12:22e9ef610ea2 | 40 | game->setup(); |
sillevl | 8:e9fb60f5a56f | 41 | game->run(); |
sillevl | 8:e9fb60f5a56f | 42 | delete game; |
sillevl | 8:e9fb60f5a56f | 43 | } |
sillevl | 9:b587bae22691 | 44 | } |
sillevl | 9:b587bae22691 | 45 | |
sillevl | 9:b587bae22691 | 46 | // show a list of games, and select one |
sillevl | 9:b587bae22691 | 47 | int Airsofttimer::select_game(){ |
sillevl | 10:afc22465169e | 48 | GameSelector* selector = new GameSelector(board); |
sillevl | 17:19dbb1dbb640 | 49 | return selector->select(); |
sillevl | 8:e9fb60f5a56f | 50 | } |