AirsoftTimer software based on mbed

Dependencies:   mbed TextLCD keypad

Committer:
sillevl
Date:
Sat Dec 13 13:59:28 2014 +0000
Revision:
9:b587bae22691
Parent:
8:e9fb60f5a56f
Child:
10:afc22465169e
show game list and added special characters

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sillevl 0:4a0929f1b4fd 1
sillevl 0:4a0929f1b4fd 2 #include "Airsofttimer.h"
sillevl 0:4a0929f1b4fd 3
sillevl 4:2c91c9eccf3a 4 // buttonPin = P0_4; //P0.4
sillevl 4:2c91c9eccf3a 5 // keyPin = P0_5; //P0.5
sillevl 4:2c91c9eccf3a 6 // ledAPin = P2_4; //P2.4
sillevl 4:2c91c9eccf3a 7 // ledBPin = P2_5; //P2.5
sillevl 4:2c91c9eccf3a 8 // buzzerPin = P2_3; //P2.3
sillevl 4:2c91c9eccf3a 9 // keyboardRowPins = {P0_8 , P0_9 , P0_10, P0_11}; // ROWS=P0.8 -> P0.11
sillevl 4:2c91c9eccf3a 10 // keyboardColPins = {P0_16, P0_17, P0_18}; // COLS=P0.16 -> P0.18
sillevl 4:2c91c9eccf3a 11 // 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 12
sillevl 4:2c91c9eccf3a 13 Airsofttimer::Airsofttimer(Pinouts pinouts){
sillevl 5:be598835bab0 14 board = new Board(pinouts);
sillevl 4:2c91c9eccf3a 15 init();
sillevl 8:e9fb60f5a56f 16 start();
sillevl 4:2c91c9eccf3a 17 }
sillevl 0:4a0929f1b4fd 18
sillevl 4:2c91c9eccf3a 19 const char* Airsofttimer::LOGO[16] = {
sillevl 4:2c91c9eccf3a 20 " \xFF\xFF\xFF \xFF \xFF\xFF\xFF",
sillevl 4:2c91c9eccf3a 21 " \xFF \xFF \xFF \xFF",
sillevl 4:2c91c9eccf3a 22 " \xFF\xFF\xFF \xFF \xFF",
sillevl 4:2c91c9eccf3a 23 " \xFF \xFF \xFF\xFF\xFF"
sillevl 4:2c91c9eccf3a 24 };
sillevl 4:2c91c9eccf3a 25
sillevl 4:2c91c9eccf3a 26 void Airsofttimer::init(){
sillevl 5:be598835bab0 27 board->buzzer->startupBeep();
sillevl 5:be598835bab0 28 board->lcd->cls();
sillevl 5:be598835bab0 29 board->lcd->showLogo(LOGO);
sillevl 5:be598835bab0 30 wait(5.0);
sillevl 5:be598835bab0 31 board->lcd->cls();
sillevl 4:2c91c9eccf3a 32 }
sillevl 8:e9fb60f5a56f 33
sillevl 8:e9fb60f5a56f 34 void Airsofttimer::start(){
sillevl 8:e9fb60f5a56f 35 while(true){
sillevl 8:e9fb60f5a56f 36 // first we need to select a game from the available games list
sillevl 9:b587bae22691 37 int game_number = select_game();
sillevl 9:b587bae22691 38 Game* game = Game::create_game(board, game_number);
sillevl 8:e9fb60f5a56f 39 game->run();
sillevl 8:e9fb60f5a56f 40 delete game;
sillevl 8:e9fb60f5a56f 41 }
sillevl 9:b587bae22691 42 }
sillevl 9:b587bae22691 43
sillevl 9:b587bae22691 44 // show a list of games, and select one
sillevl 9:b587bae22691 45 int Airsofttimer::select_game(){
sillevl 9:b587bae22691 46 board->lcd->cls();
sillevl 9:b587bae22691 47 board->lcd->printf(" DummyGame 1 \x02");
sillevl 9:b587bae22691 48 board->lcd->printf(" DummyGame 2 ");
sillevl 9:b587bae22691 49 board->lcd->printf(" DummyGame 3 ");
sillevl 9:b587bae22691 50 board->lcd->printf(" DummyGame 4 \x03");
sillevl 9:b587bae22691 51
sillevl 9:b587bae22691 52 // draw arrows (refactor this later)
sillevl 9:b587bae22691 53 board->lcd->locate(0,0);
sillevl 9:b587bae22691 54 board->lcd->putc('\x00');
sillevl 9:b587bae22691 55 board->lcd->locate(0,19);
sillevl 9:b587bae22691 56 board->lcd->putc('\x02');
sillevl 9:b587bae22691 57 board->lcd->locate(3,19);
sillevl 9:b587bae22691 58 board->lcd->putc('\x03');
sillevl 9:b587bae22691 59 while(true){} // wait until selection is done
sillevl 9:b587bae22691 60 return 0;
sillevl 8:e9fb60f5a56f 61 }