AirsoftTimer software based on mbed

Dependencies:   mbed TextLCD keypad

Committer:
sillevl
Date:
Sat May 23 22:42:51 2015 +0000
Revision:
19:2eba101d9c2c
Parent:
17:19dbb1dbb640
Child:
20:b89791ecceec
game selector working (solved strange behaviour with buttonEvent and lcd commands)

Who changed what in which revision?

UserRevisionLine numberNew 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 19:2eba101d9c2c 15 //printf("--- AirsoftTimer startup ---\r\n");
sillevl 5:be598835bab0 16 board = new Board(pinouts);
sillevl 4:2c91c9eccf3a 17 init();
sillevl 8:e9fb60f5a56f 18 start();
sillevl 4:2c91c9eccf3a 19 }
sillevl 0:4a0929f1b4fd 20
sillevl 4:2c91c9eccf3a 21 const char* Airsofttimer::LOGO[16] = {
sillevl 4:2c91c9eccf3a 22 " \xFF\xFF\xFF \xFF \xFF\xFF\xFF",
sillevl 4:2c91c9eccf3a 23 " \xFF \xFF \xFF \xFF",
sillevl 4:2c91c9eccf3a 24 " \xFF\xFF\xFF \xFF \xFF",
sillevl 4:2c91c9eccf3a 25 " \xFF \xFF \xFF\xFF\xFF"
sillevl 4:2c91c9eccf3a 26 };
sillevl 4:2c91c9eccf3a 27
sillevl 4:2c91c9eccf3a 28 void Airsofttimer::init(){
sillevl 5:be598835bab0 29 board->buzzer->startupBeep();
sillevl 5:be598835bab0 30 board->lcd->cls();
sillevl 5:be598835bab0 31 board->lcd->showLogo(LOGO);
sillevl 17:19dbb1dbb640 32 wait(3.0);
sillevl 5:be598835bab0 33 board->lcd->cls();
sillevl 4:2c91c9eccf3a 34 }
sillevl 8:e9fb60f5a56f 35
sillevl 8:e9fb60f5a56f 36 void Airsofttimer::start(){
sillevl 8:e9fb60f5a56f 37 while(true){
sillevl 8:e9fb60f5a56f 38 // first we need to select a game from the available games list
sillevl 9:b587bae22691 39 int game_number = select_game();
sillevl 14:e0bfee0a5e66 40 Game* game = GameFactory::create(board, game_number);
sillevl 12:22e9ef610ea2 41 game->setup();
sillevl 8:e9fb60f5a56f 42 game->run();
sillevl 8:e9fb60f5a56f 43 delete game;
sillevl 8:e9fb60f5a56f 44 }
sillevl 9:b587bae22691 45 }
sillevl 9:b587bae22691 46
sillevl 9:b587bae22691 47 // show a list of games, and select one
sillevl 9:b587bae22691 48 int Airsofttimer::select_game(){
sillevl 10:afc22465169e 49 GameSelector* selector = new GameSelector(board);
sillevl 17:19dbb1dbb640 50 return selector->select();
sillevl 8:e9fb60f5a56f 51 }