AirsoftTimer software based on mbed
Dependencies: mbed TextLCD keypad
Diff: games/GameSelector.cpp
- Revision:
- 19:2eba101d9c2c
- Parent:
- 18:abcebc4d0da0
- Child:
- 21:f4e556dc9885
diff -r abcebc4d0da0 -r 2eba101d9c2c games/GameSelector.cpp --- a/games/GameSelector.cpp Sat May 23 20:57:45 2015 +0000 +++ b/games/GameSelector.cpp Sat May 23 22:42:51 2015 +0000 @@ -2,7 +2,7 @@ GameSelector::GameSelector(Board* board){ this->board = board; - //this->board->attach(this, &GameSelector::buttonEvent); + this->board->attach(this, &GameSelector::buttonEvent); titles[0] = "Hold it"; titles[1] = "Capture the bomb"; titles[2] = "Hurry up"; @@ -14,36 +14,38 @@ current_selection = 0; start_position = 0; selected_game = -1; + + update_screen = false; } int GameSelector::select(){ print_list(); - printf("printed list\r\n"); while(selected_game == -1){ - //board->leds->on(Leds::RIGHT); + if(update_screen){ + print_list(); + } } // wait until selection is done - //printf("game selected: %d \r\n", selected_game); return selected_game; } -/*uint32_t GameSelector::buttonEvent(uint32_t c){ - printf("Gameselector buttonEvent start, char: %c\r\n", c); +uint32_t GameSelector::buttonEvent(uint32_t c){ switch(c){ case '2': go_up(); + update_screen = true; break; case '5': selected_game = current_selection; break; case '8': go_down(); + update_screen = true; break; default: break; } - //printf("end\r\n"); return 0; -}*/ +} void GameSelector::print_list(){ board->lcd->cls(); @@ -53,6 +55,8 @@ } print_selection_arrow(); print_up_down_arrows(); + + update_screen = false; } void GameSelector::print_up_down_arrows(){ @@ -79,7 +83,7 @@ if(current_selection - start_position >= 4){ start_position = current_selection - 3; } - print_list(); + //print_list(); } void GameSelector::go_up(){ @@ -89,5 +93,5 @@ if(current_selection - start_position < 0){ start_position = current_selection; } - print_list(); + //print_list(); }